代码拉取完成,页面将自动刷新
同步操作将从 inhere/php-console 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<?php
/**
* Created by PhpStorm.
* User: inhere
* Date: 2017-12-21
* Time: 10:02
* @link https://github.com/dealnews/Console
*/
class Status
{
public static function clearLine()
{
echo "\033[2K"; // delete the current line
echo "\r"; // return the cursor to the beginning of the line
}
/**
* Spinner that updates every call up to 4 per second
*
* .*.
*/
public static function spinner()
{
static $spinner = 0;
static $mtime = null;
// static $chars = '-\|/';
static $chars = '-.*.-';
$now = microtime(true);
if (null === $mtime || ($mtime < $now - 0.1)) {
$mtime = $now;
self::clearLine();
echo $chars[$spinner];
$spinner++;
if ($spinner > strlen($chars) - 1) {
$spinner = 0;
}
}
}
/**
* Uses `stty` to hide input/output completely.
* @param boolean $hidden Will hide/show the next data. Defaults to true.
*/
public static function hide($hidden = true)
{
system( 'stty ' . ( $hidden? '-echo' : 'echo' ) );
}
/**
* Prompts the user for input. Optionally masking it.
*
* @param string $prompt The prompt to show the user
* @param bool $masked If true, the users input will not be shown. e.g. password input
* @param int $limit The maximum amount of input to accept
* @return string
*/
public static function prompt($prompt, $masked=false, $limit=100)
{
echo "$prompt: ";
if ($masked) {
`stty -echo`; // disable shell echo
}
$buffer = "";
$char = "";
$f = fopen('php://stdin', 'r');
while (strlen($buffer) < $limit) {
$char = fread($f, 1);
if ($char === "\n" || $char === "\r") {
break;
}
$buffer.= $char;
}
if ($masked) {
`stty echo`; // enable shell echo
echo "\n";
}
return $buffer;
}
}
Status::hide();
echo 'Password: ';
$input = fgets(STDIN);
Status::hide(false);
echo $input;
die;
$total = random_int(5000, 10000);
for ($x=1; $x<=$total; $x++) {
Status::spinner();
usleep(50);
}
Status::clearLine();
//
// $answer = Status::prompt("What is the secret word?", 0);
// if ($answer == "secret") {
// echo "Yay! You got it!";
// } else {
// echo "Boo! That is wrong!";
// }
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。