Index: public/install/console.php =================================================================== --- public/install/console.php (revision 161) +++ public/install/console.php (working copy) @@ -6,7 +6,7 @@ die('There is no input arguments'); } // if - $installation = new acInstallation(new Output_Console()); + $installation = new Installation(new Output_Console()); $installation->setDatabaseType((string) trim(array_var($argv, 1))); $installation->setDatabaseHost((string) trim(array_var($argv, 2))); $installation->setDatabaseUsername((string) trim(array_var($argv, 3))); Index: public/install/include.php =================================================================== --- public/install/include.php (revision 161) +++ public/install/include.php (working copy) @@ -39,7 +39,7 @@ require_once INSTALLER_PATH . '/library/classes/Output.class.php'; require_once INSTALLER_PATH . '/library/classes/Output_Html.class.php'; require_once INSTALLER_PATH . '/library/classes/Output_Console.class.php'; - require_once INSTALLER_PATH . '/installation/acInstallation.class.php'; + require_once INSTALLER_PATH . '/installation/Installation.class.php'; require_once INSTALLATION_PATH . '/environment/classes/template/Template.class.php'; Index: public/install/index.php =================================================================== --- public/install/index.php (revision 161) +++ public/install/index.php (working copy) @@ -3,7 +3,7 @@ require_once dirname(__FILE__) . '/include.php'; // Prepare and execute - require_once INSTALLER_PATH . '/installation/installation.php'; + require_once INSTALLER_PATH . '/installation/main_installation.php'; if (!isset($installer) || !is_object($installer)) { die('Installer not prepared.'); } // if Index: public/install/installation/acInstallation.class.php =================================================================== --- public/install/installation/acInstallation.class.php (revision 161) +++ public/install/installation/acInstallation.class.php (working copy) @@ -1,453 +0,0 @@ -setOutput($output); - } // __construct - - /** - * Prepare and process config form - * - * @access public - * @param void - * @return boolean - */ - function execute() { - $database_type = $this->getDatabaseType(); - $database_host = $this->getDatabaseHost(); - $database_user = $this->getDatabaseUsername(); - $database_pass = $this->getDatabasePassword(); - $database_name = $this->getDatabaseName(); - $database_prefix = $this->getTablePrefix(); - $absolute_url = $this->getAbsoluteUrl(); - $installkey = sha1(date('l dS \of F Y h:i:s A').$_SERVER['REMOTE_ADDR'].rand(10000,99999)); - - $connected = false; - if ($this->database_connection = @mysql_connect($database_host, $database_user, $database_pass)) { - $connected = @mysql_select_db($database_name, $this->database_connection); - } // if - - if ($connected) { - $this->printMessage('Database connection has been established successfully'); - } else { - return $this->breakExecution('Failed to connect to database with data you provided'); - } // if - - // --------------------------------------------------- - // Check if we have InnoDB support - // --------------------------------------------------- - - if ($this->haveInnoDbSupport()) { - $this->printMessage('InnoDB storage engine is supported'); - } else { - return $this->breakExecution('InnoDB storage engine is not supported'); - } // if - - $constants = array( - 'DB_ADAPTER' => $database_type, - 'DB_HOST' => $database_host, - 'DB_USER' => $database_user, - 'DB_PASS' => $database_pass, - 'DB_NAME' => $database_name, - 'DB_PERSIST' => true, - 'TABLE_PREFIX' => $database_prefix, - 'ROOT_URL' => $absolute_url, - 'DEFAULT_LOCALIZATION' => 'en_us', - 'DEBUG' => false, - 'PRODUCT_VERSION' => require INSTALLATION_PATH . '/version.php', - 'SHOW_MESSAGE_BODY' => true, - 'SHOW_COMMENT_BODY' => true, - 'SHOW_MILESTONE_BODY' => true, - 'TOKEN_COOKIE_NAME' => $installkey, - - ); // array - - tpl_assign('table_prefix', $database_prefix); - tpl_assign('absolute_url', $absolute_url); - - // Check MySQL version - $mysql_version = mysql_get_server_info($this->database_connection); - if ($mysql_version && version_compare($mysql_version, '4.1', '>=')) { - $constants['DB_CHARSET'] = 'utf8'; - @mysql_query("SET NAMES 'utf8'", $this->database_connection); - tpl_assign('default_collation', 'collate utf8_unicode_ci'); - tpl_assign('default_charset', 'DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'); - } else { - tpl_assign('default_collation', ''); - tpl_assign('default_charset', ''); - } // if - - @mysql_query('BEGIN WORK', $this->database_connection); - - // Database construction - $total_queries = 0; - $executed_queries = 0; - if ($this->executeMultipleQueries(tpl_fetch(get_template_path('sql/mysql_schema.php')), $total_queries, $executed_queries)) { - $this->printMessage("Tables created in '$database_name'. (Executed queries: $executed_queries)"); - } else { - return $this->breakExecution('Failed to import database construction. MySQL said: ' . mysql_error($this->database_connection)); - } // if - - // Initial data - $total_queries = 0; - $executed_queries = 0; - if ($this->executeMultipleQueries(tpl_fetch(get_template_path('sql/mysql_initial_data.php')), $total_queries, $executed_queries)) { - $this->printMessage("Initial data imported into '$database_name'. (Executed queries: $executed_queries)"); - } else { - return $this->breakExecution('Failed to import initial data. MySQL said: ' . mysql_error($this->database_connection)); - } // if - - @mysql_query('COMMIT', $this->database_connection); - - if ($this->writeConfigFile($constants)) { - $this->printMessage('Configuration data has been successfully added to the configuration file'); - } else { - return $this->breakExecution('Failed to write config data into config file'); - } // if - - return true; - } // excute - - // --------------------------------------------------- - // Util methods - // --------------------------------------------------- - - /** - * Add error message to all messages and break the execution - * - * @access public - * @param string $error_message Reason why we are breaking execution - * @return boolean - */ - function breakExecution($error_message) { - $this->printMessage($error_message, true); - if (is_resource($this->database_connection)) { - @mysql_query('ROLLBACK', $this->database_connection); - } // if - return false; - } // breakExecution - - /** - * Write $constants in config file - * - * @access public - * @param array $constants - * @return boolean - */ - function writeConfigFile($constants) { - tpl_assign('config_file_constants', $constants); - return file_put_contents(INSTALLATION_PATH . '/config/config.php', tpl_fetch(get_template_path('config_file.php'))); - } // writeConfigFile - - /** - * This function will return true if server we are connected on has InnoDB support - * - * @param void - * @return boolean - */ - function haveInnoDbSupport() { - if ($result = mysql_query("SHOW VARIABLES LIKE 'have_innodb'", $this->database_connection)) { - if ($row = mysql_fetch_assoc($result)) { - return strtolower(array_var($row, 'Value')) == 'yes'; - } // if - } // if - return false; - } // haveInnoDBSupport - - /** - * Execute multiple queries - * - * This one is really quick and dirty because I want to finish this and catch - * the bus. Need to be redone ASAP - * - * This function returns true if all queries are executed successfully - * - * @access public - * @todo Make a better implementation - * @param string $sql - * @param integer $total_queries Total number of queries in SQL - * @param integer $executed_queries Total number of successfully executed queries - * @return boolean - */ - function executeMultipleQueries($sql, &$total_queries, &$executed_queries) { - if (!trim($sql)) { - $total_queries = 0; - $executed_queries = 0; - return true; - } // if - - // Make it work on PHP 5.0.4 - $sql = str_replace(array("\r\n", "\r"), array("\n", "\n"), $sql); - - $queries = explode(";\n", $sql); - if (!is_array($queries) || !count($queries)) { - $total_queries = 0; - $executed_queries = 0; - return true; - } // if - - $total_queries = count($queries); - foreach ($queries as $query) { - if (trim($query)) { - if (@mysql_query(trim($query))) { - $executed_queries++; - } else { - return false; - } // if - } // if - } // if - - return true; - } // executeMultipleQueries - - // --------------------------------------------------- - // Getters and setters - // --------------------------------------------------- - - /** - * Get output - * - * @param null - * @return Output - */ - function getOutput() { - return $this->output; - } // getOutput - - /** - * Set output value - * - * @param Output $value - * @return null - */ - function setOutput(Output $value) { - $this->output = $value; - return $value; - } // setOutput - - /** - * Print message through output object - * - * @param string $message - * @param boolean $is_error - * @return null - */ - function printMessage($message, $is_error = false) { - if ($this->output instanceof Output) { - $this->output->printMessage($message, $is_error); - } // if - } // printMessage - - /** - * Get database_type - * - * @param null - * @return string - */ - function getDatabaseType() { - return $this->database_type; - } // getDatabaseType - - /** - * Set database_type value - * - * @param string $value - * @return null - */ - function setDatabaseType($value) { - $this->database_type = $value; - } // setDatabaseType - - /** - * Get database_host - * - * @param null - * @return string - */ - function getDatabaseHost() { - return $this->database_host; - } // getDatabaseHost - - /** - * Set database_host value - * - * @param string $value - * @return null - */ - function setDatabaseHost($value) { - $this->database_host = $value; - } // setDatabaseHost - - /** - * Get database_username - * - * @param null - * @return string - */ - function getDatabaseUsername() { - return $this->database_username; - } // getDatabaseUsername - - /** - * Set database_username value - * - * @param string $value - * @return null - */ - function setDatabaseUsername($value) { - $this->database_username = $value; - } // setDatabaseUsername - - /** - * Get database_password - * - * @param null - * @return string - */ - function getDatabasePassword() { - return $this->database_password; - } // getDatabasePassword - - /** - * Set database_password value - * - * @param string $value - * @return null - */ - function setDatabasePassword($value) { - $this->database_password = $value; - } // setDatabasePassword - - /** - * Get database_name - * - * @param null - * @return string - */ - function getDatabaseName() { - return $this->database_name; - } // getDatabaseName - - /** - * Set database_name value - * - * @param string $value - * @return null - */ - function setDatabaseName($value) { - $this->database_name = $value; - } // setDatabaseName - - /** - * Get table_prefix - * - * @param null - * @return string - */ - function getTablePrefix() { - return $this->table_prefix; - } // getTablePrefix - - /** - * Set table_prefix value - * - * @param string $value - * @return null - */ - function setTablePrefix($value) { - $this->table_prefix = $value; - } // setTablePrefix - - /** - * Get absolute_url - * - * @param null - * @return string - */ - function getAbsoluteUrl() { - return $this->absolute_url; - } // getAbsoluteUrl - - /** - * Set absolute_url value - * - * @param string $value - * @return null - */ - function setAbsoluteUrl($value) { - $this->absolute_url = $value; - } // setAbsoluteUrl - - } // acInstallation - -?> Index: public/install/installation/Installation.class.php =================================================================== --- public/install/installation/Installation.class.php (revision 0) +++ public/install/installation/Installation.class.php (revision 0) @@ -0,0 +1,453 @@ +setOutput($output); + } // __construct + + /** + * Prepare and process config form + * + * @access public + * @param void + * @return boolean + */ + function execute() { + $database_type = $this->getDatabaseType(); + $database_host = $this->getDatabaseHost(); + $database_user = $this->getDatabaseUsername(); + $database_pass = $this->getDatabasePassword(); + $database_name = $this->getDatabaseName(); + $database_prefix = $this->getTablePrefix(); + $absolute_url = $this->getAbsoluteUrl(); + $installkey = sha1(date('l dS \of F Y h:i:s A').$_SERVER['REMOTE_ADDR'].rand(10000,99999)); + + $connected = false; + if ($this->database_connection = @mysql_connect($database_host, $database_user, $database_pass)) { + $connected = @mysql_select_db($database_name, $this->database_connection); + } // if + + if ($connected) { + $this->printMessage('Database connection has been established successfully'); + } else { + return $this->breakExecution('Failed to connect to database with data you provided'); + } // if + + // --------------------------------------------------- + // Check if we have InnoDB support + // --------------------------------------------------- + + if ($this->haveInnoDbSupport()) { + $this->printMessage('InnoDB storage engine is supported'); + } else { + return $this->breakExecution('InnoDB storage engine is not supported'); + } // if + + $constants = array( + 'DB_ADAPTER' => $database_type, + 'DB_HOST' => $database_host, + 'DB_USER' => $database_user, + 'DB_PASS' => $database_pass, + 'DB_NAME' => $database_name, + 'DB_PERSIST' => true, + 'TABLE_PREFIX' => $database_prefix, + 'ROOT_URL' => $absolute_url, + 'DEFAULT_LOCALIZATION' => 'en_us', + 'DEBUG' => false, + 'PRODUCT_VERSION' => require INSTALLATION_PATH . '/version.php', + 'SHOW_MESSAGE_BODY' => true, + 'SHOW_COMMENT_BODY' => true, + 'SHOW_MILESTONE_BODY' => true, + 'TOKEN_COOKIE_NAME' => $installkey, + + ); // array + + tpl_assign('table_prefix', $database_prefix); + tpl_assign('absolute_url', $absolute_url); + + // Check MySQL version + $mysql_version = mysql_get_server_info($this->database_connection); + if ($mysql_version && version_compare($mysql_version, '4.1', '>=')) { + $constants['DB_CHARSET'] = 'utf8'; + @mysql_query("SET NAMES 'utf8'", $this->database_connection); + tpl_assign('default_collation', 'collate utf8_unicode_ci'); + tpl_assign('default_charset', 'DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'); + } else { + tpl_assign('default_collation', ''); + tpl_assign('default_charset', ''); + } // if + + @mysql_query('BEGIN WORK', $this->database_connection); + + // Database construction + $total_queries = 0; + $executed_queries = 0; + if ($this->executeMultipleQueries(tpl_fetch(get_template_path('sql/mysql_schema.php')), $total_queries, $executed_queries)) { + $this->printMessage("Tables created in '$database_name'. (Executed queries: $executed_queries)"); + } else { + return $this->breakExecution('Failed to import database construction. MySQL said: ' . mysql_error($this->database_connection)); + } // if + + // Initial data + $total_queries = 0; + $executed_queries = 0; + if ($this->executeMultipleQueries(tpl_fetch(get_template_path('sql/mysql_initial_data.php')), $total_queries, $executed_queries)) { + $this->printMessage("Initial data imported into '$database_name'. (Executed queries: $executed_queries)"); + } else { + return $this->breakExecution('Failed to import initial data. MySQL said: ' . mysql_error($this->database_connection)); + } // if + + @mysql_query('COMMIT', $this->database_connection); + + if ($this->writeConfigFile($constants)) { + $this->printMessage('Configuration data has been successfully added to the configuration file'); + } else { + return $this->breakExecution('Failed to write config data into config file'); + } // if + + return true; + } // excute + + // --------------------------------------------------- + // Util methods + // --------------------------------------------------- + + /** + * Add error message to all messages and break the execution + * + * @access public + * @param string $error_message Reason why we are breaking execution + * @return boolean + */ + function breakExecution($error_message) { + $this->printMessage($error_message, true); + if (is_resource($this->database_connection)) { + @mysql_query('ROLLBACK', $this->database_connection); + } // if + return false; + } // breakExecution + + /** + * Write $constants in config file + * + * @access public + * @param array $constants + * @return boolean + */ + function writeConfigFile($constants) { + tpl_assign('config_file_constants', $constants); + return file_put_contents(INSTALLATION_PATH . '/config/config.php', tpl_fetch(get_template_path('config_file.php'))); + } // writeConfigFile + + /** + * This function will return true if server we are connected on has InnoDB support + * + * @param void + * @return boolean + */ + function haveInnoDbSupport() { + if ($result = mysql_query("SHOW VARIABLES LIKE 'have_innodb'", $this->database_connection)) { + if ($row = mysql_fetch_assoc($result)) { + return strtolower(array_var($row, 'Value')) == 'yes'; + } // if + } // if + return false; + } // haveInnoDBSupport + + /** + * Execute multiple queries + * + * This one is really quick and dirty because I want to finish this and catch + * the bus. Need to be redone ASAP + * + * This function returns true if all queries are executed successfully + * + * @access public + * @todo Make a better implementation + * @param string $sql + * @param integer $total_queries Total number of queries in SQL + * @param integer $executed_queries Total number of successfully executed queries + * @return boolean + */ + function executeMultipleQueries($sql, &$total_queries, &$executed_queries) { + if (!trim($sql)) { + $total_queries = 0; + $executed_queries = 0; + return true; + } // if + + // Make it work on PHP 5.0.4 + $sql = str_replace(array("\r\n", "\r"), array("\n", "\n"), $sql); + + $queries = explode(";\n", $sql); + if (!is_array($queries) || !count($queries)) { + $total_queries = 0; + $executed_queries = 0; + return true; + } // if + + $total_queries = count($queries); + foreach ($queries as $query) { + if (trim($query)) { + if (@mysql_query(trim($query))) { + $executed_queries++; + } else { + return false; + } // if + } // if + } // if + + return true; + } // executeMultipleQueries + + // --------------------------------------------------- + // Getters and setters + // --------------------------------------------------- + + /** + * Get output + * + * @param null + * @return Output + */ + function getOutput() { + return $this->output; + } // getOutput + + /** + * Set output value + * + * @param Output $value + * @return null + */ + function setOutput(Output $value) { + $this->output = $value; + return $value; + } // setOutput + + /** + * Print message through output object + * + * @param string $message + * @param boolean $is_error + * @return null + */ + function printMessage($message, $is_error = false) { + if ($this->output instanceof Output) { + $this->output->printMessage($message, $is_error); + } // if + } // printMessage + + /** + * Get database_type + * + * @param null + * @return string + */ + function getDatabaseType() { + return $this->database_type; + } // getDatabaseType + + /** + * Set database_type value + * + * @param string $value + * @return null + */ + function setDatabaseType($value) { + $this->database_type = $value; + } // setDatabaseType + + /** + * Get database_host + * + * @param null + * @return string + */ + function getDatabaseHost() { + return $this->database_host; + } // getDatabaseHost + + /** + * Set database_host value + * + * @param string $value + * @return null + */ + function setDatabaseHost($value) { + $this->database_host = $value; + } // setDatabaseHost + + /** + * Get database_username + * + * @param null + * @return string + */ + function getDatabaseUsername() { + return $this->database_username; + } // getDatabaseUsername + + /** + * Set database_username value + * + * @param string $value + * @return null + */ + function setDatabaseUsername($value) { + $this->database_username = $value; + } // setDatabaseUsername + + /** + * Get database_password + * + * @param null + * @return string + */ + function getDatabasePassword() { + return $this->database_password; + } // getDatabasePassword + + /** + * Set database_password value + * + * @param string $value + * @return null + */ + function setDatabasePassword($value) { + $this->database_password = $value; + } // setDatabasePassword + + /** + * Get database_name + * + * @param null + * @return string + */ + function getDatabaseName() { + return $this->database_name; + } // getDatabaseName + + /** + * Set database_name value + * + * @param string $value + * @return null + */ + function setDatabaseName($value) { + $this->database_name = $value; + } // setDatabaseName + + /** + * Get table_prefix + * + * @param null + * @return string + */ + function getTablePrefix() { + return $this->table_prefix; + } // getTablePrefix + + /** + * Set table_prefix value + * + * @param string $value + * @return null + */ + function setTablePrefix($value) { + $this->table_prefix = $value; + } // setTablePrefix + + /** + * Get absolute_url + * + * @param null + * @return string + */ + function getAbsoluteUrl() { + return $this->absolute_url; + } // getAbsoluteUrl + + /** + * Set absolute_url value + * + * @param string $value + * @return null + */ + function setAbsoluteUrl($value) { + $this->absolute_url = $value; + } // setAbsoluteUrl + + } // Installation + +?> Index: public/install/installation/installation.php =================================================================== --- public/install/installation/installation.php (revision 161) +++ public/install/installation/installation.php (working copy) @@ -1,27 +0,0 @@ -addStep(new WelcomeStep())); - define('ACI_CHECKS', $installer->addStep(new ChecksStep())); - define('ACI_SYSTEM_CONFIG', $installer->addStep(new SystemConfigStep())); - define('ACI_FINISH', $installer->addStep(new FinishStep())); - -?> Index: public/install/installation/main_installation.php =================================================================== --- public/install/installation/main_installation.php (revision 0) +++ public/install/installation/main_installation.php (revision 0) @@ -0,0 +1,27 @@ +addStep(new WelcomeStep())); + define('INSTALL_CHECKS', $installer->addStep(new ChecksStep())); + define('INSTALL_SYSTEM_CONFIG', $installer->addStep(new SystemConfigStep())); + define('INSTALL_FINISH', $installer->addStep(new FinishStep())); + +?> Index: public/install/installation/steps/FinishStep.class.php =================================================================== --- public/install/installation/steps/FinishStep.class.php (revision 161) +++ public/install/installation/steps/FinishStep.class.php (working copy) @@ -36,11 +36,11 @@ * @return boolean */ function execute() { - if (!$this->installer->isExecutedStep(ACI_SYSTEM_CONFIG)) { - $this->goToStep(ACI_SYSTEM_CONFIG); + if (!$this->installer->isExecutedStep(INSTALL_SYSTEM_CONFIG)) { + $this->goToStep(INSTALL_SYSTEM_CONFIG); } // if - $installation = new acInstallation(new Output_Html()); + $installation = new Installation(new Output_Html()); $installation->setDatabaseType((string) trim($this->getFromStorage('database_type'))); $installation->setDatabaseHost((string) trim($this->getFromStorage('database_host'))); $installation->setDatabaseUsername((string) trim($this->getFromStorage('database_user'))); Index: public/install/installation/steps/WelcomeStep.class.php =================================================================== --- public/install/installation/steps/WelcomeStep.class.php (revision 161) +++ public/install/installation/steps/WelcomeStep.class.php (working copy) @@ -1,7 +1,7 @@ +
  • If you have problems, check the support forum