mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Setup/firstrun
* also added check for port on this option * hide control chars from error input request for win
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -117,12 +117,18 @@ function firstrun($resume)
|
||||
require 'config/config.php';
|
||||
|
||||
$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();
|
||||
|
||||
Reference in New Issue
Block a user