public function runTask()
 {
     if (file_exists(CTM_CACHE_PATH . "server_cache/db_ini/ew_record.ini")) {
         $currentData = file_get_contents(CTM_CACHE_PATH . "server_cache/db_ini/ew_record.ini");
         // Oh shit, this is a record today?
         $recordToday = parse_ini_file(CTM_CACHE_PATH . "server_cache/db_ini/ew_record.ini", true);
         // What? This is a ini file?
         //------------------------------------------
         // Ok, file opened, and now?
         // Now, don't is day of ini, right?
         //------------------------------------------
         if ($recordToday['EW.TodayRecord']['EW.RecordDate'] != date("d/m/Y")) {
             $newData = CTM_FileManage::Lib('IniFiles')->EditIniString("EW.TodayRecord", "EW.RecordDate", date("d/m/Y"), $currentData);
             $newData = CTM_FileManage::Lib('IniFiles')->EditIniString("EW.TodayRecord", "EW.RecordHour", "00:00:00", $newData);
             $newData = CTM_FileManage::Lib('IniFiles')->EditIniString("EW.TodayRecord", "EW.RecordCount", 0, $newData);
             /* CTM_FileManage::Lib('IniFiles')->EditIniString($section, $key, $newValue, $content) - Nice Function ;D */
             //------------------------------------------
             // Good, this is excellent!
             // Now? Now... update the ini file, right?
             //------------------------------------------
             if ($fp = fopen(CTM_CACHE_PATH . "server_cache/db_ini/ew_record.ini", "w")) {
                 fwrite($fp, $newData);
                 fclose($fp);
                 //------------------------------------------
                 // That's it?
                 //------------------------------------------
                 $this->loadWrite("Record Today reseted with success!");
             } else {
                 //------------------------------------------
                 // F**k, no reset the Record Today :(
                 //------------------------------------------
                 return $this->setTaskResult($this->taskKey, "ERROR");
             }
         } else {
             //------------------------------------------
             // Ah, is not yet time ;D
             //------------------------------------------
             $this->loadWrite("Out of time command");
         }
     } else {
         //------------------------------------------
         // Failed?
         //------------------------------------------
         $this->loadWrite("The file of Record System not exists");
         return $this->setTaskResult($this->taskKey, "ERROR");
     }
     //------------------------------------------
     // End?
     //------------------------------------------
     return NULL;
 }
Exemple #2
0
 /**
  *	Run Section
  *
  *	@return	void
  */
 public function run()
 {
     if ($_GET['do'] == "check") {
         if ($_POST['accept'] == 1) {
             $this->session->StartSession($_POST['session']);
             $this->session->GetSession("sections", $session);
             $session['eula'] = true;
             $this->session->SetSession("sections", $session);
             $this->session->EndSession($_session);
             return $this->nextSection($_session);
         } else {
             $GLOBALS['error_message'] = true;
         }
     }
     $xml = CTM_FileManage::Lib('XML')->ParseXML(CTM_SETUP_PATH . "xml/license.xml");
     $GLOBALS['eula_terms'] = nl2br(trim($xml->eula));
 }
