Obtains the visitor IP address, Region location information, browser, Source Page, and visitor ip address.
<? Php // This is similar to the class visitorInfo used to obtain Visitor Information // to facilitate statistics on class visitorInfo {// to obtain the visitor ip public function getIp () {$ ip = false; if (! Empty ($ _ SERVER ["HTTP_CLIENT_IP"]) {$ ip = $ _ SERVER ["HTTP_CLIENT_IP"];} if (! Empty ($ _ SERVER ['HTTP _ X_FORWARDED_FOR ']) {$ ips = explode (",", $ _ SERVER ['HTTP _ X_FORWARDED_FOR']); if ($ ip) {array_unshift ($ ips, $ ip); $ ip = FALSE;} for ($ I = 0; $ I <count ($ ips ); $ I ++) {if (! Eregi ("^ (10 │ 172.16 │ 192.168 ). ", $ ips [$ I]) {$ ip = $ ips [$ I]; break ;}} return ($ ip? $ Ip: $ _ SERVER ['remote _ ADDR ']);} // obtain information about the city and network operator based on the ip address. public function findCityByIp ($ ip) {$ data = file_get_contents ('HTTP: // ip.taobao.com/service/getIpInfo.php? Ip = '. $ ip); return json_decode ($ data, $ assoc = true);} // get the public function getBrowser () of the user's browser type () {$ agent = $ _ SERVER ["HTTP_USER_AGENT"]; if (strpos ($ agent, 'msi ')! = False | strpos ($ agent, 'rv: 11.0 ') // ie11 determines return "ie"; else if (strpos ($ agent, 'Firefox ')! = False) return "firefox"; else if (strpos ($ agent, 'chromi ')! = False) return "chrome"; else if (strpos ($ agent, 'Opera ')! = False) return 'Opera '; else if (strpos ($ agent, 'chrome') = false) & strpos ($ agent, 'safari ')! = False) return 'safari '; else return 'unknown';} // obtain the website source public function getFromPage () {return $ _ SERVER ['HTTP _ referer'] ;}}