PHP Gets the client information class

Source: Internet
Author: User
PHP gets client information class
 Getlang ();        Get the language of your visitors: Simplified Chinese, Traditional Chinese, 中文版.     $obj->getbrowser ();        Get the Guest browser: MSIE, Firefox, Chrome, Safari, Opera, other.          $obj->getos ();        Get guest OS: Windows, MAC, Linux, Unix, BSD, other.          $obj->getip ();        Gets the guest IP address.         $obj->getadd ();        Get the visitor's location and use Baidu to hide the interface.         $obj->getisp ();   Get the guest ISP and use Baidu to hide the interface.           */class class_guest_info{function Getlang () {$Lang = substr ($_server[' http_accept_language '], 0, 4);               Use SUBSTR () to intercept a string, starting with 0 bits, intercept 4 characters if (Preg_match ('/zh-c/i ', $Lang)) {//preg_match () regular expression matching function           $Lang = ' Simplified Chinese ';           } elseif (Preg_match ('/zh/i ', $Lang)) {$Lang = ' Traditional Chinese ';           } else {$Lang = ' 中文版 ';       } 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 = ' Chrome ';           } elseif (Preg_match ('/safari/i ', $Browser)) {$Browser = ' Safari ';           } elseif (Preg_match ('/opera/i ', $Browser)) {$Browser = ' 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 nonzero 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;   }}?>
?
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.