$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'];
    }
}
 /**
  *	Run Section
  *
  *	@return	void
  */
 public function run()
 {
     global $installation;
     if ($_GET['do'] == "install") {
         $this->session->StartSession($_POST['session']);
         $this->session->GetSession("db_settings", $sql_session);
         $this->DB->settings['mssql']['hostname'] = $sql_session['sql_host'];
         $this->DB->settings['mssql']['hostport'] = $sql_session['sql_port'];
         $this->DB->settings['mssql']['database'] = $sql_session['sql_db'];
         $this->DB->settings['mssql']['username'] = $sql_session['sql_user'];
         $this->DB->settings['mssql']['password'] = $sql_session['sql_pass'];
         $this->DB->settings['mssql']['persistent'] = FALSE;
         $this->DB->settings['mssql']['hideErrors'] = TRUE;
         $this->DB->settings['mssql']['debug'] = FALSE;
         $this->DB->Connect("mssql");
         if (!$this->DB->IsConnected()) {
             $GLOBALS['error_message'] = $this->showMessage($this->lang->words['Installation']['Messages']['ConnectError'], "error");
         } else {
             switch ($_GET['set']) {
                 case "sql":
                     require_once CTM_SETUP_PATH . "sources/extensions/setup_sql_objects.php";
                     require_once CTM_SETUP_PATH . "setup/install/sql/mssql_alters.php";
                     require_once CTM_SETUP_PATH . "setup/install/sql/mssql_tables.php";
                     require_once CTM_SETUP_PATH . "setup/install/sql/mssql_procedures.php";
                     require_once CTM_SETUP_PATH . "setup/install/sql/mssql_views.php";
                     require_once CTM_SETUP_PATH . "setup/install/sql/mssql_fulltext.php";
                     $all_ok = true;
                     $this->step = "SQL";
                     if (count($install_objects) > 0) {
                         $with_objects = false;
                         $delete_success = false;
                         foreach ($install_objects as $name => $type) {
                             switch ($type) {
                                 case "table":
                                     $_type = "U";
                                     $query = "TABLE";
                                     break;
                                 case "procedure":
                                     $_type = "P";
                                     $query = "PROCEDURE";
                                     break;
                                 case "view":
                                     $_type = "V";
                                     $query = "VIEW";
                                     break;
                             }
                             $this->DB->Arguments($name);
                             $this->DB->Query("SELECT id FROM dbo.sysobjects WHERE name = '%s' AND type = '{$_type}'", $check);
                             if ($this->DB->CountRows($check) > 0) {
                                 $with_objects = true;
                                 if ($sql_session['delete_install'] == true) {
                                     $this->DB->Arguments($name);
                                     $this->DB->Query("DROP {$query} dbo.%s", $test);
                                     $delete_success = $test == true;
                                 } else {
                                     $delete_success = false;
                                 }
                             }
                         }
                         if ($with_objects == true) {
                             if ($sql_session['delete_install'] == true) {
                                 if ($delete_success == false) {
                                     $GLOBALS['error_message'] = $this->showMessage($this->lang->words['Installation']['Messages']['DeleteInstallationFailed'], "error");
                                     $all_ok = false;
                                 }
                             } else {
                                 $GLOBALS['error_message'] = $this->showMessage($this->lang->words['Installation']['Messages']['ExistingInstallation'], "error");
                                 $all_ok = false;
                             }
                         }
                     }
                     if ($all_ok == true) {
                         $this->install_vars['querys']['mu_accounts:database'] = MUACC_CORE;
                         $this->install_vars['querys']['mu_general:database'] = MUGEN_CORE;
                         $this->install_vars['querys']['coin:database'] = COIN_CORE;
                         $this->install_vars['querys']['coin:table'] = COIN_TABLE;
                         $this->install_vars['querys']['coin:column_1'] = COIN_COLUMN_1;
                         $this->install_vars['querys']['coin:column_2'] = COIN_COLUMN_2;
                         $this->install_vars['querys']['coin:column_3'] = COIN_COLUMN_3;
                         $this->install_vars['querys']['coin:login'] = COIN_LOGIN;
                         $alters = 0;
                         $tables = 0;
                         $procedures = 0;
                         $views = 0;
                         $others = 0;
                         if (count($install_alters) > 0) {
                             foreach ($install_alters as $query) {
                                 $alters++;
                                 $this->DB->Query($this->loadCompileQuery($query));
                             }
                         }
                         if (count($install_tables) > 0) {
                             foreach ($install_tables as $query) {
                                 $tables++;
                                 $this->DB->Query($this->loadCompileQuery($query));
                             }
                         }
                         if (count($install_procedures) > 0) {
                             foreach ($install_procedures as $query) {
                                 $procedures++;
                                 $this->DB->Query($this->loadCompileQuery($query));
                             }
                         }
                         if (count($install_views) > 0) {
                             foreach ($install_views as $query) {
                                 $views++;
                                 $this->DB->Query($this->loadCompileQuery($query));
                             }
                         }
                         if (count($install_fulltext) > 0) {
                             foreach ($install_fulltext as $query) {
                                 $others++;
                                 $this->DB->Query($this->loadCompileQuery($query));
                             }
                         }
                         $GLOBALS['installed_alters'] = $alters;
                         $GLOBALS['installed_tables'] = $tables;
                         $GLOBALS['installed_procedures'] = $procedures;
                         $GLOBALS['installed_views'] = $views;
                         $GLOBALS['installed_others'] = $others;
                         $GLOBALS['go_next'] = "?app=install&section=" . $this->section . "&do=install&set=template";
                     }
                     return false;
                     break;
                 case "template":
                     $xml_content = file_get_contents(CTM_SETUP_PATH . "setup/install/xml/skin_harmony.xml");
                     $path = "server_cache/db_php/skin_sources/skin_sources.php";
                     CTM_Template::Lib('ImportExport')->ImportXML($xml_content, $skin_info);
                     CTM_Controller::UpdateWebCache("effectwebkernelhash", "hash_file:" . $path, "hash_file:" . md5_file(CTM_CACHE_PATH . $path));
                     $this->step = "Template";
                     $GLOBALS['installed_templates'] = array($skin_info['Name']);
                     $GLOBALS['go_next'] = "?app=install&section=" . $this->section . "&do=install&set=settings";
                     break;
                 case "settings":
                     $xml_settings = CTM_FileManage::Lib('XML')->ParseXML(CTM_SETUP_PATH . "setup/install/xml/control_settings.xml");
                     $lines = 0;
                     $this->step = "Settings";
                     if (count($xml_settings) > 0) {
                         $this->iSettings->OpenSettings(CTM_CONTROL_PATH . "Settings.php");
                         foreach ($xml_settings->line as $xml) {
                             $lines++;
                             $this->iSettings->SetLine($xml['syntax'], $this->loadCompileSettingsArgs($xml));
                         }
                         $this->iSettings->CloseSettings();
                     }
                     $GLOBALS['changed_lines'] = $lines;
                     $GLOBALS['go_next'] = "?app=install&section=" . $this->section . "&do=install&set=data";
                     break;
                 case "data":
                     require_once CTM_SETUP_PATH . "setup/install/sql/mssql_inserts.php";
                     $this->install_vars['querys']['team_groups:name'] = $this->lang->words['InstallTexts']['AdminGroup']['Name'];
                     $this->install_vars['querys']['team_groups:group_title'] = $this->lang->words['InstallTexts']['AdminGroup']['Title'];
                     $inserts = 0;
                     $this->step = "Data";
                     if (count($install_inserts) > 0) {
                         foreach ($install_inserts as $query) {
                             $inserts++;
                             $this->DB->Query($this->loadCompileQuery($query));
                         }
                     }
                     $GLOBALS['inserted_data'] = $inserts;
                     $GLOBALS['go_next'] = "?app=install&section=" . $this->section . "&do=install&set=end";
                     break;
                 case "end":
                     $this->session->StartSession($_POST['session']);
                     $this->session->SetSession("install", array("end" => true));
                     $this->session->EndSession($new_session);
                     $this->nextSection($new_session);
                     break;
                 default:
                     header("Location: ?app=install&section=" . $this->section);
                     break;
             }
         }
     }
 }
