private function getPassword()
{
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
return trim(fgets(STDIN));
}
$oldStyle = shell_exec('stty -g');
$password = '';
shell_exec('stty -icanon -echo min 1 time 0');
while (true) {
$char = fgetc(STDIN);
if ($char === "\n") {
break;
} elseif (ord($char) === 127) {
if (strlen($password) > 0) {
fwrite(STDOUT, " ");
$password = substr($password, 0, -1);
}
} else {
fwrite(STDOUT, '*');
$password .= $char;
}
}
shell_exec('stty ' . $oldStyle);
return $password;
}