Get the UA of WAP with PHP

Source: Internet
Author: User
UA class for WAP acquisition with PHP
/**
* Class Name: Mobile
* Description: Mobile phone information class
Other
*/
Class Mobile
{
/**
* Function Name: Getphonenumber
* Function function: Take phone number
* Input Parameters: None
* Function return Value: Successful return number, failed return false
* Other Instructions: description
*/
function Getphonenumber ()
{
if (Isset ($_server[' http_x_network_info '))
{
$str 1 = $_server[' http_x_network_info ');
$getstr 1 = preg_replace ('/(. *,) (13[\d]{9}) (,. *)/I ', ' \\2 ', $str 1);
Return $getstr 1;
}
ElseIf (Isset ($_server[' http_x_up_calling_line_id '))
{
$getstr 2 = $_server[' http_x_up_calling_line_id ');
Return $GETSTR 2;
}
ElseIf (Isset ($_server[' http_x_up_subno '))
{
$str 3 = $_server[' http_x_up_subno ');
$getstr 3 = preg_replace ('/(. *) (13[\d]{9}) (. *)/I ', ' \\2 ', $str 3);
Return $GETSTR 3;
}
ElseIf (Isset ($_server[' DEVICEID '))
{
Return $_server[' DEVICEID '];
}
Else
{
Return false;
}
}

/**
* Function Name: Gethttpheader
* Function Function: Take header information
* Input Parameters: None
* Function return Value: Successful return number, failed return false
* Other Instructions: description
*/
function Gethttpheader ()
{
$str = ";
foreach ($_server as $key = $val)
{
$gstr = Str_replace ("&", "&", $val);
$str. = "$key". $gstr. " \ r \ n ";
}
Return $str;
}

/**
* Function Name: Getua
* Function function: Take UA
* Input Parameters: None
* Function return Value: Successful return number, failed return false
* Other Instructions: description
*/
function Getua ()
{
if (Isset ($_server[' http_user_agent '))
{
Return $_server[' http_user_agent '];
}
Else
{
Return false;
}
}

/**
* Function Name: Getphonetype
* Function function: Get phone type
* Input Parameters: None
* Function return Value: String returned successfully, failure returned false
* Other Instructions: description
*/
function Getphonetype ()
{
$ua = $this->getua ();
if ($ua!=false)
{
$str = Explode (' ', $ua);
Return $str [0];
}
Else
{
Return false;
}
}

/**
* Function Name: Isopera
* Function Function: Judge whether it is opera
* Input Parameters: None
* Function return Value: String returned successfully, failure returned false
* Other Instructions: description
*/
function Isopera ()
{
$uainfo = $this->getua ();
if (Preg_match ('/.*opera.*/i ', $uainfo))
{
Return true;
}
Else
{
Return false;
}
}

/**
* Function Name: ism3gate
* Function Function: Judge whether it is m3gate
* Input Parameters: None
* Function return Value: String returned successfully, failure returned false
* Other Instructions: description
*/
function Ism3gate ()
{
$uainfo = $this->getua ();
if (Preg_match ('/m3gate/i ', $uainfo))
{
Return true;
}
Else
{
Return false;
}
}

/**
* Function Name: gethttpaccept
* Function function: Get ha
* Input Parameters: None
* Function return Value: String returned successfully, failure returned false
* Other Instructions: description
*/
function Gethttpaccept ()
{
if (Isset ($_server[' http_accept '))
{
Return $_server[' http_accept '];
}
Else
{
Return false;
}
}

/**
* Function Name: GetIP
* Function function: Get phone IP
* Input Parameters: None
* Function return Value: String returned successfully
* Other Instructions: description
*/
function GetIP ()
{
$ip =getenv (' remote_addr ');
$ip _ = getenv (' http_x_forwarded_for ');
if (($ip _! = "") && ($ip _! = "Unknown"))
{
$ip = $ip _;
}
return $IP;
}
}
?>

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