set_device() 更新通知 能在服务端识别设备了,更新后,移动端首次访问速度明显提升
时间:2016-07-28
文件目录 ./config/functions.php
搜索 function set_device()
把这里函数替换成如下:
搜索 function set_device()
把这里函数替换成如下:
//记录用户的访问设备 Monxin专用(PHP代码/函数) function set_device(){ $device_array=array('pc','phone'); //if(!isset($_COOKIE['monxin_device'])){$_COOKIE['monxin_device']=$device_array[0];return true;} if(isset($_GET['monxin_device']) && in_array(@$_GET['monxin_device'],$device_array)){ $_COOKIE['monxin_device']=$_GET['monxin_device']; //echo $_COOKIE['monxin_device'].'=monxin_device'; return true; } if(!in_array(@$_COOKIE['monxin_device'],$device_array)){ $_COOKIE['monxin_device']=$device_array[0]; return true; } if(isset($_COOKIE['monxin_device'])){return true;} $pc=array('Windows','Mac-into-sh'); $phone=array('Android','iPhone','iPod','BlackBerry','Windows Phone'); foreach($pc as $v){ if(strpos($_SERVER['HTTP_USER_AGENT'],$v)!==false){$_COOKIE['monxin_device']='pc';break;} } foreach($phone as $v){ if(strpos($_SERVER['HTTP_USER_AGENT'],$v)!==false){$_COOKIE['monxin_device']='phone';break;} } return false; }