/** * Installs SQL schematic * * @return void */ public function install_sql() { //----------------------------------------- // INIT //----------------------------------------- $previous = $_REQUEST['previous']; $skip = $_REQUEST['_skip']; //----------------------------------------- // Write config //----------------------------------------- if (!$previous and !$skip) { /* Write Configuration Files */ $output[] = 'Запись файлов конфигурации<br />'; $test = IPSInstall::writeConfiguration(); //----------------------------------- // Check that it wrote //----------------------------------- if (!is_file(IPSSetUp::getSavedData('install_dir') . '/conf_global.php')) { $this->registry->output->setTitle("Установка: Ошибка"); $this->registry->output->setNextAction('install&do=sql'); $this->registry->output->setHideButton(TRUE); $this->registry->output->addError("Невозможна запись конфигурации в файл conf_global.php. Пожалуйста, убедитесь, что файл имеет полный доступ на чтение и запись."); $this->registry->output->addContent(""); $this->registry->output->sendOutput(); exit; } else { $INFO = array(); require IPSSetUp::getSavedData('install_dir') . '/conf_global.php'; /*noLibHook*/ if (!$INFO['sql_driver']) { $this->registry->output->setTitle("Установка: Ошибка"); $this->registry->output->setNextAction('install&do=sql'); $this->registry->output->setHideButton(TRUE); $this->registry->output->addError("Невозможна запись конфигурации в файл conf_global.php. Пожалуйста, убедитесь, что файл имеет полный доступ на чтение и запись."); $this->registry->output->addContent(""); $this->registry->output->sendOutput(); exit; } } } /* Set up DB driver */ $extra_install = $this->_setUpDBDriver(FALSE); //----------------------------------------- // Import System Templates // We have to do this here un case we counter a driver error //----------------------------------------- require_once IPS_ROOT_PATH . 'sources/classes/output/systemTemplates.php'; /*noLibHook*/ $systemTemplates = new systemTemplates(); $systemTemplates->writeDefaults(); //----------------------------------------- // Fetch next 'un //----------------------------------------- $next = IPSSetUp::fetchNextApplication($previous, '', $this->settings['gb_char_set']); if ($next['key']) { //----------------------------------------- // INIT //----------------------------------------- $_PATH = IPSLib::getAppDir($next['key']) . '/setup/versions/install/sql/'; $_FILE = $_PATH . $next['key'] . '_' . strtolower(IPSSetUp::getSavedData('sql_driver')); //----------------------------------------- // Tables //----------------------------------------- if (is_file($_FILE . '_tables.php')) { $TABLE = array(); include $_FILE . '_tables.php'; /*noLibHook*/ if (is_array($TABLE) and count($TABLE)) { $output[] = $next['title'] . ": Создание таблиц"; foreach ($TABLE as $q) { preg_match("/CREATE TABLE (\\S+)(\\s)?\\(/", $q, $match); if ($match[1]) { $this->DB->dropTable(str_replace(IPSSetUp::getSavedData('db_pre'), '', $match[1])); } if ($extra_install and method_exists($extra_install, 'process_query_create')) { $q = $extra_install->process_query_create($q); } $this->DB->allow_sub_select = 1; $this->DB->error = ''; $this->DB->query($q); if ($this->DB->error) { $this->registry->output->addError(nl2br($q) . "<br /><br />" . $this->DB->error); } } } } //--------------------------------------------- // Create the fulltext index... //--------------------------------------------- if ($this->DB->checkFulltextSupport()) { if (is_file($_FILE . '_fulltext.php')) { $INDEX = array(); include $_FILE . '_fulltext.php'; /*noLibHook*/ if (is_array($INDEX) and count($INDEX)) { $output[] = $next['title'] . ": Создание индексов"; foreach ($INDEX as $q) { //--------------------------------------------- // Pass to handler //--------------------------------------------- if ($extra_install and method_exists($extra_install, 'process_query_index')) { $q = $extra_install->process_query_index($q); } //--------------------------------------------- // Pass query //--------------------------------------------- $this->DB->allow_sub_select = 1; $this->DB->error = ''; $this->DB->query($q); if ($this->DB->error) { $this->registry->output->addError(nl2br($q) . "<br /><br />" . $this->DB->error); } } } } } //----------------------------------------- // INSERTS //----------------------------------------- if (is_file($_FILE . '_inserts.php')) { $INSERT = array(); include $_FILE . '_inserts.php'; /*noLibHook*/ if (is_array($INSERT) && count($INSERT)) { $output[] = $next['title'] . ": Наполнение таблиц"; foreach ($INSERT as $q) { $q = str_replace("<%time%>", time(), $q); $q = str_replace('<%admin_name%>', IPSSetUp::getSavedData('admin_user'), $q); $q = str_replace('<%admin_seoname%>', IPSText::makeSeoTitle(IPSSetUp::getSavedData('admin_user')), $q); //--------------------------------------------- // Pass to handler //--------------------------------------------- if ($extra_install and method_exists($extra_install, 'process_query_insert')) { $q = $extra_install->process_query_insert($q); } $this->DB->allow_sub_select = 1; $this->DB->error = ''; $this->DB->query($q); if ($this->DB->error) { $this->registry->output->addError(nl2br($q) . "<br /><br />" . $this->DB->error); } } } } //----------------------------------------- // Sort out groups // This has to be here so the applications // can populate group settings appropriately //----------------------------------------- if ($next['key'] == 'core') { $output[] = "Добавление информации о группах..."; $xml = new classXML(IPSSetUp::charSet); if ($extra_install and method_exists($extra_install, 'before_inserts_run')) { $q = $extra_install->before_inserts_run('groups'); } $xml->load(IPS_ROOT_PATH . 'setup/xml/groups.xml'); foreach ($xml->fetchElements('row') as $xmlelement) { $data = $xml->fetchElementsFromRecord($xmlelement); $this->DB->insert('groups', $data); } if ($extra_install and method_exists($extra_install, 'after_inserts_run')) { $q = $extra_install->after_inserts_run('groups'); } } //----------------------------------------- // Done.. so get some more! //----------------------------------------- $output = (is_array($output) and count($output)) ? $output : array(0 => $next['title'] . ": Наполнение таблиц завершено"); $this->_finishStep($output, "Установка: SQL", 'install&do=sql&previous=' . $next['key']); } else { //----------------------------------------- // NO MORE TO INSTALL //----------------------------------------- $output[] = "Действия SQL завершены"; IPSInstall::createAdminAccount(); //----------------------------------------- // Next... //----------------------------------------- $output = (is_array($output) and count($output)) ? $output : array(0 => $next['title'] . ": Наполнение таблиц завершено"); $this->_finishStep($output, "Установка: SQL", 'install&do=sql_steps'); } }
// Set Configuration //----------------------------------------- IPSSetUp::setSavedData('install_apps', $_SERVER['argv'][1]); IPSSetUp::setSavedData('install_dir', $_SERVER['argv'][2]); IPSSetUp::setSavedData('install_url', $_SERVER['argv'][3]); IPSSetUp::setSavedData('lkey', $_SERVER['argv'][4]); IPSSetUp::setSavedData('sql_driver', 'mysql'); IPSSetUp::setSavedData('db_host', $_SERVER['argv'][5]); IPSSetUp::setSavedData('db_name', $_SERVER['argv'][6]); IPSSetUp::setSavedData('db_user', $_SERVER['argv'][7]); IPSSetUp::setSavedData('db_pass', $_SERVER['argv'][8]); IPSSetUp::setSavedData('db_pre', ''); IPSSetUp::setSavedData('admin_user', $_SERVER['argv'][9]); IPSSetUp::setSavedData('admin_pass', $_SERVER['argv'][10]); IPSSetUp::setSavedData('admin_email', $_SERVER['argv'][11]); /* Write it */ IPSInstall::writeConfiguration(); //----------------------------------------- // Install //----------------------------------------- file_get_contents("http://license.invisionpower.com/?a=activate&key={$_SERVER['argv'][4]}&url={$_SERVER['argv'][3]}"); file_put_contents("../../../cache/installer_lock.php", "AUTOINSTALLED"); require_once IPS_ROOT_PATH . 'setup/applications/install/sections/install.php'; /*noLibHook*/ $controller = new install_install(); $output = new CLIOutput($steps, $controller); $registry->setClass('output', $output); $controller->makeRegistryShortcuts($registry); $output->setNextAction('do=sql'); $output->sendOutput(); exit;
/** * Installs SQL schematic * * @return void */ public function install_sql() { //----------------------------------------- // INIT //----------------------------------------- $previous = $_REQUEST['previous']; $skip = $_REQUEST['_skip']; //----------------------------------------- // Write config //----------------------------------------- if (!$previous and !$skip) { /* Write Configuration Files */ $output[] = 'Writing configuration files...<br />'; $test = IPSInstall::writeConfiguration(); //----------------------------------- // Check that it wrote //----------------------------------- if (!file_exists(IPSSetUp::getSavedData('install_dir') . '/conf_global.php')) { $this->registry->output->setTitle("Install: Error"); $this->registry->output->setNextAction('install&do=sql'); $this->registry->output->setHideButton(TRUE); $this->registry->output->addError("We were unable to write your configuration information to the conf_global.php file. Please verify that this file has full read and write privileges."); $this->registry->output->addContent(""); $this->registry->output->sendOutput(); exit; } else { unset($INFO); require IPSSetUp::getSavedData('install_dir') . '/conf_global.php'; if (!is_array($INFO)) { $this->registry->output->setTitle("Install: Error"); $this->registry->output->setNextAction('install&do=sql'); $this->registry->output->setHideButton(TRUE); $this->registry->output->addError("We were unable to write your configuration information to the conf_global.php file. Please verify that this file has full read and write privileges."); $this->registry->output->addContent(""); $this->registry->output->sendOutput(); exit; } } } /* Set up DB driver */ $extra_install = $this->_setUpDBDriver(FALSE); //----------------------------------------- // Fetch next 'un //----------------------------------------- $next = IPSSetUp::fetchNextApplication($previous); if ($next['key']) { //----------------------------------------- // INIT //----------------------------------------- $_PATH = IPSLib::getAppDir($next['key']) . '/setup/versions/install/sql/'; $_FILE = $_PATH . $next['key'] . '_' . strtolower(IPSSetUp::getSavedData('sql_driver')); //----------------------------------------- // Tables //----------------------------------------- if (file_exists($_FILE . '_tables.php')) { include $_FILE . '_tables.php'; $output[] = $next['title'] . ": Creating SQL Tables..."; if (is_array($TABLE) and count($TABLE)) { foreach ($TABLE as $q) { preg_match("/CREATE TABLE (\\S+)(\\s)?\\(/", $q, $match); if ($match[1]) { $this->DB->dropTable(str_replace(IPSSetUp::getSavedData('db_pre'), '', $match[1])); } if ($extra_install and method_exists($extra_install, 'process_query_create')) { $q = $extra_install->process_query_create($q); } $this->DB->allow_sub_select = 1; $this->DB->error = ''; $this->DB->query($q); if ($this->DB->error) { $this->registry->output->addError(nl2br($q) . "<br /><br />" . $this->DB->error); } } } } //--------------------------------------------- // Create the fulltext index... //--------------------------------------------- if ($this->DB->checkFulltextSupport()) { if (file_exists($_FILE . '_fulltext.php')) { include $_FILE . '_fulltext.php'; $output[] = $next['title'] . ": Building indexes..."; if (is_array($INDEX) and count($INDEX)) { foreach ($INDEX as $q) { //--------------------------------------------- // Pass to handler //--------------------------------------------- if ($extra_install and method_exists($extra_install, 'process_query_index')) { $q = $extra_install->process_query_index($q); } //--------------------------------------------- // Pass query //--------------------------------------------- $this->DB->allow_sub_select = 1; $this->DB->error = ''; $this->DB->query($q); if ($this->DB->error) { $this->registry->output->addError(nl2br($q) . "<br /><br />" . $this->DB->error); } } } } } //----------------------------------------- // INSERTS //----------------------------------------- if (file_exists($_FILE . '_inserts.php')) { include $_FILE . '_inserts.php'; $output[] = $next['title'] . ": Populating SQL Tables..."; foreach ($INSERT as $q) { $q = str_replace("<%time%>", time(), $q); $q = str_replace('<%admin_name%>', IPSSetUp::getSavedData('admin_user'), $q); $q = str_replace('<%admin_seoname%>', IPSText::makeSeoTitle(IPSSetUp::getSavedData('admin_user')), $q); //--------------------------------------------- // Pass to handler //--------------------------------------------- if ($extra_install and method_exists($extra_install, 'process_query_insert')) { $q = $extra_install->process_query_insert($q); } $this->DB->allow_sub_select = 1; $this->DB->error = ''; $this->DB->query($q); if ($this->DB->error) { $this->registry->output->addError(nl2br($q) . "<br /><br />" . $this->DB->error); } } } //----------------------------------------- // Done.. so get some more! //----------------------------------------- $output = (is_array($output) and count($output)) ? $output : array(0 => $next['title'] . ": SQL insertion complete"); $this->_finishStep($output, "Install: SQL", 'install&do=sql&previous=' . $next['key']); } else { //----------------------------------------- // NO MORE TO INSTALL //----------------------------------------- $output[] = "SQL section complete..."; IPSInstall::createAdminAccount(); //----------------------------------------- // Next... //----------------------------------------- $output = (is_array($output) and count($output)) ? $output : array(0 => $next['title'] . ": SQL insertion complete"); $this->_finishStep($output, "Install: SQL", 'install&do=sql_steps'); } }