function getTranslationData($translation = "")
{
    global $LZLANG, $RESPONSE;
    administrationLog("getTranslationData", serialize($_POST), CALLER_SYSTEM_ID);
    if (!(isset($_POST["p_int_trans_iso"]) && (strlen($_POST["p_int_trans_iso"]) == 2 || strlen($_POST["p_int_trans_iso"]) == 5))) {
        $RESPONSE->SetStandardResponse(1, "");
        return;
    }
    $langid = $_POST["p_int_trans_iso"];
    if (strpos($langid, "..") === false && strlen($langid) <= 6) {
        requireDynamic(getLocalizationFileString($langid), LIVEZILLA_PATH . "_language/");
        $translation .= "<language key=\"" . base64_encode($langid) . "\">\r\n";
        foreach ($LZLANG as $key => $value) {
            $translation .= "<val key=\"" . base64_encode($key) . "\">" . base64_encode($value) . "</val>\r\n";
        }
        $translation .= "</language>\r\n";
        $RESPONSE->SetStandardResponse(1, $translation);
    } else {
        $RESPONSE->SetStandardResponse(0, $translation);
    }
}
Пример #2
0
/****************************************************************************************
 * LiveZilla index.php
 *
 * Copyright 2013 LiveZilla GmbH
 * All rights reserved.
 * LiveZilla is a registered trademark.
 *
 ***************************************************************************************/
$langFileLocation = '.';
$LZLANG = array();
if (isset($_GET['g_language'])) {
    $language = $_GET['g_language'] != '' ? htmlentities($_GET['g_language']) : 'en';
    require $langFileLocation . '/langmobileorig.php';
    $LZLANGEN = $LZLANG;
    //if (file_exists($langFileLocation . '/langmobile' . $language . '.php'))
    requireDynamic($langFileLocation . '/langmobile' . $language . '.php', $langFileLocation);
    $stringArray = array();
    foreach ($LZLANGEN as $key => $value) {
        if (preg_match('/^mobile_/', $key) != 0) {
            if (array_key_exists($key, $LZLANG) && $LZLANG[$key] != null && $LZLANG[$key] != '') {
                array_push($stringArray, array('orig' => $value, $language => $LZLANG[$key]));
                //error_log(print_r(array('en' => $value, $language => $LZLANG[$key]), true), 3, '/tmp/lzm-translation.log');
            } else {
                array_push($stringArray, array('orig' => $value, $language => $value));
            }
        }
    }
    exit(base64_encode(json_encode($stringArray)));
} else {
    die(json_encode('No get or post parameter given'));
}
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 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/");
    }
}