PHP language, browser, operating system, IP, location, isp,phpisp_php tutorial

Source: Internet
Author: User
Tags php language

PHP language, browser, operating system, IP, location, Isp,phpisp


   
 $obj= NewClass_guest_info;
$obj -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 operating system:Windows,MAC,Linux,Unix,BSD, Other.
$obj -GetIP(); //Get VisitorsIPaddress.
$obj -Getadd(); //get a visitor's location, useBaiduhides the interface.
$obj -Getisp(); //Get VisitorsISP, usingBaiduhides the interface.
classClass_guest_info
{
functionGetlang()
{
$Lang= substr($_server[' Http_accept_language '], 0, 4);
//Usesubstr ()intercepts a string from0bit start, intercept4of 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;
}

functionGetbrowser()
{
$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;
}

functionGetos()
{
$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;
}

functionGetIP()
{
if(!Emptyempty($_server[' Http_client_ip '])) {
//If the variable is a non-null or nonzero value, theempty ()returnFALSE.
$IP= Explode(',', $_server[' Http_client_ip ']);
}ElseIf(!Emptyempty($_server[' Http_x_forwarded_for '])) {
$IP= Explode(',', $_server[' Http_x_forwarded_for ']);
}ElseIf(!Emptyempty($_server[' REMOTE_ADDR '])) {
$IP= Explode(',', $_server[' REMOTE_ADDR ']);
}Else{
$IP[0] = ' None ';
}
return$IP[0];
}

Private FunctionGetaddisp()
{
$IP= $this -GetIP();
$ADDISP= mb_convert_encoding(file_get_contents(' http://open.baidu.com/ipsearch/stn=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;
}

functionGetadd()
{
$ADD= $this -Getaddisp();
return$ADD[0];
}

functionGetisp()
{
$ISP= $this -Getaddisp();
if($ISP[0] != ' None '&&isset($ISP[1])) {
$ISP= $ISP[1];
}Else{
$ISP= ' None ';
}
return$ISP;
}
}

http://www.bkjia.com/PHPjc/1105143.html www.bkjia.com true http://www.bkjia.com/PHPjc/1105143.html techarticle PHP language, browser, operating system, IP, geographic location, isp,phpisp php $obj = new Class_guest_info; $obj-getlang ();//Get the language of the visitor: Simplified Chinese, Traditional Chinese 、...

  • 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.