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/"); } }
function getConfig($xml = "") { global $_CONFIG, $CONFIG, $INTERNAL; $skeys = array("gl_db_host", "gl_db_user", "gl_db_pass", "gl_db_name"); $hashfile = FILE_CONFIG; $ms = base64_decode($_CONFIG["gl_lzst"]) == 1; $cindex = 0; $cfiles = getDirectory(PATH_CONFIG, "config.inc.php"); foreach ($_CONFIG as $index => $server_val) { if (is_array($server_val)) { $xml .= "<conf key=\"" . base64_encode($index) . "\">\r\n"; foreach ($server_val as $skey => $sval) { if (!is_array($sval)) { $xml .= "<sub key=\"" . base64_encode($skey) . "\">" . $sval . "</sub>\r\n"; } } $xml .= "</conf>\r\n"; } else { if (!(is_int($index) && is_array($server_val))) { $xml .= "<conf value=\"" . $server_val . "\" key=\"" . base64_encode($index) . "\" />\r\n"; } } } if (!empty($CONFIG["gl_root"])) { $cfiles = array_merge(array("config.inc.php"), $cfiles); } $rootBased = $CONFIG["gl_root"]; foreach ($cfiles as $file) { if (substr($file, 0, 7) == "config." && strpos($file, ".inc.php") == strlen($file) - 8) { $chost = str_replace("inc.php", "", str_replace("config.", "", $file)); $chost = strlen($chost) > 0 ? substr($chost, 0, strlen($chost) - 1) : $chost; if (!$ms || (empty($_GET["ws"]) && strtolower($_SERVER["HTTP_HOST"]) == strtolower($chost) || empty($chost) && strtolower($_SERVER["HTTP_HOST"]) == strtolower($CONFIG["gl_host"]) || !empty($_GET["ws"]) && base64_decode($_GET["ws"]) == $chost || !empty($rootBased) && SERVERSETUP && !MANAGEMENT || in_array($chost, $INTERNAL[CALLER_SYSTEM_ID]->WebsitesConfig) || in_array($chost, $INTERNAL[CALLER_SYSTEM_ID]->WebsitesUsers))) { if (!empty($chost) && file_exists(str_replace("config.inc", "config." . $chost . ".inc", FILE_CONFIG))) { $hashfile = str_replace("config.inc", "config." . $chost . ".inc", FILE_CONFIG); requireDynamic($hashfile, LIVEZILLA_PATH . "_config/"); loadConfig(false); initDataProvider(); } foreach ($_CONFIG as $index => $server_val) { if (is_int($index) && is_array($server_val)) { $xml .= "<site index=\"" . base64_encode($cindex) . "\">\r\n"; foreach ($server_val as $key => $site_val) { if (is_array($site_val)) { $xml .= "<conf key=\"" . base64_encode($key) . "\">\r\n"; foreach ($site_val as $skey => $sval) { $xml .= "<sub key=\"" . base64_encode($skey) . "\">" . $sval . "</sub>\r\n"; } $xml .= "</conf>\r\n"; } else { if (!in_array($key, $skeys) || SERVERSETUP) { $xml .= "<conf value=\"" . $site_val . "\" key=\"" . base64_encode($key) . "\" />\r\n"; } else { $xml .= "<conf value=\"" . base64_encode("") . "\" key=\"" . base64_encode($key) . "\" />\r\n"; } } } $cindex++; if ($CONFIG["gl_host"] == base64_decode($server_val["gl_host"])) { $xml .= "<db_conf>\r\n"; if (!empty($CONFIG["db"]["cct"])) { $xml .= "<cct>\r\n"; foreach ($CONFIG["db"]["cct"] as $cct) { $xml .= $cct->GetXML(); } $xml .= "</cct>\r\n"; } if (!empty($CONFIG["db"]["ccpp"])) { $xml .= "<ccpp>\r\n"; foreach ($CONFIG["db"]["ccpp"] as $ccpp) { $xml .= $ccpp->GetXML(); } $xml .= "</ccpp>\r\n"; } if (!empty($CONFIG["db"]["gl_email"])) { $xml .= "<gl_email>\r\n"; foreach ($CONFIG["db"]["gl_email"] as $mb) { $xml .= $mb->GetXML(); } $xml .= "</gl_email>\r\n"; } $xml .= "</db_conf>\r\n"; } $xml .= "</site>\r\n"; } } } } } if (SERVERSETUP) { $xml .= "<translations>\r\n"; $files = getDirectory("./_language", "index", true); foreach ($files as $translation) { if (strpos($translation, ".bak.") === false) { $lang = str_replace(".php", "", str_replace("lang", "", $translation)); $parts = explode(".", $lang); if (ISSUBSITE && strpos($translation, SUBSITEHOST) !== false || !ISSUBSITE && substr_count($translation, ".") == 1) { $xml .= "<language key=\"" . base64_encode($parts[0]) . "\" blocked=\"" . base64_encode(@filesize("./_language/" . $translation) == 0 ? 1 : "0") . "\" />\r\n"; } else { if (ISSUBSITE && strpos($translation, SUBSITEHOST) === false && !@file_exists(getLocalizationFileString($parts[0], false))) { $xml .= "<language key=\"" . base64_encode($parts[0]) . "\" derived=\"" . base64_encode(1) . "\" />\r\n"; } } } } $xml .= "</translations>\r\n"; } $xml .= "<php_cfg_vars post_max_size=\"" . base64_encode(cfgFileSizeToBytes(!isnull(@get_cfg_var("post_max_size")) ? get_cfg_var("post_max_size") : MAX_POST_SIZE_SAFE_MODE)) . "\" upload_max_filesize=\"" . base64_encode(cfgFileSizeToBytes(!isnull(@get_cfg_var("upload_max_filesize")) ? get_cfg_var("upload_max_filesize") : MAX_UPLOAD_SIZE_SAFE_MODE)) . "\" />\r\n"; $xml .= "</gl_c>\r\n"; return "<gl_c h=\"" . base64_encode(substr(md5file($hashfile), 0, 5)) . "\">\r\n" . $xml; }
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, ""); }