[英]Mobile site fails to load on ipad from chrome safari
I have some code at the front of my index.php file that calls out to a mobile detect php. 我在index.php文件的开头有一些代码,用于调用移动检测php。 It was working fine on iPhone and Android and iPad until one of the more recent ios updates... 8.0 .1 or maybe .2.
在iPhone,Android和iPad上,它一直运行良好,直到有最新的ios更新... 8.0 .1或.2.。 The code seems to try to forward to the flash page.
该代码似乎试图转发到Flash页面。
It still continues to work on Android and iPhone iOS 7. if possible can someone help me figure out what to change in order to get this script to work with the newer versions of iOS. 它仍然可以在Android和iPhone iOS 7上继续运行。如果可能,有人可以帮助我找出要更改的内容,以使此脚本与更新版本的iOS一起使用。
<?php
$tablet_browser = 0;
$mobile_browser = 0;
if (preg_match('/(tablet|ipad|playbook)|(android(?!.*(mobi|opera mini)))/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
$tablet_browser++;
}
if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android|iemobile)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
$mobile_browser++;
}
if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
$mobile_browser++;
}
$mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
$mobile_agents = array(
'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
'newt','noki','palm','pana','pant','phil','play','port','prox',
'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
'wapr','webc','winw','winw','xda ','xda-');
if (in_array($mobile_ua,$mobile_agents)) {
$mobile_browser++;
}
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'opera mini') > 0) {
$mobile_browser++;
//Check for tablets on opera mini alternative headers
$stock_ua = strtolower(isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])?$_SERVER['HTTP_X_OPERAMINI_PHONE_UA']:(isset($_SERVER['HTTP_DEVICE_STOCK_UA'])?$_SERVER['HTTP_DEVICE_STOCK_UA']:''));
if (preg_match('/(tablet|ipad|playbook)|(android(?!.*mobile))/i', $stock_ua)) {
$tablet_browser++;
}
}
/*if ($tablet_browser > 0) {
// do something for tablet devices
// echo 'is tablet';
}
else if ($mobile_browser > 0) {
// do something for mobile devices
echo 'is mobile';
}
else {
// do something for everything else
// echo 'is desktop';
} */
?>
I would suggest using https://github.com/serbanghita/Mobile-Detect/ 我建议使用https://github.com/serbanghita/Mobile-Detect/
Updates are added on the regular, and popularity ensures momentum going forward with future mobile devices. 定期添加更新,其受欢迎程度确保了未来移动设备的发展势头。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.