diff -r de56132c008d -r bdac73ed481e install/includes/stages/database_postgresql.php --- a/install/includes/stages/database_postgresql.php Sun Mar 28 21:49:26 2010 -0400 +++ b/install/includes/stages/database_postgresql.php Sun Mar 28 23:10:46 2010 -0400 @@ -14,152 +14,152 @@ */ if ( !defined('IN_ENANO_INSTALL') ) - die(); + die(); if ( isset($_POST['_cont']) ) { - $allow_go = true; - // Do we have everything? If so, continue with installation. - foreach ( array('db_host', 'db_name', 'db_user', 'db_pass', 'db_port') as $field ) - { - if ( empty($_POST[$field]) ) - { - $allow_go = false; - } - } - if ( $allow_go ) - { - require( ENANO_ROOT . '/install/includes/stages/database_post.php' ); - return true; - } + $allow_go = true; + // Do we have everything? If so, continue with installation. + foreach ( array('db_host', 'db_name', 'db_user', 'db_pass', 'db_port') as $field ) + { + if ( empty($_POST[$field]) ) + { + $allow_go = false; + } + } + if ( $allow_go ) + { + require( ENANO_ROOT . '/install/includes/stages/database_post.php' ); + return true; + } } if ( isset($_POST['ajax_test']) ) { - // Test the database connection - $return = array( - 'can_install' => false, - 'host_good' => true, - 'creating_user' => false, - 'db_exist' => false, - 'creating_db' => false, - 'creating_db_grant' => false, - 'root_fail' => false, - 'version' => array( - 'version' => 'unknown', - 'good' => 'indeterminate' - ), - 'last_error' => '' - ); - - if ( !isset($_POST['info']) ) - die(); - - $info = $_POST['info']; - - // From here on out will be JSON responses - header('Content-type: application/json'); - - try - { - $info = @enano_json_decode($info); - } - catch ( Zend_Json_Exception $e ) - { - die(enano_json_encode(array( - 'mode' => 'error', - 'error' => 'Exception in JSON decoder' - ))); - } - - if ( !is_int($info['db_port']) ) - { - $return['host_good'] = false; - echo enano_json_encode($return); - exit; - } - - $port = $info['db_port'] ? $info['db_port'] : 5432; - - // Try to connect as the normal user - // generate connection string - $conn_string = "dbname = '" . addslashes($info['db_name']) . "' port = '$port' host = '" . addslashes($info['db_host']) . "' " . - "user= '" . addslashes($info['db_user']) . "' password = '" . addslashes($info['db_pass']) . "'"; - $test = @pg_connect($conn_string); - if ( !$test ) - { - // Connection as normal user failed. PgSQL doesn't give us an error string so - // just try to connect as root. If even that fails, exit with an error - $return['creating_user'] = true; - if ( !empty($info['db_root_user']) && !empty($info['db_root_pass']) ) - { - $conn_string_root = "dbname = '" . addslashes($info['db_name']) . "' port = '$port' host = '" . addslashes($info['db_host']) . "' " . - "user= '" . addslashes($info['db_root_user']) . "' password = '" . addslashes($info['db_root_pass']) . "'"; - // Attempt connection as root - $test_root = @pg_connect($conn_string_root); - if ( !$test_root ) - { - $return['root_fail'] = true; - } - else - { - $return['can_install'] = true; - } - } - } - else - { - $return['can_install'] = true; - } - - $did_version_check = false; - - if ( isset($test) && @is_resource($test) ) - { - $server_info = @pg_version($test); - if ( isset($server_info['server']) ) - { - $did_version_check = true; - $return['version'] = array( - 'version' => $server_info['server'], - 'good' => ( version_compare($server_info['server'], '8.2.5', '>=') ) - ); - } - @pg_close($test); - } - - if ( isset($test_root) && @is_resource($test_root) ) - { - $server_info = @pg_version($test_root); - if ( isset($server_info['server']) ) - { - $did_version_check = true; - $return['version'] = array( - 'version' => $server_info['server'], - 'good' => ( version_compare($server_info['server'], '8.2.5', '>=') ) - ); - } - @pg_close($test_root); - } - - if ( !$did_version_check ) - { - $return['version'] = array( - 'version' => 'indeterminate', - 'good' => false - ); - } - else - { - if ( !$return['version']['good'] ) - { - $return['can_install'] = false; - } - } - - echo enano_json_encode($return); - - exit(); + // Test the database connection + $return = array( + 'can_install' => false, + 'host_good' => true, + 'creating_user' => false, + 'db_exist' => false, + 'creating_db' => false, + 'creating_db_grant' => false, + 'root_fail' => false, + 'version' => array( + 'version' => 'unknown', + 'good' => 'indeterminate' + ), + 'last_error' => '' + ); + + if ( !isset($_POST['info']) ) + die(); + + $info = $_POST['info']; + + // From here on out will be JSON responses + header('Content-type: application/json'); + + try + { + $info = @enano_json_decode($info); + } + catch ( Zend_Json_Exception $e ) + { + die(enano_json_encode(array( + 'mode' => 'error', + 'error' => 'Exception in JSON decoder' + ))); + } + + if ( !is_int($info['db_port']) ) + { + $return['host_good'] = false; + echo enano_json_encode($return); + exit; + } + + $port = $info['db_port'] ? $info['db_port'] : 5432; + + // Try to connect as the normal user + // generate connection string + $conn_string = "dbname = '" . addslashes($info['db_name']) . "' port = '$port' host = '" . addslashes($info['db_host']) . "' " . + "user= '" . addslashes($info['db_user']) . "' password = '" . addslashes($info['db_pass']) . "'"; + $test = @pg_connect($conn_string); + if ( !$test ) + { + // Connection as normal user failed. PgSQL doesn't give us an error string so + // just try to connect as root. If even that fails, exit with an error + $return['creating_user'] = true; + if ( !empty($info['db_root_user']) && !empty($info['db_root_pass']) ) + { + $conn_string_root = "dbname = '" . addslashes($info['db_name']) . "' port = '$port' host = '" . addslashes($info['db_host']) . "' " . + "user= '" . addslashes($info['db_root_user']) . "' password = '" . addslashes($info['db_root_pass']) . "'"; + // Attempt connection as root + $test_root = @pg_connect($conn_string_root); + if ( !$test_root ) + { + $return['root_fail'] = true; + } + else + { + $return['can_install'] = true; + } + } + } + else + { + $return['can_install'] = true; + } + + $did_version_check = false; + + if ( isset($test) && @is_resource($test) ) + { + $server_info = @pg_version($test); + if ( isset($server_info['server']) ) + { + $did_version_check = true; + $return['version'] = array( + 'version' => $server_info['server'], + 'good' => ( version_compare($server_info['server'], '8.2.5', '>=') ) + ); + } + @pg_close($test); + } + + if ( isset($test_root) && @is_resource($test_root) ) + { + $server_info = @pg_version($test_root); + if ( isset($server_info['server']) ) + { + $did_version_check = true; + $return['version'] = array( + 'version' => $server_info['server'], + 'good' => ( version_compare($server_info['server'], '8.2.5', '>=') ) + ); + } + @pg_close($test_root); + } + + if ( !$did_version_check ) + { + $return['version'] = array( + 'version' => 'indeterminate', + 'good' => false + ); + } + else + { + if ( !$return['version']['good'] ) + { + $return['can_install'] = false; + } + } + + echo enano_json_encode($return); + + exit(); } $ui->add_header(''); @@ -169,173 +169,173 @@ @@ -344,144 +344,144 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
-

get('dbpgsql_table_title'); ?>

-
- get('dbpgsql_field_hostname_title'); ?> -
get('dbpgsql_field_hostname_body'); ?> -
-
- - - Good/bad icon -
- get('dbpgsql_field_port_title'); ?> -
get('dbpgsql_field_port_body'); ?> -
-
- - - Good/bad icon -
- get('dbpgsql_field_dbname_title'); ?>
- get('dbpgsql_field_dbname_body'); ?>
- -
- - - Good/bad icon -
- get('dbpgsql_field_dbauth_title'); ?>
- get('dbpgsql_field_dbauth_body'); ?>
- -
-
-
- -
- Good/bad icon -
-

get('database_heading_optionalinfo'); ?>

-
- get('dbpgsql_field_tableprefix_title'); ?>
- get('dbpgsql_field_tableprefix_body'); ?> -
- - - Good/bad icon -
- get('dbpgsql_field_rootauth_title'); ?>
- get('dbpgsql_field_rootauth_body'); ?>
- -
-
-
- -
- Good/bad icon -
- get('dbpgsql_field_pgsqlversion_title'); ?> - - get('dbpgsql_field_pgsqlversion_blurb_willbechecked'); ?> - - Good/bad icon -
- get('dbpgsql_field_droptables_title'); ?>
- get('dbpgsql_field_droptables_body'); ?> -
- -
- -
-
+

get('dbpgsql_table_title'); ?>

+
+ get('dbpgsql_field_hostname_title'); ?> +
get('dbpgsql_field_hostname_body'); ?> +
+
+ + + Good/bad icon +
+ get('dbpgsql_field_port_title'); ?> +
get('dbpgsql_field_port_body'); ?> +
+
+ + + Good/bad icon +
+ get('dbpgsql_field_dbname_title'); ?>
+ get('dbpgsql_field_dbname_body'); ?>
+ +
+ + + Good/bad icon +
+ get('dbpgsql_field_dbauth_title'); ?>
+ get('dbpgsql_field_dbauth_body'); ?>
+ +
+
+
+ +
+ Good/bad icon +
+

get('database_heading_optionalinfo'); ?>

+
+ get('dbpgsql_field_tableprefix_title'); ?>
+ get('dbpgsql_field_tableprefix_body'); ?> +
+ + + Good/bad icon +
+ get('dbpgsql_field_rootauth_title'); ?>
+ get('dbpgsql_field_rootauth_body'); ?>
+ +
+
+
+ +
+ Good/bad icon +
+ get('dbpgsql_field_pgsqlversion_title'); ?> + + get('dbpgsql_field_pgsqlversion_blurb_willbechecked'); ?> + + Good/bad icon +
+ get('dbpgsql_field_droptables_title'); ?>
+ get('dbpgsql_field_droptables_body'); ?> +
+ +
+ +
+
- - - - + + + +
- - -

- get('meta_lbl_before_continue'); ?>
- • get('database_objective_test'); ?>
- • get('database_objective_uncrypt'); ?> -

-
+ + +

+ get('meta_lbl_before_continue'); ?>
+ • get('database_objective_test'); ?>
+ • get('database_objective_uncrypt'); ?> +

+