Example #3
0
 /**
  *	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();
 }
 /**
  *	Run Section
  *
  *	@return	void
  */
 public function run()
 {
     global $versionHistory, $installation;
     $this->session->StartSession($_SESSION['SETUP_SESSION']);
     $this->session->GetSession("options", $options);
     $this->session->GetSession("repair_db", $repair_db);
     if ($_GET['do'] == "run") {
         switch ($_GET['set']) {
             case "sql":
                 require_once CTM_SETUP_PATH . "sources/extensions/setup_sql_objects.php";
                 require_once CTM_SETUP_PATH . "setup/install/sql/mssql_alters.php";
                 require_once CTM_SETUP_PATH . "setup/install/sql/mssql_tables.php";
                 require_once CTM_SETUP_PATH . "setup/install/sql/mssql_procedures.php";
                 require_once CTM_SETUP_PATH . "setup/install/sql/mssql_views.php";
                 require_once CTM_SETUP_PATH . "setup/install/sql/mssql_fulltext.php";
                 $all_ok = true;
                 $vault_ready = false;
                 $reset_data = 0;
                 $this->step = "SQL";
                 /*if(count($install_objects) > 0 && $options['repair_db_web'] == true)
                 					{
                 						$delete_success = false;
                 
                 						foreach($install_objects as $name => $type)
                 						{
                 							switch($type)
                 							{
                 								case "table" :
                 									$_type = "U";
                 									$query = "TABLE";
                 								break;
                 								case "procedure" :
                 									$_type = "P";
                 									$query = "PROCEDURE";
                 								break;
                 								case "view" :
                 									$_type = "V";
                 									$query = "VIEW";
                 								break;
                 							}
                 
                 							if($repair_db['db_web']['reset_all_tables'] == true && $query == "TABLE")
                 							{
                 								$this->DB->Arguments($name);
                 								$this->DB->Query("SELECT id FROM dbo.sysobjects WHERE name = '%s' AND type = '{$_type}'", $check);
                 
                 								if($this->DB->CountRows($check) > 0)
                 								{
                 									$this->DB->Arguments($name);
                 									$this->DB->Query("DROP {$query} dbo.%s", $test);
                 
                 									$delete_success = $test == true;
                 								}
                 							}
                 						}
                 
                 						if($repair_db['db_web']['reset_all_tables'] == true && $query == "TABLE")
                 						{
                 							if($delete_success == false)
                 							{
                 								$GLOBALS['error_message'] = $this->showMessage($this->lang->words['Installation']['Messages']['DeleteTablesFailed'], "error");
                 								$all_ok = false;
                 							}
                 						}
                 					}*/
                 if (count($repair_objects['Server']) > 0 && $options['repair_db_server'] == true) {
                     foreach ($repair_objects['Server'] as $name => $type) {
                         if ($name == "MEMB_INFO" && $repair_db['db_server']['reset_member_data'] == true) {
                             $reset_data += $this->loadResetDBData(MUACC_CORE . ".dbo.MEMB_INFO", $type);
                         } elseif ($name == "Character" && $repair_db['db_server']['reset_character_data'] == true) {
                             $reset_data += $this->loadResetDBData(MUACC_CORE . ".dbo.Character", $type);
                         } else {
                             switch ($type) {
                                 case "table":
                                     $_type = "U";
                                     $query = "TABLE";
                                     break;
                                 case "procedure":
                                     $_type = "P";
                                     $query = "PROCEDURE";
                                     break;
                                 case "view":
                                     $_type = "V";
                                     $query = "VIEW";
                                     break;
                             }
                             if ($repair_db['db_server']['reset_all_tables'] == true && $query == "TABLE" && $name != "EffectWebVirtualVault") {
                                 $this->DB->Arguments($name);
                                 $this->DB->Query("SELECT id FROM " . MUGEN_CORE . ".dbo.sysobjects WHERE name = '%s' AND type = '{$_type}'", $check);
                                 if ($this->DB->CountRows($check) > 0) {
                                     $this->DB->Arguments($name);
                                     $this->DB->Query("DROP {$query} " . MUGEN_CORE . ".dbo.%s", $test);
                                     $delete_success = $test == true;
                                 }
                             }
                         }
                         if ($repair_db['db_server']['reset_virtual_vault_items'] == true && $name == "EffectWebVirtualVault" && $vault_ready == false) {
                             $this->DB->Query("SELECT id FROM " . MUGEN_CORE . ".dbo.sysobjects WHERE name = 'EffectWebVirtualVault' AND type = '{$_type}'", $check);
                             if ($this->DB->CountRows($check) > 0) {
                                 $this->DB->Arguments($name);
                                 $this->DB->Query("DROP TABLE " . MUGEN_CORE . ".dbo.EffectWebVirtualVault", $test);
                                 $vault_ready = true;
                                 $delete_success = $test == true;
                             }
                         }
                         if ($repair_db['db_server']['reset_all_tables'] == true && $query == "TABLE") {
                             if ($delete_success == false) {
                                 $GLOBALS['error_message'] = $this->showMessage($this->lang->words['Installation']['Messages']['DeleteTablesFailed'], "error");
                                 $all_ok = false;
                             }
                         }
                     }
                 }
                 if ($all_ok == true) {
                     $this->install_vars['querys']['mu_accounts:database'] = MUACC_CORE;
                     $this->install_vars['querys']['mu_general:database'] = MUGEN_CORE;
                     $this->install_vars['querys']['coin:database'] = COIN_CORE;
                     $this->install_vars['querys']['coin:table'] = COIN_TABLE;
                     $this->install_vars['querys']['coin:column_1'] = COIN_COLUMN_1;
                     $this->install_vars['querys']['coin:column_2'] = COIN_COLUMN_2;
                     $this->install_vars['querys']['coin:column_3'] = COIN_COLUMN_3;
                     $this->install_vars['querys']['coin:login'] = COIN_LOGIN;
                     $alters = 0;
                     $tables = 0;
                     $procedures = 0;
                     $views = 0;
                     $others = 0;
                     $_install_alters = array();
                     $_install_tables = array();
                     $_install_procedures = array();
                     $_install_views = array();
                     $_install_fulltext = array();
                     if (count($install_alters) > 0) {
                         foreach ($install_alters as $_query) {
                             /*if($_query['db'] == "system" && $options['repair_db_web'] == true)
                             		{
                             			$_install_tables[] = $_query;
                             		}*/
                             if ($_query['db'] == "server" && $options['repair_db_server'] == true) {
                                 $_install_alters[] = $_query;
                             }
                         }
                     }
                     if (count($install_tables) > 0) {
                         foreach ($install_tables as $_query) {
                             /*if($_query['db'] == "system" && $options['repair_db_web'] == true)
                             		{
                             			$_install_tables[] = $_query;
                             		}*/
                             if ($_query['db'] == "server" && $options['repair_db_server'] == true) {
                                 $_install_tables[] = $_query;
                             }
                         }
                     }
                     if (count($install_procedures) > 0) {
                         foreach ($install_procedures as $_query) {
                             /*if($_query['db'] == "system" && $options['repair_db_web'] == true)
                             		{
                             			$_install_procedures[] = $_query;
                             		}*/
                             if ($_query['db'] == "server" && $options['repair_db_server'] == true) {
                                 $_install_procedures[] = $_query;
                             }
                         }
                     }
                     if (count($install_views) > 0) {
                         foreach ($install_views as $_query) {
                             /*if($_query['db'] == "system" && $options['repair_db_web'] == true)
                             		{
                             			$_install_views[] = $_query;
                             		}*/
                             if ($_query['db'] == "server" && $options['repair_db_server'] == true) {
                                 $_install_views[] = $_query;
                             }
                         }
                     }
                     if (count($install_fulltext) > 0) {
                         foreach ($install_fulltext as $_query) {
                             /*if($_query['db'] == "system" && $options['repair_db_web'] == true)
                             		{
                             			$_install_fulltext[] = $_query;
                             		}*/
                             if ($_query['db'] == "server" && $options['repair_db_server'] == true) {
                                 $_install_fulltext[] = $_query;
                             }
                         }
                     }
                     if (count($_install_alters) > 0) {
                         foreach ($_install_alters as $query) {
                             $this->DB->Query($this->loadCompileQuery($query), $test);
                             if ($test == true) {
                                 $alters++;
                             }
                         }
                     }
                     if (count($_install_tables) > 0) {
                         foreach ($_install_tables as $query) {
                             $this->DB->Query($this->loadCompileQuery($query), $test);
                             if ($test == true) {
                                 $tables++;
                             }
                         }
                     }
                     if (count($_install_procedures) > 0) {
                         foreach ($_install_procedures as $query) {
                             $this->DB->Query($this->loadCompileQuery($query), $test);
                             if ($test == true) {
                                 $procedures++;
                             }
                         }
                     }
                     if (count($_install_views) > 0) {
                         foreach ($_install_views as $query) {
                             $this->DB->Query($this->loadCompileQuery($query), $test);
                             if ($test == true) {
                                 $views++;
                             }
                         }
                     }
                     if (count($_install_fulltext) > 0) {
                         foreach ($_install_fulltext as $query) {
                             $this->DB->Query($this->loadCompileQuery($query), $test);
                             if ($test == true) {
                                 $others++;
                             }
                         }
                     }
                 }
                 $GLOBALS['repaired_alters'] = $alters;
                 $GLOBALS['repaired_tables'] = $tables;
                 $GLOBALS['repaired_procedures'] = $procedures;
                 $GLOBALS['repaired_views'] = $views;
                 $GLOBALS['repaired_others'] = $others;
                 $GLOBALS['reseted_data'] = $reset_data;
                 $GLOBALS['go_next'] = "?app=repair&section=" . $this->section . "&do=run&set=template";
                 return false;
                 break;
             case "template":
                 if ($options['restore_factory_template'] == true) {
                     $xml_content = file_get_contents(CTM_SETUP_PATH . "setup/install/xml/skin_harmony.xml");
                     $path = "server_cache/db_php/skin_sources/skin_sources.php";
                     CTM_Template::Lib('ImportExport')->ImportXML($xml_content, $skin_info);
                     CTM_Controller::UpdateWebCache("effectwebkernelhash", "hash_file:" . $path, "hash_file:" . md5_file(CTM_CACHE_PATH . $path));
                     $this->step = "Template";
                     $GLOBALS['restored_templates'] = array($skin_info['Name']);
                     $GLOBALS['go_next'] = "?app=repair&section=" . $this->section . "&do=run&set=data";
                 } else {
                     header("Location: ?app=repair&section=" . $this->section . "&do=install&set=data");
                 }
                 break;
             case "data":
                 require_once CTM_SETUP_PATH . "sources/extensions/setup_sql_data.php";
                 require_once CTM_SETUP_PATH . "setup/install/sql/mssql_inserts.php";
                 $this->install_vars['querys']['team_groups:name'] = $this->lang->words['InstallTexts']['AdminGroup']['Name'];
                 $this->install_vars['querys']['team_groups:group_title'] = $this->lang->words['InstallTexts']['AdminGroup']['Title'];
                 $inserts = 0;
                 $this->step = "Data";
                 if ($options['create_admin_account'] == true) {
                     $test = array(false, false);
                     //$this->DB->Query($this->loadCompileQuery($install_inserts['General']['AdminAccount']['Group']), $test[0]);
                     $this->install_vars['querys']['team_members:group_id'] = 1;
                     //$this->DB->GetLastedId();
                     $this->DB->Query($this->loadCompileQuery($install_inserts['AdminAccount:Account']), $test[1]);
                     //if($test[0] == true)
                     //$inserts++;
                     if ($test[1] == true) {
                         $inserts++;
                     }
                 }
                 if ($options['restore_factory_tasks'] == true) {
                     $test = false;
                     if (count($sql_data) > 0) {
                         foreach ($sql_data as $index => $query) {
                             if (substr($index, 0, 9) == "CronTask:") {
                                 $this->DB->Query($query['Select'], $test);
                                 if ($this->DB->CountRows($test) > 0) {
                                     $this->DB->Query($query['Delete']);
                                 }
                                 $this->DB->Query($this->loadCompileQuery($install_inserts[$index]), $test);
                                 if ($test == true) {
                                     $inserts++;
                                 }
                             }
                         }
                     }
                 }
                 $GLOBALS['inserted_data'] = $inserts;
                 $GLOBALS['go_next'] = "?app=repair&section=" . $this->section . "&do=run&set=end";
                 break;
             case "end":
                 $this->session->StartSession($_POST['session']);
                 $this->session->SetSession("repair", array("end" => true));
                 $this->session->EndSession($new_session);
                 $this->nextSection($new_session);
                 break;
             default:
                 header("Location: ?app=repair&section=" . $this->section);
                 break;
         }
     }
 }
 /**
  *	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;
 }
Example #6
0
 /**
  *	Redirect: Logout Success
  *
  *	@return	void
  */
 private function loadRedirectLogoutSuccess()
 {
     CTM_Template::setTag("REDIRECT_TITLE", CTM_Language::Load("Redirector[LogoutSuccess][Title]"));
     CTM_Template::setTag("REDIRECT_MESSAGE", NULL);
     CTM_Template::setTag("REDIRECT_REFERER", $this->refererLink);
 }
 /**
  *	Run Section
  *
  *	@return	void
  */
 public function run()
 {
     global $versionHistory, $installation;
     if ($_GET['do'] == "install") {
         require_once CTM_SETUP_PATH . "sources/extensions/setup_versions_update.php";
         $end = 0;
         foreach ($versionHistory as $version => $info) {
             if ($version > $installation['current_version']) {
                 $versions_to_update[$end++] = $version;
             }
         }
         $end -= 1;
         $current_step = !$_GET['step'] ? 0 : ($_GET['step'] > $end ? $end : $_GET['step']);
         $current_version = $versions_to_update[$current_step];
         switch ($_GET['set']) {
             case "sql":
                 if ($update_versions[$current_version]['sql_site'] == true || $update_versions[$current_version]['sql_server'] == true) {
                     require_once CTM_SETUP_PATH . "setup/updates/" . $current_version . "/sql/mssql_drops.php";
                     require_once CTM_SETUP_PATH . "setup/updates/" . $current_version . "/sql/mssql_alters.php";
                     require_once CTM_SETUP_PATH . "setup/updates/" . $current_version . "/sql/mssql_tables.php";
                     require_once CTM_SETUP_PATH . "setup/updates/" . $current_version . "/sql/mssql_procedures.php";
                     require_once CTM_SETUP_PATH . "setup/updates/" . $current_version . "/sql/mssql_views.php";
                     require_once CTM_SETUP_PATH . "setup/updates/" . $current_version . "/sql/mssql_fulltext.php";
                     $this->step = "SQL";
                     $this->install_vars['querys']['mu_accounts:database'] = MUACC_CORE;
                     $this->install_vars['querys']['mu_general:database'] = MUGEN_CORE;
                     $this->install_vars['querys']['coin:database'] = COIN_CORE;
                     $this->install_vars['querys']['coin:table'] = COIN_TABLE;
                     $this->install_vars['querys']['coin:column_1'] = COIN_COLUMN_1;
                     $this->install_vars['querys']['coin:column_2'] = COIN_COLUMN_2;
                     $this->install_vars['querys']['coin:column_3'] = COIN_COLUMN_3;
                     $this->install_vars['querys']['coin:login'] = COIN_LOGIN;
                     $drops = 0;
                     $alters = 0;
                     $tables = 0;
                     $procedures = 0;
                     $views = 0;
                     $others = 0;
                     if (count($update_drops) > 0) {
                         foreach ($update_drops as $query) {
                             $drops++;
                             $this->DB->Query($this->loadCompileQuery($query, $current_version));
                         }
                     }
                     if (count($update_alters) > 0) {
                         foreach ($update_alters as $query) {
                             $alters++;
                             $this->DB->Query($this->loadCompileQuery($query, $current_version));
                         }
                     }
                     if (count($update_tables) > 0) {
                         foreach ($update_tables as $query) {
                             $tables++;
                             $this->DB->Query($this->loadCompileQuery($query, $current_version));
                         }
                     }
                     if (count($update_procedures) > 0) {
                         foreach ($update_procedures as $query) {
                             $procedures++;
                             $this->DB->Query($this->loadCompileQuery($query, $current_version));
                         }
                     }
                     if (count($update_views) > 0) {
                         foreach ($update_views as $query) {
                             $views++;
                             $this->DB->Query($this->loadCompileQuery($query, $current_version));
                         }
                     }
                     if (count($update_fulltext) > 0) {
                         foreach ($update_fulltext as $query) {
                             $others++;
                             $this->DB->Query($this->loadCompileQuery($query, $current_version));
                         }
                     }
                     $GLOBALS['droped_objects'] = $drops;
                     $GLOBALS['installed_alters'] = $alters;
                     $GLOBALS['installed_tables'] = $tables;
                     $GLOBALS['installed_procedures'] = $procedures;
                     $GLOBALS['installed_views'] = $views;
                     $GLOBALS['installed_others'] = $others;
                     $GLOBALS['go_next'] = "?app=upgrade&section=" . $this->section . "&do=install&set=template&step=" . $current_step;
                 } else {
                     header("Location: ?app=upgrade&section=" . $this->section . "&do=install&set=template&step=" . $current_step);
                 }
                 break;
             case "template":
                 if ($update_versions[$current_version]['templates'] == true) {
                     $xml_content = file_get_contents(CTM_SETUP_PATH . "setup/install/xml/skin_harmony.xml");
                     $path = "server_cache/db_php/skin_sources/skin_sources.php";
                     CTM_Template::Lib('ImportExport')->ImportXML($xml_content, $skin_info);
                     CTM_Controller::UpdateWebCache("effectwebkernelhash", "hash_file:" . $path, "hash_file:" . md5_file(CTM_CACHE_PATH . $path));
                     $this->step = "Template";
                     $GLOBALS['updated_templates'] = array($skin_info['Name']);
                     $GLOBALS['go_next'] = "?app=upgrade&section=" . $this->section . "&do=install&set=data&step=" . $current_step;
                 } else {
                     header("Location: ?app=upgrade&section=" . $this->section . "&do=install&set=data&step=" . $current_step);
                 }
                 break;
             case "data":
                 if ($update_versions[$current_version]['sql_site'] == true || $update_versions[$current_version]['sql_server'] == true) {
                     require_once CTM_SETUP_PATH . "setup/updates/" . $current_version . "/sql/mssql_inserts.php";
                     $this->install_vars['querys']['team_groups:name'] = $this->lang->words['InstallTexts']['AdminGroup']['Name'];
                     $this->install_vars['querys']['team_groups:group_title'] = $this->lang->words['InstallTexts']['AdminGroup']['Title'];
                     $inserts = 0;
                     $this->step = "Data";
                     if (count($update_inserts) > 0) {
                         foreach ($update_inserts as $query) {
                             $inserts++;
                             $this->DB->Query($this->loadCompileQuery($query));
                         }
                     }
                     $GLOBALS['inserted_data'] = $inserts;
                     $GLOBALS['go_next'] = "?app=upgrade&section=" . $this->section . "&do=install&set=end&step=" . $current_step;
                 } else {
                     header("Location: ?app=upgrade&section=" . $this->section . "&do=install&set=end&step=" . $current_step);
                 }
                 break;
             case "end":
                 if ($current_step == $end) {
                     $this->session->StartSession($_POST['session']);
                     $this->session->SetSession("install", array("end" => true));
                     $this->session->EndSession($new_session);
                     $this->nextSection($new_session);
                 } else {
                     header("Location: ?app=upgrade&section=" . $this->section . "&do=install&set=sql&step=" . ($current_step + 1));
                 }
                 break;
             default:
                 header("Location: ?app=upgrade&section=" . $this->section);
                 break;
         }
         $GLOBALS['current_version']['string'] = $versionHistory[$current_version]['show'];
         $GLOBALS['current_version']['key'] = $current_version;
     }
 }
 /**
  *	Compile Cache File
  *	Compile the HTML Logic from files to cache
  *
  *	@return	void
  */
 public function CompileCache()
 {
     $full_path = CTM_CACHE_PATH . "skin_cache/templates/" . $this->tpl_folder . "/skin_" . $this->file_name . ".php";
     parent::Lib('Logic')->PrepareToBuild();
     foreach ($this->database as $key => $value) {
         parent::Lib('Logic')->ConvertHTMLToPHP(str_replace(array("::x####\$####x::", "::x####code:n####x::"), array("\$", "\\n"), $value), $key, NULL);
     }
     parent::Lib('Logic')->CompileSkinFile("skin_" . $this->file_name, "skin_" . $this->file_name, $full_path);
 }
Example #9
0
 /**
  *	Library Factory
  *
  *	@param	array	Lib Settings
  *	@return	void
  */
 public static function libraryFactory($settings)
 {
     self::$settings = $settings;
 }
Example #10
0
 /**
  *	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;
 }