1.自动识别WEB和WAP访客的商商城源码
自动识别WEB和WAP访客的源码
既然要利用已经存在的为HTML浏览器编写的代码,就需要知道请求是城源从HTML浏览器还是从WML浏览器过来的。同样地,源码如果想重新引导的商商城dz地方门户源码HTML浏览器直接到相应的HTML文档上,WML浏览器到WML页面上,城源以下的源码体育直播php源码PHP代码就可以做到这些。
// Because this 商商城script sends out HTTP header information,
// the first characters in the file must be the ? PHP tag.
// relative URL to your HTML file
$htmlredirect = "/html/my_htmlpage.html";
// ABSOLUTE URL to your WML file
$wmlredirect = "/wml/my_wmldeck.wml";
if(strpos(strtoupper($HTTP_ACCEPT),"VND.WAP.WML") 0)
{ // Check whether the browser/gateway says it accepts WML.
$br = "WML";
}
else {
$browser=substr(trim($HTTP_USER_AGENT),0,4);
if($browser=="Noki" || // Nokia phones and emulators
$browser=="Eric" || // Ericsson WAP phones and emulators
$browser=="WapI" || // Ericsson WapIDE 2.0
$browser=="MC" || // Ericsson MC
$browser=="AUR " || // Ericsson R
$browser=="R" || // Ericsson R
$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"?)
{
$br = "WML";
}
else {
$br = "HTML";
}
}
if($br == "WML") {
// Force the browser to load the WML file instead
header(" Moved Temporarily");
header("Location: ".$wmlredirect);
exit;
}
else {
// Force the browser to load the HTML file instead
header(" Moved Temporarily");
header("Location: ".$htmlredirect);
exit;
}
?
这个判断是在服务端完成的, PHP代码将首先查看网关是城源否接收text/vnd.wap.vml MIME类型。如果不是源码,将检测前面的商商城字符,查看是城源否为WML浏览器。如果不符合,源码那么就假设为HTML浏览器。商商城seata源码解析目录如果有新的城源WML浏览器,那么ID字符串也要增加。源码
这个代码基于Robert Whitinger(robert@wapsight.com)的php资金盘源码代码,使用了Don Amaro(donamaro.concepcion@nl.unisys.com)提供的列表。
注意:由于只需要四个字符串就可以辨别,因此例如:"WapIDE-SDK/2.0;(Rs(Arial))" 可以使用“WapI”来代替是996传奇引擎源码可行的做法,也是足够的。
同样的功能也可以通过ASP来解决。先判断请求的是“/index.wml” 或者 “/index.html” 和所需要的MIME类型。另外以下的脚本辨别的方式和上面不一样。另外还需要网关告诉服务器它能接收的text/vnd.wap.wml MIME类型。该例子如下所示:
%
Response.Buffer = TRUE
Dim IsWap
httpAccept = LCase(Request.ServerVariables("HTTP_ACCEPT"))
if Instr(httpAccept,"wap") then
IsWap=1
Else Response.Redirect "/index.html" : Response.Flush : Response.End
End if
%
%Response.ContentType = "text/vnd.wap.wml"%?xml version="1.0"?
%Response.Flush%
!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml"
wml
card id="redirect"
onevent type="onenterforward"
go href="/index.wml"/
/onevent
p
a href="/index.wml"enter/a
/p
/card
/wml
%Response.Flush:Response.End%