diff -r 0b7ff06aad13 -r f3a5a276208c install/includes/stages/database_mysql.php --- a/install/includes/stages/database_mysql.php Fri Mar 06 11:19:55 2009 -0500 +++ b/install/includes/stages/database_mysql.php Sat Mar 14 14:06:02 2009 -0400 @@ -21,7 +21,7 @@ { $allow_go = true; // Do we have everything? If so, continue with installation. - foreach ( array('db_host', 'db_name', 'db_user', 'db_pass') as $field ) + foreach ( array('db_host', 'db_port', 'db_name', 'db_user', 'db_pass') as $field ) { if ( empty($_POST[$field]) ) { @@ -73,8 +73,20 @@ ))); } + if ( preg_match('/^:/', $info['db_host']) && !@file_exists(substr($info['db_host'], 1)) ) + { + $return['host_good'] = false; + echo enano_json_encode($return); + exit(); + } + + if ( $info['db_host'] == 'localhost' && !empty($info['db_port']) && $info['db_port'] != 3306 ) + $info['db_host'] = '127.0.0.1'; + + $dbhost = ( preg_match('/^:/', $info['db_host']) ) ? $info['db_host'] : "{$info['db_host']}:{$info['db_port']}"; + // Try to connect as the normal user - $test = @mysql_connect($info['db_host'], $info['db_user'], $info['db_pass']); + $test = @mysql_connect($dbhost, $info['db_user'], $info['db_pass']); if ( !$test ) { $return['creating_user'] = true; @@ -89,7 +101,7 @@ // Log in with root rights and if that works, tell 'em we'll reset the password or create // the account if it doesn't exist already. This is done with GRANT ALL PRIVILEGES ON enano_db.* // etc etc, a little hackish but known to work with MySQL >= 4.1. - $test_root = @mysql_connect($info['db_host'], $info['db_root_user'], $info['db_root_pass']); + $test_root = @mysql_connect($dbhost, $info['db_root_user'], $info['db_root_pass']); if ( $test_root ) { // We logged in with root rights, assume that we have appropriate permissions. @@ -152,7 +164,7 @@ if ( !empty($info['db_root_user']) && !empty($info['db_root_pass']) ) { // Log in with root rights and if that works, tell 'em we'll create the database. - $test_root = @mysql_connect($info['db_host'], $info['db_root_user'], $info['db_root_pass']); + $test_root = @mysql_connect($dbhost, $info['db_root_user'], $info['db_root_pass']); if ( $test_root ) { // We logged in with root rights, assume that we have appropriate permissions. @@ -240,6 +252,7 @@ // List of fields var fields = { db_host: frm.db_host, + db_port: frm.db_port, db_name: frm.db_name, db_user: frm.db_user, db_pass: frm.db_pass, @@ -251,11 +264,18 @@ // Main validation if ( field == fields.db_host || !field ) { - var matches = fields.db_host.value.match(/^([a-z0-9_-]+)((\.([a-z0-9_-]+))*)?$/); + var matches = fields.db_host.value.match(/^(([a-z0-9_-]+)((\.([a-z0-9_-]+))*)|:[A-z0-9_:\.\/-]+)$/); document.getElementById('s_db_host').src = ( matches ) ? img_neu : img_bad; if ( !matches ) passed = false; } + if ( field == fields.db_port || !field ) + { + var matches = fields.db_port.value.match(/^[0-9]+$/); + document.getElementById('s_db_port').src = ( matches ) ? img_neu : img_bad; + if ( !matches ) + passed = false; + } if ( field == fields.db_name || !field ) { var matches = fields.db_name.value.match(/^[A-z0-9_-]+$/); @@ -302,6 +322,7 @@ var frm = document.forms.database_info; var connection_info = 'info=' + ajaxEscape(toJSONString({ db_host: frm.db_host.value, + db_port: frm.db_port.value, db_name: frm.db_name.value, db_user: frm.db_user.value, db_pass: frm.db_pass.value, @@ -402,12 +423,25 @@ + get('dbmysql_field_port_title'); ?> +
get('dbmysql_field_port_body'); ?> +
+ + + + + + Good/bad icon + + + + get('dbmysql_field_dbname_title'); ?>
get('dbmysql_field_dbname_body'); ?>
- + Good/bad icon @@ -420,9 +454,9 @@ -
+

- + Good/bad icon @@ -439,7 +473,7 @@ get('dbmysql_field_tableprefix_body'); ?> - + Good/bad icon @@ -452,9 +486,9 @@ -
+

- + Good/bad icon @@ -477,12 +511,12 @@ get('dbmysql_field_droptables_body'); ?> - + - +
@@ -492,7 +526,7 @@
- +