function getChatVoucherTemplate($html = "")
{
    Server::InitDataBlock(array("DBCONFIG"));
    if (!Is::Defined("DB_CONNECTION") || !empty(Server::$Configuration->Database["ccpp"]["Custom"])) {
        return "";
    }
    if (!empty(Server::$Configuration->File["gl_ccac"])) {
        foreach (Server::$Configuration->Database["cct"] as $type) {
            $html .= $type->GetTemplate();
        }
    }
    $cchtml = IOStruct::GetFile(PATH_TEMPLATES . "chat_voucher_checkout.tpl");
    $mycountry = "";
    $replacements = array("<!--lp_company-->" => "", "<!--lp_firstname-->" => "", "<!--lp_email-->" => "", "<!--lp_lastname-->" => "", "<!--lp_taxid-->" => "", "<!--lp_business_type-->" => "", "<!--lp_address_1-->" => "", "<!--lp_address_2-->" => "", "<!--lp_city-->" => "", "<!--lp_state-->" => "", "<!--lp_country-->" => "", "<!--lp_phone-->" => "", "<!--lp_zip-->" => "");
    $prefillco = !empty($_GET["co"]) ? " OR id='" . DBManager::RealEscape(Encoding::Base64UrlDecode($_GET["co"])) . "'" : "";
    if (!Is::Null(Cookie::Get("userid")) || !empty($prefillco)) {
        $result = DBManager::Execute(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_VOUCHERS . "` WHERE `visitor_id`='" . DBManager::RealEscape(Cookie::Get("userid")) . "'" . $prefillco . " ORDER BY `created` DESC LIMIT 1;");
        if ($result) {
            if ($row = DBManager::FetchArray($result)) {
                $replacements = array("<!--lp_company-->" => $row["company"], "<!--lp_firstname-->" => $row["firstname"], "<!--lp_lastname-->" => $row["lastname"], "<!--lp_taxid-->" => $row["tax_id"], "<!--lp_email-->" => $row["email"], "<!--lp_business_type-->" => $row["business_type"], "<!--lp_address_1-->" => $row["address_1"], "<!--lp_address_2-->" => $row["address_2"], "<!--lp_city-->" => $row["city"], "<!--lp_state-->" => $row["state"], "<!--lp_country-->" => $row["country"], "<!--lp_phone-->" => $row["phone"], "<!--lp_zip-->" => $row["zip"]);
                $mycountry = $row["country"];
            }
        }
    }
    $clist = Server::$Countries;
    asort($clist);
    $countrieshtml = "";
    foreach ($clist as $isokey => $value) {
        if (!empty($isokey)) {
            $countrieshtml .= $isokey == $mycountry ? "<option value=\"" . $isokey . "\" SELECTED>" . utf8_encode($value) . "</option>" : "<option value=\"" . $isokey . "\">" . utf8_encode($value) . "</option>";
        }
    }
    $cchtml = str_replace("<!--countries-->", $countrieshtml, $cchtml);
    foreach ($replacements as $key => $value) {
        $cchtml = str_replace($key, $value, $cchtml);
    }
    $cchtml = str_replace("<!--show_VAT-->", !empty(Server::$Configuration->File["gl_ccsv"]) ? "''" : "none", $cchtml);
    $cchtml = str_replace("<!--voucher_form-->", $html, $cchtml);
    if (!empty(Server::$Configuration->Database["ccpp"]["PayPal"]->LogoURL)) {
        $cchtml = str_replace("<!--pp_logo_url-->", " src=\"" . Server::$Configuration->Database["ccpp"]["PayPal"]->LogoURL . "\"", $cchtml);
    } else {
        $cchtml = str_replace("<!--pp_logo_url-->", "", $cchtml);
    }
    $cchtml = str_replace("<!--extends_voucher-->", !empty($_GET["co"]) && strlen(Encoding::Base64UrlDecode($_GET["co"])) == 16 ? Encoding::Base64UrlDecode($_GET["co"]) : "", $cchtml);
    $cchtml = str_replace("<!--ofc-->", !empty($_GET["ofc"]) ? "MQ__" : "", $cchtml);
    $cchtml = str_replace("<!--VAT-->", str_replace("<!--VAT-->", Server::$Configuration->File["gl_ccva"], LocalizationManager::$TranslationStrings["client_voucher_include_vat"]), $cchtml);
    return $cchtml;
}
 static function TriggerEvents()
 {
     if (count(Server::$Events) == 0) {
         return;
     }
     $actionData = "";
     $url = VisitorMonitoring::$Browser->History[count(VisitorMonitoring::$Browser->History) - 1];
     $previous = count(VisitorMonitoring::$Browser->History) > 1 ? VisitorMonitoring::$Browser->History[count(VisitorMonitoring::$Browser->History) - 2]->Url->GetAbsoluteUrl() : "";
     foreach (Server::$Events->Events as $event) {
         if (!$event->IsActive || empty($url)) {
             continue;
         }
         $urlor = count($event->FunnelUrls) == 0 && $event->MatchesURLCriterias($url->Url->GetAbsoluteUrl(), $url->Referrer->GetAbsoluteUrl(), $previous, time() - $url->Entrance);
         $urlfunnel = count($event->FunnelUrls) > 0 && $event->MatchesURLFunnelCriterias(VisitorMonitoring::$Browser->History);
         $global = $event->MatchesGlobalCriterias(count(VisitorMonitoring::$Browser->History), VisitorMonitoring::$Visitor->ExitTime - VisitorMonitoring::$Visitor->FirstActive, VisitorMonitoring::$Visitor->HasAcceptedChatRequest, VisitorMonitoring::$Visitor->HasDeclinedChatRequest, VisitorMonitoring::$Visitor->WasInChat(), VisitorMonitoring::$Browser->Query, VisitorMonitoring::$IsMobile || VisitorMonitoring::$IsTablet, VisitorMonitoring::$Visitor->GeoCountryISO2);
         if ($global && ($urlfunnel || $urlor)) {
             foreach (array($event->Goals, $event->Actions) as $elements) {
                 foreach ($elements as $action) {
                     $EventTrigger = new EventTrigger(CALLER_USER_ID, CALLER_BROWSER_ID, $action->Id, time(), 1);
                     $EventTrigger->Load();
                     $aexists = $action->Exists(CALLER_USER_ID, CALLER_BROWSER_ID);
                     if (!$EventTrigger->Exists || $EventTrigger->Exists && $event->MatchesTriggerCriterias($EventTrigger)) {
                         if (!$aexists) {
                             if ($event->SaveInCookie) {
                                 if (!Is::Null(Cookie::Get("ea_" . $action->Id))) {
                                     continue;
                                 } else {
                                     Cookie::Set("ea_" . $action->Id, time());
                                 }
                             }
                             $EventTrigger->Save($event->Id);
                             if ($action->Type < 2) {
                                 foreach ($action->GetInternalReceivers() as $user_id) {
                                     $intaction = new EventActionInternal($user_id, $EventTrigger->Id);
                                     $intaction->Save();
                                 }
                             } else {
                                 if ($action->Type == 2 && !defined("EVENT_INVITATION")) {
                                     $sender = getActionSender($action->Invitation->Senders, true);
                                     Server::InitDataBlock(array("GROUPS"));
                                     if (!empty($sender) && !empty(Server::$Groups[$sender->GroupId]) && Server::$Groups[$sender->GroupId]->IsHumanAvailable(false) && !(VisitorMonitoring::$Browser->ChatRequest != null && !VisitorMonitoring::$Browser->ChatRequest->Closed) && !VisitorMonitoring::$Visitor->IsInChat(false, null, true)) {
                                         define("EVENT_INVITATION", true);
                                         $chatrequest = new ChatRequest($sender->UserSystemId, $sender->GroupId, CALLER_USER_ID, CALLER_BROWSER_ID, getActionText($sender, $action));
                                         $chatrequest->EventActionId = $action->Id;
                                         $chatrequest->Save();
                                         if (!$chatrequest->Displayed) {
                                             VisitorMonitoring::$Browser->ForceUpdate();
                                         }
                                         VisitorMonitoring::$Browser->ChatRequest = $chatrequest;
                                     }
                                 } else {
                                     if ($action->Type == 3 && !defined("EVENT_ALERT")) {
                                         define("EVENT_ALERT", true);
                                         $alert = new Alert(CALLER_USER_ID, CALLER_BROWSER_ID, $action->Value);
                                         $alert->EventActionId = $action->Id;
                                         $alert->Save();
                                         VisitorMonitoring::$Browser->LoadAlerts();
                                     } else {
                                         if ($action->Type == 4 && !defined("EVENT_WEBSITE_PUSH")) {
                                             define("EVENT_WEBSITE_PUSH", true);
                                             $sender = getActionSender($action->WebsitePush->Senders, false);
                                             $websitepush = new WebsitePush($sender->UserSystemId, $sender->GroupId, CALLER_USER_ID, CALLER_BROWSER_ID, getActionText($sender, $action), $action->WebsitePush->Ask, $action->WebsitePush->TargetURL);
                                             $websitepush->EventActionId = $action->Id;
                                             $websitepush->Save();
                                             VisitorMonitoring::$Browser->LoadWebsitePush();
                                         } else {
                                             if ($action->Type == 5 && !defined("EVENT_OVERLAY_BOX")) {
                                                 define("EVENT_OVERLAY_BOX", true);
                                                 $overlaybox = new OverlayBox(CALLER_USER_ID, CALLER_BROWSER_ID, $action->Value);
                                                 $overlaybox->EventActionId = $action->Id;
                                                 $overlaybox->Save();
                                                 VisitorMonitoring::$Browser->LoadOverlayBoxes();
                                             } else {
                                                 if ($action->Type == 9 && STATS_ACTIVE) {
                                                     Server::$Statistic->ProcessAction(ST_ACTION_GOAL, array(CALLER_USER_ID, $action->Id, VisitorMonitoring::$Visitor->Visits == 1 ? 1 : 0, VisitorMonitoring::$Browser->GetQueryId(Cookie::Get("sp"), null, 255, true)));
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     if ($EventTrigger->Exists && $aexists) {
                         $EventTrigger->Update();
                     }
                 }
             }
         }
     }
     return $actionData;
 }
 static function Replace($_toReplace, $jsa = "")
 {
     $_toReplace = str_replace("<!--geo_url-->", GeoTracking::GetURL() . "?aid=" . Server::$Configuration->File["wcl_geo_tracking"] . "&sid=" . base64_encode(Server::$Configuration->File["gl_lzid"]) . "&dbp=" . Server::$Configuration->File["gl_gtdb"], $_toReplace);
     if (!empty(Server::$Configuration->File["gl_use_ngl"])) {
         if (!Is::Null(trim(Server::$Configuration->File["gl_pr_ngl"]))) {
             $gkey = Server::$Configuration->File["gl_pr_ngl"];
         }
         if (!empty($gkey)) {
             $jsc = "var chars = new Array(";
             $jso = "var order = new Array(";
             $chars = str_split(sha1($gkey . date("d"), false));
             $keys = array_keys($chars);
             shuffle($keys);
             foreach ($keys as $key) {
                 $jsc .= "'" . $chars[$key] . "',";
                 $jso .= $key . ",";
             }
             $jsa .= $jsc . "0);\r\n";
             $jsa .= $jso . "0);\r\n";
             $jsa .= "while(lz_oak.length < (chars.length-1))for(var f in order)if(order[f] == lz_oak.length)lz_oak += chars[f];\r\n";
         }
     }
     $_toReplace = str_replace("<!--calcoak-->", $jsa, $_toReplace);
     $_toReplace = str_replace("<!--mip-->", Communication::GetIP(false, true), $_toReplace);
     return $_toReplace;
 }
Пример #4
0
 } else {
     if (isset($_GET["clch"])) {
         $chat = VisitorChat::FromCache(VisitorMonitoring::$Visitor->UserId, Communication::ReadParameter("clch", ""));
         $chat->ExternalClose();
         $chat->Destroy();
     }
     VisitorMonitoring::$Browser->LastActive = time();
     VisitorMonitoring::$Browser->VisitId = VisitorMonitoring::$Visitor->VisitId;
     $parameters = Communication::GetTargetParameters(false);
     $conline = operatorsAvailable(0, $parameters["exclude"], $parameters["include_group"], $parameters["include_user"], false) > 0;
     VisitorMonitoring::$Browser->OverlayContainer = !empty($_GET["ovlc"]);
     if (VisitorMonitoring::$IsActive) {
         VisitorMonitoring::$Browser->Save();
         if (!empty($currentURL) && (count(VisitorMonitoring::$Browser->History) == 0 || count(VisitorMonitoring::$Browser->History) > 0 && VisitorMonitoring::$Browser->History[count(VisitorMonitoring::$Browser->History) - 1]->Url->GetAbsoluteUrl() != $currentURL->Url->GetAbsoluteUrl())) {
             VisitorMonitoring::$Browser->History[] = $currentURL;
             if (!Is::Null(VisitorMonitoring::$Browser->History[count(VisitorMonitoring::$Browser->History) - 1]->Referrer->GetAbsoluteUrl())) {
                 if (VisitorMonitoring::$Browser->SetQuery(VisitorMonitoring::$Browser->History[count(VisitorMonitoring::$Browser->History) - 1]->Referrer->GetAbsoluteUrl())) {
                     VisitorMonitoring::$Browser->History[count(VisitorMonitoring::$Browser->History) - 1]->Referrer->MarkSearchEngine();
                 }
             }
             VisitorMonitoring::$Browser->History[count(VisitorMonitoring::$Browser->History) - 1]->Save(CALLER_BROWSER_ID, count(VisitorMonitoring::$Browser->History) == 1);
             VisitorMonitoring::$Browser->ForceUpdate();
         } else {
             if (count(VisitorMonitoring::$Browser->History) == 0) {
                 VisitorMonitoring::Abort(11);
             }
         }
         VisitorMonitoring::$Browser->LoadWebsitePush();
         VisitorMonitoring::$Visitor->LoadChatRequests();
         VisitorMonitoring::$Browser->LoadAlerts();
         VisitorMonitoring::$Response .= VisitorMonitoring::TriggerEvents();
 function LoadTopTable($_id, $_maxlength, $_tables, $_fields, $_blanks, $_relSource, $_isURL = false, $_countField = "amount", $_orderField = "amount", $_direction = "DESC")
 {
     $counter = 0;
     if ($_relSource > 0) {
         if (count($_tables) == 2) {
             $_blanks = $_blanks ? "" : " AND `" . DB_PREFIX . DBManager::RealEscape($_tables[1]) . "`.`" . DBManager::RealEscape($_fields[0]) . "`!=''";
             $result = DBManager::Execute(true, "SELECT `" . DB_PREFIX . DBManager::RealEscape($_tables[1]) . "`.`" . DBManager::RealEscape($_fields[0]) . "`,`" . $_countField . "` FROM `" . DB_PREFIX . DBManager::RealEscape($_tables[0]) . "` INNER JOIN `" . DB_PREFIX . DBManager::RealEscape($_tables[1]) . "` ON `" . DB_PREFIX . DBManager::RealEscape($_tables[0]) . "`.`" . DBManager::RealEscape($_fields[1]) . "`=`" . DB_PREFIX . DBManager::RealEscape($_tables[1]) . "`.`id` WHERE " . $this->GetDateMatch() . $_blanks . "  ORDER BY `" . $_orderField . "` " . $_direction . "  LIMIT " . DBManager::RealEscape(StatisticProvider::$DayItemAmount) . ";");
         } else {
             $result = DBManager::Execute(true, "SELECT `" . DB_PREFIX . DBManager::RealEscape($_tables[0]) . "`.`" . DBManager::RealEscape($_fields[0]) . "`,`" . $_countField . "` FROM `" . DB_PREFIX . DBManager::RealEscape($_tables[0]) . "` WHERE " . $this->GetDateMatch() . " ORDER BY `" . $_orderField . "` " . $_direction . "  LIMIT " . DBManager::RealEscape(StatisticProvider::$DayItemAmount) . ";");
         }
         $values = array();
         while ($row = DBManager::FetchArray($result)) {
             if (!Is::Null(trim($row[$_fields[0]]))) {
                 if ($_id != 6) {
                     $row[$_fields[0]] = $_isURL ? "<a href=\"" . @htmlentities(StatisticProvider::$Dereferrer . $row[$_fields[0]], ENT_QUOTES, 'UTF-8') . "\" target=\"_blank\">" . @htmlentities(substr($row[$_fields[0]], 0, $_maxlength), ENT_QUOTES, 'UTF-8') . "</a>" : @htmlentities(substr($row[$_fields[0]], 0, $_maxlength), ENT_QUOTES, 'UTF-8');
                 } else {
                     $row[$_fields[0]] = $row[$_fields[0]];
                 }
                 $title = $row[$_fields[0]];
             } else {
                 $title = "<!--lang_stats_unknown-->";
             }
             if (!isset($values[$title])) {
                 $values[$title] = 0;
             }
             $values[$title] += $row[$_countField];
         }
         foreach ($values as $title => $amount) {
             $this->Tops[$_id][++$counter] = array($title, @round(100 * $amount / $_relSource, StatisticProvider::$RoundPrecision), 100 - 100 * $amount / $_relSource, $amount);
         }
     }
     if ($counter == 0) {
         $this->Tops[$_id][++$counter] = array("<!--lang_stats_none-->", 0, 100, 0);
     }
 }
 private function SEND_PHP_MAIL($_receiver = "", $result = "", $_html = false)
 {
     if (strpos($_receiver, ",") !== false) {
         $emails = explode(",", $_receiver);
         foreach ($emails as $mail) {
             if (!empty($mail) && !Is::Null(strpos($mail, "@"))) {
                 $result = $this->SEND_PHP_MAIL(trim($mail), $result);
             }
         }
         return $result;
     }
     $mailtext = $this->MailBodyText;
     $ehash = md5(date('r', time()));
     $EOL = "\r\n";
     if (empty($this->FakeSender)) {
         $headers = "From: " . $this->Mailbox->Email . $EOL;
     } else {
         $headers = "From: " . $this->FakeSender . $EOL;
     }
     $headers .= "Reply-To: " . $this->ReplyTo . $EOL;
     $headers .= "Date: " . date("r") . $EOL;
     $headers .= "MIME-Version: 1.0" . $EOL;
     $headers .= "X-Mailer: LiveZilla.net/" . VERSION . $EOL;
     if ($this->Attachments != null) {
         $headers .= "Content-Type: multipart/mixed; boundary=\"" . $ehash . "\"" . $EOL . $EOL;
         $headers .= "--" . $ehash . $EOL;
         $headers .= "Content-Type: text/plain; charset=UTF-8; format=flowed" . $EOL;
         $headers .= "Content-Transfer-Encoding: 8bit" . $EOL . $EOL;
         $headers .= $mailtext . $EOL . $EOL;
         $headers .= "--" . $ehash . $EOL;
         foreach ($this->Attachments as $resId) {
             $res = KnowledgeBaseEntry::GetById($resId);
             if ($res == null) {
                 continue;
             }
             $content = chunk_split(base64_encode(file_get_contents("./uploads/" . $res["value"])));
             $headers .= "Content-Type: application/octet-stream; name=\"" . $res["title"] . "\"" . $EOL;
             $headers .= "Content-Transfer-Encoding: base64" . $EOL;
             $headers .= "Content-Disposition: attachment; filename=\"" . $res["title"] . "\"" . $EOL . $EOL;
             $headers .= $content . $EOL . $EOL;
             $headers .= "--" . $ehash . $EOL;
         }
         $mailtext = "";
         $headers .= "--" . $ehash . "--" . $EOL;
     } else {
         $headers .= "Content-Type: text/plain; charset=UTF-8; format=flowed" . $EOL;
         $headers .= "Content-Transfer-Encoding: 8bit" . $EOL . $EOL;
     }
     if (@mail($_receiver, $this->Subject, $mailtext, $headers)) {
         return 1;
     } else {
         return "The email could not be sent using PHP mail(). Please try another Return Email Address or use SMTP.";
     }
 }
 function GetPredefinedOperator($_user, &$direct_target, $_allowBots, $_requireBot, $desired = "")
 {
     if (!empty($this->TargetOperatorSystemId) && isset(Server::$Operators[$this->TargetOperatorSystemId]) && Server::$Operators[$this->TargetOperatorSystemId]->Status < USER_STATUS_OFFLINE) {
         if (!(!empty($this->TargetGroupId) && !in_array($this->TargetGroupId, Server::$Operators[$this->TargetOperatorSystemId]->GetGroupList(true)))) {
             $desired = $this->TargetOperatorSystemId;
         }
     } else {
         $this->TargetOperatorSystemId = null;
         $opParam = Operator::ReadParams();
         if (!empty($opParam)) {
             $desired = $direct_target = Operator::GetSystemId($opParam);
         } else {
             if (!Is::Null(Cookie::Get("internal_user")) && !empty(Server::$Configuration->File["gl_save_op"])) {
                 $desired = Operator::GetSystemId(Cookie::Get("internal_user"));
                 if (!empty(Server::$Operators[$desired]) && !(!empty($this->TargetGroupId) && !in_array($this->TargetGroupId, Server::$Operators[$desired]->GetGroupList(true)))) {
                     $direct_target = $desired;
                 } else {
                     $desired = "";
                 }
             } else {
                 if (empty($desired) && !empty(Server::$Configuration->File["gl_save_op"])) {
                     $desired = $_user->GetLastChatOperator(true);
                 }
             }
         }
     }
     if (!empty($desired) && Server::$Operators[$desired]->MobileSleep($_user->Browsers[0])) {
         $this->TargetOperatorSystemId = $desired = "";
     } else {
         if (!empty($desired) && !$_allowBots && Server::$Operators[$desired]->IsBot) {
             $this->TargetOperatorSystemId = $desired = "";
         } else {
             if (!empty($desired) && $_requireBot && !Server::$Operators[$desired]->IsBot) {
                 $this->TargetOperatorSystemId = $desired = "";
             }
         }
     }
     return $desired;
 }
Пример #8
0
/****************************************************************************************
* LiveZilla getfile.php
* 
* Copyright 2014 LiveZilla GmbH
* All rights reserved.
* LiveZilla is a registered trademark.
* 
* Improper changes to this file may cause critical errors.
***************************************************************************************/
define("IN_LIVEZILLA", true);
if (!defined("LIVEZILLA_PATH")) {
    define("LIVEZILLA_PATH", "./");
}
require LIVEZILLA_PATH . "_definitions/definitions.inc.php";
require LIVEZILLA_PATH . "_definitions/definitions.protocol.inc.php";
require LIVEZILLA_PATH . "_lib/functions.global.inc.php";
require LIVEZILLA_PATH . "_definitions/definitions.dynamic.inc.php";
if (isset($_GET["id"]) && Server::InitDataProvider()) {
    $id = $_GET["id"];
    if (strpos($id, ".") === false && !Is::Null($res = KnowledgeBaseEntry::GetById($id))) {
        if (file_exists("./uploads/" . $res["value"]) && strpos($res["value"], "..") === false) {
            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Length: ' . filesize("./uploads/" . $res["value"]));
            header('Content-Disposition: attachment; filename=' . urlencode($res["title"]));
            exit(file_get_contents("./uploads/" . $res["value"]));
        }
    }
}
header("HTTP/1.0 404 Not Found");
 function GetQueryId($_query, $_referrer, $_maxlength = 255, $_self = false)
 {
     if (empty($_query)) {
         $_query = "";
     }
     if (!$_self && $_maxlength != null && strlen($_query) > $_maxlength) {
         $_query = substr($_query, 0, $_maxlength);
     }
     $result = DBManager::Execute(false, "INSERT INTO `" . DB_PREFIX . DATABASE_VISITOR_DATA_QUERIES . "` (`id`, `query`) VALUES (NULL, '" . DBManager::RealEscape($_query) . "');");
     if (!$_self && !empty($_query) && !$result && !Is::Null(DBManager::GetErrorCode()) && DBManager::GetErrorCode() != 1062) {
         $this->GetQueryId(utf8_encode(urldecode($_query)), $_referrer, $_maxlength, true);
     }
     $row = DBManager::FetchArray(DBManager::Execute(true, "SELECT `id` FROM `" . DB_PREFIX . DATABASE_VISITOR_DATA_QUERIES . "` WHERE `query`='" . DBManager::RealEscape($_query) . "';"));
     return $row["id"];
 }
 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;
 }