Exemplo n.º 1
0
 /**
  *	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;
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  *	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;
     }
 }
Exemplo n.º 3
0
 /**
  *	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;
         }
     }
 }
Exemplo n.º 4
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;
 }