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)); } $row = $EXTERNALUSER->CreateSignature();
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"]); VisitorMonitoring::$HideOverlayOnMobile = !empty($_GET["ovlhm"]) && (VisitorMonitoring::$IsMobile || VisitorMonitoring::$IsTablet);
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)); } } } }
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)); } } } }