diff options
Diffstat (limited to 'installer')
-rw-r--r-- | installer/cli.php | 2 | ||||
-rw-r--r-- | installer/database_config.php | 2 | ||||
-rw-r--r-- | installer/installer.php | 6 | ||||
-rw-r--r-- | installer/web.php | 1 |
4 files changed, 7 insertions, 4 deletions
diff --git a/installer/cli.php b/installer/cli.php index 182c3d26..f736ffcb 100644 --- a/installer/cli.php +++ b/installer/cli.php @@ -95,7 +95,7 @@ function parse_cli_params() { $config["dbname"] = $argv[++$i]; break; case "-h": - $config["host"] = $argv[++$i]; + list ($config["host"], $config["port"]) = explode(":", $argv[++$i]); break; case "-u": $config["user"] = $argv[++$i]; diff --git a/installer/database_config.php b/installer/database_config.php index 0f04b95c..8abf35e7 100644 --- a/installer/database_config.php +++ b/installer/database_config.php @@ -33,7 +33,7 @@ $config['default'] = array( 'user' => '<?php print $user ?>', 'pass' => '<?php print str_replace("'", "\\'", $password) ?>', 'host' => '<?php print $host ?>', - 'port' => false, + 'port' => <?php if (!empty($port)): ?>'<?php print $port ?>' <?php else: ?>false<?php endif ?>, 'socket' => false, 'database' => '<?php print $dbname ?>' ), diff --git a/installer/installer.php b/installer/installer.php index 70afc440..3b1716e2 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -77,7 +77,8 @@ class installer { // counterparts. if (!function_exists("mysql_query")) { function mysql_connect($host, $user, $pass) { - installer::$mysqli = new mysqli($host, $user, $pass); + list ($host, $port) = explode(":", $host); + installer::$mysqli = new mysqli($host, $user, $pass, $port); // http://php.net/manual/en/mysqli.connect.php says to use mysqli_connect_error() instead of // $mysqli->connect_error because of bugs before PHP 5.2.9 $error = mysqli_connect_error(); @@ -97,7 +98,8 @@ class installer { } } - return @mysql_connect($config["host"], $config["user"], $config["password"]); + $host = empty($config["port"]) ? $config['host'] : "{$config['host']}:{$config['port']}"; + return @mysql_connect($host, $config["user"], $config["password"]); } static function select_db($config) { diff --git a/installer/web.php b/installer/web.php index c46f072a..65233b31 100644 --- a/installer/web.php +++ b/installer/web.php @@ -38,6 +38,7 @@ if (installer::already_installed()) { "dbname" => $_POST["dbname"], "prefix" => $_POST["prefix"], "type" => function_exists("mysqli_set_charset") ? "mysqli" : "mysql"); + list ($config["host"], $config["port"]) = explode(":", $config["host"]); if (!installer::connect($config)) { $content = render("invalid_db_info.html.php"); |