Setup/firstrun

* also added check for port on this option
 * hide control chars from error input request for win
This commit is contained in:
Sarjuuk
2015-10-06 22:00:51 +02:00
parent ef5d7cce3b
commit dabf307c13
2 changed files with 16 additions and 13 deletions

View File

@@ -188,27 +188,27 @@ class CLISetup
public static function red($str)
{
return "\e[31m".$str."\e[0m";
return self::$win ? $str : "\e[31m".$str."\e[0m";
}
public static function green($str)
{
return "\e[32m".$str."\e[0m";
return self::$win ? $str : "\e[32m".$str."\e[0m";
}
public static function yellow($str)
{
return "\e[33m".$str."\e[0m";
return self::$win ? $str : "\e[33m".$str."\e[0m";
}
public static function blue($str)
{
return "\e[36m".$str."\e[0m";
return self::$win ? $str : "\e[36m".$str."\e[0m";
}
public static function bold($str)
{
return "\e[1m".$str."\e[0m";
return self::$win ? $str : "\e[1m".$str."\e[0m";
}
public static function log($txt = '', $lvl = -1)
@@ -255,13 +255,10 @@ class CLISetup
$msg .= $txt."\n";
}
// remove highlights for logging & win
$raw = preg_replace(["/\e\[\d+m/", "/\e\[0m/"], '', $msg);
echo $msg;
echo self::$win ? $raw : $msg;
if (self::$logHandle)
fwrite(self::$logHandle, $raw);
if (self::$logHandle) // remove highlights for logging
fwrite(self::$logHandle, preg_replace(["/\e\[\d+m/", "/\e\[0m/"], '', $msg));
flush();
}

View File

@@ -116,13 +116,19 @@ function firstrun($resume)
{
require 'config/config.php';
$error = [];
$error = [];
$defPort = ini_get('mysqli.default_port');
foreach (['world', 'aowow', 'auth'] as $what)
{
if ($what == 'auth' && (empty($AoWoWconf['auth']) || empty($AoWoWconf['auth']['host'])))
continue;
if ($link = @mysqli_connect($AoWoWconf[$what]['host'], $AoWoWconf[$what]['user'], $AoWoWconf[$what]['pass'], $AoWoWconf[$what]['db']))
$port = 0;
if (strstr($AoWoWconf[$what]['host'], ':'))
list($AoWoWconf[$what]['host'], $port) = explode(':', $AoWoWconf[$what]['host']);
if ($link = @mysqli_connect($AoWoWconf[$what]['host'], $AoWoWconf[$what]['user'], $AoWoWconf[$what]['pass'], $AoWoWconf[$what]['db'], $port ?: $defPort))
mysqli_close($link);
else
$error[] = ' * '.$what.': '.'['.mysqli_connect_errno().'] '.mysqli_connect_error();