diff -r 299a90e28abc -r 87e08a6e4fec install/includes/stages/database_postgresql.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install/includes/stages/database_postgresql.php Wed Jan 16 13:55:49 2008 -0500 @@ -0,0 +1,454 @@ + 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' + ))); + } + + // Try to connect as the normal user + // generate connection string + $conn_string = "dbname = '" . addslashes($info['db_name']) . "' port = '5432' 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 = '5432' 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(''); +$ui->show_header(); + +?> + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

get('dbpgsql_table_title'); ?>

+
+ get('dbpgsql_field_hostname_title'); ?> +
get('dbpgsql_field_hostname_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'); ?> +

+
+ +
+ + +