/** * @return string */ public function getName() { if (!$this->isDetected) { $detector = new DeviceDetector(); $detector->detect($this); } return $this->name; }
private function addTopMenuMobileApp(MenuTop $menu) { if (empty($_SERVER['HTTP_USER_AGENT'])) { return; } if (!class_exists("DeviceDetector")) { throw new \Exception("DeviceDetector could not be found, maybe you are using Piwik from git and need to have update Composer. <br>php composer.phar update"); } $ua = new \DeviceDetector($_SERVER['HTTP_USER_AGENT']); $ua->parse(); $os = $ua->getOs('short_name'); if ($os && in_array($os, array('AND', 'IOS'))) { $menu->add('Piwik Mobile App', null, array('module' => 'Proxy', 'action' => 'redirect', 'url' => 'http://piwik.org/mobile/'), true, 4); } }
/** * @return string */ public function getName() { if (!isset($this->name)) { DeviceDetector::detect($this, $this->getUserAgent()); } return $this->name; }
protected function loadInfo() { list($plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie) = $this->request->getPlugins(); $resolution = $this->request->getParam('res'); $userAgent = $this->request->getUserAgent(); $deviceDetector = new \DeviceDetector($userAgent); $deviceDetector->setCache(new CacheFile('tracker', 86400)); $deviceDetector->parse(); $aBrowserInfo = $deviceDetector->getBrowser(); $browserName = !empty($aBrowserInfo['short_name']) ? $aBrowserInfo['short_name'] : 'UNK'; $browserVersion = !empty($aBrowserInfo['version']) ? $aBrowserInfo['version'] : ''; $os = $deviceDetector->getOS(); $os = empty($os['short_name']) ? 'UNK' : $os['short_name']; $browserLang = substr($this->request->getBrowserLanguage(), 0, 20); // limit the length of this string to match db $configurationHash = $this->getConfigHash($os, $browserName, $browserVersion, $plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $this->ipAddress, $browserLang); $this->params = array('config_id' => $configurationHash, 'config_os' => $os, 'config_browser_name' => $browserName, 'config_browser_version' => $browserVersion, 'config_resolution' => $resolution, 'config_pdf' => $plugin_PDF, 'config_flash' => $plugin_Flash, 'config_java' => $plugin_Java, 'config_director' => $plugin_Director, 'config_quicktime' => $plugin_Quicktime, 'config_realplayer' => $plugin_RealPlayer, 'config_windowsmedia' => $plugin_WindowsMedia, 'config_gears' => $plugin_Gears, 'config_silverlight' => $plugin_Silverlight, 'config_cookie' => $plugin_Cookie, 'location_browser_lang' => $browserLang); }
protected function getDevice($userAgent) { if (!class_exists('DeviceDetector')) { throw new \LogicException('class DeviceDetector is exists. UserAgentTheme require "piwik/device-detector": "~1.0" '); } if (is_null($this->device)) { $deviceDetector = new \DeviceDetector($userAgent); $deviceDetector->parse(); $device = $deviceDetector->getDevice(); /* \DeviceDetector::$deviceTypes = array( 'desktop', // 0 'smartphone', // 1 'tablet', // 2 'feature phone', // 3 'console', // 4 'tv', // 5 'car browser', // 6 'smart display', // 7 'camera' // 8 ); */ $this->device = $device === '' ? '' : \DeviceDetector::$deviceTypes[$device]; } return $this->device; }
public static function detect() { $agent = $_SERVER['HTTP_USER_AGENT']; if (strpos($agent, 'iPad') !== false) { if (strpos($agent, 'OS 3') !== false) { self::$isOldIOSDevice = true; } else { self::$isiPad4Device = true; } } else { if (strpos($agent, 'iPhone') !== false) { if (strpos($agent, 'iPhone OS 3') !== false) { self::$isOldIOSDevice = true; } else { self::$isNewIOSDevice = true; } } else { if (strpos($agent, 'Android') !== false) { self::$isAndroidDevice = true; } } } if (self::$isNewIOSDevice) { self::$category = "browser-ios4"; } else { if (self::$isiPad4Device) { self::$category = "browser-ipad4"; } else { if (self::$isOldIOSDevice) { self::$category = "browser-old-ios"; } else { if (self::$isAndroidDevice) { self::$category = "browser-android"; } else { self::$category = "browser-desktop"; } } } } }
} if (!defined("CALLER_USER_ID")) { if (!JAVASCRIPT) { define("CALLER_USER_ID", substr(md5(getIP()), 0, USER_ID_LENGTH)); define("CALLER_BROWSER_ID", substr(strrev(md5(getIP())), 0, USER_ID_LENGTH)); } else { define("CALLER_USER_ID", Visitor::IDValidate()); define("CALLER_BROWSER_ID", Visitor::IDValidate()); } } if (getCookieValue("userid") != CALLER_USER_ID) { setCookieValue("userid", CALLER_USER_ID); } $EXTERNALUSER = Visitor::FromCache(CALLER_USER_ID); $EXTERNALUSER->AppendPersonalData(); $detector = new DeviceDetector(); $detector->DetectBrowser(); $MobileDetect = $detector->DetectOperatingSystem($EXTERNALUSER->Host); $openChatExternal = !empty($CONFIG["gl_moce"]) && $MobileDetect->isMobile() && !$MobileDetect->isTablet(); $openTicketExternal = !empty($_GET["ovloe"]) || $openChatExternal; $monitoringActive = !empty($CONFIG["gl_vmac"]) || !empty($_GET["ovlc"]) || !empty($_GET["fbpos"]); if (isset($_GET[GET_TRACK_OUTPUT_TYPE]) && ($_GET[GET_TRACK_OUTPUT_TYPE] == "jscript" || $_GET[GET_TRACK_OUTPUT_TYPE] == "jcrpt")) { $fullname = base64UrlEncode($EXTERNALUSER->Fullname); $email = base64UrlEncode($EXTERNALUSER->Email); $company = base64UrlEncode($EXTERNALUSER->Company); $question = base64UrlEncode($EXTERNALUSER->Question); $phone = base64UrlEncode($EXTERNALUSER->Phone); $customs = array(); if (empty($_GET[GET_TRACK_NO_SEARCH_ENGINE])) { exit(getFile(TEMPLATE_HTML_SUPPORT)); }
<?php require_once 'config.php'; require constant('HOCKEY_INCLUDE_DIR'); $router = Router::get(array('appDirectory' => dirname(__FILE__) . DIRECTORY_SEPARATOR)); $apps = $router->app; $b = $router->baseURL; DeviceDetector::detect(); ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>App Installer</title> <meta name="viewport" content="width=device-width" /> <link rel="stylesheet" href="<?php echo $b; ?> blueprint/screen.css" type="text/css" media="screen, projection"> <link rel="stylesheet" href="<?php echo $b; ?> blueprint/print.css" type="text/css" media="print"> <!--[if IE]><link rel="stylesheet" href="<?php echo $b; ?> blueprint/ie.css" type="text/css" media="screen, projection"><![endif]--> <link rel="stylesheet" href="<?php echo $b; ?> blueprint/plugins/buttons/screen.css" type="text/css" media="screen, projection">
function Save($_config, $_resolution, $_color, $_timezone, $_lat, $_long, $_countryiso2, $_city, $_region, $_geotimezone, $_isp, $_geosspan, $_grid, $_js = true, $_fromCookie = false) { global $STATS, $COUNTRIES, $COUNTRY_ALIASES; if (!$this->FirstCall) { $this->KeepAlive(); } else { if (!isnull(getCookieValue("visits")) && $this->Visits == 1) { $this->Visits = getCookieValue("visits") + 1; } setCookieValue("visits", $this->Visits); if (!isnull(getCookieValue("last_visit"))) { $this->VisitLast = getCookieValue("last_visit"); } setCookieValue("last_visit", time()); $this->IP = getIP(); $this->SystemInfo = !empty($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : ""; $localization = getBrowserLocalization(); $this->Language = $localization[0]; $this->GeoCountryISO2 = $localization[1]; $this->Resolution = !empty($_resolution) && count($_resolution) == 2 && !empty($_resolution[0]) && !empty($_resolution[1]) ? $_resolution[0] . " x " . $_resolution[1] : ""; $this->Resolution .= !empty($_color) ? " (" . $_color . " Bit)" : ""; $this->GeoTimezoneOffset = getLocalTimezone($_timezone); $this->GeoResult = 0; if (!empty($_geosspan)) { createSSpanFile($_geosspan); } if (!empty($_config["gl_pr_ngl"]) && $_js) { if (!empty($_lat) && base64_decode($_lat) > -180) { setCookieValue(GEO_LATITUDE, $this->GeoLatitude = base64_decode($_lat)); setCookieValue(GEO_LONGITUDE, $this->GeoLongitude = base64_decode($_long)); setCookieValue(GEO_COUNTRY_ISO_2, $this->GeoCountryISO2 = base64_decode($_countryiso2)); setCookieValue(GEO_CITY, $this->GeoCity = base64_decode($_city)); setCookieValue(GEO_REGION, $this->GeoRegion = base64_decode($_region)); setCookieValue(GEO_TIMEZONE, $this->GeoTimezoneOffset = base64_decode($_geotimezone)); setCookieValue(GEO_ISP, $this->GeoISP = utf8_decode(base64_decode($_isp))); setCookieValue("geo_data", time()); } else { if (isset($_lat) && !empty($_lat)) { $this->GeoLatitude = base64_decode($_lat); $this->GeoLongitude = base64_decode($_long); } else { if (!isnull(getCookieValue("geo_data")) && !isnull(getCookieValue(GEO_LATITUDE))) { $this->GeoLatitude = getCookieValue(GEO_LATITUDE); $this->GeoLongitude = getCookieValue(GEO_LONGITUDE); $this->GeoCountryISO2 = getCookieValue(GEO_COUNTRY_ISO_2); $this->GeoCity = getCookieValue(GEO_CITY); $this->GeoRegion = getCookieValue(GEO_REGION); $this->GeoTimezoneOffset = getCookieValue(GEO_TIMEZONE); $this->GeoISP = getCookieValue(GEO_ISP); $_fromCookie = true; } } } removeSSpanFile(false); if ($_fromCookie) { $this->GeoResultId = 6; } else { if (!isnull($span = getSpanValue())) { if ($span > time() + CONNECTION_ERROR_SPAN) { $this->GeoResultId = 5; } else { $this->GeoResultId = 4; } } else { if (base64_decode($_lat) == -777) { $this->GeoResultId = 5; } else { if (base64_decode($_lat) == -522) { $this->GeoResultId = 2; } else { if ($_grid != 4) { $this->GeoResultId = 3; } else { $this->GeoResultId = $_grid; } } } } } } else { $this->GeoResultId = 7; } initData(false, false, false, false, false, false, true); if (isset($COUNTRY_ALIASES[$this->GeoCountryISO2])) { $this->GeoCountryISO2 = $COUNTRY_ALIASES[$this->GeoCountryISO2]; } else { if (!isset($COUNTRIES[$this->GeoCountryISO2]) && DEBUG_MODE) { logit($this->GeoCountryISO2, LIVEZILLA_PATH . "_log/unknown_countries.txt"); } } $detector = new DeviceDetector(); $detector->DetectBrowser(); if ($detector->AgentType == AGENT_TYPE_BROWSER || $detector->AgentType == AGENT_TYPE_UNKNOWN) { $detector->DetectOperatingSystem(); if (DEBUG_MODE && !empty($_SERVER["HTTP_USER_AGENT"])) { if ($detector->OperatingSystemUnknown) { logit("OS UNKNOWN: " . $_SERVER["HTTP_USER_AGENT"], LIVEZILLA_PATH . "_log/unknown_os.txt"); } else { if ($detector->AgentType == AGENT_TYPE_UNKNOWN) { logit("AGENT UNKNOWN: " . $_SERVER["HTTP_USER_AGENT"], LIVEZILLA_PATH . "_log/unknown_ag.txt"); } } } $bid = $this->GetBrowserId($detector->Browser, $detector->AgentType); $oid = $this->GetOSId($detector->OperatingSystem); $row = $this->CreateSignature(); if (is_array($row) && $row["id"] != $this->UserId) { $this->UserId = $row["id"]; $this->SignatureMismatch = true; } else { queryDB(true, "INSERT INTO `" . DB_PREFIX . DATABASE_VISITORS . "` (`id`, `entrance`,`last_active`, `host`,`ip`,`system`,`browser`, `visits`,`visit_id`,`visit_last`,`resolution`, `language`, `country`, `city`, `region`, `isp`, `timezone`, `latitude`, `longitude`, `geo_result`, `js`, `signature`) VALUES ('" . @mysql_real_escape_string($this->UserId) . "', '" . @mysql_real_escape_string(time()) . "','" . @mysql_real_escape_string(time()) . "', '" . @mysql_real_escape_string($this->Host) . "', '" . @mysql_real_escape_string($this->IP) . "', '" . @mysql_real_escape_string($oid) . "','" . @mysql_real_escape_string($bid) . "', '" . @mysql_real_escape_string($this->Visits) . "', '" . @mysql_real_escape_string($this->VisitId) . "','" . @mysql_real_escape_string($this->VisitLast) . "', '" . @mysql_real_escape_string(getValueId(DATABASE_VISITOR_DATA_RESOLUTIONS, "resolution", $this->Resolution, false, 32)) . "', '" . @mysql_real_escape_string(substr(strtoupper($this->Language), 0, 5)) . "','" . @mysql_real_escape_string($this->GeoCountryISO2) . "', '" . @mysql_real_escape_string(getValueId(DATABASE_VISITOR_DATA_CITIES, "city", $this->GeoCity, false)) . "', '" . @mysql_real_escape_string(getValueId(DATABASE_VISITOR_DATA_REGIONS, "region", $this->GeoRegion, false)) . "', '" . @mysql_real_escape_string(getValueId(DATABASE_VISITOR_DATA_ISPS, "isp", utf8_encode($this->GeoISP), false)) . "', '" . @mysql_real_escape_string($this->GeoTimezoneOffset) . "', '" . @mysql_real_escape_string($this->GeoLatitude) . "', '" . @mysql_real_escape_string($this->GeoLongitude) . "', '" . @mysql_real_escape_string($this->GeoResultId) . "', '" . @mysql_real_escape_string($_js ? 1 : 0) . "', '" . @mysql_real_escape_string($this->Signature) . "');"); if (mysql_affected_rows() == 1) { queryDB(true, "UPDATE `" . DB_PREFIX . DATABASE_VISITORS . "` SET `visit_latest`=0 WHERE `id`='" . @mysql_real_escape_string($this->UserId) . "' AND `visit_id`!='" . @mysql_real_escape_string($this->VisitId) . "';"); } } } else { if (STATS_ACTIVE) { $this->IsCrawler = true; $STATS->ProcessAction(ST_ACTION_LOG_CRAWLER_ACCESS, array($this->GetCrawlerId($detector->Browser), null)); } } } }
define("CALLER_USER_ID", substr(md5(Communication::GetIP()), 0, USER_ID_LENGTH)); define("CALLER_BROWSER_ID", substr(strrev(md5(Communication::GetIP())), 0, USER_ID_LENGTH)); } else { define("CALLER_USER_ID", Visitor::IDValidate()); define("CALLER_BROWSER_ID", Visitor::IDValidate()); } } if (Cookie::Get("userid") != CALLER_USER_ID) { Cookie::Set("userid", CALLER_USER_ID); } VisitorMonitoring::$Visitor = new Visitor(CALLER_USER_ID); VisitorMonitoring::$Visitor->Load(); if (empty(VisitorMonitoring::$Visitor->Host) && VisitorMonitoring::$Visitor->FirstCall) { VisitorMonitoring::$Visitor->ResolveHost(); } $detector = new DeviceDetector(); $detector->DetectBrowser(VisitorMonitoring::$Visitor->Host); $MobileDetect = $detector->DetectOperatingSystem(VisitorMonitoring::$Visitor->Host); VisitorMonitoring::$IsMobile = $MobileDetect->isMobile(); VisitorMonitoring::$IsTablet = $MobileDetect->isTablet(); if (!empty($_GET["ovlc"]) && empty($_GET["prv"]) && $detector->BrowserName == "Internet Explorer") { if ($detector->BrowserVersion <= 6) { unset($_GET["ovlc"]); } else { if ($detector->BrowserVersion < 9) { $_GET["ovloe"] = "MQ_"; } } } Visitor::$OpenChatExternal = !empty($_GET["ovloe"]) || !empty(Server::$Configuration->File["gl_moce"]) && VisitorMonitoring::$IsMobile; VisitorMonitoring::$IsActive = !empty(Server::$Configuration->File["gl_vmac"]) || !empty($_GET["ovlc"]);
public static function getOperatingSystemNameFromId($osId) { self::init(); if (isset(self::$operatingSystemsIdToName[$osId])) { return self::$operatingSystemsIdToName[$osId]; } if (class_exists('DeviceDetector')) { return DeviceDetector::getOsNameFromId($osId); } return false; }
function Save($_resolution, $_color, $_timezone, $_lat, $_long, $_countryiso2, $_city, $_region, $_geotimezone, $_isp, $_geosspan, $_grid, $_js = true, $_fromCookie = false) { if (!$this->FirstCall) { $this->KeepAlive(); } else { if (!Is::Null(Cookie::Get("visits")) && $this->Visits == 1) { $this->Visits = Cookie::Get("visits") + 1; } Cookie::Set("visits", $this->Visits); if (!Is::Null(Cookie::Get("last_visit"))) { $this->VisitLast = Cookie::Get("last_visit"); } Cookie::Set("last_visit", time()); $this->IP = Communication::GetIP(); $this->SystemInfo = !empty($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : ""; $localization = LocalizationManager::GetBrowserLocalization(); $this->Language = $localization[0]; if (!empty($localization[1])) { $this->GeoCountryISO2 = $localization[1]; } $this->Resolution = !empty($_resolution) && count($_resolution) == 2 && !empty($_resolution[0]) && !empty($_resolution[1]) ? $_resolution[0] . " x " . $_resolution[1] : ""; $this->Resolution .= !empty($_color) ? " (" . $_color . " Bit)" : ""; $this->GeoTimezoneOffset = SystemTime::GetLocalTimezone($_timezone); $this->GeoResult = 0; if (!empty($_geosspan)) { GeoTracking::SpanCreate($_geosspan); } if (!empty(Server::$Configuration->File["gl_use_ngl"]) && $_js) { if (!Is::Null(Cookie::Get("geo_data")) && !Is::Null(Cookie::Get(GEO_LATITUDE))) { $this->GeoLatitude = Cookie::Get(GEO_LATITUDE); $this->GeoLongitude = Cookie::Get(GEO_LONGITUDE); $this->GeoCountryISO2 = Cookie::Get(GEO_COUNTRY_ISO_2); $this->GeoCity = Cookie::Get(GEO_CITY); $this->GeoRegion = Cookie::Get(GEO_REGION); $this->GeoTimezoneOffset = Cookie::Get(GEO_TIMEZONE); $this->GeoISP = Cookie::Get(GEO_ISP); $_fromCookie = true; } else { if (!empty($_lat) && $_lat > -180) { Cookie::Set(GEO_LATITUDE, $this->GeoLatitude = $_lat); Cookie::Set(GEO_LONGITUDE, $this->GeoLongitude = $_long); Cookie::Set(GEO_COUNTRY_ISO_2, $this->GeoCountryISO2 = $_countryiso2); Cookie::Set(GEO_CITY, $this->GeoCity = $_city); Cookie::Set(GEO_REGION, $this->GeoRegion = $_region); Cookie::Set(GEO_TIMEZONE, $this->GeoTimezoneOffset = $_geotimezone); Cookie::Set(GEO_ISP, $this->GeoISP = $_isp); Cookie::Set("geo_data", time()); } else { if (!empty($_lat)) { $this->GeoLatitude = $_lat; $this->GeoLongitude = $_long; } } } GeoTracking::SpanRemove(false); if ($_fromCookie) { $this->GeoResultId = 6; } else { if (!Is::Null($span = GeoTracking::SpanExists())) { if ($span > time() + CONNECTION_ERROR_SPAN) { $this->GeoResultId = 5; } else { $this->GeoResultId = 4; } } else { if ($_lat == -777) { $this->GeoResultId = 5; } else { if ($_lat == -522) { $this->GeoResultId = 2; } else { if ($_grid != 4) { $this->GeoResultId = 3; } else { $this->GeoResultId = $_grid; } } } } } } else { $this->GeoResultId = 7; } Server::InitDataBlock(array("COUNTRIES")); if (isset(Server::$CountryAliases[$this->GeoCountryISO2])) { $this->GeoCountryISO2 = Server::$CountryAliases[$this->GeoCountryISO2]; } $detector = new DeviceDetector(); $detector->DetectBrowser($this->Host); if ($detector->AgentType == AGENT_TYPE_BROWSER || $detector->AgentType == AGENT_TYPE_UNKNOWN) { $detector->DetectOperatingSystem($this->Host); $bid = $this->GetBrowserId($detector->Browser, $detector->AgentType); $oid = $this->GetOSId($detector->OperatingSystem); $this->CreateSignature(); DBManager::Execute(true, "INSERT IGNORE INTO `" . DB_PREFIX . DATABASE_VISITORS . "` (`id`, `entrance`,`last_active`, `host`,`ip`,`system`,`browser`, `visits`,`visit_id`,`visit_last`,`resolution`, `language`, `country`, `city`, `region`, `isp`, `timezone`, `latitude`, `longitude`, `geo_result`, `js`, `signature`) VALUES ('" . DBManager::RealEscape($this->UserId) . "', '" . DBManager::RealEscape(time()) . "','" . DBManager::RealEscape(time()) . "', '" . DBManager::RealEscape($this->Host) . "', '" . DBManager::RealEscape($this->IP) . "', '" . DBManager::RealEscape($oid) . "','" . DBManager::RealEscape($bid) . "', '" . DBManager::RealEscape($this->Visits) . "', '" . DBManager::RealEscape($this->VisitId) . "','" . DBManager::RealEscape($this->VisitLast) . "', '" . DBManager::RealEscape(CacheManager::GetDataTableIdFromValue(DATABASE_VISITOR_DATA_RESOLUTIONS, "resolution", $this->Resolution, false, 32)) . "', '" . DBManager::RealEscape(substr(strtoupper($this->Language), 0, 5)) . "','" . DBManager::RealEscape($this->GeoCountryISO2) . "', '" . DBManager::RealEscape(CacheManager::GetDataTableIdFromValue(DATABASE_VISITOR_DATA_CITIES, "city", $this->GeoCity, false)) . "', '" . DBManager::RealEscape(CacheManager::GetDataTableIdFromValue(DATABASE_VISITOR_DATA_REGIONS, "region", $this->GeoRegion, false)) . "', '" . DBManager::RealEscape(CacheManager::GetDataTableIdFromValue(DATABASE_VISITOR_DATA_ISPS, "isp", utf8_encode($this->GeoISP), false)) . "', '" . DBManager::RealEscape($this->GeoTimezoneOffset) . "', '" . DBManager::RealEscape($this->GeoLatitude) . "', '" . DBManager::RealEscape($this->GeoLongitude) . "', '" . DBManager::RealEscape($this->GeoResultId) . "', '" . DBManager::RealEscape($_js ? 1 : 0) . "', '" . DBManager::RealEscape($this->Signature) . "');"); if ($this->VisitsDay > 1 && DBManager::GetAffectedRowCount() == 1) { DBManager::Execute(true, "UPDATE `" . DB_PREFIX . DATABASE_VISITORS . "` SET `visit_latest`=0 WHERE `id`='" . DBManager::RealEscape($this->UserId) . "' AND `visit_id`!='" . DBManager::RealEscape($this->VisitId) . "';"); } } else { if (STATS_ACTIVE) { $this->IsCrawler = true; Server::$Statistic->ProcessAction(ST_ACTION_LOG_CRAWLER_ACCESS, array($this->GetCrawlerId($detector->Browser), null)); } } } }