<?php class Client {////Gets the Guest browser type function Get_browser () {if (!empty ($_server[' http_user_agent '])) {$BR = $_se
rver[' Http_user_agent '];
if (Preg_match ('/msie/i ', $br)) {$br = ' msie ';
} elseif (Preg_match ('/firefox/i ', $br)) {$br = ' Firefox ';
} elseif (Preg_match ('/chrome/i ', $br)) {$br = ' Chrome ';
} elseif (Preg_match ('/safari/i ', $br)) {$br = ' Safari ';
} elseif (Preg_match ('/opera/i ', $br)) {$br = ' Opera ';
}else {$br = ' other ';
return $BR;
} else{return "Unknow"; ////Gets the Guest browser language function Get_lang () {if (!empty ($_server[' http_accept_language '))) {$lang = $_server[' Http_
Accept_language '];
$lang = substr ($lang, 0,5);
if (Preg_match ("/zh-cn/i", $lang)) {$lang = "Simplified Chinese";
} elseif (Preg_match ("/zh/i", $lang)) {$lang = "Traditional Chinese";
} else{$lang = "中文版"; } return$lang;
} else{return "Unknow"; ////Get guest OS function Get_os () {if (!empty ($_server[' http_user_agent '))) {$OS = $_server[' Http_user_ag
ENT '];
if (Preg_match ('/win/i ', $OS)) {$OS = ' Windows ';
} elseif (Preg_match ('/mac/i ', $OS)) {$OS = ' mac ';
} elseif (Preg_match ('/linux/i ', $OS)) {$OS = ' Linux ';
} elseif (Preg_match ('/unix/i ', $OS)) {$OS = ' Unix ';
} elseif (Preg_match ('/bsd/i ', $OS)) {$OS = ' BSD ';
else {$OS = ' other ';
return $OS;
} else{return "Unknow"; ////Get visitors true Ip function get_ip_addr () {if (!empty ($_server["Http_client_ip")) {$ip = $_server
["Http_client_ip"];
} if (!empty ($_server[' http_x_forwarded_for ')) {//get proxy IP $ips = explode (', ', $_server[' http_x_forwarded_for ']);
} if ($ip) {$ips = Array_unshift ($ips, $IP); } $counT = count ($ips); For ($i =0 $i < $count $i + +) {if (!preg_match ("/^ (10172\.16192\.168) \./i", $ips [$i])) {//excluding LAN IP $IP = $ips
[$i];
Break }} $tip = Empty ($_server[' remote_addr '))?
$ip: $_server[' remote_addr '];
if ($tip = = "127.0.0.1") {//Get local real IP return Self::get_onlineip ();
else{return $tip; ////get local real IP function Get_onlineip () {$ip _json = @file_get_contents ("Http://ip.taobao.com/service/getIpInf
O.php?ip=myip ");
$ip _arr=json_decode (stripslashes ($ip _json), 1);
if ($ip _arr[' code ']==0) {return $ip _arr[' data '] [' IP '];
}////the visitor location based on Ip get_ip_from ($ip = ') {if (empty ($ip)) {$ip = Self::getip (); } $ip _json= @file_get_contents ("http://ip.taobao.com/service/getIpInfo.php?ip=". $ip)//According to the Taobao IP $ip _arr=json_d
Ecode (stripslashes ($ip _json), 1);
if ($ip _arr[' code ']==0) {return $ip _arr; else {return FAlse; }
}
}