X-Git-Url: https://dev.renevier.net/?p=syp.git;a=blobdiff_plain;f=inc%2Fhtml%2Finstall.php;h=c5ff654fa72d068b5a3359b7f9f84cce539db141;hp=4b2d02cb3673dca4cc1a1a53d096015f807cce6b;hb=HEAD;hpb=1eff14d093d541d9858f73ffca042de5a2bf3ea5 diff --git a/inc/html/install.php b/inc/html/install.php index 4b2d02c..c5ff654 100644 --- a/inc/html/install.php +++ b/inc/html/install.php @@ -54,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"; @@ -70,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" . @@ -119,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"])); @@ -138,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 { @@ -174,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]; @@ -208,7 +244,7 @@ par_success (trans ('Found user table.')); } else { $empty_pass = (isset ($_POST ["admin_pass"]) && (strlen ($_POST ["admin_pass"]) == 0)); - if ($_POST ["admin_pass"]) { + if (isset ($_POST["admin_pass"]) and $_POST ["admin_pass"]) { try { $connection->create_users_table (true); } catch (Exception $e) {