Discuz教程网

终于发现了酷派手机为什么不能进WAP的原因

[复制链接]
authicon 矮矮 发表于 2013-5-18 20:34:06 | 显示全部楼层 |阅读模式
通过今天一天的研究,终于发现了酷派手机为什么不能进WAP的原因

source/function/function_core.php
  1. function checkmobile() {
  2. global $_G;
  3. $mobile = array();
  4. static $mobilebrowser_list =array('iphone', 'Android', 'phone', 'mobile','coolpad', 'wap', 'netfront', 'java', 'opera mobi',
  5. 'opera mini',
  6. 'ucweb', 'windows ce', 'symbian', 'series', 'webos', 'sony', 'blackberry', 'dopod', 'nokia',
  7. 'samsung',
  8. 'palmsource', 'xda', 'pieplus', 'meizu', 'midp', 'cldc', 'motorola', 'foma', 'docomo', 'up.browser',
  9. 'up.link', 'blazer', 'helio', 'hosin', 'huawei', 'novarra', 'coolpad', 'webos', 'techfaith',
  10. 'palmsource',
  11. 'alcatel', 'amoi', 'ktouch', 'nexian', 'ericsson', 'philips', 'sagem', 'wellcom', 'bunjalloo', 'maui',
  12. 'smartphone',
  13. 'iemobile', 'spice', 'bird', 'zte-', 'longcos', 'pantech', 'gionee', 'portalmmm', 'jig browser',
  14. 'hiptop',
  15. 'benq', 'haier', '^lct', '320x320', '240x320', '176X320','480x320');
  16. $pad_list = array('pad', 'gt-p1000');
  17. $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
  18. if(dstrpos($useragent, $pad_list)) {
  19. return false;
  20. }
  21. if(($v = dstrpos($useragent, $mobilebrowser_list, true))) {
  22. $_G['mobile'] = $v;
  23. return true;
  24. }
  25. $brower = array('mozilla', 'chrome', 'safari', 'opera', 'm3gate', 'winwap', 'openwave', 'myop');
  26. if(dstrpos($useragent, $brower)) return false;
  27. $_G['mobile'] = 'unknown';
  28. if($_GET['mobile'] === 'yes') {
  29. return true;
  30. } else {
  31. return false;
  32. }
  33. }
复制代码
上面的代码中因为先判断是否是Pad设备访问,然后再判断是否是手机访问。由于Pad的标识与酷派(Coolpad)的标识中都有Pad字样。因此,酷派就这样被判断成Pad设备了,自然也就跳转到电脑页面而非WAP了。

解决方法很简单,就是将PAD判断与酷派的判断更换一下先后顺序就可以了。如下:
  1. function checkmobile() {
  2. global $_G;
  3. $mobile = array();
  4. static $mobilebrowser_list =array('iphone', 'Android', 'phone', 'mobile','coolpad', 'wap', 'netfront', 'java', 'opera mobi',
  5. 'opera mini',
  6. 'ucweb', 'windows ce', 'symbian', 'series', 'webos', 'sony', 'blackberry', 'dopod', 'nokia',
  7. 'samsung',
  8. 'palmsource', 'xda', 'pieplus', 'meizu', 'midp', 'cldc', 'motorola', 'foma', 'docomo', 'up.browser',
  9. 'up.link', 'blazer', 'helio', 'hosin', 'huawei', 'novarra', 'coolpad', 'webos', 'techfaith',
  10. 'palmsource',
  11. 'alcatel', 'amoi', 'ktouch', 'nexian', 'ericsson', 'philips', 'sagem', 'wellcom', 'bunjalloo', 'maui',
  12. 'smartphone',
  13. 'iemobile', 'spice', 'bird', 'zte-', 'longcos', 'pantech', 'gionee', 'portalmmm', 'jig browser',
  14. 'hiptop',
  15. 'benq', 'haier', '^lct', '320x320', '240x320', '176X320','480x320');
  16. $pad_list = array('pad', 'gt-p1000');
  17. $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
  18. if(($v = dstrpos($useragent, $mobilebrowser_list, true))) {
  19. $_G['mobile'] = $v;
  20. return true;
  21. }
  22. if(dstrpos($useragent, $pad_list)) {
  23. return false;
  24. }
  25. $brower = array('mozilla', 'chrome', 'safari', 'opera', 'm3gate', 'winwap', 'openwave', 'myop');
  26. if(dstrpos($useragent, $brower)) return false;
  27. $_G['mobile'] = 'unknown';
  28. if($_GET['mobile'] === 'yes') {
  29. return true;
  30. } else {
  31. return false;
  32. }
  33. }
复制代码



上一篇:X3 发帖的时候出现 内部错误
下一篇:論壇管理後台登陆后秒退
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-2 13:21

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表