function isMobile(){
$useragent=isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$useragent_commentsblock=preg_match('|(.*?)|',$useragent,$matches)>0?$matches[0]:'';
函数 CheckSubstrs($substrs,$text){
foreach($substrs as $substr)
if(false!==strpos($text,$substr)){
返回 true;
}
返回 false;
}
$mobile_os_list=array('Google 无线转码器','Windows CE','WindowsCE','Symbian','Android','armv6l','armv5','Mobile','CentOS' ,'mowser','AvantGo','Opera Mobi','J2ME/MIDP','智能手机','Go.Web','Palm','iPAQ');
$mobile_token_list=array('Profile/ MIDP','配置/CLDC-','160×160','176×220','240×240','240×320','320×240','UP.Browser','UP.Link ','SymbianOS','PalmOS','PocketPC','SonyEricsson','诺基亚','黑莓','沃达丰','明基','Novarra-Vision','Iris','NetFront','HTC_ ','Xda_','SAMSUNG-SGH','Wapaka','DoCoMo','iPhone','iPod');
$found_mobile=CheckSubstrs($mobile_os_list,$useragent_commentsblock) ||
CheckSubstrs($mobile_token_list,$useragent);
if ($found_mobile){
返回 true;
}else{
返回 false;
}
}
if (isMobile())
echo '手机登录m.jb51.com';
else
echo '电脑登录www.jb51.com';
?>