From ef5d7cce3bec7cb8398ee73010634cc553230537 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Sat, 3 Oct 2015 12:18:24 +0200 Subject: [PATCH] Setup/DBConfig * fixed parsing port on host ip (already worked, but setup threw an error) --- setup/tools/clisetup/dbconfig.func.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/setup/tools/clisetup/dbconfig.func.php b/setup/tools/clisetup/dbconfig.func.php index e259a804..9227e30a 100644 --- a/setup/tools/clisetup/dbconfig.func.php +++ b/setup/tools/clisetup/dbconfig.func.php @@ -24,19 +24,24 @@ function dbconfig() ); $testDB = function($idx, $name, $dbInfo) { - $buff = '['.CLISetup::bold($idx).'] '.str_pad($name, 17); - $errStr = ''; + $buff = '['.CLISetup::bold($idx).'] '.str_pad($name, 17); + $errStr = ''; + $defPort = ini_get('mysqli.default_port'); + $port = 0; + + if (strstr($dbInfo['host'], ':')) + list($dbInfo['host'], $port) = explode(':', $dbInfo['host']); if ($dbInfo['host']) { // test DB - if ($link = @mysqli_connect($dbInfo['host'], $dbInfo['user'], $dbInfo['pass'], $dbInfo['db'])) + if ($link = @mysqli_connect($dbInfo['host'], $dbInfo['user'], $dbInfo['pass'], $dbInfo['db'], $port ?: $defPort)) mysqli_close($link); else $errStr = '['.mysqli_connect_errno().'] '.mysqli_connect_error(); $buff .= $errStr ? CLISetup::red('ERR ') : CLISetup::green('OK '); - $buff .= 'mysqli://'.$dbInfo['user'].':'.str_pad('', mb_strlen($dbInfo['pass']), '*').'@'.$dbInfo['host'].'/'.$dbInfo['db']; + $buff .= 'mysqli://'.$dbInfo['user'].':'.str_pad('', mb_strlen($dbInfo['pass']), '*').'@'.$dbInfo['host'].($port ? ':'.$port : null).'/'.$dbInfo['db']; $buff .= ($dbInfo['prefix'] ? ' table prefix: '.$dbInfo['prefix'] : null).' '.$errStr; } else