//获取正确时间
function gettime()
{
$tmphour=date("g")+8;
$tmpnow=date("Y-n-j")." ".$tmphour.date(":i:s");
return $tmpnow;
}
//获取真实IP
function getip()
{
$ip = getenv("HTTP_X_FORWARDED_FOR");
if (($ip = "") || ($ip = "unknown")) $ip=getenv("REMOTE_ADDR");
return $ip;
}
//获取操作系统类型
function getos()
{
$agent = $_ENV["HTTP_USER_AGENT"];
if (eregi('win', $agent) && strpos($agent, '95')){
$os = 'Windows 95';
}
else if (eregi('win 9x', $agent) && strpos($agent, '4.90')){
$os = 'Windows ME';
}
else if (eregi('win', $agent) && ereg('98', $agent)){
$os = 'Windows 98';
}
else if (eregi('win', $agent) && eregi('nt 5.1', $agent)){
$os = 'Windows XP';
}
else if (eregi('win', $agent) && eregi('nt 5', $agent)){
$os = 'Windows 2000';
}
else if (eregi('win', $agent) && eregi('nt', $agent)){
$os = 'Windows NT';
}
else if (eregi('win', $agent) && ereg('32', $agent)){
$os = 'Windows 32';
}
else if (eregi('linux', $agent)){
$os = 'Linux';
}
else if (eregi('unix', $agent)){
$os = 'Unix';
}
else if (eregi('sun', $agent) && eregi('os', $agent)){
$os = 'SunOS';
}
else if (eregi('ibm', $agent) && eregi('os', $agent)){
$os = 'IBM OS/2';
}
else if (eregi('Mac', $agent) && eregi('PC', $agent)){
$os = 'Macintosh';
}
else if (eregi('PowerPC', $agent)){
$os = 'PowerPC';
}
else if (eregi('AIX', $agent)){
$os = 'AIX';
}
else if (eregi('HPUX', $agent)){
$os = 'HPUX';
}
else if (eregi('NetBSD', $agent)){
$os = 'NetBSD';
}
else if (eregi('BSD', $agent)){
$os = 'BSD';
}
else if (ereg('OSF1', $agent)){
$os = 'OSF1';
}
else if (ereg('IRIX', $agent)){
$os = 'IRIX';
}
else if (eregi('FreeBSD', $agent)){
$os = 'FreeBSD';
}
else if (eregi('teleport', $agent)){
$os = 'teleport';
}
else if (eregi('flashget', $agent)){
$os = 'flashget';
}
else if (eregi('webzip', $agent)){
$os = 'webzip';
}
else if (eregi('offline', $agent)){
$os = 'offline';
}
else {
$os = 'Unknown';
}
return $os;
}
//提示信息并导向
function alert($msg,$url)
{
if (is_int($url)==true)
{
if ($url==0)
{
echo "alert(\"$msg\");window.close();";
}
else
{
echo "alert(\"$msg\");history.go(-$url);";
}
}
else
{
echo "alert(\"$msg\");window.location=\"$url\";";
}
exit;
}
//检查是否合法参数
function chkint($value)
{
$value=intval($value);
if ($value {
echo "alert(\"参数错误!\");history.go(-1);";
exit;
}
return $value;
}
?>