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 setConfig($id = 0) { global $INTERNAL, $RESPONSE, $STATS; if (SERVERSETUP && $INTERNAL[CALLER_SYSTEM_ID]->Level == USER_LEVEL_ADMIN) { if (STATS_ACTIVE && isset($_POST[POST_INTERN_RESET_STATS]) && $_POST[POST_INTERN_RESET_STATS] == "1") { $STATS->ResetAll(); } $id = createFile(FILE_CONFIG, base64_decode($_POST[POST_INTERN_UPLOAD_VALUE]), true); if (isset($_POST[POST_INTERN_SERVER_AVAILABILITY])) { setAvailability($_POST[POST_INTERN_SERVER_AVAILABILITY]); } if (isset($_POST[POST_INTERN_FILE_CARRIER_LOGO]) && strlen($_POST[POST_INTERN_FILE_CARRIER_LOGO]) > 0) { base64ToFile(FILE_CARRIERLOGO, $_POST[POST_INTERN_FILE_CARRIER_LOGO]); } else { if (isset($_POST[POST_INTERN_FILE_CARRIER_LOGO]) && file_exists(FILE_CARRIERLOGO)) { @unlink(FILE_CARRIERLOGO); } } if (isset($_POST[POST_INTERN_FILE_CARRIER_HEADER]) && strlen($_POST[POST_INTERN_FILE_CARRIER_HEADER]) > 0) { base64ToFile(FILE_CARRIERHEADER, $_POST[POST_INTERN_FILE_CARRIER_HEADER]); } else { if (isset($_POST[POST_INTERN_FILE_CARRIER_HEADER]) && file_exists(FILE_CARRIERHEADER)) { @unlink(FILE_CARRIERHEADER); } } if (isset($_POST[POST_INTERN_FILE_INVITATION_LOGO]) && strlen($_POST[POST_INTERN_FILE_INVITATION_LOGO]) > 0) { base64ToFile(FILE_INVITATIONLOGO, $_POST[POST_INTERN_FILE_INVITATION_LOGO]); } else { if (isset($_POST[POST_INTERN_FILE_INVITATION_LOGO]) && file_exists(FILE_INVITATIONLOGO)) { @unlink(FILE_INVITATIONLOGO); } } $int = 1; while (isset($_POST[POST_INTERN_DOWNLOAD_TRANSLATION_ISO . "_" . $int]) && strpos($_POST[POST_INTERN_DOWNLOAD_TRANSLATION_ISO . "_" . $int], "..") === false) { if (!isset($_POST[POST_INTERN_DOWNLOAD_TRANSLATION_DELETE . "_" . $int])) { createFile("./_language/lang" . strtolower($_POST[POST_INTERN_DOWNLOAD_TRANSLATION_ISO . "_" . $int]) . ".php", slashesStrip($_POST[POST_INTERN_DOWNLOAD_TRANSLATION_CONTENT . "_" . $int]), true); } else { @unlink("./_language/lang" . strtolower($_POST[POST_INTERN_DOWNLOAD_TRANSLATION_ISO . "_" . $int]) . ".php"); } $int++; } } removeSSpanFile(true); setIdle(0); $RESPONSE->SetStandardResponse($id, ""); }
function createStaticFile($_externalUser, $_resolution, $_color, $_timezone, $_lat, $_long, $_countryiso2, $_city, $_region, $_geotimezone, $_isp, $_geosspan, $_grid, $_fromCookie = false) { global $CONFIG; if (isnull(getCookieValue("userid"))) { setCookieValue("visits", $_externalUser->ExternalStatic->Visits = 1); } else { if (!isnull(getCookieValue("userid"))) { setCookieValue("visits", $_externalUser->ExternalStatic->Visits = getCookieValue("visits") + 1); } } $_externalUser->ExternalStatic->IP = getIP(); $_externalUser->ExternalStatic->Host = getHost(); $_externalUser->ExternalStatic->SystemInfo = !isnull($userAgent = getServerParam("HTTP_USER_AGENT")) ? $userAgent : ""; $_externalUser->ExternalStatic->Language = !isnull($acceptLanguage = getServerParam("HTTP_ACCEPT_LANGUAGE")) ? $acceptLanguage : ""; if (strlen($_externalUser->ExternalStatic->Language) > 8 || strpos($_externalUser->ExternalStatic->Language, ";") !== false) { $parts = explode(";", $_externalUser->ExternalStatic->Language); if (count($parts) > 0) { $_externalUser->ExternalStatic->Language = $parts[0]; } else { $_externalUser->ExternalStatic->Language = substr($_externalUser->ExternalStatic->Language, 0, 8); } } $_externalUser->ExternalStatic->Resolution = is_array($_resolution) && count($_resolution) == 2 ? $_resolution[0] . " x " . $_resolution[1] : ""; $_externalUser->ExternalStatic->Resolution .= !isnull($_color) ? " (" . $_color . " Bit)" : ""; $_externalUser->ExternalStatic->GeoTimezoneOffset = getLocalTimezone($_timezone); if (!isnull($_geosspan)) { createSSpanFile($_geosspan); } if (!isnull($CONFIG["wcl_geo_tracking"])) { if (!isnull($_lat) && base64_decode($_lat) > -180) { setCookieValue(GEO_LATITUDE, $_externalUser->ExternalStatic->GeoLatitude = base64_decode($_lat)); setCookieValue(GEO_LONGITUDE, $_externalUser->ExternalStatic->GeoLongitude = base64_decode($_long)); setCookieValue(GEO_COUNTRY_ISO_2, $_externalUser->ExternalStatic->GeoCountryISO2 = base64_decode($_countryiso2)); setCookieValue(GEO_CITY, $_externalUser->ExternalStatic->GeoCity = base64_decode($_city)); setCookieValue(GEO_REGION, $_externalUser->ExternalStatic->GeoRegion = base64_decode($_region)); setCookieValue(GEO_TIMEZONE, $_externalUser->ExternalStatic->GeoTimezoneOffset = base64_decode($_geotimezone)); setCookieValue(GEO_ISP, $_externalUser->ExternalStatic->GeoISP = base64_decode($_isp)); setCookieValue("geo_data", time()); } else { if (isset($_lat)) { $_externalUser->ExternalStatic->GeoLatitude = base64_decode($_lat); $_externalUser->ExternalStatic->GeoLongitude = base64_decode($_long); } else { if (!isnull(getCookieValue("geo_data"))) { $_externalUser->ExternalStatic->GeoLatitude = getCookieValue(GEO_LATITUDE); $_externalUser->ExternalStatic->GeoLongitude = getCookieValue(GEO_LONGITUDE); $_externalUser->ExternalStatic->GeoCountryISO2 = getCookieValue(GEO_COUNTRY_ISO_2); $_externalUser->ExternalStatic->GeoCity = getCookieValue(GEO_CITY); $_externalUser->ExternalStatic->GeoRegion = getCookieValue(GEO_REGION); $_externalUser->ExternalStatic->GeoTimezoneOffset = getCookieValue(GEO_TIMEZONE); $_externalUser->ExternalStatic->GeoISP = getCookieValue(GEO_ISP); $_fromCookie = true; } } } removeSSpanFile(false); if ($_fromCookie) { $_externalUser->ExternalStatic->GeoResultId = 6; } else { if (isSSpanFile()) { if (@filemtime(FILE_SERVER_GEO_SSPAN) > time() + CONNECTION_ERROR_SPAN) { $_externalUser->ExternalStatic->GeoResultId = 5; } else { $_externalUser->ExternalStatic->GeoResultId = 4; } } else { if (base64_decode($_lat) == -777) { $_externalUser->ExternalStatic->GeoResultId = 5; } else { if (base64_decode($_lat) == -522) { $_externalUser->ExternalStatic->GeoResultId = 2; } else { if ($_grid != 4) { $_externalUser->ExternalStatic->GeoResultId = 3; } else { $_externalUser->ExternalStatic->GeoResultId = $_grid; } } } } } if (strlen($_externalUser->ExternalStatic->Language) == 2 && !isnull(GEO_COUNTRY_ISO_2)) { $_externalUser->ExternalStatic->Language .= "-" . $_externalUser->ExternalStatic->GeoCountryISO2; } } $_externalUser->ExternalStatic->Save(); }
function setConfig($id = 0) { global $INTERNAL, $RESPONSE, $STATS, $CONFIG; administrationLog("setConfig", "", CALLER_SYSTEM_ID); if (isValidated() && ($INTERNAL[CALLER_SYSTEM_ID]->Level == USER_LEVEL_ADMIN || in_array($CONFIG["gl_host"], $INTERNAL[CALLER_SYSTEM_ID]->WebsitesConfig))) { if (is("STATS_ACTIVE") && !empty($_POST["p_reset_stats"])) { $STATS->ResetAll(); } $int = 0; $file = ISSUBSITE || $INTERNAL[CALLER_SYSTEM_ID]->Level != USER_LEVEL_ADMIN ? str_replace("config.inc", "config." . SUBSITEHOST . ".inc", FILE_CONFIG) : FILE_CONFIG; if (DB_CONNECTION && (!ISSUBSITE || file_exists($file))) { queryDB(true, "UPDATE `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_TYPES . "` SET `delete`='1';"); queryDB(true, "DELETE FROM `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_LOCALIZATIONS . "`;"); while (!empty($_POST["p_cfg_cct_id_" . $int])) { $cct = new CommercialChatBillingType($_POST["p_cfg_cct_id_" . $int], $_POST["p_cfg_cct_mnoc_" . $int], $_POST["p_cfg_cct_mtloc_" . $int], $_POST["p_cfg_cct_tae_" . $int], $_POST["p_cfg_cct_tvbo_" . $int], $_POST["p_cfg_cct_svbo_" . $int], $_POST["p_cfg_cct_evbo_" . $int], $_POST["p_cfg_cct_citl_" . $int], $_POST["p_cfg_cct_p_" . $int]); $cct->Save(); $iint = 0; while (!empty($_POST["p_cfg_cctli_id_" . $int . "_" . $iint])) { $cctl = new CommercialChatVoucherLocalization($_POST["p_cfg_cctli_id_" . $int . "_" . $iint], $_POST["p_cfg_cctli_itl_" . $int . "_" . $iint], $_POST["p_cfg_cctli_t_" . $int . "_" . $iint], $_POST["p_cfg_cctli_d_" . $int . "_" . $iint], $_POST["p_cfg_cctli_terms_" . $int . "_" . $iint], $_POST["p_cfg_cctli_emvc_" . $int . "_" . $iint], $_POST["p_cfg_cctli_emvp_" . $int . "_" . $iint], $_POST["p_cfg_cctli_emvu_" . $int . "_" . $iint], $_POST["p_cfg_cctli_exr_" . $int . "_" . $iint]); $cctl->Save($_POST["p_cfg_cct_id_" . $int]); $iint++; } $int++; } $int = 0; queryDB(true, "DELETE FROM `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_PROVIDERS . "`;"); while (!empty($_POST["p_cfg_ccpp_id_" . $int])) { $ccpp = new CommercialChatPaymentProvider($_POST["p_cfg_ccpp_id_" . $int], $_POST["p_cfg_ccpp_n_" . $int], $_POST["p_cfg_ccpp_a_" . $int], $_POST["p_cfg_ccpp_u_" . $int], $_POST["p_cfg_ccpp_l_" . $int]); $ccpp->Save(); $int++; } $int = 0; queryDB(true, "DELETE FROM `" . DB_PREFIX . DATABASE_MAILBOXES . "`;"); while (!empty($_POST["p_cfg_es_i_" . $int])) { $acc = new Mailbox($int, true); $acc->Save(); $int++; } queryDB(true, "DELETE FROM `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_TYPES . "` WHERE `delete`='1';"); queryDB(true, "DELETE FROM `" . DB_PREFIX . DATABASE_CONFIG . "`;"); foreach ($_POST as $key => $value) { if (strpos($key, "p_cfg_g_") === 0) { $skey = str_replace("p_cfg_g_", "", $key); $value = base64_decode($value); queryDB(true, "REPLACE INTO `" . DB_PREFIX . DATABASE_CONFIG . "` (`key`,`value`) VALUES ('" . DBManager::RealEscape($skey) . "','" . DBManager::RealEscape($value) . "');"); } } } if (isset($_POST["p_available"])) { setAvailability(!empty($_POST["p_available"])); } $id = createFile($file, base64_decode($_POST["p_upload_value"]), true); $int = 1; $delete = false; while (isset($_POST["p_int_trans_iso_" . $int]) && strpos($_POST["p_int_trans_iso_" . $int], "..") === false) { $file = getLocalizationFileString($_POST["p_int_trans_iso_" . $int], false); if (!isset($_POST["p_int_trans_delete_" . $int])) { createFile($file, $_POST["p_int_trans_content_" . $int], true); } else { $delete = true; if (file_exists($file)) { @unlink($file); } if (empty($CONFIG["gl_root"])) { createFile($file, "", true); } } $int++; } if (!$delete && (!@file_exists($file) || @file_exists($file) && @filemtime($file) !== false && @filemtime($file) < time() - 10)) { header("HTTP/1.1 502 Bad Gateway"); exit("HTTP/1.1 502 Bad Gateway"); } } removeSSpanFile(true); setIdle(0); $RESPONSE->SetStandardResponse($id, ""); }
function setConfig($id = 0) { global $INTERNAL, $RESPONSE; if (SERVERSETUP) { $id = createFile(FILE_CONFIG, base64_decode($_POST[POST_INTERN_UPLOAD_VALUE]), true); if (isset($_POST[POST_INTERN_SERVER_AVAILABILITY])) { setAvailability($_POST[POST_INTERN_SERVER_AVAILABILITY]); } if (isset($_POST[POST_INTERN_FILE_CARRIER_LOGO]) && strlen($_POST[POST_INTERN_FILE_CARRIER_LOGO]) > 0) { base64ToFile(FILE_CARRIERLOGO, $_POST[POST_INTERN_FILE_CARRIER_LOGO]); } else { if (isset($_POST[POST_INTERN_FILE_CARRIER_LOGO]) && file_exists(FILE_CARRIERLOGO)) { @unlink(FILE_CARRIERLOGO); } } if (isset($_POST[POST_INTERN_FILE_INVITATION_LOGO]) && strlen($_POST[POST_INTERN_FILE_INVITATION_LOGO]) > 0) { base64ToFile(FILE_INVITATIONLOGO, $_POST[POST_INTERN_FILE_INVITATION_LOGO]); } else { if (isset($_POST[POST_INTERN_FILE_INVITATION_LOGO]) && file_exists(FILE_INVITATIONLOGO)) { @unlink(FILE_INVITATIONLOGO); } } } removeSSpanFile(true); setIdle(0); $RESPONSE->SetStandardResponse($id, ""); }