diff -r de56132c008d -r bdac73ed481e install/includes/stages/database_post.php --- a/install/includes/stages/database_post.php Sun Mar 28 21:49:26 2010 -0400 +++ b/install/includes/stages/database_post.php Sun Mar 28 23:10:46 2010 -0400 @@ -14,7 +14,7 @@ */ if ( !defined('IN_ENANO_INSTALL') ) - die(); + die(); // Start up the DBAL require( ENANO_ROOT . '/includes/dbal.php' ); @@ -31,9 +31,9 @@ if ( !preg_match('/^[a-z0-9_]*$/', $db_prefix) ) { - $ui->show_header(); - echo '

That table prefix isn\'t going to work.

'; - return true; + $ui->show_header(); + echo '

That table prefix isn\'t going to work.

'; + return true; } $result = $dbal->connect(true, $db_host, $db_user, $db_pass, $db_name, $db_port); @@ -41,83 +41,83 @@ // If connection failed, we have the root login, AND we're on MySQL, try to force our way in if ( !$result && !empty($_POST['db_root_user']) && !empty($_POST['db_root_pass']) && $driver == 'mysql' ) { - // Allow a jump / breakout - switch ( 'foo' ) { case 'foo': - - // Try to connect to the DB as root - $result_root = $dbal->connect(true, $db_host, $db_root_user, $db_root_pass, 'mysql', $db_port); - if ( !$result_root ) - break; - - $q = $dbal->sql_query('CREATE DATABASE IF NOT EXISTS `' . $dbal->escape($db_name) . '`;'); - if ( !$q ) - break; - - if ( $db_host == 'localhost' || $db_host == '127.0.0.1' ) - { - $q = $dbal->sql_query('GRANT ALL PRIVILEGES ON `' . $dbal->escape($db_name) . '`.* TO \'' . $dbal->escape($db_user) . '\'@\'localhost\'' . "\n" . - ' IDENTIFIED BY \'' . $dbal->escape($db_pass) . '\' WITH GRANT OPTION'); - } - else - { - $q = $dbal->sql_query('GRANT ALL PRIVILEGES ON `' . $dbal->escape($db_name) . '`.* TO \'' . $dbal->escape($db_user) . '\'@\'%\'' . "\n" . - ' IDENTIFIED BY \'' . $dbal->escape($db_pass) . '\' WITH GRANT OPTION'); - } - - if ( !$q ) - break; - - $dbal->close(); - $result = $dbal->connect(true, $db_host, $db_user, $db_pass, $db_name, $db_port); - - break; - } + // Allow a jump / breakout + switch ( 'foo' ) { case 'foo': + + // Try to connect to the DB as root + $result_root = $dbal->connect(true, $db_host, $db_root_user, $db_root_pass, 'mysql', $db_port); + if ( !$result_root ) + break; + + $q = $dbal->sql_query('CREATE DATABASE IF NOT EXISTS `' . $dbal->escape($db_name) . '`;'); + if ( !$q ) + break; + + if ( $db_host == 'localhost' || $db_host == '127.0.0.1' ) + { + $q = $dbal->sql_query('GRANT ALL PRIVILEGES ON `' . $dbal->escape($db_name) . '`.* TO \'' . $dbal->escape($db_user) . '\'@\'localhost\'' . "\n" . + ' IDENTIFIED BY \'' . $dbal->escape($db_pass) . '\' WITH GRANT OPTION'); + } + else + { + $q = $dbal->sql_query('GRANT ALL PRIVILEGES ON `' . $dbal->escape($db_name) . '`.* TO \'' . $dbal->escape($db_user) . '\'@\'%\'' . "\n" . + ' IDENTIFIED BY \'' . $dbal->escape($db_pass) . '\' WITH GRANT OPTION'); + } + + if ( !$q ) + break; + + $dbal->close(); + $result = $dbal->connect(true, $db_host, $db_user, $db_pass, $db_name, $db_port); + + break; + } } $ui->show_header(); if ( $result ) { - // We're good, do table drop if requested - if ( isset($_POST['drop_tables']) ) - { - global $system_table_list; - foreach ( $system_table_list as $table ) - { - $dbal->sql_query("DROP TABLE {$db_prefix}$table"); - } - } - // Write out a config file - $ch = @fopen( ENANO_ROOT . '/config.new.php', 'w' ); - if ( !$ch ) - { - ?> -
-

Configuration file generation failed.

-

Couldn't open the configuration file to write out database settings. Check your file permissions.

-

- -

-
- That table prefix isn\'t going to work.

'; - return true; - } - if ( !preg_match('/^[0-9]*$/', $db_port) ) - { - echo '

That port isn\'t going to work.

'; - return true; - } - fwrite($ch, "sql_query("DROP TABLE {$db_prefix}$table"); + } + } + // Write out a config file + $ch = @fopen( ENANO_ROOT . '/config.new.php', 'w' ); + if ( !$ch ) + { + ?> +
+

Configuration file generation failed.

+

Couldn't open the configuration file to write out database settings. Check your file permissions.

+

+ +

+
+ That table prefix isn\'t going to work.

'; + return true; + } + if ( !preg_match('/^[0-9]*$/', $db_port) ) + { + echo '

That port isn\'t going to work.

'; + return true; + } + fwrite($ch, " -

Can't load schema file

-

The SQL schema file couldn't be loaded.

- $e"; ?> - sql_query('SELECT config_name, config_value FROM ' . $db_prefix . 'config LIMIT 1;'); - if ( !$q ) - { - $sql_parser->assign_vars(array( - 'TABLE_PREFIX' => $db_prefix - )); - $sql = $sql_parser->parse(); - foreach ( $sql as $q ) - { - if ( !$dbal->sql_query($q) ) - { - ?> -
- - -

get('database_msg_sql_fail_title'); ?>

-

get('database_msg_sql_fail_body'); ?>

-

get('database_msg_post_fail_desc'); ?> - sql_error(); - ?> -

-

- -

-
- free_result(); - if ( !$dbal->sql_query('DELETE FROM ' . $db_prefix . 'config WHERE config_name = \'install_aes_key\';') ) - { - $dbal->_die('install database_post.php trying to remove old AES installer key'); - } - } - $dbal->close(); - ?> -
- - -

