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 languageSelect($_mylang = "", $_require = false) { global $CONFIG, $INTERNAL, $LANGUAGES, $DEFAULT_BROWSER_LANGUAGE, $LANG_DIR, $LZLANG; //++ if (is("DB_CONNECTION")) { initData(array("LANGUAGES")); if (!$_require && !empty($DEFAULT_BROWSER_LANGUAGE)) { return; } requireDynamic(getLocalizationFileString("en"), LIVEZILLA_PATH . "_language/"); if (empty($_mylang)) { if (defined("CALLER_TYPE") && CALLER_TYPE == CALLER_TYPE_INTERNAL && defined("CALLER_SYSTEM_ID")) { $_mylang = strtolower($INTERNAL[CALLER_SYSTEM_ID]->Language); } else { $_mylang = getBrowserLocalization(); $_mylang = strtolower($_mylang[0]); } } if (!empty($CONFIG["gl_on_def_lang"]) && file_exists($tfile = getLocalizationFileString($CONFIG["gl_default_language"])) && @filesize($tfile) > 0) { $DEFAULT_BROWSER_LANGUAGE = $CONFIG["gl_default_language"]; requireDynamic(getLocalizationFileString($CONFIG["gl_default_language"]), LIVEZILLA_PATH . "_language/"); } else { if (empty($_mylang) || !empty($_mylang) && strpos($_mylang, "..") === false) { if (!empty($_mylang) && strlen($_mylang) >= 5 && substr($_mylang, 2, 1) == "-" && file_exists($tfile = getLocalizationFileString(substr($_mylang, 0, 5))) && @filesize($tfile) > 0) { requireDynamic(getLocalizationFileString($s_browser_language = strtolower(substr($_mylang, 0, 5))), LIVEZILLA_PATH . "_language/"); } else { if (!empty($_mylang) && strlen($_mylang) > 1 && file_exists($tfile = getLocalizationFileString(substr($_mylang, 0, 2))) && @filesize($tfile) > 0) { requireDynamic(getLocalizationFileString($s_browser_language = strtolower(substr($_mylang, 0, 2))), LIVEZILLA_PATH . "_language/"); } else { if (file_exists($tfile = getLocalizationFileString($CONFIG["gl_default_language"])) && @filesize($tfile) > 0) { requireDynamic(getLocalizationFileString($s_browser_language = $CONFIG["gl_default_language"]), LIVEZILLA_PATH . "_language/"); } } } if (isset($s_browser_language)) { $DEFAULT_BROWSER_LANGUAGE = $s_browser_language; } } else { if (file_exists(getLocalizationFileString($CONFIG["gl_default_language"]))) { requireDynamic(getLocalizationFileString($CONFIG["gl_default_language"]), LIVEZILLA_PATH . "_language/"); } } } if (empty($DEFAULT_BROWSER_LANGUAGE) && file_exists(getLocalizationFileString("en"))) { $DEFAULT_BROWSER_LANGUAGE = "en"; } if (empty($DEFAULT_BROWSER_LANGUAGE) || !empty($DEFAULT_BROWSER_LANGUAGE) && !@file_exists(getLocalizationFileString($DEFAULT_BROWSER_LANGUAGE))) { if (!(defined("SERVERSETUP") && SERVERSETUP)) { exit("Localization error: default language is not available."); } } $LANG_DIR = $LANGUAGES[strtoupper($DEFAULT_BROWSER_LANGUAGE)][2] ? "rtl" : "ltr"; if ($_require) { DataInput::Build(); } } else { requireDynamic(getLocalizationFileString("en"), LIVEZILLA_PATH . "_language/"); } }
} else { if ($_GET[GET_EXTERN_TEMPLATE] == "lz_chat_frame.3.2.chat.5.0") { $html = getFile(PATH_FRAMES . $_GET[GET_EXTERN_TEMPLATE] . ".tpl"); $html = str_replace("<!--alert-->", getAlertTemplate(), $html); } else { if ($_GET[GET_EXTERN_TEMPLATE] == "lz_chat_frame.4.1") { $html = getFile(PATH_FRAMES . "lz_chat_frame.4.1.tpl"); $html = str_replace("<!--param-->", @$CONFIG["gl_cpar"], $html); } else { if ($_GET[GET_EXTERN_TEMPLATE] == "lz_chat_frame.3.2.chat.7.0") { $html = getFile(PATH_FRAMES . $_GET[GET_EXTERN_TEMPLATE] . ".tpl"); $tlanguages = ""; if (strlen($CONFIG["gl_otrs"]) > 1) { require LIVEZILLA_PATH . "_lib/functions.external.inc.php"; $mylang = getBrowserLocalization(); $tlanguages = getLanguageSelects(getBrowserLocalization()); } require LIVEZILLA_PATH . "_lib/trdp/mobde.php"; $MobileDetect = new Mobile_Detect(); $small = $MobileDetect->isMobile() && !$MobileDetect->isTablet(); $html = str_replace("<!--translation_display-->", !$small && strlen($CONFIG["gl_otrs"]) > 1 ? "" : "none", $html); $html = str_replace("<!--transcript_option_display-->", !$small && !empty($CONFIG["gl_uret"]) ? "" : "none", $html); $html = str_replace("<!--languages-->", $tlanguages, $html); } else { if (in_array($_GET[GET_EXTERN_TEMPLATE], $static_frames) && strpos($_GET[GET_EXTERN_TEMPLATE], "..") === false) { $html = getFile(PATH_FRAMES . $_GET[GET_EXTERN_TEMPLATE] . ".tpl"); } } } } }
} else { if ($_GET[GET_EXTERN_TEMPLATE] == "lz_chat_frame.3.2.chat.4.0") { $html = getFile(PATH_FRAMES . $_GET[GET_EXTERN_TEMPLATE] . ".tpl"); $html = str_replace("<!--alert-->", getAlertTemplate(), $html); } else { if ($_GET[GET_EXTERN_TEMPLATE] == "lz_chat_frame.4.1") { $html = getFile(PATH_FRAMES . $_GET[GET_EXTERN_TEMPLATE] . ".tpl"); $html = str_replace("<!--param-->", $CONFIG["gl_c_param"], $html); } else { if ($_GET[GET_EXTERN_TEMPLATE] == "lz_chat_frame.3.2.chat.6.0") { $html = getFile(PATH_FRAMES . $_GET[GET_EXTERN_TEMPLATE] . ".tpl"); $tlanguages = ""; if (!empty($CONFIG["gl_otrs"])) { initData(false, false, false, false, false, true); require "./_lib/functions.external.inc.php"; $mylang = getBrowserLocalization(); foreach ($LANGUAGES as $iso => $langar) { if ($langar[1]) { $tlanguages .= "<option value=\"" . strtolower($iso) . "\"" . ($mylang[0] == $iso || strtolower($iso) == strtolower($CONFIG["gl_default_language"]) && (empty($mylang[0]) || !empty($mylang[0]) && isset($LANGUAGES[$mylang[0]]) && !$LANGUAGES[$mylang[0]][1]) ? " SELECTED" : "") . ">" . $langar[0] . "</option>"; } } $html = str_replace("<!--translator_api-->", "<script type=\"text/javascript\" src=\"https://www.google.com/jsapi\"></script><script type=\"text/javascript\">top.lz_translator = google;top.lz_translator.load(\"language\", \"1\");</script>", $html); } $html = str_replace("<!--translation_display-->", $CONFIG["gl_otrs"] ? "" : "none", $html); $html = str_replace("<!--transcript_option_display-->", $CONFIG["gl_uret"] ? "" : "none", $html); $html = str_replace("<!--languages-->", $tlanguages, $html); } else { $html = getFile(PATH_FRAMES . $_GET[GET_EXTERN_TEMPLATE] . ".tpl"); } } }