diff options
author | nikrou <nikrou@piwigo.org> | 2010-03-21 22:51:36 +0000 |
---|---|---|
committer | nikrou <nikrou@piwigo.org> | 2010-03-21 22:51:36 +0000 |
commit | 4773d7a35052df4683b0445c08feae609764bfb0 (patch) | |
tree | 98a5e8345ad4698acd71b55040fd99e64f388fd2 /install.php | |
parent | 4158d3296072973d094cd295cc18f0035b5d7000 (diff) |
Feature 1255 :
only one function
use exceptions to deal with differents possible errors
git-svn-id: http://piwigo.org/svn/trunk@5236 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'install.php')
-rw-r--r-- | install.php | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/install.php b/install.php index ea8bdf402..d722288f5 100644 --- a/install.php +++ b/install.php @@ -236,21 +236,13 @@ if (!isset($step)) //---------------------------------------------------------------- form analyze if ( isset( $_POST['install'] )) { - ob_start(); - if (($pwg_db_link = pwg_db_connect($_POST['dbhost'], $_POST['dbuser'], - $_POST['dbpasswd'], $_POST['dbname'], false))!==false) + try { - if (pwg_select_db($_POST['dbname'], $pwg_db_link, false)!==false) - { - array_push( $infos, l10n('Parameters are correct') ); - } - else - { - array_push( $errors, - l10n('Connection to server succeed, but it was impossible to connect to database') ); - } - ob_end_clean(); - + $pwg_db_link = pwg_db_connect($_POST['dbhost'], $_POST['dbuser'], + $_POST['dbpasswd'], $_POST['dbname']); + + array_push( $infos, l10n('Parameters are correct') ); + $required_version = constant('REQUIRED_'.strtoupper($dblayer).'_VERSION'); if ( version_compare(pwg_get_db_version(), $required_version, '>=') ) { @@ -276,10 +268,9 @@ if ( isset( $_POST['install'] )) } } } - else + catch (Exception $e) { - array_push( $errors, l10n('Can\'t connect to server') ); - ob_end_clean(); + array_push( $errors, l10n($e->getMessage())); } $webmaster = trim(preg_replace( '/\s{2,}/', ' ', $admin_name )); if ( empty($webmaster)) |