get('database_msg_success_title'); ?>

-

get('database_msg_success_body'); ?>

-

get('database_msg_success_redirect'); ?>

-
- - +

Can't load schema file

+

The SQL schema file couldn't be loaded.

+ $e"; ?> + sql_query('SELECT config_name, config_value FROM ' . $db_prefix . 'config LIMIT 1;'); + if ( !$q ) + { + $sql_parser->assign_vars(array( + 'TABLE_PREFIX' => $db_prefix + )); + $sql = $sql_parser->parse(); + foreach ( $sql as $q ) + { + if ( !$dbal->sql_query($q) ) + { + ?> +
+ + +

get('database_msg_sql_fail_title'); ?>

+

get('database_msg_sql_fail_body'); ?>

+

get('database_msg_post_fail_desc'); ?> + sql_error(); + ?> +

+

+ +

+
+ free_result(); + if ( !$dbal->sql_query('DELETE FROM ' . $db_prefix . 'config WHERE config_name = \'install_aes_key\';') ) + { + $dbal->_die('install database_post.php trying to remove old AES installer key'); + } + } + $dbal->close(); + ?> +
+ + +

get('database_msg_success_title'); ?>

+

get('database_msg_success_body'); ?>

+

get('database_msg_success_redirect'); ?>

+
+ + -
- - -

get('database_msg_post_fail_title'); ?>

-

get('database_msg_post_fail_body'); ?>

-

get('database_msg_post_fail_desc'); ?> - sql_error(); - ?> -

-

- -

-
- +
+ + +

get('database_msg_post_fail_title'); ?>

+

get('database_msg_post_fail_body'); ?>

+

get('database_msg_post_fail_desc'); ?> + sql_error(); + ?> +

+

+ +

+
+