コード例 #1
0
 static function GetConfig($xml = "")
 {
     global $_CONFIG;
     $skeys = array("gl_db_host", "gl_db_user", "gl_db_pass", "gl_db_name");
     $hashfile = FILE_CONFIG;
     $cindex = 0;
     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";
             }
         }
     }
     $sxml = "";
     foreach ($_CONFIG as $index => $server_val) {
         if (is_int($index) && is_array($server_val)) {
             $sxml .= "<site index=\"" . base64_encode($cindex) . "\">\r\n";
             foreach ($server_val as $key => $site_val) {
                 if (is_array($site_val)) {
                     $sxml .= "<conf key=\"" . base64_encode($key) . "\">\r\n";
                     foreach ($site_val as $skey => $sval) {
                         $sxml .= "<sub key=\"" . base64_encode($skey) . "\">" . $sval . "</sub>\r\n";
                     }
                     $sxml .= "</conf>\r\n";
                 } else {
                     if (!in_array($key, $skeys) || SERVERSETUP) {
                         $sxml .= "<conf value=\"" . $site_val . "\" key=\"" . base64_encode($key) . "\" />\r\n";
                     } else {
                         $sxml .= "<conf value=\"" . base64_encode("") . "\" key=\"" . base64_encode($key) . "\" />\r\n";
                     }
                 }
             }
             $cindex++;
             if (Server::$Configuration->File["gl_host"] == base64_decode($server_val["gl_host"])) {
                 $sxml .= "<db_conf>\r\n";
                 if (!empty(Server::$Configuration->Database["cct"])) {
                     $sxml .= "<cct>\r\n";
                     foreach (Server::$Configuration->Database["cct"] as $cct) {
                         $sxml .= $cct->GetXML();
                     }
                     $sxml .= "</cct>\r\n";
                 }
                 if (!empty(Server::$Configuration->Database["ccpp"])) {
                     $sxml .= "<ccpp>\r\n";
                     foreach (Server::$Configuration->Database["ccpp"] as $ccpp) {
                         $sxml .= $ccpp->GetXML();
                     }
                     $sxml .= "</ccpp>\r\n";
                 }
                 if (!empty(Server::$Configuration->Database["gl_email"])) {
                     $sxml .= "<gl_email>\r\n";
                     foreach (Server::$Configuration->Database["gl_email"] as $mb) {
                         $sxml .= $mb->GetXML();
                     }
                     $sxml .= "</gl_email>\r\n";
                 }
                 if (!empty(Server::$Configuration->Database["gl_fb"])) {
                     $sxml .= "<gl_fbc>\r\n";
                     foreach (Server::$Configuration->Database["gl_fb"] as $fbc) {
                         $sxml .= $fbc->GetXML();
                     }
                     $sxml .= "</gl_fbc>\r\n";
                 }
                 if (!empty(Server::$Configuration->Database["gl_go"])) {
                     $sxml .= "<gl_go>\r\n";
                     foreach (Server::$Configuration->Database["gl_go"] as $goal) {
                         $sxml .= $goal->GetXML();
                     }
                     $sxml .= "</gl_go>\r\n";
                 }
                 $sxml .= "</db_conf>\r\n";
             }
             $sxml .= "</site>\r\n";
         }
     }
     $xml .= $sxml;
     $xml .= "<translations>\r\n";
     $files = IOStruct::ReadDirectory("./_language", "index", true);
     foreach ($files as $translation) {
         if (strpos($translation, ".bak.") === false && endsWith($translation, ".php")) {
             $lang = substr($translation, 4, strlen($translation) - 1);
             $mobile = false;
             if (strpos($lang, "mobile") === 0) {
                 $lang = substr($lang, 6, strlen($lang) - 6);
                 $mobile = true;
             }
             $parts = explode(".", $lang);
             if (ISSUBSITE && strpos($translation, $parts[0] . "." . SUBSITEHOST) !== false || !ISSUBSITE && substr_count($translation, ".") == 1) {
                 $xml .= "<language m=\"" . base64_encode($mobile ? "1" : "0") . "\" key=\"" . base64_encode($parts[0]) . "\" blocked=\"" . base64_encode(@filesize("./_language/" . $translation) == 0 ? 1 : "0") . "\" />\r\n";
             } else {
                 if (ISSUBSITE && strpos($translation, $parts[0] . "." . SUBSITEHOST) === false && !@file_exists(LocalizationManager::GetLocalizationFileString($parts[0], false)) && substr_count($translation, ".") == 1) {
                     $xml .= "<language m=\"" . base64_encode($mobile ? "1" : "0") . "\" key=\"" . base64_encode($parts[0]) . "\" derived=\"" . base64_encode(1) . "\" />\r\n";
                 }
             }
         }
     }
     $xml .= "</translations>\r\n";
     $xml .= "<php_cfg_vars post_max_size=\"" . base64_encode(IOStruct::ToBytes(!Is::Null(@get_cfg_var("post_max_size")) ? get_cfg_var("post_max_size") : MAX_POST_SIZE_SAFE_MODE)) . "\" upload_max_filesize=\"" . base64_encode(IOStruct::ToBytes(!Is::Null(@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(IOStruct::HashMD5($hashfile), 0, 5)) . "\">\r\n" . $xml;
 }