Exemple #3
0
 /**
  *	Run Section
  *
  *	@return	void
  */
 public function run()
 {
     global $versionHistory, $installation;
     $this->lang->loadLanguageFile("details");
     if ($_GET['do'] == "check") {
         $this->session->StartSession($_POST['session']);
         $this->session->GetSession("sections", $session);
         $session['details'] = true;
         $this->session->SetSession("sections", $session);
         $this->session->EndSession($_session);
         $this->nextSection($_session);
     }
     require_once CTM_SETUP_PATH . "sources/extensions/setup_versions_update.php";
     $versions_to_update = array();
     foreach ($versionHistory as $version => $info) {
         if ($version > $installation['current_version'] && file_exists(CTM_SETUP_PATH . "setup/updates/" . $version . "/xml/info_details.xml")) {
             $xml = CTM_FileManage::Lib('XML')->ParseXML(CTM_SETUP_PATH . "setup/updates/" . $version . "/xml/info_details.xml");
             $versions_to_update[$version]['version'] = $versionHistory[$version]['show'];
             $versions_to_update[$version]['details'] = nl2br($xml->details);
         }
     }
     arsort($versions_to_update);
     $GLOBALS['versions_to_update'] = $versions_to_update;
 }
 public static function run()
 {
     if ($_GET['run'] == "uploadify") {
         $array = array("error_no" => 4, "max_file_size" => NULL, "file_extension" => NULL, "parsed_file_name" => NULL, "saved_upload_name" => NULL);
         if (file_exists(CTM_CACHE_PATH . "temp_cache/" . md5($_REQUEST['tmp_session'] . "__key_upload") . ".tmp")) {
             $CACHE = file_get_contents(CTM_CACHE_PATH . "temp_cache/" . md5($_REQUEST['tmp_session'] . "__key_upload") . ".tmp");
             $CACHE = unserialize($CACHE);
             if ($CACHE) {
                 $upload = CTM_FileManage::Lib('Upload');
                 $upload->upload_form_field = $CACHE['UPLOADIFY_CACHE_SESSION']['FIELD_NAME'];
                 $upload->out_file_name = $CACHE['UPLOADIFY_CACHE_SESSION']['FILE_NAME'];
                 $upload->out_file_dir = $CACHE['UPLOADIFY_CACHE_SESSION']['FILE_DIR'];
                 $upload->max_file_size = $CACHE['UPLOADIFY_CACHE_SESSION']['MAX_SIZE'];
                 $upload->allowed_file_ext = $CACHE['UPLOADIFY_CACHE_SESSION']['EXTENSIONS'];
                 $upload->make_make_script_safe = TRUE;
                 $upload->check_file_ext = TRUE;
                 $upload->upload();
                 $array = array("error_no" => $upload->error_no, "max_file_size" => $upload->max_file_size, "file_extension" => $upload->file_extension, "parsed_file_name" => $upload->parsed_file_name, "saved_upload_name" => $upload->saved_upload_name);
             }
             self::destroy($_REQUEST['tmp_session']);
         }
         exit(base64_encode(serialize($array)));
     }
 }
 /**
  *	Private: Web Record Online [Players online]
  *
  *	@return	void
  */
 private function loadWebRecordOnline()
 {
     $timeCache = time();
     $totalQuery = $this->DB->Query("SELECT count(IP) FROM " . MUACC_CORE . ".dbo.MEMB_STAT WHERE ConnectStat > 0");
     $totalOnline = $this->DB->FetchRow($totalQuery);
     //$this->DB->FreeResult($totalQuery);
     if (!function_exists("returnRecordArray")) {
         function returnRecordArray($recordGeneral, $recordToday)
         {
             return array("EW.GeneralRecord" => array("EW.RecordDate" => date("d/m/Y", $recordGeneral[0]), "EW.RecordHour" => date("H:i:s", $recordGeneral[0]), "EW.RecordCount" => $recordGeneral[1]), "EW.TodayRecord" => array("EW.RecordDate" => date("d/m/Y", $recordToday[0]), "EW.RecordHour" => date("H:i:s", $recordToday[0]), "EW.RecordCount" => $recordToday[1]));
         }
     }
     if (!file_exists(CTM_CACHE_PATH . "server_cache/db_ini/ew_record.ini")) {
         $create = "[EW.GeneralRecord]\r\n";
         $create .= "EW.RecordDate\t= " . date("d/m/Y", $timeCache) . "\r\n";
         $create .= "EW.RecordHour\t= " . date("H:i:s", $timeCache) . "\r\n";
         $create .= "EW.RecordCount\t= " . $totalOnline[0] . "\r\n";
         $create .= "\r\n";
         $create .= "[EW.TodayRecord]\r\n";
         $create .= "EW.RecordDate\t= " . date("d/m/Y", $timeCache) . "\r\n";
         $create .= "EW.RecordHour\t= " . date("H:i:s", $timeCache) . "\r\n";
         $create .= "EW.RecordCount\t= " . $totalOnline[0];
         $webRecord = returnRecordArray(array($timeCache, $totalOnline[0]), array($timeCache, $totalOnline[0]));
         $fp = fopen(CTM_CACHE_PATH . "server_cache/db_ini/ew_record.ini", "w");
         fwrite($fp, $create);
         fclose($fp);
     } else {
         $webRecord = parse_ini_file(CTM_CACHE_PATH . "server_cache/db_ini/ew_record.ini", TRUE);
         if ($totalOnline[0] > $webRecord['EW.GeneralRecord']['EW.RecordCount']) {
             $currentData = file_get_contents(CTM_CACHE_PATH . "server_cache/db_ini/ew_record.ini");
             $newData = CTM_FileManage::Lib('IniFiles')->EditIniString("EW.GeneralRecord", "EW.RecordDate", date("d/m/Y", $timeCache), $currentData);
             $newData = CTM_FileManage::Lib('IniFiles')->EditIniString("EW.GeneralRecord", "EW.RecordHour", date("H:i:s", $timeCache), $newData);
             $newData = CTM_FileManage::Lib('IniFiles')->EditIniString("EW.GeneralRecord", "EW.RecordCount", $totalOnline[0], $newData);
             $newData = CTM_FileManage::Lib('IniFiles')->EditIniString("EW.TodayRecord", "EW.RecordDate", date("d/m/Y", $timeCache), $newData);
             $newData = CTM_FileManage::Lib('IniFiles')->EditIniString("EW.TodayRecord", "EW.RecordHour", date("H:i:s", $timeCache), $newData);
             $newData = CTM_FileManage::Lib('IniFiles')->EditIniString("EW.TodayRecord", "EW.RecordCount", $totalOnline[0], $newData);
             $webRecord = returnRecordArray(array($timeCache, $totalOnline[0]), array($timeCache, $totalOnline[0]));
             $fp = fopen(CTM_CACHE_PATH . "server_cache/db_ini/ew_record.ini", "w");
             fwrite($fp, $newData);
             fclose($fp);
             $this->DB->Arguments(date("d/m/Y", $timeCache), date("H:i:s", $timeCache), $totalOnline[0]);
             $this->DB->Query("INSERT INTO dbo.CTM_RecordLogs ([Date],Hour,Record) VALUES ('%s','%s',%d)");
         } elseif ($totalOnline[0] > $webRecord['EW.TodayRecord']['EW.RecordCount']) {
             $currentData = file_get_contents(CTM_CACHE_PATH . "server_cache/db_ini/ew_record.ini");
             $newData = CTM_FileManage::Lib('IniFiles')->EditIniString("EW.TodayRecord", "EW.RecordDate", date("d/m/Y", $timeCache), $currentData);
             $newData = CTM_FileManage::Lib('IniFiles')->EditIniString("EW.TodayRecord", "EW.RecordHour", date("H:i:s", $timeCache), $newData);
             $newData = CTM_FileManage::Lib('IniFiles')->EditIniString("EW.TodayRecord", "EW.RecordCount", $totalOnline[0], $newData);
             $webRecord['EW.TodayRecord']['EW.RecordDate'] = date("d/m/Y", $timeCache);
             $webRecord['EW.TodayRecord']['EW.RecordHour'] = date("H:i:s", $timeCache);
             $webRecord['EW.TodayRecord']['EW.RecordCount'] = $totalOnline[0];
             $fp = fopen(CTM_CACHE_PATH . "server_cache/db_ini/ew_record.ini", "w");
             fwrite($fp, $newData);
             fclose($fp);
         }
     }
     $x1 = "<strong>" . $webRecord['EW.GeneralRecord']['EW.RecordDate'] . "</strong>";
     $x2 = "<strong>" . $webRecord['EW.GeneralRecord']['EW.RecordHour'] . "</strong>";
     $x3 = "<strong>" . $webRecord['EW.GeneralRecord']['EW.RecordCount'] . "</strong>";
     $y1 = "<strong>" . $webRecord['EW.TodayRecord']['EW.RecordDate'] . "</strong>";
     $y2 = "<strong>" . $webRecord['EW.TodayRecord']['EW.RecordHour'] . "</strong>";
     $y3 = "<strong>" . $webRecord['EW.TodayRecord']['EW.RecordCount'] . "</strong>";
     $this->updateVars("sidebar,infos,recordOnline,general", $webRecord['EW.GeneralRecord']['EW.RecordCount']);
     $this->updateVars("sidebar,infos,recordOnline,today", $webRecord['EW.TodayRecord']['EW.RecordCount']);
     $this->lang->setTags("Sidebar,Infos,RecordOnline,Messages,General", $x1, $x2, $x3);
     $this->lang->setTags("Sidebar,Infos,RecordOnline,Messages,Today", $y1, $y2, $y3);
 }
 /**
  *	Private: Compile Query String
  *
  *	@param	string	Query string
  *	@param	string	Query key (Default -> query)
  *	@return	string
  */
 private function loadCompileQuery($_query, $key = "query")
 {
     if (!$this->xml['query_texts']) {
         $this->xml['query_texts'] = CTM_FileManage::Lib('XML')->ParseXML(CTM_SETUP_PATH . "setup/repair/xml/texts_querys.xml");
     }
     if (count($_query['arguments']) > 0) {
         foreach ($_query['arguments'] as $param => $type) {
             switch ($type) {
                 case "session":
                     list($_key, $value) = explode(":", $param);
                     $session = $this->session->GetSession($_key);
                     $_query[$key] = str_replace("{:" . $param . ":}", $session[$value], $_query[$key]);
                     break;
                 case "text":
                     $_query[$key] = str_replace("{:" . $param . ":}", $this->xml['query_texts']->{$param}, $_query[$key]);
                     break;
                 case "var":
                     $_query[$key] = str_replace("{:" . $param . ":}", $this->install_vars['querys'][$param], $_query[$key]);
                     break;
             }
         }
     }
     return $_query[$key];
 }
 /**
  *	Library Factory
  *
  *	@param	array	Lib Settings
  *	@return	void
  */
 public static function libraryFactory($settings)
 {
     self::$settings = $settings;
 }
 /**
  *	Private: Import/Export Templates
  *	Import/Export templates by XML
  *
  *	@return	void
  */
 private function loadImportExportTemplates()
 {
     if ($_GET['process']) {
         switch ($_GET['process']) {
             case "import":
                 if (empty($_FILES['FileUpload']['name']) && empty($_POST['FilePath'])) {
                     $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['SelectFile'];
                     $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                 } else {
                     $break = FALSE;
                     $uploaded = FALSE;
                     $is_zip = FALSE;
                     if (!empty($_FILES['FileUpload']['name'])) {
                         $type = $_FILES['FileUpload']['type'];
                         $is_zip = $type == "application/x-gzip" || $type == "application/gzip" ? "gzip" : ($type == "application/zip" ? "zip" : "none");
                         if ($type != "text/xml" && $type != "application/x-gzip" && $type != "application/gzip" && $type != "application/zip") {
                             $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['InvalidFile'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                             $break = TRUE;
                         } else {
                             $filepath = CTM_CACHE_PATH . "temp_cache/" . md5(time() . "&ew_template_temp_file&" . mt_rand()) . ".tmp";
                             if (!copy($_FILES['FileUpload']['tmp_name'], $filepath)) {
                                 $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['UploadError'];
                                 $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                                 $break = TRUE;
                             } else {
                                 $uploaded = TRUE;
                             }
                         }
                     } else {
                         $filepath = CTM_ROOT_PATH . $_POST['FilePath'];
                         $find_end = strrpos($filepath, ".");
                         $file_end = substr($filepath, $find_end + 1);
                         if (!file_exists($filepath)) {
                             $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['FileNoExists'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                             $break = TRUE;
                         } elseif ($file_end != "xml" && $file_end != "gz" && $file_end != "zip") {
                             $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['InvalidFile'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                             $break = TRUE;
                         } else {
                             $is_zip = $file_end == "gz" ? "gzip" : ($file_end == "zip" ? "zip" : NULL);
                         }
                     }
                     if ($is_zip == "gzip" && $break == false) {
                         if (!function_exists("gzopen") || !function_exists("gzread") || !function_exists("gzclose")) {
                             $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['UnZipError'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                             $break = TRUE;
                         } else {
                             if ($gzip = gzopen($filepath, "r")) {
                                 $tmp_path = CTM_CACHE_PATH . "temp_cache/" . md5(time() . "&" . EffectWebFiles::TEMPLATE_XML_FILENAME . "&" . mt_rand()) . ".tmp";
                                 $gz_content = gzread($gzip, filesize($filepath) * 2);
                                 gzclose($gzip);
                                 if ($uploaded == true) {
                                     unlink($filepath);
                                 }
                                 $fp = fopen($tmp_path, "w");
                                 fwrite($fp, $gz_content);
                                 fclose($fp);
                             } else {
                                 $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['UnZipError'];
                                 $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                                 $break = TRUE;
                             }
                         }
                     } elseif ($is_zip == "zip" && $break == false) {
                         if (!class_exists("ZipArchive")) {
                             $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['UnZipError'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                             $break = TRUE;
                         } else {
                             $zip = new ZipArchive();
                             if ($zip->open($filepath)) {
                                 $filename = md5(time() . "&" . EffectWebFiles::TEMPLATE_XML_FILENAME . "&" . mt_rand()) . ".tmp";
                                 $tmp_path = CTM_CACHE_PATH . "temp_cache/" . $filename;
                                 $zip->renameName(EffectWebFiles::TEMPLATE_XML_FILENAME, $filename);
                                 $zip->extractTo(CTM_CACHE_PATH . "temp_cache/", array($filename));
                                 $zip->renameName($filename, EffectWebFiles::TEMPLATE_XML_FILENAME);
                                 $zip->close();
                                 if ($uploaded == true) {
                                     unlink($filepath);
                                 }
                             } else {
                                 $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['UnZipError'];
                                 $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                                 $break = TRUE;
                             }
                         }
                     } else {
                         $tmp_path = $filepath;
                     }
                     if ($break == false) {
                         $xml_content = file_get_contents($tmp_path);
                         if (file_exists($tmp_path) && $tmp_path != $filepath && ($is_zip == "gzip" || $is_zip == "zip")) {
                             unlink($tmp_path);
                         }
                         if ($uploaded == true && $is_zip == "none") {
                             unlink($filepath);
                         }
                         if (!CTM_FileManage::Lib('XML')->IsXML($xml_content) || !strstr($xml_content, "<skin_xml") || !strstr($xml_content, "<skin_info>")) {
                             $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['FileCorrupted'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                         } else {
                             CTM_Template::Lib('ImportExport')->ImportXML($xml_content, $skin_info);
                             if ($skin_info == "XML_CORRUPTED") {
                                 $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['FileCorrupted'];
                                 $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                             } elseif ($skin_info == "INVALID_CODEKEY") {
                                 $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['InvalidTemplate'];
                                 $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                             } elseif ($skin_info == "VAR_0_ERROR") {
                                 $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['LicenseError'];
                                 $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                             } else {
                                 $path = "server_cache/db_php/skin_sources/skin_sources.php";
                                 CTM_Controller::UpdateWebCache("effectwebkernelhash", "hash_file:" . $path, "hash_file:" . md5_file(CTM_CACHE_PATH . $path));
                                 $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Import']['Messages']['Success'];
                                 $GLOBALS['result_command'] = sprintf($GLOBALS['result_command'], $skin_info['Name'], $skin_info['SkinSet']);
                                 $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3);
                             }
                         }
                     } else {
                         if ($uploaded == true) {
                             if (file_exists($filepath)) {
                                 unlink($filepath);
                             }
                             if (file_exists($tmp_path)) {
                                 unlink($tmp_path);
                             }
                         }
                     }
                 }
                 break;
             case "export":
                 CTM_Template::Lib('Sources')->OpenDatabase();
                 if (!CTM_Template::Lib('Sources')->CheckSkin($_POST['Template'])) {
                     CTM_Template::Lib('Sources')->CloseDatabase();
                     $GLOBALS['result_command'] = $this->lang->words['System']['Templates']['ImportExport']['Export']['Messages']['TemplateInvalid'];
                     $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                 } else {
                     CTM_Template::Lib('ImportExport')->ExportXML("ew_template", $_POST['Template'], $this->skin_cache_keys, true, CTM_ACP_USE_ZIP);
                 }
                 break;
         }
     }
     CTM_Template::Lib('Sources')->OpenDatabase();
     CTM_Template::Lib('Sources')->GetAllSkins($_templates);
     CTM_Template::Lib('Sources')->CloseDatabase();
     if (count($_templates) > 0) {
         foreach ($_templates as $key => $value) {
             $GLOBALS['templates'][$key] = $value['Name'];
         }
     }
     $GLOBALS['template_default_xml_file'] = EffectWebFiles::TEMPLATE_XML_FILENAME;
 }
 /**
  *	Remove Full Skin
  *	Delete all cache files from skin
  *
  *	@param	string	Skin set
  *	@return	void
  */
 public function RemoveFullSkin($template)
 {
     if (file_exists(CTM_CACHE_PATH . "skin_cache/templates/" . $template)) {
         CTM_FileManage::Lib('Directory')->RemoveDirectory(CTM_CACHE_PATH . "skin_cache/templates/" . $template);
     }
     if (file_exists(CTM_CACHE_PATH . "server_cache/db_php/skin_sources/" . $template)) {
         CTM_FileManage::Lib('Directory')->RemoveDirectory(CTM_CACHE_PATH . "server_cache/db_php/skin_sources/" . $template);
     }
     if (file_exists(CTM_PUBLIC_PATH . "style_css/" . $template)) {
         CTM_FileManage::Lib('Directory')->RemoveDirectory(CTM_PUBLIC_PATH . "style_css/" . $template);
     }
     if (file_exists(CTM_PUBLIC_PATH . "style_images/" . $template)) {
         CTM_FileManage::Lib('Directory')->RemoveDirectory(CTM_PUBLIC_PATH . "style_images/" . $template);
     }
     if (file_exists(CTM_PUBLIC_PATH . "style_resources/" . $template)) {
         CTM_FileManage::Lib('Directory')->RemoveDirectory(CTM_PUBLIC_PATH . "style_resources/" . $template);
     }
     CTM_Template::Lib('Sources')->OpenDatabase();
     CTM_Template::Lib('Sources')->RemoveSkin($template);
     CTM_Template::Lib('Sources')->CloseDatabase();
 }
 /**
  *	Private: Compile Settings String
  *
  *	@param	string	Settings string
  *	@return	string
  */
 private function loadCompileSettingsArgs($xml)
 {
     if (!$this->xml['settings_texts']) {
         $this->xml['settings_texts'] = CTM_FileManage::Lib('XML')->ParseXML(CTM_SETUP_PATH . "setup/install/xml/texts_settings.xml");
     }
     $arguments = array();
     $i = 0;
     foreach ($xml as $_xml) {
         switch ($_xml['type']) {
             case "session":
                 list($key, $value) = explode(":", $_xml['param']);
                 $session = $this->session->GetSession($key);
                 $arguments[$i++] = $session[$value];
                 break;
             case "text":
                 $arguments[$i++] = $this->xml['settings_texts']->{$param};
                 break;
             case "var":
                 $arguments[$i++] = $this->install_vars['settings'][$param];
                 break;
         }
     }
     return $arguments;
 }
Exemple #11
0
 /**
  *	Load Vault Bonus
  *
  *	@return	void
  */
 private function loadVaultBonus($bonus, $account)
 {
     $serialize_file = CTM_FileManage::Lib('ReadScript')->CheckSerializeFile("Web_RegisterVault.serialize.dat") == false;
     $structure_file = CTM_FileManage::Lib('ReadScript')->StructureFile(CTM_CONTROL_PATH . "Data/RegisterVault.txt", "Web_RegisterVault.serialize.dat", FALSE);
     $serialize_data = CTM_FileManage::Lib('ReadScript')->ReadScript();
     CTM_MuOnline::Lib('Item')->Vault()->OpenVault($account);
     $itemCount = 0;
     foreach ($serialize_data[$bonus] as $value) {
         $itemSize = array();
         $hexItem = NULL;
         if (preg_replace("/(.*?),(.*?)/i", "\$1", $value[15]) > -2) {
             $value[14] = "0,0";
         } elseif (preg_replace("/(.*?),(.*?)/i", "\$1", $value[16]) > -2) {
             $value[14] = "0,0";
         } elseif (preg_replace("/(.*?),(.*?)/i", "\$1", $value[17]) > -2) {
             $value[14] = "0,0";
         } elseif (preg_replace("/(.*?),(.*?)/i", "\$1", $value[18]) > -2) {
             $value[14] = "0,0";
         } elseif (preg_replace("/(.*?),(.*?)/i", "\$1", $value[19]) > -2) {
             $value[14] = "0,0";
         }
         CTM_MuOnline::Lib('Item')->Database()->GetItemSize($value[0], $value[1], $itemSize);
         CTM_MuOnline::Lib('Item')->MakeItemHex($value[0], $value[1], array("Level" => $value[2], "Option" => $value[5], "Skill" => $value[4] == 1, "Luck" => $value[3] == 1, "Excellent" => array(0 => $value[6] == 1, 1 => $value[7] == 1, 2 => $value[8] == 1, 3 => $value[9] == 1, 4 => $value[10] == 1, 5 => $value[11] == 1), "Ancient" => $value[12], "Refine" => $value[13] == 1, "Harmony" => explode(",", $value[14]), "SocketOption" => array(0 => explode(",", $value[15]), 1 => explode(",", $value[16]), 2 => explode(",", $value[17]), 3 => explode(",", $value[18]), 4 => explode(",", $value[19]))), $hexItem);
         CTM_MuOnline::Lib('Item')->Vault()->FindSlotFree($itemSize['x'], $itemSize['y'], $itemCount);
         CTM_MuOnline::Lib('Item')->Vault()->InsertItem($hexItem, $itemCount++);
     }
     CTM_MuOnline::Lib('Item')->Vault()->CloseVault(true);
     unset($itemData, $itemCount);
 }
 /**
  *	Page: VIP Advantages
  *	Advantages from VIP plans
  *
  *	@return	void
  */
 private function loadVIP_Advantages()
 {
     require_once THIS_APPLICATION_PATH . "sources/variables/userpanel_options.php";
     $permission = $this->settings['USERPANEL']['PERMISSION'];
     foreach ($userpanel_options as $key => $value) {
         foreach ($value as $k => $v) {
             if ($v['privilegy'] == true) {
                 $GLOBALS['coinvip']['vip_advantages']['advantages'][$k][0] = $permission[$key][$k][1] == true ? "tick" : "cross";
                 $GLOBALS['coinvip']['vip_advantages']['advantages'][$k][1] = $permission[$key][$k][2] == true ? "tick" : "cross";
                 if (VIP_NUMBER >= 2) {
                     $GLOBALS['coinvip']['vip_advantages']['advantages'][$k][2] = $permission[$key][$k][3] == true ? "tick" : "cross";
                     if (VIP_NUMBER >= 3) {
                         $GLOBALS['coinvip']['vip_advantages']['advantages'][$k][3] = $permission[$key][$k][4] == true ? "tick" : "cross";
                         if (VIP_NUMBER >= 4) {
                             $GLOBALS['coinvip']['vip_advantages']['advantages'][$k][4] = $permission[$key][$k][5] == true ? "tick" : "cross";
                             if (VIP_NUMBER == 5) {
                                 $GLOBALS['coinvip']['vip_advantages']['advantages'][$k][5] = $permission[$key][$k][+6] == true ? "tick" : "cross";
                             }
                         }
                     }
                 }
             }
         }
     }
     $yes = "<font color=\"red\">" . $this->lang->words['Words']['Yes'] . "</font>";
     $no = "<font color=\"green\">" . $this->lang->words['Words']['No'] . "</font>";
     $MResetCoin = constant("COIN_NAME_" . $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['COIN_NUMBER']);
     if ($this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['MODE'] < 4) {
         $MODE = self::instance()->functions->GetResetInfo(0, "MODE");
         for ($i = 0; $i < VIP_NUMBER + 1; $i++) {
             $resetTable['level_reset'][$i] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['LEVEL_RESET'][$i];
             $resetTable['money_require'][$i] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['MONEY_REQUIRE'][$i];
             $resetTable['level_after'][$i] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['LEVEL_AFTER'][$i];
             $resetTable['clear_invent'][$i] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['CLEAR_INVENT'][$i] == true ? $yes : $no;
             $resetTable['clear_skill'][$i] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['CLEAR_SKILL'][$i] == true ? $yes : $no;
             $resetTable['clear_quest'][$i] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['CLEAR_QUEST'][$i] == true ? $yes : $no;
             if ($MODE == 0xc1 || $MODE == 0xc2) {
                 $resetTable['set_points'][$i] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][$MODE]['SET_POINTS'][$i];
             }
         }
     } else {
         $serialize_file = CTM_FileManage::Lib('ReadScript')->CheckSerializeFile("Web_ResetTable.serialize.dat") == false;
         $structure_file = CTM_FileManage::Lib('ReadScript')->StructureFile(CTM_CONTROL_PATH . "Data/ResetTable.txt", "Web_ResetTable.serialize.dat", FALSE);
         $serialize_data = CTM_FileManage::Lib('ReadScript')->ReadScript();
         foreach ($serialize_data as $key => $value) {
             for ($i = 0; $i < VIP_NUMBER + 1; $i++) {
                 $resetTable[$key]['level_reset'][$i] = $value[0][$i];
                 $resetTable[$key]['money_require'][$i] = $value[1][$i];
                 $resetTable[$key]['level_after'][$i] = $value[2][$i];
                 $resetTable[$key]['clear_invent'][$i] = $value[3][$i] == 1 ? $yes : $no;
                 $resetTable[$key]['clear_skill'][$i] = $value[4][$i] == 1 ? $yes : $no;
                 $resetTable[$key]['clear_quest'][$i] = $value[5][$i] == 1 ? $yes : $no;
                 $resetTable[$key]['set_points'][$i] = $value[6][$i];
             }
         }
         unset($tData);
     }
     switch ($this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['MODE']) {
         case 1:
             $MRMODE = 0xc0;
             break;
         case 2:
             $MRMODE = 0xc1;
             break;
     }
     for ($i = 0; $i < VIP_NUMBER + 1; $i++) {
         $mresetTable['level_reset'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['LEVEL_RESET'][$i];
         $mresetTable['money_require'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['MONEY_REQUIRE'][$i];
         $mresetTable['reset_points'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['RESET_POINTS'][$i] == true ? $yes : $no;
         $mresetTable['clear_invent'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['CLEAR_INVENT'][$i] == true ? $yes : $no;
         $mresetTable['clear_skill'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['CLEAR_SKILL'][$i] == true ? $yes : $no;
         $mresetTable['clear_quest'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['CLEAR_QUEST'][$i] == true ? $yes : $no;
         $mresetTable['coin_award'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['COIN_AWARD'][$i];
         if ($this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['MODE'] < 3) {
             $mresetTable['resets_require'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][$MRMODE]['RESETS_REQUIRE'][$i];
             if ($MRMODE == 192) {
                 $mresetTable['resets_remove'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][$MRMODE]['RESETS_REMOVE'][$i];
             }
         }
     }
     $mresetTable['strength_require'] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['STATS_REQUIRE'][0];
     $mresetTable['dexterity_require'] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['STATS_REQUIRE'][1];
     $mresetTable['vitality_require'] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['STATS_REQUIRE'][2];
     $mresetTable['energy_require'] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['STATS_REQUIRE'][3];
     $mresetTable['command_require'] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['STATS_REQUIRE'][4];
     $this->lang->setArguments("CoinVIP,VIP_Advantages,Advantages,ResetTable,Title", $this->functions->GetResetInfo("TYPE", TRUE));
     $this->lang->setArguments("CoinVIP,VIP_Advantages,Advantages,MResetTable,CoinAward", $MResetCoin);
     $GLOBALS['coinvip']['vip_advantages']['resetTable'] = $resetTable;
     $GLOBALS['coinvip']['vip_advantages']['masterResetTable'] = $mresetTable;
 }
 /**
  *	Server Informations
  *
  *	@return	void
  */
 private function loadServerInformations()
 {
     if (loadIsAjax() == true) {
         $CTM_EWGeneral = new CTM_EWGeneral();
         $CTM_EWGeneral->registry();
         $CTM_EWGeneral->loadHeaderQuerys();
     }
     $yes = "<font color=\"red\">" . $this->lang->words['Words']['Yes'] . "</font>";
     $no = "<font color=\"green\">" . $this->lang->words['Words']['No'] . "</font>";
     $MResetCoin = constant("COIN_NAME_" . $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['COIN_NUMBER']);
     $this->lang->setArguments("Infos,ResetTable,Title", $this->functions->GetResetInfo("TYPE", TRUE));
     $this->lang->setArguments("Infos,MResetTable,CoinAward", $MResetCoin);
     switch (SERVER_STATUS) {
         case 1:
             $fp = fsockopen(GAMESERVER_HOST, GAMESERVER_PORT, $error, $msg, 1);
             $status = $fp ? "<font color=\"green\">Online</span>" : "<font color=\"red\">Offline</font>";
             break;
         case 2:
             $status = "<font color=\"red\">" . $this->lang->words['Infos']['Maintenance'] . "</font>";
             break;
     }
     if ($this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['MODE'] < 4) {
         $MODE = self::instance()->functions->GetResetInfo(0, "MODE");
         for ($i = 0; $i < VIP_NUMBER + 1; $i++) {
             $resetTable['level_reset'][$i] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['LEVEL_RESET'][$i];
             $resetTable['money_require'][$i] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['MONEY_REQUIRE'][$i];
             $resetTable['level_after'][$i] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['LEVEL_AFTER'][$i];
             $resetTable['clear_invent'][$i] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['CLEAR_INVENT'][$i] == true ? $yes : $no;
             $resetTable['clear_skill'][$i] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['CLEAR_SKILL'][$i] == true ? $yes : $no;
             $resetTable['clear_quest'][$i] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['CLEAR_QUEST'][$i] == true ? $yes : $no;
             if ($MODE == 0xc1 || $MODE == 0xc2) {
                 $resetTable['set_points'][$i] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][$MODE]['SET_POINTS'][$i];
             }
         }
     } else {
         $serialize_file = CTM_FileManage::Lib('ReadScript')->CheckSerializeFile("Web_ResetTable.serialize.dat") == false;
         $structure_file = CTM_FileManage::Lib('ReadScript')->StructureFile(CTM_CONTROL_PATH . "Data/ResetTable.txt", "Web_ResetTable.serialize.dat", FALSE);
         $serialize_data = CTM_FileManage::Lib('ReadScript')->ReadScript();
         foreach ($serialize_data as $key => $value) {
             for ($i = 0; $i < VIP_NUMBER + 1; $i++) {
                 $resetTable[$key]['level_reset'][$i] = $value[0][$i];
                 $resetTable[$key]['money_require'][$i] = $value[1][$i];
                 $resetTable[$key]['level_after'][$i] = $value[2][$i];
                 $resetTable[$key]['clear_invent'][$i] = $value[3][$i] == 1 ? $yes : $no;
                 $resetTable[$key]['clear_skill'][$i] = $value[4][$i] == 1 ? $yes : $no;
                 $resetTable[$key]['clear_quest'][$i] = $value[5][$i] == 1 ? $yes : $no;
                 $resetTable[$key]['set_points'][$i] = $value[6][$i];
             }
         }
         unset($tData);
     }
     switch ($this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['MODE']) {
         case 1:
             $MRMODE = 0xc0;
             break;
         case 2:
             $MRMODE = 0xc1;
             break;
     }
     for ($i = 0; $i < VIP_NUMBER + 1; $i++) {
         $mresetTable['level_reset'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['LEVEL_RESET'][$i];
         $mresetTable['money_require'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['MONEY_REQUIRE'][$i];
         $mresetTable['reset_points'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['RESET_POINTS'][$i] == true ? $yes : $no;
         $mresetTable['clear_invent'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['CLEAR_INVENT'][$i] == true ? $yes : $no;
         $mresetTable['clear_skill'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['CLEAR_SKILL'][$i] == true ? $yes : $no;
         $mresetTable['clear_quest'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['CLEAR_QUEST'][$i] == true ? $yes : $no;
         $mresetTable['coin_award'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['COIN_AWARD'][$i];
         if ($this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['MODE'] < 3) {
             $mresetTable['resets_require'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][$MRMODE]['RESETS_REQUIRE'][$i];
             if ($MRMODE == 192) {
                 $mresetTable['resets_remove'][$i] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][$MRMODE]['RESETS_REMOVE'][$i];
             }
         }
     }
     $mresetTable['strength_require'] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['STATS_REQUIRE'][0];
     $mresetTable['dexterity_require'] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['STATS_REQUIRE'][1];
     $mresetTable['vitality_require'] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['STATS_REQUIRE'][2];
     $mresetTable['energy_require'] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['STATS_REQUIRE'][3];
     $mresetTable['command_require'] = $this->settings['USERPANEL']['CHARACTER']['MASTER_RESET'][0xff]['STATS_REQUIRE'][4];
     $queryCharsPk = self::DB()->Query("SELECT count(Name) FROM " . MUGEN_CORE . ".dbo.Character WHERE PkLevel > 3");
     $queryCharsHero = self::DB()->Query("SELECT count(Name) FROM " . MUGEN_CORE . ".dbo.Character WHERE PkLevel < 3");
     //$queryOnlines = self::DB()->Query("SELECT count(memb___id) FROM ".MUACC_CORE.".dbo.MEMB_STAT WHERE ConnectStat > 0");
     $countCharsPk = self::DB()->FetchRow($queryCharsPk);
     $countCharsHero = self::DB()->FetchRow($queryCharsHero);
     //$countOnlines = self::DB()->FetchRow($queryOnlines);
     $GLOBALS['informations'] = array("count" => array("chars_pk" => number_format($countCharsPk[0], 0, false, "."), "chars_hero" => number_format($countCharsHero[0], 0, false, ".")), "status" => $status, "resetTable" => $resetTable, "masterResetTable" => $mresetTable);
 }
Exemple #14
0
 /**
  *	Run Section
  *
  *	@return	void
  */
 public function run()
 {
     global $versionHistory, $installation;
     $this->lang->loadLanguageFile("settings");
     require_once CTM_SETUP_PATH . "sources/extensions/setup_versions_update.php";
     $end = 0;
     $versions_to_update = array();
     foreach ($versionHistory as $version => $info) {
         if ($version > $installation['current_version'] && $update_versions[$version]['settings'] == true && file_exists(CTM_SETUP_PATH . "setup/updates/" . $version . "/xml/control_settings.xml")) {
             $versions_to_update[$end++] = $version;
         }
     }
     //$end -= 1;
     $current_step = $_GET['step'] < 1 ? 0 : ($_GET['step'] > $end ? $end : $_GET['step']);
     $current_version = $versions_to_update[$current_step];
     $_xml = CTM_FileManage::Lib('XML')->ParseXML(CTM_SETUP_PATH . "setup/updates/" . $current_version . "/xml/control_settings.xml");
     $this->_settings = file_get_contents(CTM_CONTROL_PATH . "Settings.php");
     if ($_GET['do'] == "check") {
         $line = array();
         $i = 0;
         if ($_xml) {
             foreach ($_xml as $xml) {
                 if ($xml->command == "change") {
                     if (preg_match("/" . $this->buildSyntax($xml->search, true) . "/is", $this->_settings)) {
                         //$line[$i++] = "NoChanged";
                     } elseif (!preg_match("/" . $this->buildSyntax($xml->syntax, true) . "/is", $this->_settings)) {
                         //$line[$i++] = "NoChanged";
                     }
                 } elseif ($xml->command == "remove") {
                     if (preg_match("/" . $this->buildSyntax($xml->syntax, true) . "/is", $this->_settings)) {
                         //$line[$i++] = "NoRemoved";
                     }
                 } elseif ($xml->command == "insert") {
                     if (!preg_match("/" . $this->buildSyntax($xml->syntax, true) . "/is", $this->_settings)) {
                         //$line[$i++] = "NoInserted";
                     }
                 }
             }
         }
         if (count($line) > 0) {
             $GLOBALS['lines_error'] = $line;
         } else {
             if ($current_step == $end) {
                 $this->session->StartSession($_POST['session']);
                 $this->session->GetSession("sections", $session);
                 $session['settings'] = true;
                 $this->session->SetSession("sections", $session);
                 $this->session->EndSession($_session);
                 $this->nextSection($_session);
             } else {
                 header("Location: ?app=" . CTM_SETUP_MODE . "&section=" . $this->section . "&step=" . ($current_step + 1));
                 exit;
             }
         }
     }
     $line = array();
     $i = 0;
     if ($_xml) {
         foreach ($_xml as $xml) {
             $line[$i] = array("command" => $xml->command, "syntax" => $this->buildSyntax($xml->syntax));
             if (!empty($xml->search)) {
                 $line[$i]['search'] = $this->buildSyntax($xml->search);
             }
             if (!empty($xml->insert)) {
                 switch ($xml->insert) {
                     case "abdove":
                         $line[$i]['insert'] = "Abdove";
                         break;
                     case "below":
                         $line[$i]['insert'] = "Below";
                         break;
                     case "before":
                         $line[$i]['insert'] = "Before";
                         break;
                     case "after":
                         $line[$i]['insert'] = "After";
                         break;
                 }
             }
             $i++;
         }
     }
     $GLOBALS['current_version']['string'] = $versionHistory[$current_version]['show'];
     $GLOBALS['current_version']['key'] = $current_version;
     $GLOBALS['settings_lines'] = $line;
     $GLOBALS['do'] = "check&amp;step=" . $current_step;
 }
 /**
  *	Option: Reset System
  *	Reset the character
  *
  *	@return	void
  */
 public function ResetSystem()
 {
     $charStatus = $this->MuLib('Member')->LoadChar($this->character);
     if ($this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['MODE'] == 4) {
         $serialize_file = CTM_FileManage::Lib('ReadScript')->CheckSerializeFile("Web_ResetTable.serialize.dat") == false;
         $structure_file = CTM_FileManage::Lib('ReadScript')->StructureFile(CTM_CONTROL_PATH . "Data/ResetTable.txt", "Web_ResetTable.serialize.dat", FALSE);
         $serialize_data = CTM_FileManage::Lib('ReadScript')->ReadScript();
         foreach ($serialize_data as $key => $value) {
             $separate = explode("-", $key);
             if ($separate[1] == "XXX") {
                 $separate[1] = $charStatus[COLUMN_RESET];
             }
             if ($charStatus[COLUMN_RESET] >= $separate[0] && $charStatus[COLUMN_RESET] <= $separate[1]) {
                 $setData = $value;
                 break;
             }
         }
         $settings['LEVEL_RESET'] = $setData[0][$this->userData['vip'][VIP_COLUMN]];
         $settings['MONEY_REQUIRE'] = $setData[1][$this->userData['vip'][VIP_COLUMN]];
         $settings['LEVEL_AFTER'] = $setData[2][$this->userData['vip'][VIP_COLUMN]];
         $settings['CLEAR_INVENT'] = (bool) $setData[3][$this->userData['vip'][VIP_COLUMN]];
         $settings['CLEAR_SKILL'] = (bool) $setData[4][$this->userData['vip'][VIP_COLUMN]];
         $settings['CLEAR_QUEST'] = (bool) $setData[5][$this->userData['vip'][VIP_COLUMN]];
         $settings['SET_POINTS'] = $setData[6][$this->userData['vip'][VIP_COLUMN]];
     } else {
         switch ($this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['MODE']) {
             case 1:
                 $CONFIG = 0xc0;
                 break;
             case 2:
                 $CONFIG = 0xc1;
                 break;
             case 3:
                 $CONFIG = 0xc2;
                 break;
         }
         $settings['LEVEL_RESET'] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['LEVEL_RESET'][$this->userData['vip'][VIP_COLUMN]];
         $settings['MONEY_REQUIRE'] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['MONEY_REQUIRE'][$this->userData['vip'][VIP_COLUMN]];
         $settings['LEVEL_AFTER'] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['LEVEL_AFTER'][$this->userData['vip'][VIP_COLUMN]];
         $settings['CLEAR_INVENT'] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['CLEAR_INVENT'][$this->userData['vip'][VIP_COLUMN]];
         $settings['CLEAR_SKILL'] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['CLEAR_SKILL'][$this->userData['vip'][VIP_COLUMN]];
         $settings['CLEAR_QUEST'] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['CLEAR_QUEST'][$this->userData['vip'][VIP_COLUMN]];
         if ($this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['MODE'] > 1) {
             $settings['SET_POINTS'] = $this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][$CONFIG]['SET_POINTS'][$this->userData['vip'][VIP_COLUMN]];
         }
     }
     if ($_GET['write'] == true) {
         $error = $this->LoadClass("Error", "class_sources");
         if ($charStatus['cLevel'] < $settings['LEVEL_RESET']) {
             $error->AddError($this->lang->words['UserPanel']['ResetSystem']['Messages']['Error_Level']);
         }
         if ($charStatus['Money'] < $settings['MONEY_REQUIRE']) {
             $error->AddError($this->lang->words['UserPanel']['ResetSystem']['Messages']['Error_Money']);
         }
         if ($error->count[0] > 0) {
             $message = $this->lang->words['UserPanel']['ResetSystem']['Messages']['Error_Message'];
             $message .= "<br /><br />" . $error->showError();
             return setResult(showMessage($message, 2));
         } else {
             $columnsUpdate = array("cLevel" => $settings['LEVEL_AFTER'], "Money" => "minus:" . $settings['MONEY_REQUIRE'], "Experience" => 0, COLUMN_RESET => "plus:1");
             $this->DB->ForceDataType("cLevel", "integer");
             $this->DB->ForceDataType("Money", "integer");
             $this->DB->ForceDataType("Experience", "integer");
             $this->DB->ForceDataType(COLUMN_RESET, "integer");
             if ($this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['MODE'] == 2) {
                 $columnsUpdate['LevelUpPoint'] = "plus:" . $settings['SET_POINTS'];
                 $this->DB->ForceDataType("LevelUpPoint", "integer");
             } elseif ($this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['MODE'] > 2) {
                 $stats = $this->functions->CharInitialPoints($charStatus['Class']);
                 $columnsUpdate['LevelUpPoint'] = $settings['SET_POINTS'] * ($charStatus[COLUMN_RESET] + 1);
                 $columnsUpdate['Strength'] = $stats[0];
                 $columnsUpdate['Dexterity'] = $stats[1];
                 $columnsUpdate['Vitality'] = $stats[2];
                 $columnsUpdate['Energy'] = $stats[3];
                 $this->DB->ForceDataType("LevelUpPoint", "integer");
                 $this->DB->ForceDataType("Strength", "integer");
                 $this->DB->ForceDataType("Dexterity", "integer");
                 $this->DB->ForceDataType("Vitality", "integer");
                 $this->DB->ForceDataType("Energy", "integer");
                 if ($this->functions->ClassIsLord($charStatus['Class']) == true) {
                     $columnsUpdate[COLUMN_COMMAND] = $stats[4];
                     $this->DB->ForceDataType(COLUMN_COMMAND, "integer");
                 }
             }
             if ($settings['CLEAR_INVENT'] == true) {
                 $columnsUpdate['Inventory'] = "0x" . str_repeat("FF", CTM_INVENTORY_SIZE);
                 $this->DB->ForceDataType("Inventory", "none");
             }
             if ($settings['CLEAR_SKILL'] == true) {
                 $columnsUpdate['MagicList'] = "0x" . str_repeat("FF0000", CTM_SKILL_SIZE / 6);
                 $this->DB->ForceDataType("MagicList", "none");
             }
             if ($settings['CLEAR_QUEST'] == true) {
                 $columnsUpdate['Quest'] = "0x" . str_repeat("FF", 50);
                 $columnsUpdate['Class'] = $this->functions->CharInitialClass($charStatus['Class']);
                 $this->DB->ForceDataType("Quest", "none");
                 $this->DB->ForceDataType("Class", "integer");
             }
             $this->DB->Arguments($this->character, USER_ACCOUNT);
             $this->DB->Update(MUGEN_CORE . "@Character", $columnsUpdate, "Name = '%s' AND AccountID = '%s'");
             if ($this->settings['PANELUSER']['CHARACTER']['RESET_SYSTEM'][0xff]['MODE'] == 1) {
                 $columnsUpdate['LevelUpPoint'] = $charStatus['LevelUpPoint'];
             } elseif ($this->settings['PANELUSER']['CHARACTER']['RESET_SYSTEM'][0xff]['MODE'] < 3) {
                 $columnsUpdate['Strength'] = $charStatus['Strength'];
                 $columnsUpdate['Dexterity'] = $charStatus['Dexterity'];
                 $columnsUpdate['Vitality'] = $charStatus['Vitality'];
                 $columnsUpdate['Energy'] = $charStatus['Energy'];
                 $columnsUpdate[COLUMN_COMMAND] = $charStatus[COLUMN_COMMAND];
             }
             $this->WriteLog(array("option" => "Reset System", "character" => true, "data" => array("[Before] Class: " . $this->functions->ClassInfo($charStatus['Class']), "[Before] Resets: " . number_format($charStatus[COLUMN_RESET], 0, false, "."), "[Before] Level: " . $charStatus['cLevel'], "[Before] Points: " . number_format($charStatus['LevelUpPoint'], 0, false, "."), "[Before] Money: " . number_format($charStatus['Money'], 0, false, "."), "[Before] Strength: " . number_format($charStatus['Strength'], 0, false, "."), "[Before] Dexterity: " . number_format($charStatus['Dexterity'], 0, false, "."), "[Before] Vitality: " . number_format($charStatus['Vitality'], 0, false, "."), "[Before] Energy: " . number_format($charStatus['Energy'], 0, false, "."), "[Before] Command: " . number_format($this->functions->ClassIsLord($charStatus['Class']) ? $charStatus[COLUMN_COMMAND] : 0, 0, false, "."), "[After] Class: " . $this->functions->ClassInfo($settings['CLEAR_QUEST'] == true ? $columnsUpdate['Class'] : $charStatus['Class']), "[After] Resets: " . number_format($charStatus[COLUMN_RESET] + 1, 0, false, "."), "[After] Level: " . $columnsUpdate['cLevel'], "[After] Points: " . number_format($columnsUpdate['LevelUpPoint'], 0, false, "."), "[After] Money: " . number_format($charStatus['Money'] - $settings['MONEY_REQUIRE'], 0, false, "."), "[After] Strength: " . number_format($columnsUpdate['Strength'], 0, false, "."), "[After] Dexterity: " . number_format($columnsUpdate['Dexterity'], 0, false, "."), "[After] Vitality: " . number_format($columnsUpdate['Vitality'], 0, false, "."), "[After] Energy: " . number_format($columnsUpdate['Energy'], 0, false, "."), "[After] Command: " . number_format($this->functions->ClassIsLord($charStatus['Class']) ? $columnsUpdate[COLUMN_COMMAND] : 0, 0, false, "."), "[After] Clear Inventory: " . ($settings['CLEAR_INVENT'] == true ? "Yes" : "No"), "[After] Clear Skills: " . ($settings['CLEAR_SKILL'] == true ? "Yes" : "No"), "[After] Clear Quests: " . ($settings['CLEAR_QUEST'] == true ? "Yes" : "No"))));
             $this->lang->setArguments("UserPanel,ResetSystem,Messages,Success", $charStatus[COLUMN_RESET] + 1);
             setResult(showMessage($this->lang->words['UserPanel']['ResetSystem']['Messages']['Success'], 3));
         }
     }
     $number = create_function("\$integer", "return number_format(\$integer, 0, false, '.');");
     $span = create_function("\$string, \$bool", "return '<span style=\"color: '.(\$bool == true ? 'red' : 'green').'\">'.\$string.'</span>';");
     $clear_after = array(0 => $settings['CLEAR_INVENT'] == true ? $this->lang->words['Words']['Yes'] : $this->lang->words['Words']['No'], 1 => $settings['CLEAR_SKILL'] == true ? $this->lang->words['Words']['Yes'] : $this->lang->words['Words']['No'], 2 => $settings['CLEAR_QUEST'] == true ? $this->lang->words['Words']['Yes'] : $this->lang->words['Words']['No']);
     $GLOBALS['userpanel']['reset_system']['mode'] = $this->functions->GetResetInfo(0, "TYPE");
     $GLOBALS['userpanel']['reset_system']['class_is_lord'] = $this->functions->ClassIsLord($charStatus['Class']);
     $GLOBALS['userpanel']['reset_system']['require']['level'] = $settings['LEVEL_RESET'];
     $GLOBALS['userpanel']['reset_system']['require']['money'] = $number($settings['MONEY_REQUIRE']);
     $GLOBALS['userpanel']['reset_system']['before']['resets'] = $number($charStatus[COLUMN_RESET]);
     $GLOBALS['userpanel']['reset_system']['before']['level'] = $charStatus['cLevel'];
     $GLOBALS['userpanel']['reset_system']['before']['points'] = $number($charStatus['LevelUpPoint']);
     $GLOBALS['userpanel']['reset_system']['before']['class'] = $this->functions->ClassInfo($charStatus['Class']);
     $GLOBALS['userpanel']['reset_system']['before']['money'] = $number($charStatus['Money']);
     if ($this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['MODE'] > 2) {
         $GLOBALS['userpanel']['reset_system']['before']['strength'] = $number($charStatus['Strength']);
         $GLOBALS['userpanel']['reset_system']['before']['dexterity'] = $number($charStatus['Dexterity']);
         $GLOBALS['userpanel']['reset_system']['before']['vitality'] = $number($charStatus['Vitality']);
         $GLOBALS['userpanel']['reset_system']['before']['energy'] = $number($charStatus['Energy'], 0);
         $GLOBALS['userpanel']['reset_system']['before']['command'] = $number($charStatus[COLUMN_COMMAND]);
     }
     $GLOBALS['userpanel']['reset_system']['after']['resets'] = $number($charStatus[COLUMN_RESET] + 1);
     $GLOBALS['userpanel']['reset_system']['after']['level'] = $settings['LEVEL_AFTER'];
     $GLOBALS['userpanel']['reset_system']['after']['money'] = $number($charStatus['Money'] - $settings['MONEY_REQUIRE']);
     switch ($this->settings['USERPANEL']['CHARACTER']['RESET'][0xff]['MODE']) {
         case 1:
             $GLOBALS['userpanel']['reset_system']['after']['points'] = $number($charStatus['LevelUpPoint']);
             break;
         case 2:
             $GLOBALS['userpanel']['reset_system']['after']['points'] = $number($charStatus['LevelUpPoint'] + $settings['SET_POINTS']);
             break;
         default:
             $GLOBALS['userpanel']['reset_system']['after']['points'] = $number($settings['SET_POINTS'] * ($charStatus[COLUMN_RESET] + 1));
     }
     $GLOBALS['userpanel']['reset_system']['after']['class'] = $settings['CLEAR_QUEST'] == true ? $this->functions->ClassInfo($this->functions->CharInitialClass($charStatus['Class'])) : $this->functions->ClassInfo($charStatus['Class']);
     if ($this->settings['USERPANEL']['CHARACTER']['RESET_SYSTEM'][0xff]['MODE'] > 2) {
         $set = $this->functions->CharInitialPoints($charStatus['Class']);
         $GLOBALS['userpanel']['reset_system']['after']['strength'] = $set[0];
         $GLOBALS['userpanel']['reset_system']['after']['dexterity'] = $set[1];
         $GLOBALS['userpanel']['reset_system']['after']['vitality'] = $set[2];
         $GLOBALS['userpanel']['reset_system']['after']['energy'] = $set[3];
         $GLOBALS['userpanel']['reset_system']['after']['command'] = $set[4];
     }
     $GLOBALS['userpanel']['reset_system']['after']['clear_invent'] = $span($clear_after[0], $settings['CLEAR_SKILL']);
     $GLOBALS['userpanel']['reset_system']['after']['clear_skill'] = $span($clear_after[1], $settings['CLEAR_SKILL']);
     $GLOBALS['userpanel']['reset_system']['after']['clear_quest'] = $span($clear_after[2], $settings['CLEAR_QUEST']);
 }
 /**
  *	Export Skin XML
  *	Export the skin files in XML
  *
  *	@param	string	XML File name
  *	@param	array	Skin key
  *	@param	array	Skin set
  *	@param	boolean	Download file
  *	@param	string	File compress (default -> gzip)
  *	@param	array	Force codekey
  *	@return	string	XML content
  */
 public function ExportXML($xml_file, $skin_key, $skin_set, $download = FALSE, $compress = "gzip", $force_codekey = array())
 {
     set_time_limit(0);
     ini_set("memory_limit", 128000000);
     $set_files = array();
     $css_files = array();
     $img_files = array();
     $rsc_files = array();
     $count_set = 0;
     $count_css = 0;
     $count_img = 0;
     $count_rsc = 0;
     parent::Lib('Sources')->OpenDatabase();
     parent::Lib('Sources')->GetSkin($skin_key, $skin_info);
     parent::Lib('Sources')->CloseDatabase();
     foreach ($skin_set as $key) {
         $all_files = array();
         parent::Lib('Database')->OpenDatabase($skin_key, $key);
         parent::Lib('Database')->GetAllFiles($all_files);
         parent::Lib('Database')->CloseDatabase();
         $_files = array();
         $_count = 0;
         foreach ($all_files as $name => $content) {
             $spaces = chr(9) . chr(9) . chr(9) . chr(9) . chr(9) . chr(9);
             $_files['template#:' . $_count++] = array("a:hash" => md5($content), "filename" => $name, "content" => "<![CDATA[" . str_replace(array("<![CDATA[", "]]>"), array("<!#^#|CDATA|", "|#^#]>"), $content) . "]]>");
         }
         $set_files['skin_set#:' . $count_set++] = array("name" => $key, "files" => $_files);
     }
     if (file_exists(CTM_PUBLIC_PATH . "style_css/" . $skin_key)) {
         if (count($iterator = new DirectoryIterator(CTM_PUBLIC_PATH . "style_css/" . $skin_key)) > 0) {
             $spaces = chr(9) . chr(9) . chr(9) . chr(9) . chr(9);
             foreach ($iterator as $fileinfo) {
                 if ($fileinfo->isDot() == false && $fileinfo->isDir() == false) {
                     if ($fileinfo->isFile() == true || $fileinfo->isLink() == true) {
                         $file_name = $fileinfo->getFilename();
                         $file_data = file_get_contents($fileinfo->getPathname());
                         $css_files['css_file#:' . $count_css++] = array("a:checksum" => md5_file($fileinfo->getPathname()), "name" => $file_name, "content" => "\r\n" . $spaces . rtrim(chunk_split(base64_encode($file_data), 80, "\r\n" . $spaces), "\r\n" . $spaces) . "\r\n" . substr($spaces, 1));
                     }
                 }
             }
         }
     }
     if (file_exists(CTM_PUBLIC_PATH . "style_images/" . $skin_key)) {
         $spaces = chr(9) . chr(9) . chr(9) . chr(9) . chr(9);
         if (count($iterator = new DirectoryIterator(CTM_PUBLIC_PATH . "style_images/" . $skin_key)) > 0) {
             foreach ($iterator as $fileinfo) {
                 if ($fileinfo->isDot() == false) {
                     if ($fileinfo->isDir() == true) {
                         $my_array = $this->loadExporterSetDirectory("images_folder", "image_file", $fileinfo->getPathname());
                         $key_array = array("a:name" => $fileinfo->getFilename());
                         $img_files['images_folder#:' . $count_img++] = array_merge($key_array, $my_array);
                     } elseif ($fileinfo->isFile() == true || $fileinfo->isLink() == true) {
                         $file_name = $fileinfo->getFilename();
                         $file_data = file_get_contents($fileinfo->getPathname());
                         $img_files['image_file#:' . $count_img++] = array("a:checksum" => md5_file($fileinfo->getPathname()), "name" => $file_name, "content" => "\r\n" . $spaces . rtrim(chunk_split(base64_encode($file_data), 80, "\r\n" . $spaces), "\r\n" . $spaces) . "\r\n" . substr($spaces, 1));
                     }
                 }
             }
         }
     }
     if (file_exists(CTM_PUBLIC_PATH . "style_resources/" . $skin_key)) {
         $spaces = chr(9) . chr(9) . chr(9) . chr(9) . chr(9);
         if (count($iterator = new DirectoryIterator(CTM_PUBLIC_PATH . "style_resources/" . $skin_key)) > 0) {
             foreach ($iterator as $fileinfo) {
                 if ($fileinfo->isDot() == false) {
                     if ($fileinfo->isDir() == true) {
                         $my_array = $this->loadExporterSetDirectory("resources_folder", "resource_file", $fileinfo->getPathname(), 1);
                         $key_array = array("a:name" => $fileinfo->getFilename());
                         $rsc_files['resources_folder#:' . $count_rsc++] = array_merge($key_array, $my_array);
                     } elseif ($fileinfo->isFile() == true || $fileinfo->isLink() == true) {
                         $file_name = $fileinfo->getFilename();
                         $file_data = file_get_contents($fileinfo->getPathname());
                         $rsc_files['resource_file#:' . $count_rsc++] = array("a:checksum" => md5_file($fileinfo->getPathname()), "name" => $file_name, "content" => "\r\n" . $spaces . rtrim(chunk_split(base64_encode($file_data), 80, "\r\n" . $spaces), "\r\n" . $spaces) . "\r\n" . substr($spaces, 1));
                     }
                 }
             }
         }
     }
     $_xml_inf = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("skin_info" => array("skin_name" => $skin_info['Name'], "skin_key" => $skin_key, "skin_codekey" => $this->loadGenerateCodeKey($skin_key, $skin_info['Name'], $skin_info['CodeKey'], $force_codekey), "skin_author" => array("name" => $skin_info['Author']['Name'], "site" => $skin_info['Author']['Site']))));
     $_xml_set = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("skin_templates" => $set_files));
     $_xml_css = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("style_css" => $css_files));
     $_xml_img = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("style_images" => $img_files));
     $_xml_rsc = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("style_resources" => $rsc_files));
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $_xml_inf, false, $xml_inf);
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $_xml_set, false, $xml_set);
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $_xml_css, false, $xml_css);
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $_xml_img, false, $xml_img);
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $_xml_rsc, false, $xml_rsc);
     $spaces = chr(9) . chr(9);
     $skin_info = $spaces . rtrim(chunk_split($this->loadXMLEncode($xml_inf, "skin_info"), 80, "\n" . $spaces), "\n" . $spaces);
     $skin_templates = $spaces . rtrim(chunk_split($this->loadXMLEncode($xml_set, "skin_set"), 80, "\n" . $spaces), "\n" . $spaces);
     $skin_css = $spaces . rtrim(chunk_split($this->loadXMLEncode($xml_css, "skin_css"), 80, "\n" . $spaces), "\n" . $spaces);
     $skin_images = $spaces . rtrim(chunk_split($this->loadXMLEncode($xml_img, "skin_images"), 80, "\n" . $spaces), "\n" . $spaces);
     $skin_resources = $spaces . rtrim(chunk_split($this->loadXMLEncode($xml_rsc, "skin_resources"), 80, "\n" . $spaces), "\n" . $spaces);
     $xml = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("skin_info" => "\n" . $skin_info . "\n" . substr($spaces, 1), "skin_templates" => "\n" . $skin_templates . "\n" . substr($spaces, 1), "skin_css" => "\n" . $skin_css . "\n" . substr($spaces, 1), "skin_images" => "\n" . $skin_images . "\n" . substr($spaces, 1), "skin_resources" => "\n" . $skin_resources . "\n" . substr($spaces, 1)));
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $xml, false, $xml_source);
     if ($download == true) {
         if ($compress == "gzip" && function_exists("gzencode")) {
             $down_source = gzencode($xml_source, 9);
             $down_suffix = ".gz";
         } elseif ($compress == "zip" && (class_exists("ZipArchive") || class_exists("ZipFile"))) {
             if (!class_exists("ZipArchive")) {
                 $zip = new ZipArchive();
                 $zip->open($filepath = CTM_CACHE_PATH . "temp_cache/" . md5(mt_rand() . "template__kernel::" . time() . "__zip") . ".tmp", ZipArchive::CREATE);
                 $zip->addFromString(self::TEMPLATE_ENGINE_EXPORT_FILE, $xml_source);
                 $zip->close();
                 $down_source = file_get_contents($filepath);
                 unlink($filepath);
             } else {
                 $zip = new ZipFile();
                 $zip->addFile($xml_source, self::TEMPLATE_ENGINE_EXPORT_FILE);
                 $down_source = $zip->file();
             }
             $down_suffix = ".zip";
         } else {
             $down_source = $xml_source;
             $down_suffix = NULL;
         }
         $length = strlen($down_source) + 3;
         header("Pragma: public");
         header("Expires: 0");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Cache-Control: public");
         header("Content-Description: File Transfer");
         header("Content-type: application/octet-stream");
         header("Content-Disposition: attachment; filename=\"" . $xml_file . ".xml" . $down_suffix . "\"");
         header("Content-Transfer-Encoding: binary");
         header("Content-Length: " . $length);
         ob_end_flush();
         ob_end_clean();
         exit($down_source);
     }
     return $xml_source;
 }
 /**
  *	Ranking Data
  *	Generate the ranking result
  *
  *	@param	string	Template var name
  *	@param	array	Databases
  *	@param	integer	Result Limit
  *	@param	integer	Profile Image
  *	@param	string	Cache Key
  *	@return	void
  */
 private function loadRankingData($name, $db, $limit = 5, $image = 1, $cache = NULL)
 {
     if ($limit < 1) {
         $limit = 1;
     }
     if ($limit > 5) {
         $limit = 5;
     }
     $return = array();
     $i = 0;
     if ($this->settings['WEBCACHE']['RANKINGS']['SWITCH'] == false) {
         $string = "USE [" . $db['RANK']['DB'] . "]; ";
         $string .= "SELECT TOP " . (int) $limit . " [" . $db['RANK']['TABLE'] . "].[" . $db['RANK']['NAME'] . "],[" . $db['RANK']['TABLE'] . "].[" . $db['RANK']['COLUMN'] . "]";
         $string .= ",[" . $db['IMAGE']['TABLE'] . "].[" . $db['IMAGE']['COLUMN'] . "] FROM [" . $db['RANK']['DB'] . "].[dbo].[" . $db['RANK']['TABLE'] . "]";
         if ($db['RANK']['DB'] . $db['RANK']['TABLE'] != $db['IMAGE']['DB'] . $db['IMAGE']['TABLE']) {
             $string .= " JOIN [" . $db['IMAGE']['DB'] . "].dbo.[" . $db['IMAGE']['TABLE'] . "] ON ([" . $db['IMAGE']['TABLE'] . "].[" . $db['IMAGE']['NAME'] . "]";
             $string .= " = [" . $db['RANK']['TABLE'] . "].[" . $db['RANK']['NAME'] . "])";
         }
         $string .= " " . (!empty($db['RANK']['WHERE']) ? "WHERE " . $db['RANK']['WHERE'] . " " : NULL);
         $string .= "ORDER BY " . $db['RANK']['COLUMN'] . " DESC; USE [" . CTMEW_CORE . "];";
         $query = $this->DB->Query($string);
         if ($this->DB->CountRows($query) > 0) {
             while ($data = $this->DB->FetchObject($query)) {
                 if ($image > 0) {
                     if ($image == 2) {
                         $setImage = self::instance()->functions->GetGuildMark($data->{$db['IMAGE']['COLUMN']});
                     } else {
                         $setImage = self::instance()->functions->GetCharImage($data->{$db['IMAGE']['COLUMN']});
                     }
                 }
                 if ($this->settings['HOME']['TOP_RANK']['FORMAT']) {
                     $result = number_format($data->{$db['RANK']['COLUMN']}, 0, FALSE, ".");
                 } else {
                     $result = $data->{$db['RANK']['COLUMN']};
                 }
                 $return[] = array("order" => $i + 1, "name" => $data->{$db['RANK']['NAME']}, "result" => $result, "image" => $setImage);
                 $i++;
             }
         }
     } else {
         if (file_exists(CTM_CACHE_PATH . "server_cache/db_xml/mu_rankings.xml")) {
             $xml = CTM_FileManage::Lib('XML')->ParseXML(CTM_CACHE_PATH . "server_cache/db_xml/mu_rankings.xml");
             $i = 0;
             foreach ($xml->{$cache}->{$image == 2 ? "guildInfo" : "charInfo"} as $key => $data) {
                 if ($i >= $limit) {
                     break;
                 }
                 $i++;
                 if ($image > 0) {
                     if ($image == 2) {
                         $setImage = self::instance()->functions->GetGuildMark(base64_decode($data->mark));
                     } else {
                         $setImage = self::instance()->functions->GetCharImage($data->image);
                     }
                 }
                 if ($_HOME['TOP_RANK']['FORMAT']) {
                     $result = number_format($data->result, 0, FALSE, ".");
                 } else {
                     $result = $data->result;
                 }
                 if ($image == 1) {
                     if (empty($data->guild)) {
                         $setSecondary = $this->lang->words['Words']['None'];
                     } else {
                         $setSecondary = $data->guild;
                     }
                 }
                 if ($image == 2) {
                     $setSecondary = $data->master;
                 }
                 $return[] = array("order" => $data['rank'], "name" => $data['name'], "result" => $result, "image" => $setImage, "secondary" => $setSecondary);
             }
         }
     }
     $GLOBALS['home_module']['rankings'][$name] = $return;
 }
 /**
  *	Get Quest Database
  *	Get the quest database
  *
  *	@param	integer	Quest ID
  *	@param	&array	Quest Database
  *	@return	array
  */
 public function GetQuestDatabase($quest = -1, &$quest_database = array())
 {
     $serialize_file = CTM_FileManage::Lib('ReadScript')->CheckSerializeFile("Quest_Data.serialize.dat") == false;
     $structure_file = CTM_FileManage::Lib('ReadScript')->StructureFile($this->settings['Files']['Database'], "Quest_Data.serialize.dat", false);
     $serialize_data = CTM_FileManage::Lib('ReadScript')->ReadScript();
     if ($serialize_file == true || $structure_file == true) {
         foreach ($serialize_data as $key => $value) {
             if ($key == "0-X") {
                 foreach ($value as $v) {
                     $this->database['Data'][$v[0]]['Id'] = $v[0];
                     $this->database['Data'][$v[0]]['Name'] = $v[1];
                     $this->database['Data'][$v[0]]['MinLevel'] = $v[2];
                     $this->database['Data'][$v[0]]['MaxLevel'] = $v[3];
                     $this->database['Data'][$v[0]]['DW/SM/GM'] = $v[4];
                     $this->database['Data'][$v[0]]['DK/BK/BM'] = $v[5];
                     $this->database['Data'][$v[0]]['FE/ME/HE'] = $v[6];
                     $this->database['Data'][$v[0]]['MG/DM'] = $v[7];
                     $this->database['Data'][$v[0]]['DL/LE'] = $v[8];
                     $this->database['Data'][$v[0]]['SU/BS/DIM'] = $v[9];
                     $this->database['Data'][$v[0]]['RF/FE'] = $v[10];
                 }
             } else {
                 $id = substr($key, 2);
                 for ($i = 0; $i < $this->settings['QuestNumber']; $i++) {
                     $this->database['Data'][$id]['RequireQuest']['DW/SM/GM'][$i] = $value[0][$i + 1];
                     $this->database['Data'][$id]['RequireQuest']['DK/BK/BM'][$i] = $value[1][$i + 1];
                     $this->database['Data'][$id]['RequireQuest']['FE/ME/HE'][$i] = $value[2][$i + 1];
                     $this->database['Data'][$id]['RequireQuest']['MG/DM'][$i] = $value[3][$i + 1];
                     $this->database['Data'][$id]['RequireQuest']['DL/LE'][$i] = $value[4][$i + 1];
                     $this->database['Data'][$id]['RequireQuest']['SU/BS/DIM'][$i] = $value[5][$i + 1];
                     $this->database['Data'][$id]['RequireQuest']['RF/FE'][$i] = $value[6][$i + 1];
                 }
             }
         }
         CTM_FileManage::Lib('ReadScript')->WriteSerializeData("Quest_Data.serialize.dat", $this->database['Data'], md5_file($this->settings['Files']['Database']));
     } elseif (!$this->database['Data']) {
         $this->database['Data'] = $serialize_data;
     }
     return $quest_database = $quest == -1 ? $this->database['Data'] : $this->database['Data'][$quest];
 }
 /**
  *	Construct Socket Database
  *	Construct the socket database from SocketSystem.txt
  *
  *	@return	void
  */
 private final function ConstructSocketDatabase()
 {
     $serialize_file = CTM_FileManage::Lib('ReadScript')->CheckSerializeFile("Item_SocketSystem.serialize.dat") == false;
     $structure_file = CTM_FileManage::Lib('ReadScript')->StructureFile($this->settings['Files']['SocketSystem'], "Item_SocketSystem.serialize.dat", TRUE);
     $serialize_data = CTM_FileManage::Lib('ReadScript')->ReadScript();
     if ($serialize_file == true || $structure_file == true) {
         foreach ($serialize_data[0] as $key => $value) {
             $this->database['Socket']['Types'][$key] = array("Index" => $key, "Name" => $value);
         }
         foreach ($serialize_data[1] as $key => $value) {
             $this->database['Socket']['Options'][$key]['Index'] = $key;
             $this->database['Socket']['Options'][$key]['Type'] = $value[0];
             $this->database['Socket']['Options'][$key]['Name'] = $value[1];
             $this->database['Socket']['Options'][$key]['Values'][1] = $value[2];
             $this->database['Socket']['Options'][$key]['Values'][2] = $value[3];
             $this->database['Socket']['Options'][$key]['Values'][3] = $value[4];
             $this->database['Socket']['Options'][$key]['Values'][4] = $value[5];
             $this->database['Socket']['Options'][$key]['Values'][5] = $value[6];
         }
         CTM_FileManage::Lib('ReadScript')->WriteSerializeData("Item_SocketSystem.serialize.dat", $this->database['Socket'], md5_file($this->settings['Files']['SocketSystem']));
     } elseif (!$this->database['Socket']) {
         $this->database['Socket']['Types'] = $serialize_data['Types'];
         $this->database['Socket']['Options'] = $serialize_data['Options'];
     }
 }
 $muSettings['JoinServer']['Timeout'] = $CTM_SETTINGS['JOINSERVER']['CONNECTION']['TIMEOUT'];
 $fileSettings['ReadScript']['SerializePath'] = CTM_CACHE_PATH . "server_cache/db_scripts/";
 $fileSettings['ReadScript']['HashFilesPath'] = "hash_files.txt";
 $skinSettings['Database']['SystemName'] = "Effect Web " . EW_REAL_VERSION;
 $skinSettings['Database']['DatabaseDir'] = CTM_CACHE_PATH . "server_cache/db_php/skin_sources/";
 $skinSettings['Sources']['SystemName'] = "Effect Web " . EW_REAL_VERSION;
 $skinSettings['Sources']['CodeKeyCryptKey'] = "h+C\$/AY#p2kmU90%";
 $skinSettings['Sources']['DatabaseDir'] = CTM_CACHE_PATH . "server_cache/db_php/skin_sources/skin_sources.php";
 $skinSettings['Logic']['SystemName'] = "Effect Web " . EW_REAL_VERSION;
 $skinSettings['ImportExport']['SystemName'] = "Effect Web Template Engine";
 $skinSettings['ImportExport']['Version'] = EW_BUILD_VERSION;
 $skinSettings['ImportExport']['XMLCryptKey'] = "z7RvS82*#M2+tpu+";
 $skinSettings['ImportExport']['CodeKeyCryptKey'] = "h+C\$/AY#p2kmU90%";
 $skinSettings['ImportExport']['CodeKeyVars'][0] = array();
 CTM_MuOnline::libraryFactory($muSettings);
 CTM_FileManage::libraryFactory($fileSettings);
 CTM_Template::libraryFactory($skinSettings);
 $CTM_Mailer = new CTM_Mailer();
 $CTM_Mailer->LibFactory();
 $CTM_Mailer->SendMethod = $CTM_SETTINGS['MAILER']['TYPE'];
 $CTM_Mailer->Debug = CTM_MAILER_DEBUG_MODE;
 $CTM_Mailer->FromMail = array($CTM_SETTINGS['MAILER']['FROM'], SERVER_NAME);
 $CTM_Mailer->LogPath = EW_LOG_PATH . "Mailer/";
 if ($CTM_SETTINGS['MAILER']['TYPE'] == 1) {
     $CTM_Mailer->SMTPHost = $CTM_SETTINGS['MAILER']['SMTP']['HOST'];
     $CTM_Mailer->SMTPPort = $CTM_SETTINGS['MAILER']['SMTP']['PORT'];
     $CTM_Mailer->SMTPUser = $CTM_SETTINGS['MAILER']['SMTP']['USER'];
     $CTM_Mailer->SMTPPass = $CTM_SETTINGS['MAILER']['SMTP']['PASS'];
     $CTM_Mailer->SMTPHelo = $CTM_SETTINGS['MAILER']['SMTP']['HELO'];
     $CTM_Mailer->SMTPSecure = $CTM_SETTINGS['MAILER']['SMTP']['SECURE'];
 }
 /**
  *	Get Socket Data
  *	Get Socket System options from database
  *	
  *	@param	integer	Socket Slot
  *	@param	integer	Socket Option
  *	@param	integer	Socket Level
  *	@param	&string	Socket Data
  *
  *	@return	string	Socket options
  */
 public final function GetSocketData($slot, $option, $level, &$socketData = NULL)
 {
     if (!$this->socketStrings) {
         CTM_FileManage::Lib('ReadScript')->StructureFile($this->settings['Files']['SocketSystem'], "Item_SocketStrings.serialize.dat", TRUE);
         CTM_FileManage::Lib('ReadScript')->ReadScript(NULL, $serialize_data);
         $this->socketStrings = $serialize_data;
     }
     if ($option == -1) {
         return $socketData = "Socket " . $slot . " : Free Slot";
     }
     $level += 2;
     $string = "Socket " . $slot . " : ";
     $string .= $this->socketStrings[0][$this->socketStrings[1][$option][0]][0];
     $string .= " (" . $this->socketStrings[1][$option][1] . ") + ";
     $string .= $this->socketStrings[1][$option][$level];
     return $socketData = $string;
 }