<?php
if (!defined('IN_DZZ')) {
exit('Access Denied');
}
class helper_browser
{
static function getBrowser($useragent = null)
{
$useragent = $useragent ? $useragent : $_SERVER['HTTP_USER_AGENT'];
if (strpos($useragent, 'MSIE') !== FALSE && strpos($useragent, 'Opera') === FALSE && strpos($useragent, 'Netscape') === FALSE) {
if (preg_match("/Blazer\/([0-9]{1}\.[0-9]{1}(\.[0-9])?)/", $useragent, $matches)) {
return array('blazer' => $matches[1]);
}
if (preg_match("/MSIE ([0-9]{1,2}\.[0-9]{1,2})/", $useragent, $matches)) {
return array('ie' => $matches[1]);
}
} elseif (strpos($useragent, 'IEMobile') !== FALSE) {
if (preg_match("/IEMobile\/([0-9]{1,2}\.[0-9]{1,2})/", $useragent, $matches)) {
return array('ie' => $matches[1], 'ismobile' => $matches[1]);
}
} elseif (strpos($useragent, 'Gecko')) {
if (strpos($useragent, 'Trident/7.0') !== FALSE && strpos($useragent, 'rv:11.0') !== FALSE) {
return array('ie' => 11);
} elseif (preg_match("/Firefox\/([0-9]{1,2}\.[0-9]{1,2}(\.[0-9]{1,2})?)/", $useragent, $matches)) {
return array('firefox' => $matches[1]);
}
if (preg_match("/Netscape\/([0-9]{1}\.[0-9]{1}(\.[0-9])?)/", $useragent, $matches)) {
return array('netscape' => $matches[1]);
}
if (preg_match("/Chrome\/([^\s]+)/", $useragent, $matches)) {
return array('chrome' => $matches[1]);
}
if (preg_match("/Safari\/([0-9]{2,4}(\.[0-9])?)/", $useragent, $matches)) {
return array('safari' => $matches[1]);
}
if (preg_match("/Galeon\/([0-9]{1}\.[0-9]{1}(\.[0-9])?)/", $useragent, $matches)) {
return array('galeon' => $matches[1]);
}
if (preg_match("/Konqueror\/([0-9]{1}\.[0-9]{1}(\.[0-9])?)/", $useragent, $matches)) {
return array('konqueror' => $matches[1]);
}
if (preg_match("/Fennec\/([0-9]{1}\.[0-9]{1}(\.[0-9])?)/", $useragent, $matches)) {
return array('fennec' => $matches[1]);
}
if (preg_match("/Maemo\/([0-9]{1}\.[0-9]{1}(\.[0-9])?)/", $useragent, $matches)) {
return array('maemo' => $matches[1]);
}
return array('Gecko based' => true);
} elseif (strpos($useragent, 'Opera') !== FALSE) {
if (preg_match("/Opera[\/ ]([0-9]{1}\.[0-9]{1}([0-9])?)/", $useragent, $matches)) {
return array('opera' => $matches[1]);
}
} elseif (strpos($useragent, 'Lynx') !== FALSE) {
if (preg_match("/Lynx\/([0-9]{1}\.[0-9]{1}(\.[0-9])?)/", $useragent, $matches)) {
return array('lynx' => $matches[1]);
}
} elseif (strpos($useragent, 'Netscape') !== FALSE) {
if (preg_match("/Netscape\/([0-9]{1}\.[0-9]{1}(\.[0-9])?)/", $useragent, $matches)) {
return array('netscape' => $matches[1]);
}
} else {
return 'unknown';
}
}
static function is_wxwork()
{
if (strpos($_SERVER['HTTP_USER_AGENT'], 'wxwork') !== false) {
return true;
} else {
return false;
}
}
static function ismobile()
{
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
if (preg_match("/WindowsWechat/i", $agent)) {
return false }
elseif (preg_match("/macintosh/i", $agent) && preg_match("/MicroMessenger/i", $agent)) {
return false }
elseif (preg_match("/MicroMessenger/i", $agent)) {
return 'wechat';
}
elseif (preg_match("/iphone/i", $agent) && preg_match("/mac os/i", $agent)) {
return 'iPhone';
} elseif (preg_match("/ipod/i", $agent) && preg_match("/mac os/i", $agent)) {
return 'iPod';
} elseif (preg_match("/ipad/i", $agent) && preg_match("/mac os/i", $agent)) {
return 'iPad';
} elseif (preg_match("/linux/i", $agent) && preg_match("/Android/i", $agent)) {
return 'Android';
}
return false;
}
static function getplatform()
{
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
$os = array();;
if (preg_match("/win/i", $agent) && preg_match('/nt 5.1/', $agent)) {
$os = array('Windows' => 'XP');
} elseif (preg_match('win', $agent) && preg_match('/nt 5.0/', $agent)) {
$os = array('Windows' => '2000');
} elseif (preg_match('win', $agent) && preg_match("/nt 5.2/i", $agent)) {
$os = array('Windows' => '2003');
} elseif (preg_match("/win/i", $agent) && preg_match("/nt 6.0/i", $agent)) {
$os = array('Windows' => '2008');
} elseif (preg_match("/win/i", $agent) && preg_match("/6.0/i", $agent)) {
$os = array('Windows' => 'vasta');
} elseif (preg_match("/win/i", $agent) && preg_match("/6.1/i", $agent)) {
$os = array('Windows' => '7');
} elseif (preg_match("/win/i", $agent) && preg_match("/6.2/i", $agent)) {
$os = array('Windows' => '8');
} elseif (preg_match("/win/i", $agent) && preg_match("/nt 6.3/i", $agent)) {
$os = array('Windows' => '8.1');
} elseif (preg_match("/win/i", $agent) && preg_match("/nt 10/i", $agent)) {
$os = array('Windows' => '10');
}elseif (preg_match("/win/i", $agent) && preg_match("/nt/i", $agent)) {
$os = array('Windows' => 'nt');
} elseif (preg_match("/ipad/i", $agent) && preg_match('/mac os/i', $agent)) {
$os = array('iPad' => true);
} elseif (preg_match("/iphone/i", $agent) && preg_match('/mac os/i', $agent)) {
$os = array('iPhone' => true);
} elseif (preg_match("/ipod/i", $agent) && preg_match('/mac os/i', $agent)) {
$os = array('iPod' => true);
} elseif (preg_match("/linux/i", $agent) && preg_match('/Android/i', $agent)) {
$os = array('Android' => true);
} elseif (preg_match("/linux/i", $agent)) {
$os = array('Linux' => true);
} elseif (preg_match("/unix/i", $agent)) {
$os = array('Unix' => true);
} elseif (preg_match("/Mac/i", $agent) && preg_match("/Macintosh/i", $agent)) {
$os = array('Macintosh' => true);
}
return $os;
}
}
?>