本文整理汇总了PHP中Vtiger_Functions::browerCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_Functions::browerCache方法的具体用法?PHP Vtiger_Functions::browerCache怎么用?PHP Vtiger_Functions::browerCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vtiger_Functions
的用法示例。
在下文中一共展示了Vtiger_Functions::browerCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBrowserInfo
public function getBrowserInfo()
{
if (!self::$browerCache) {
$HTTP_USER_AGENT = strtolower($_SERVER['HTTP_USER_AGENT']);
$browser = new stdClass();
$browser->ver = 0;
$browser->https = false;
$browser->win = strpos($HTTP_USER_AGENT, 'win') != false;
$browser->mac = strpos($HTTP_USER_AGENT, 'mac') != false;
$browser->linux = strpos($HTTP_USER_AGENT, 'linux') != false;
$browser->unix = strpos($HTTP_USER_AGENT, 'unix') != false;
$browser->webkit = strpos($HTTP_USER_AGENT, 'applewebkit') !== false;
$browser->opera = strpos($HTTP_USER_AGENT, 'opera') !== false || $browser->webkit && strpos($HTTP_USER_AGENT, 'opr/') !== false;
$browser->ns = strpos($HTTP_USER_AGENT, 'netscape') !== false;
$browser->chrome = !$browser->opera && strpos($HTTP_USER_AGENT, 'chrome') !== false;
$browser->ie = !$browser->opera && (strpos($HTTP_USER_AGENT, 'compatible; msie') !== false || strpos($HTTP_USER_AGENT, 'trident/') !== false);
$browser->safari = !$browser->opera && !$browser->chrome && ($browser->webkit || strpos($HTTP_USER_AGENT, 'safari') !== false);
$browser->mz = !$browser->ie && !$browser->safari && !$browser->chrome && !$browser->ns && !$browser->opera && strpos($HTTP_USER_AGENT, 'mozilla') !== false;
if ($browser->opera) {
if (preg_match('/(opera|opr)\\/([0-9.]+)/', $HTTP_USER_AGENT, $regs)) {
$browser->ver = (double) $regs[2];
}
} else {
if (preg_match('/(chrome|msie|version|khtml)(\\s*|\\/)([0-9.]+)/', $HTTP_USER_AGENT, $regs)) {
$browser->ver = (double) $regs[3];
} else {
if (preg_match('/rv:([0-9.]+)/', $HTTP_USER_AGENT, $regs)) {
$browser->ver = (double) $regs[1];
}
}
}
if (preg_match('/ ([a-z]{2})-([a-z]{2})/', $HTTP_USER_AGENT, $regs)) {
$browser->lang = $regs[1];
} else {
$browser->lang = 'en';
}
if (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') {
$browser->https = true;
}
if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') {
$browser->https = true;
}
self::$browerCache = $browser;
}
return self::$browerCache;
}
示例2: getBrowserInfo
public static function getBrowserInfo()
{
if (!self::$browerCache) {
$HTTP_USER_AGENT = strtolower($_SERVER['HTTP_USER_AGENT']);
$browser = new stdClass();
$browser->ver = 0;
$browser->https = false;
$browser->win = strpos($HTTP_USER_AGENT, 'win') != false;
$browser->mac = strpos($HTTP_USER_AGENT, 'mac') != false;
$browser->linux = strpos($HTTP_USER_AGENT, 'linux') != false;
$browser->unix = strpos($HTTP_USER_AGENT, 'unix') != false;
$browser->webkit = strpos($HTTP_USER_AGENT, 'applewebkit') !== false;
$browser->opera = strpos($HTTP_USER_AGENT, 'opera') !== false || $browser->webkit && strpos($HTTP_USER_AGENT, 'opr/') !== false;
$browser->ns = strpos($HTTP_USER_AGENT, 'netscape') !== false;
$browser->chrome = !$browser->opera && strpos($HTTP_USER_AGENT, 'chrome') !== false;
$browser->ie = !$browser->opera && (strpos($HTTP_USER_AGENT, 'compatible; msie') !== false || strpos($HTTP_USER_AGENT, 'trident/') !== false);
$browser->safari = !$browser->opera && !$browser->chrome && ($browser->webkit || strpos($HTTP_USER_AGENT, 'safari') !== false);
$browser->mz = !$browser->ie && !$browser->safari && !$browser->chrome && !$browser->ns && !$browser->opera && strpos($HTTP_USER_AGENT, 'mozilla') !== false;
if ($browser->opera) {
if (preg_match('/(opera|opr)\\/([0-9.]+)/', $HTTP_USER_AGENT, $regs)) {
$browser->ver = (double) $regs[2];
}
} else {
if (preg_match('/(chrome|msie|version|khtml)(\\s*|\\/)([0-9.]+)/', $HTTP_USER_AGENT, $regs)) {
$browser->ver = (double) $regs[3];
} else {
if (preg_match('/rv:([0-9.]+)/', $HTTP_USER_AGENT, $regs)) {
$browser->ver = (double) $regs[1];
}
}
}
if (preg_match('/ ([a-z]{2})-([a-z]{2})/', $HTTP_USER_AGENT, $regs)) {
$browser->lang = $regs[1];
} else {
$browser->lang = 'en';
}
if (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') {
$browser->https = true;
}
if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') {
$browser->https = true;
}
$sp = strtolower($_SERVER['SERVER_PROTOCOL']);
$protocol = substr($sp, 0, strpos($sp, '/')) . ($browser->https ? 's' : '');
$port = $_SERVER['SERVER_PORT'];
$port = !$browser->https && $port == '80' || $browser->https && $port == '443' ? '' : ':' . $port;
$host = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null);
$host = isset($host) ? $host : $_SERVER['SERVER_NAME'] . $port;
$browser->url = $protocol . '://' . $host . $_SERVER['REQUEST_URI'];
self::$browerCache = $browser;
}
return self::$browerCache;
}