From dabf307c13d3674ce91a98b4c98eb295e5eaa90a Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Tue, 6 Oct 2015 22:00:51 +0200 Subject: [PATCH] Setup/firstrun * also added check for port on this option * hide control chars from error input request for win --- setup/tools/CLISetup.class.php | 19 ++++++++----------- setup/tools/clisetup/firstrun.func.php | 10 ++++++++-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/setup/tools/CLISetup.class.php b/setup/tools/CLISetup.class.php index d7f8010f..79267b5b 100644 --- a/setup/tools/CLISetup.class.php +++ b/setup/tools/CLISetup.class.php @@ -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(); } diff --git a/setup/tools/clisetup/firstrun.func.php b/setup/tools/clisetup/firstrun.func.php index 244020ca..ea8308cc 100644 --- a/setup/tools/clisetup/firstrun.func.php +++ b/setup/tools/clisetup/firstrun.func.php @@ -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();