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 isSSpanFile()
{
    return !isnull(getSpanValue());
}