Authored by hf

code review by fei.hong: do modify check is mobile access

... ... @@ -49,7 +49,7 @@ class WebAction extends Controller_Abstract
*/
public function init()
{
Mobile::isGoMobile();
$this->isAjax() || Mobile::isGoMobile();
$this->_request = $this->getRequest();
// 设置环境变量
... ...
... ... @@ -49,28 +49,28 @@ class Mobile
public static function match($url, $host, $uri)
{
//guang.yohobuy.com
//guang.yohobuy.com/1.html
$list = array(
array(
'match' => '#^([guang\.]*)yohobuy\.com(\/*)$#',
),
array(
'match' => '#([guang\.]*)yohobuy.com/([0-9]+).html#',
'to' => 'guang.m.yohobuy.com/info/index?id='.substr($uri,1,(strpos($uri,'.')-1)) ,
),
);
foreach ($list as $value) {
if (preg_match($value['match'], $url) && !empty($value['to'])) {
return $value['to'];
} else if (preg_match($value['match'], $url)) {
$newHost = self::newHost($host);
return $newHost . $uri;
}
}
$continueList = array('www', 'list', 'search');
$hostSplit = explode('.', $host);
// //guang.yohobuy.com
// //guang.yohobuy.com/1.html
// $list = array(
// array(
// 'match' => '#^([guang\.]*)yohobuy\.com(\/*)$#',
// ),
// array(
// 'match' => '#([guang\.]*)yohobuy.com/([0-9]+).html#',
// 'to' => 'guang.m.yohobuy.com/info/index?id='.substr($uri,1,(strpos($uri,'.')-1)) ,
// ),
// );
// foreach ($list as $value) {
// if (preg_match($value['match'], $url) && !empty($value['to'])) {
// return $value['to'];
// } else if (preg_match($value['match'], $url)) {
// $newHost = self::newHost($host);
// return $newHost . $uri;
// }
// }
//
// $continueList = array('www', 'list', 'search');
// $hostSplit = explode('.', $host);
return 'm.yohobuy.com';
}
... ... @@ -91,18 +91,18 @@ class Mobile
public static function isMobile()
{
$userAgent = self::getUserAgent();
$mobile_agents = Array("240x320","acer","acoon","acs-","abacho","ahong","airness","alcatel","amoi","android","anywhereyougo.com","applewebkit/525","applewebkit/532","asus","audio","au-mic","avantogo","becker","benq","bilbo","bird","blackberry","blazer","bleu","cdm-","compal","coolpad","danger","dbtel","dopod","elaine","eric","etouch","fly ","fly_","fly-","go.web","goodaccess","gradiente","grundig","haier","hedy","hitachi","htc","huawei","hutchison","inno","ipad","ipaq","ipod","jbrowser","kddi","kgt","kwc","lenovo","lg ","lg2","lg3","lg4","lg5","lg7","lg8","lg9","lg-","lge-","lge9","longcos","maemo","mercator","meridian","micromax","midp","mini","mitsu","mmm","mmp","mobi","mot-","moto","nec-","netfront","newgen","nexian","nf-browser","nintendo","nitro","nokia","nook","novarra","obigo","palm","panasonic","pantech","philips","phone","pg-","playstation","pocket","pt-","qc-","qtek","rover","sagem","sama","samu","sanyo","samsung","sch-","scooter","sec-","sendo","sgh-","sharp","siemens","sie-","softbank","sony","spice","sprint","spv","symbian","tablet","talkabout","tcl-","teleca","telit","tianyu","tim-","toshiba","tsm","up.browser","utec","utstar","verykool","virgin","vk-","voda","voxtel","vx","wap","wellco","wig browser","wii","windows ce","wireless","xda","xde","zte");
$is_mobile = false;
if (stristr($userAgent, 'ipad')) {
return $is_mobile;
return false;
}
foreach ($mobile_agents as $device) {
$mobileAgents = array('iphone','android',"240x320","acer","acoon","acs-","abacho","ahong","airness","alcatel","amoi","anywhereyougo.com","applewebkit/525","applewebkit/532","asus","audio","au-mic","avantogo","becker","benq","bilbo","bird","blackberry","blazer","bleu","cdm-","compal","coolpad","danger","dbtel","dopod","elaine","eric","etouch","fly ","fly_","fly-","go.web","goodaccess","gradiente","grundig","haier","hedy","hitachi","htc","huawei","hutchison","inno","ipad","ipaq","ipod","jbrowser","kddi","kgt","kwc","lenovo","lg ","lg2","lg3","lg4","lg5","lg7","lg8","lg9","lg-","lge-","lge9","longcos","maemo","mercator","meridian","micromax","midp","mini","mitsu","mmm","mmp","mobi","mot-","moto","nec-","netfront","newgen","nexian","nf-browser","nintendo","nitro","nokia","nook","novarra","obigo","palm","panasonic","pantech","philips","phone","pg-","playstation","pocket","pt-","qc-","qtek","rover","sagem","sama","samu","sanyo","samsung","sch-","scooter","sec-","sendo","sgh-","sharp","siemens","sie-","softbank","sony","spice","sprint","spv","symbian","tablet","talkabout","tcl-","teleca","telit","tianyu","tim-","toshiba","tsm","up.browser","utec","utstar","verykool","virgin","vk-","voda","voxtel","vx","wap","wellco","wig browser","wii","windows ce","wireless","xda","xde","zte");
$isMobile = false;
foreach ($mobileAgents as $device) {
if (stristr($userAgent, $device)) {
$is_mobile = true;
$isMobile = true;
break;
}
}
return $is_mobile;
return $isMobile;
}
/**
... ...