static function ImportButtons($_folder, $_prefix, $_connection) { try { Logging::SecurityLog("ServerManager::ImportButtons", "", CALLER_SYSTEM_ID); $buttons = IOStruct::ReadDirectory($_folder, ".php", true); foreach ($buttons as $button) { $parts = explode("_", $button); if (count($parts) == 3) { $type = $parts[0] == "overlay" ? $parts[0] : "inlay"; $id = intval($parts[1]); $online = explode(".", $parts[2]); $online = $online[0]; $parts = explode(".", $button); $itype = $parts[1]; $_connection->Query(false, "INSERT INTO `" . DBManager::RealEscape($_prefix) . DATABASE_IMAGES . "` (`id`,`online`,`button_type`,`image_type`,`data`) VALUES ('" . DBManager::RealEscape($id) . "','" . DBManager::RealEscape($online) . "','" . DBManager::RealEscape($type) . "','" . DBManager::RealEscape($itype) . "','" . DBManager::RealEscape(IOStruct::ToBase64($_folder . $button)) . "');"); } } } catch (Exception $e) { Logging::GeneralLog(serialize($e)); } }
static function DeleteHTMLReports() { if (!empty(Server::$Configuration->File["gl_st_ders"]) && is_numeric(Server::$Configuration->File["gl_st_derd"])) { foreach (array(STATISTIC_PERIOD_TYPE_MONTH, STATISTIC_PERIOD_TYPE_YEAR, STATISTIC_PERIOD_TYPE_DAY) as $type) { $files = IOStruct::ReadDirectory(PATH_STATS . $type, ""); foreach ($files as $file) { if (!ISSUBSITE || ISSUBSITE && strpos($file, Server::$Configuration->File["gl_host"]) !== false) { $mtime = @filemtime(PATH_STATS . $type . "/" . $file); if (!empty($mtime) && $mtime < time() - 86400 * Server::$Configuration->File["gl_st_derd"]) { @unlink(PATH_STATS . $type . "/" . $file); } } } } $tables = array(DATABASE_STATS_AGGS_GOALS, DATABASE_STATS_AGGS_GOALS_QUERIES, DATABASE_STATS_AGGS_PAGES_ENTRANCE, DATABASE_STATS_AGGS_PAGES_EXIT, DATABASE_STATS_AGGS_CRAWLERS, DATABASE_STATS_AGGS_DOMAINS, DATABASE_STATS_AGGS_BROWSERS, DATABASE_STATS_AGGS_RESOLUTIONS, DATABASE_STATS_AGGS_COUNTRIES, DATABASE_STATS_AGGS_VISITS, DATABASE_STATS_AGGS_SYSTEMS, DATABASE_STATS_AGGS_LANGUAGES, DATABASE_STATS_AGGS_CITIES, DATABASE_STATS_AGGS_REGIONS, DATABASE_STATS_AGGS_ISPS, DATABASE_STATS_AGGS_QUERIES, DATABASE_STATS_AGGS_PAGES, DATABASE_STATS_AGGS_REFERRERS, DATABASE_STATS_AGGS_AVAILABILITIES, DATABASE_STATS_AGGS_DURATIONS, DATABASE_STATS_AGGS_CHATS, DATABASE_STATS_AGGS_SEARCH_ENGINES, DATABASE_STATS_AGGS_VISITORS); $result = DBManager::Execute(true, "SELECT `year`,`month`,`day` FROM `" . DB_PREFIX . DATABASE_STATS_AGGS . "` WHERE `year`<" . date("Y") . " AND `aggregated`>0 AND `time`<" . (time() - 86400 * Server::$Configuration->File["gl_st_derd"]) . " LIMIT 1;"); if ($result) { if ($row = DBManager::FetchArray($result)) { foreach ($tables as $table) { DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . $table . "` WHERE `year`<" . date("Y") . " AND `day`=" . $row["day"] . " AND `month`=" . $row["month"] . " AND `year`=" . $row["year"]); } DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_STATS_AGGS . "` WHERE `year`<" . date("Y") . " AND `aggregated`>0 AND `day`=" . $row["day"] . " AND `month`=" . $row["month"] . " AND `year`=" . $row["year"] . " LIMIT 1;"); } } } }
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; }