public function isMobile()
{
if ($_GET['mobile'] === 'yes') {
setcookie('ismobile', 'yes', 3600);
return true;
} elseif ($_GET['mobile'] === 'no') {
setcookie('ismobile', 'no', 3600);
return false;
}
$cookie = $_COOKIE('ismobile');
if ($cookie === 'yes') {
return true;
} elseif ($cookie === 'no') {
return false;
} else {
$cookie = null;
static $mobileBrowserList = ['iphone', 'android', 'phone', 'mobile', 'wap', 'netfront', 'java', 'opera mobi', 'opera mini', 'ucweb', 'windows ce', 'symbian', 'series', 'webos', 'sony', 'blackberry', 'dopod', 'nokia', 'samsung', 'palmsource', 'xda', 'pieplus', 'meizu', 'midp', 'cldc', 'motorola', 'foma', 'docomo', 'up.browser', 'up.link', 'blazer', 'helio', 'hosin', 'huawei', 'novarra', 'coolpad', 'webos', 'techfaith', 'palmsource', 'alcatel', 'amoi', 'ktouch', 'nexian', 'ericsson', 'philips', 'sagem', 'wellcom', 'bunjalloo', 'maui', 'smartphone', 'iemobile', 'spice', 'bird', 'zte-', 'longcos', 'pantech', 'gionee', 'portalmmm', 'jig browser', 'hiptop', 'benq', 'haier', '^lct', '320x320', '240x320', '176x220'];
foreach ($mobileBrowserList as $val) {
$result = strpos(strtolower($_SERVER['HTTP_USER_AGENT']), $val);
if (false !== $result) {
setcookie('ismobile', 'yes', 3600);
return true;
}
}
setcookie('ismobile', 'no', 3600);
return false;
}
}