Php retrieves browser information and visitor languages: Simplified Chinese and traditional? Chinese and English. Obtain guest operating systems: Windows, MAC, Linux, Unix, BSD, and Other. Obtain the visitor IP address. Obtain the geographic location of a visitor and use the Baidu hidden interface. Get guest ISP, use
Php retrieves browser information and visitor languages: Simplified Chinese and traditional? Chinese and English. Obtain guest operating systems: Windows, MAC, Linux, Unix, BSD, and Other. Obtain the visitor IP address. Obtain the geographic location of a visitor and use the Baidu hidden interface. Obtain the visitor's ISP and use the Baidu hidden interface.
GetLang (); // Obtain the visitor's language: Simplified Chinese, traditional? Chinese and English. * $ Obj-> GetBrowser (); // Obtain the visitor's browsers: MSIE, Firefox, Chrome, Safari, Opera, and Other. * $ Obj-> GetOS (); // Obtain guest operating systems: Windows, MAC, Linux, Unix, BSD, and Other. * $ Obj-> GetIP (); // Obtain the visitor's IP address. * $ Obj-> GetAdd (); // Obtain the geographical location of a visitor. use the Baidu hidden interface. * $ Obj-> GetIsp (); // Obtain the visitor's ISP and use the Baidu hidden interface. */Class guest_info {function GetLang () {$ Lang = substr ($ _ SERVER ['http _ ACCEPT_LANGUAGE '], 0, 4); // use substr () to intercept a string, starting from 0, truncates four characters (if (preg_match ('/zh-c/I', $ Lang) {// preg_match () regular Expression Matching function $ Lang = 'simplified Chinese';} elseif (preg_match ('/zh/I', $ Lang) {$ Lang = 'fan? Chinese';} else {$ Lang = 'English ';} return $ Lang;} function GetBrowser () {$ Browser = $ _ SERVER ['http _ USER_AGENT']; if (preg_match ('/MSIE/I', $ Browser) {$ Browser = 'msie ';} elseif (preg_match ('/Firefox/I ', $ Browser )) {$ Browser = 'Firefox ';} elseif (preg_match ('/Chrome/I ', $ Browser) {$ Browser = 'chromi ';} elseif (preg_match ('/Safari/I', $ Browser) {$ Browser = 'Safari ';} elseif (preg_match ('/Opera/I ', $ Browser )) {$ Br Owser = 'Opera ';} else {$ Browser = 'other';} return $ Browser;} function GetOS () {$ OS = $ _ SERVER ['http _ USER_AGENT ']; 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;} function GetIP () {if (! Empty ($ _ SERVER ['http _ CLIENT_IP ']) {// if the variable is a non-null or non-zero value, empty () returns FALSE. $ IP = explode (',', $ _ SERVER ['http _ CLIENT_IP ']);} elseif (! Empty ($ _ SERVER ['http _ X_FORWARDED_FOR ']) {$ IP = explode (', ', $ _ SERVER ['http _ X_FORWARDED_FOR']);} elseif (! Empty ($ _ SERVER ['remote _ ADDR ']) {$ IP = explode (', ', $ _ SERVER ['remote _ ADDR']);} else {$ IP [0] = 'none';} return $ IP [0];} private function GetAddIsp () {$ IP = $ this-> GetIP (); $ AddIsp = mb_convert_encoding (file_get_contents (' http://open.baidu.com/ipsearch/s?tn=ipjson&wd= '. $ IP), 'utf-8', 'gbk'); // mb_convert_encoding () converts the character encoding. If (preg_match ('/noresult/I', $ AddIsp) {$ AddIsp = 'none';} else {$ Sta = stripos ($ AddIsp, $ IP) + strlen ($ IP) + strlen ('From '); $ Len = stripos ($ AddIsp,' "} ')-$ Sta; $ AddIsp = substr ($ AddIsp, $ Sta, $ Len) ;}$ AddIsp = explode ('', $ AddIsp); return $ AddIsp;} function GetAdd () {$ Add = $ this-> GetAddIsp (); return $ Add [0];} function GetIsp () {$ Isp = $ this-> GetAddIsp (); if ($ Isp [0]! = 'None' & isset ($ Isp [1]) {$ Isp = $ Isp [1];} else {$ Isp = 'none ';} return $ Isp ;}$ obj = new guest_info; echo $ obj-> GetLang (); // Obtain the visitor's language: Simplified Chinese, traditional? Chinese and English. Echo $ obj-> GetBrowser (); // Obtain the visitor's browsers: MSIE, Firefox, Chrome, Safari, Opera, and Other. Echo $ obj-> GetOS (); // Obtain guest operating systems: Windows, MAC, Linux, Unix, BSD, and Other. Echo $ obj-> GetIP (); // Obtain the visitor's IP address. Echo $ obj-> GetAdd (); // Obtain the geographical location of a visitor. use the Baidu hidden interface. Echo $ obj-> GetIsp (); // Obtain the visitor's ISP and use Baidu to hide the access?>