X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=blobdiff_plain;f=inc%2Fhtml%2Finstall.php;h=7bab8efd67b21eed0fa9c9f52be97d38583ea4b5;hp=d3def31fe5b96dbb7273298cb98f7ac777e2e65c;hb=81b566d916827fa6ee03b6fbf06c180ec249e7e7;hpb=b8be7edca1802692be4d330c7065e5260fb348f6 diff --git a/inc/html/install.php b/inc/html/install.php index d3def31..7bab8ef 100644 --- a/inc/html/install.php +++ b/inc/html/install.php @@ -10,6 +10,10 @@ <?php ptrans ('SYP wizard')?> @@ -39,12 +54,14 @@ function create_install_form () { if (isset ($_POST ["db_form_submit"])) { + $type = $_POST ["db_type"]; $host = $_POST ["db_host"]; $name = $_POST ["db_name"]; $user = $_POST ["db_user"]; $prefix = $_POST ["db_prefix"]; $title = $_POST ["site_title"]; } else { + $type = "mysql"; $host = "localhost"; $user = "syp"; $name = "syp"; @@ -55,6 +72,37 @@ print '
' . "\n"; print '' . trans ("SYP configuration") . '' . "\n"; + $drivers = array(); + $handle = opendir("./inc/db"); + if (!$handle) { + par_error_and_leave (trans ('Could not list inc/db directory')); + } + while (false !== ($file = readdir($handle))) { + if ($file == "." or $file == "..") { + continue; + } + $driver_name = substr($file,0,strrpos($file,'.')); + if ($driver_name == "anydb") { + continue; + } + array_push ($drivers, $driver_name); + } + closedir($handle); + + + print '
' . "\n" . + '" . "\n"; + print '
' . "\n" . @@ -104,6 +152,7 @@ } } + define (DBTYPE, _unquote ($_POST ["db_type"])); define (DBHOST, _unquote ($_POST ["db_host"])); define (DBNAME, _unquote ($_POST ["db_name"])); define (DBUSER, _unquote ($_POST ["db_user"])); @@ -123,7 +172,9 @@ leave (); } - require_once ("./inc/db/mysql.php"); + if (!include_once ("./inc/db/" . DBTYPE . ".php")) { + par_error_and_leave (trans("Unkown backend: ", DBTYPE)); + } require_once ("./inc/utils.php"); try { @@ -159,7 +210,7 @@ if ($handle) { while (!feof ($handle)) { $line = fgets ($handle, 4096); - foreach (array ("DBHOST", "DBNAME", "DBUSER", "DBPWD", "DBPREFIX", "SITETITLE") as $value) { + foreach (array ("DBTYPE", "DBHOST", "DBNAME", "DBUSER", "DBPWD", "DBPREFIX", "SITETITLE") as $value) { $pattern = "(define\s+\(\s*\"$value\"\s*,\s*\")[^\"]*(\"\s*\)\s*;)"; if (preg_match( "/$pattern/", $line, $match )) { $line = $match[1] . addslashes (constant ($value)) . $match[2]; @@ -192,7 +243,8 @@ if ($users_table_exists) { par_success (trans ('Found user table.')); } else { - if (isset($_POST ["admin_pass"])) { + $empty_pass = (isset ($_POST ["admin_pass"]) && (strlen ($_POST ["admin_pass"]) == 0)); + if ($_POST ["admin_pass"]) { try { $connection->create_users_table (true); } catch (Exception $e) { @@ -207,11 +259,15 @@ par_success (trans ('Admin password initialized.')); } else { - print (' + print (' - - - '); + '); + if ($empty_pass) { + print ('

' . trans('Password cannot be empty') . '

'); + } else { + print (''); + } + print ('
'); leave (); } }