Authored by hf

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

@@ -49,7 +49,7 @@ class WebAction extends Controller_Abstract @@ -49,7 +49,7 @@ class WebAction extends Controller_Abstract
49 */ 49 */
50 public function init() 50 public function init()
51 { 51 {
52 - Mobile::isGoMobile(); 52 + $this->isAjax() || Mobile::isGoMobile();
53 $this->_request = $this->getRequest(); 53 $this->_request = $this->getRequest();
54 54
55 // 设置环境变量 55 // 设置环境变量
@@ -49,28 +49,28 @@ class Mobile @@ -49,28 +49,28 @@ class Mobile
49 49
50 public static function match($url, $host, $uri) 50 public static function match($url, $host, $uri)
51 { 51 {
52 - //guang.yohobuy.com  
53 - //guang.yohobuy.com/1.html  
54 - $list = array(  
55 - array(  
56 - 'match' => '#^([guang\.]*)yohobuy\.com(\/*)$#',  
57 - ),  
58 - array(  
59 - 'match' => '#([guang\.]*)yohobuy.com/([0-9]+).html#',  
60 - 'to' => 'guang.m.yohobuy.com/info/index?id='.substr($uri,1,(strpos($uri,'.')-1)) ,  
61 - ),  
62 - );  
63 - foreach ($list as $value) {  
64 - if (preg_match($value['match'], $url) && !empty($value['to'])) {  
65 - return $value['to'];  
66 - } else if (preg_match($value['match'], $url)) {  
67 - $newHost = self::newHost($host);  
68 - return $newHost . $uri;  
69 - }  
70 - }  
71 -  
72 - $continueList = array('www', 'list', 'search');  
73 - $hostSplit = explode('.', $host); 52 +// //guang.yohobuy.com
  53 +// //guang.yohobuy.com/1.html
  54 +// $list = array(
  55 +// array(
  56 +// 'match' => '#^([guang\.]*)yohobuy\.com(\/*)$#',
  57 +// ),
  58 +// array(
  59 +// 'match' => '#([guang\.]*)yohobuy.com/([0-9]+).html#',
  60 +// 'to' => 'guang.m.yohobuy.com/info/index?id='.substr($uri,1,(strpos($uri,'.')-1)) ,
  61 +// ),
  62 +// );
  63 +// foreach ($list as $value) {
  64 +// if (preg_match($value['match'], $url) && !empty($value['to'])) {
  65 +// return $value['to'];
  66 +// } else if (preg_match($value['match'], $url)) {
  67 +// $newHost = self::newHost($host);
  68 +// return $newHost . $uri;
  69 +// }
  70 +// }
  71 +//
  72 +// $continueList = array('www', 'list', 'search');
  73 +// $hostSplit = explode('.', $host);
74 return 'm.yohobuy.com'; 74 return 'm.yohobuy.com';
75 } 75 }
76 76
@@ -91,18 +91,18 @@ class Mobile @@ -91,18 +91,18 @@ class Mobile
91 public static function isMobile() 91 public static function isMobile()
92 { 92 {
93 $userAgent = self::getUserAgent(); 93 $userAgent = self::getUserAgent();
94 - $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");  
95 - $is_mobile = false;  
96 if (stristr($userAgent, 'ipad')) { 94 if (stristr($userAgent, 'ipad')) {
97 - return $is_mobile; 95 + return false;
98 } 96 }
99 - foreach ($mobile_agents as $device) { 97 + $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");
  98 + $isMobile = false;
  99 + foreach ($mobileAgents as $device) {
100 if (stristr($userAgent, $device)) { 100 if (stristr($userAgent, $device)) {
101 - $is_mobile = true; 101 + $isMobile = true;
102 break; 102 break;
103 } 103 }
104 } 104 }
105 - return $is_mobile; 105 + return $isMobile;
106 } 106 }
107 107
108 /** 108 /**