Файл: adultscript-2.0.3-pro/files/libraries/framework/browser.php
Строк: 62
<?php
defined('_VALID') or die('Restricted Access!');
class VBrowser
{
private static $__cache = array();
public static function get($var)
{
if (isset(self::$__cache[$var])) {
return self::$__cache[$var];
}
$info = array();
$user_agent = VServer::get('HTTP_USER_AGENT');
$browsers = VF::cfg('library.mobile');
foreach ($browsers as $agent => $name) {
if (stripos($user_agent, $name) !== FALSE) {
$info['name'] = $name;
$info['is_browser'] = FALSE;
$info['is_mobile'] = TRUE;
$info['is_robot'] = FALSE;
if (preg_match('|'.preg_quote($agent).'[^0-9.]*+([0-9.][0-9.a-z]*)|i', $user_agent, $match)) {
$info['version'] = $match['1'];
} else {
$info['version'] = '';
}
break;
}
}
if (!isset($info['name'])) {
$browsers = VF::cfg('library.browsers');
foreach ($browsers as $agent => $name) {
if (stripos($user_agent, $name) !== FALSE) {
$info['name'] = $name;
$info['is_browser'] = TRUE;
$info['is_robot'] = FALSE;
$info['is_mobile'] = FALSE;
if (preg_match('|'.preg_quote($agent).'[^0-9.]*+([0-9.][0-9.a-z]*)|i', $user_agent, $match)) {
$info['version'] = $match['1'];
} else {
$info['version'] = '';
}
break;
}
}
}
// identify search engines
$robots = VF::cfg('library.robots');
foreach ($robots as $robot => $name) {
if (stripos($user_agent, $name) !== FALSE) {
$info['name'] = $name;
$info['is_browser'] = FALSE;
$info['is_robot'] = TRUE;
$info['is_mobile'] = FALSE;
$info['version'] = '';
break;
}
}
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$HTTP_ACCEPT_LANGUAGE = VServer::get('HTTP_ACCEPT_LANGUAGE');
if (preg_match_all('/[-a-z]{2,}/', strtolower(trim($HTTP_ACCEPT_LANGUAGE)), $matches)) {
$info['languages'] = $matches['0'];
}
}
if (!empty($_SERVER['HTTP_ACCEPT_CHARSET'])) {
$HTTP_ACCEPT_CHARSET = VServer::get('HTTP_ACCEPT_CHARSET');
if (preg_match_all('/[-a-z0-9]{2,}/', strtolower(trim($HTTP_ACCEPT_CHARSET)), $matches)) {
$info['charsets'] = $matches['0'];
}
}
self::$__cache = $info;
return (isset($info[$var])) ? $info[$var] : NULL;
}
}
?>