From 7673e256c8bb8dd4f22db6351b3ac7cbd554fe73 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Mon, 29 Jun 2015 00:04:13 +0200 Subject: [PATCH] Setup: added some checks when useing WIN lets just say, the CLI works somewhat differently.. --- setup/tools/CLISetup.class.php | 26 +++++++++++++++++------- setup/tools/clisetup/siteconfig.func.php | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/setup/tools/CLISetup.class.php b/setup/tools/CLISetup.class.php index ef3b5e2c..63e2167c 100644 --- a/setup/tools/CLISetup.class.php +++ b/setup/tools/CLISetup.class.php @@ -12,7 +12,8 @@ class CLISetup const CHR_BELL = 7; const CHR_BACK = 8; const CHR_TAB = 9; - const CHR_RETURN = 10; + const CHR_LF = 10; + const CHR_CR = 13; const CHR_ESC = 27; const CHR_BACKSPACE = 127; @@ -325,10 +326,18 @@ class CLISetup /* read input */ /**************/ + /* + since the CLI on WIN ist not interactive, the following things have to be considered + you do not receive keystrokes but whole strings upon pressing (wich also appends a \r) + as such and probably other control chars can not be registered + this also means, you can't hide input at all, least process it + */ + public static function readInput(&$fields, $singleChar = false) { - // prevent default output - readline_callback_handler_install('', function() { }); + // prevent default output on *nix (readline doen't exist for WIN) + if (!self::$win) + readline_callback_handler_install('', function() { }); foreach ($fields as $name => $data) { @@ -353,7 +362,10 @@ class CLISetup if ($keyId == self::CHR_TAB) // ignore this one continue; - if ($keyId == self::CHR_ESC) + if ($keyId == self::CHR_CR) // also ignore this bastard! + continue; + + if ($keyId == self::CHR_ESC) // will not be send on WIN .. other ways of returning from setup? (besides ctrl + c) { echo chr(self::CHR_BELL); return false; @@ -366,7 +378,7 @@ class CLISetup $charBuff = substr($charBuff, 0, -1); echo chr(self::CHR_BACK)." ".chr(self::CHR_BACK); } - else if ($keyId == self::CHR_RETURN) + else if ($keyId == self::CHR_LF) { $fields[$name] = $charBuff; break; @@ -374,10 +386,10 @@ class CLISetup else if (!$validPattern || preg_match($validPattern, $char)) { $charBuff .= $char; - if (!$isHidden) + if (!$isHidden && !self::$win) // see note above echo $char; - if ($singleChar) + if ($singleChar && !self::$win) // see note above { $fields[$name] = $charBuff; break; diff --git a/setup/tools/clisetup/siteconfig.func.php b/setup/tools/clisetup/siteconfig.func.php index da93c325..bda95f6f 100644 --- a/setup/tools/clisetup/siteconfig.func.php +++ b/setup/tools/clisetup/siteconfig.func.php @@ -140,7 +140,7 @@ function siteconfig() $buff .= $conf['flags'] & CON_FLAG_PHP ? " PHP: " : "AOWOW: "; $buff .= $conf['flags'] & CON_FLAG_PHP ? strtolower($conf['key']) : strtoupper('cfg_'.$conf['key']); - if ($info[1]) + if (!empty($info[1])) $buff .= " - ".$info[1]; CLISetup::log($buff);