Mobile devices are becoming more and more mainstream, and there are many websites where rival machines are not particularly friendly. So we're going to have to assign a different interface to mobile phone customers for Web Access. How to tell if it is a mobile phone or a computer access?
First, when the mobile phone access, will be accompanied by sending user-agent information, this information will have mobile phone number information. If we can get ... Forget, with toe head also think, this is belongs to user personal privacy information, mobile and Unicom company certainly to shield or encrypt. Unless your server IP is on their white list.
So let's change the other way, when the phone is accessed through a proxy server, the HTTP header information will undoubtedly contain a message: via. This information provides valuable judgment information.
Like what:
The VIA information obtained by Henan Mobile is:
http/1.1 Hazz-b-gw001-wap (INFOX-WISG, Huawei Technologies)
The VIA information of Henan Unicom is:
Zxwap Gateway,zte Technologies
This way we get the VIA information string for HTTP to see if it contains WAP characters, if any, is accessed via the phone. This is quite accurate, but it will also block the use of mobile phone simulator users, (that is, with a WAP-enabled browser) ...
First look at the code "=====
Check_wap () { return stristr ($_server[' Http_via '), "WAP")? True:false; }
of course, the above method is too accurate, we also want those who use mobile phone simulator customers can also visit, it is necessary to think of a way.
Here is a way I check online, by judging the browser proxy identifier, determine whether it is a WAP-enabled browser to determine access to the page. One drawback is that it is not possible to list all of the phone's browser identifiers with the supported browser identifier. Uh, well ...
First look at the code "= =
<?php function Check_wap () { if (isset ($_server[' Http_via ')) return true; if (Isset ($_server[' Http_x_nokia_connection_mode ')) return true; if (Isset ($_server[' http_x_up_calling_line_id ')) return true; if (Strpos (Strtoupper ($_server[' http_accept ')), "VND. Wap. WML ") > 0) { //Check whether the Browser/gateway says it accepts WML. $BR = "WML";
Above returns True is WAP access} else {$browser = isset ($_server[' http_user_agent ')? Trim ($_server[' Http_user_agen T ']): "; if (empty ($browser)) return true; $browser =substr ($browser, 0,4); if ($browser = = "Noki" | |//Nokia phones and emulators $browser = = "Eric" | |//Ericsson WAP phones and emulator s $browser = = "WapI" | | Ericsson Wapide 2.0 $browser = = "MC21" | | Ericsson MC218 $browser = = "AUR" | | Ericsson R320 $browser = = "R380" | | Ericsson R380 $browser = = "up. B "| | Up. Browser $browser = = "WINW" | | Winwap browser $browser = = "UPG1" | | Up. SDK 4.0 $browser = = "Upsi" | | Another kind of up. Browser?? $browser = = "Qwap" | | Unknown qwapper Browser $browser = = "Jigs" | | Unknown JigSaw Browser $browser = = "Java" | | Unknown Java based Browser $browser = = "Alca" | | Unknown alcatel-bE3 browser (up based?) $browser = = "MITS" | | Unknown Mitsubishi Browser $browser = = "Mot-" | | Unknown browser (up based?) $browser = = "My S" | | Unknown Ericsson Devkit Browser? $browser = = "WAPJ" | | Virtual Wapjag www.wapjag.de $browser = = "Fetc" | | fetchpage.cgi Perl script from www.wapcab.de $browser = = "Alav" | | Yet another unknown up based browser? $browser = = "Wapa" | | Another unknown browser (Web based "Wapalyzer"?) $browser = = "Oper")//Opera {$br = "WML"; } else {$br = "HTML"; }} if ($br = = "WML") {return TRUE; } else {return FALSE; }} if (!check_wap ()) {Header ("Location:http://youurl"); Exit (); }our aim, of course, is to return to those customers who are not computer-accessible, the very friendly interface that suits them.
Then I think a good way is to use PHP to determine the browser's access to the Web details, browser size, version, kernel, and so on, to the individualized return of the Web interface.
How to tell if a phone or computer is accessing the Web