Setup/DBConfig

* fixed parsing port on host ip (already worked, but setup threw an error)
This commit is contained in:
Sarjuuk
2015-10-03 12:18:24 +02:00
parent d7c6092d5f
commit ef5d7cce3b

View File

@@ -26,17 +26,22 @@ function dbconfig()
{ {
$buff = '['.CLISetup::bold($idx).'] '.str_pad($name, 17); $buff = '['.CLISetup::bold($idx).'] '.str_pad($name, 17);
$errStr = ''; $errStr = '';
$defPort = ini_get('mysqli.default_port');
$port = 0;
if (strstr($dbInfo['host'], ':'))
list($dbInfo['host'], $port) = explode(':', $dbInfo['host']);
if ($dbInfo['host']) if ($dbInfo['host'])
{ {
// test DB // 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); mysqli_close($link);
else else
$errStr = '['.mysqli_connect_errno().'] '.mysqli_connect_error(); $errStr = '['.mysqli_connect_errno().'] '.mysqli_connect_error();
$buff .= $errStr ? CLISetup::red('ERR ') : CLISetup::green('OK '); $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; $buff .= ($dbInfo['prefix'] ? ' table prefix: '.$dbInfo['prefix'] : null).' '.$errStr;
} }
else else