read stdin

@param   boolean $secret
@return  string
426624
public function readline($secret = false)
    {
        $line = null;

        if ($secret) {
            if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
                system('stty -echo');
                $line = trim(fgets(STDIN));
                system('stty echo');
            }
        }
        
        $line = $line !== null ? $line : trim(fgets(STDIN));

        return $line;
    }
118414
public function read($dn)
	{
		$base = substr($dn, strpos($dn, ',') + 1);
		$cn = substr($dn, 0, strpos($dn, ','));
		$result = @ldap_read($this->resource, $base, $cn);

		if ($result)
		{
			return @ldap_get_entries($this->resource, $result);
		}
		else
		{
			return $result;
		}
	}
901230
protected function _statsRead($decode = true) {
		$status = strtok($this->_read(), ' ');

		switch ($status) {
			case 'OK':
				$data = $this->_read((integer) strtok(' '));
				return $decode ? $this->_decode($data) : $data;
			default:
				$this->_error($status);
				return false;
		}
	}
1324032
private function getStdin()
    {
        if (!isset($this->stdin)) {
            $this->stdin = \fopen('php://stdin', 'r');
        }

        if (\feof($this->stdin)) {
            throw new BreakException('Ctrl+D');
        }

        return $this->stdin;
    }
1364538
public function getCode($secret, $time = null)
    {
        $secretkey = $this->base32Decode($secret);

        $timestamp = "\0\0\0\0" . pack('N*', $this->getTimeSlice($this->getTime($time)));  // Pack time into binary string
        $hashhmac = hash_hmac($this->algorithm, $timestamp, $secretkey, true);             // Hash it with users secret key
        $hashpart = substr($hashhmac, ord(substr($hashhmac, -1)) & 0x0F, 4);               // Use last nibble of result as index/offset and grab 4 bytes of the result
        $value = unpack('N', $hashpart);                                                   // Unpack binary value
        $value = $value[1] & 0x7FFFFFFF;                                                   // Drop MSB, keep only 31 bits

        return str_pad($value % pow(10, $this->digits), $this->digits, '0', STR_PAD_LEFT);
    }
1032086
protected function readLine($size = 1024)
    {
        $line = '';

        if (!$size) {
            $size = 1024;
        }

        do {
            if ($this->eof()) {
                return $line ?: null;
            }

            $buffer = fgets($this->fp, $size);

            if ($buffer === false) {
                $this->closeSocket();
                break;
            }

            if ($this->debug) {
                $this->debug('S: '. rtrim($buffer));
            }

            $line .= $buffer;
        }
        while (substr($buffer, -1) != "\n");

        return $line;
    }
158411
public static function read( $prefix = '' ) 
	{
		if ( !static::is_windows() ) 
		{	
			$line = readline( $prefix ); 
			readline_add_history( $line );
		} 
		else 
		{	
			static::write( $prefix );
			$line = trim( fgets( STDIN ) );
		}
		
		return $line;
	}
482940
public static function shaHashBase64($signature, $secret)
    {
        return base64_encode(
            hash_hmac(Hmac::ALGORITHM_SHA256, $signature, $secret, true)
        );
    }
194707
private function readline($message)
    {
        echo Color::green("$message y/N >>> ");

        $input = strtolower(trim(readline()));

        if (is_null($input) || strlen($input) == 0) {
            $input = 'n';
        }

        if (!in_array($input, ['y', 'n'])) {
            echo Color::red('Invalid choice')."\n";

            return $this->readline($message);
        }

        if (strtolower($input) == "y") {
            return true;
        }

        return false;
    }
962164
private function readline()
    {
        if ($this->hasReadline) {
            $line = readline($this->prompt);
        } else {
            $this->output->write($this->prompt);
            $line = fgets(STDIN, 1024);
            $line = (!$line && strlen($line) == 0) ? false : rtrim($line);
        }

        return $line;
    }
726883
protected function generateSignature($params, $secret) {
    // Work with sorted data.
    ksort($params);

    // Generate the base string.
    $base_string = '';
    foreach ($params as $key => $value) {
      $base_string .= $key . '=' . $value;
    }
    $base_string .= $secret;

    return md5($base_string);
  }
1111966
public function readPhpInt()
    {
        list(, $res) = unpack('N', $this->_rawread(4));
        if ($this->_is64bits) {
            $sres = sprintf("%u", $res);
            return (int)$sres;
        } else {
            return $res;
        }
    }
1317404
public static function convert($input = STDIN)
    {
        $stream = fopen('php://temp', 'rw');

        foreach ($_SERVER as $key => $value) {
            if (0 === strpos($key, 'HTTP_')) {
                $key = str_replace('_', '-', strtolower(substr($key, 5)));
                fwrite($stream, "$key: $value\r\n");
            } elseif (in_array($key, ['CONTENT_LENGTH', 'CONTENT_MD5', 'CONTENT_TYPE'])) {
                $key = str_replace('_', '-', strtolower($key));
                fwrite($stream, "$key: $value\r\n");
            }
        }

        fwrite($stream, "\r\n");

        stream_copy_to_stream($input, $stream);

        rewind($stream);

        return new StreamedPart($stream);
    }
948946
public function read( $plaintext = false )
	{
		return $plaintext
			? $this->buildPlainTextMessage( $this->message )
			: $this->message;
	}
878066
public function readLine()
    {
        do {
            $line = rtrim(fgets($this->socket));

            // server must have dropped the connection
            if ($line === '' && feof($this->socket)) {
                $this->close();

                return false;
            }
        } while ($line === '');

        return $line;
    }
320190
public static function readChar(string $message = '', bool $nl = false): string
    {
        $line = self::readln($message, $nl);

        return $line !== '' ? $line[0] : '';
    }
606963
public static function readln($message = null, $nl = false, array $opts = []): string
    {
        if ($message) {
            Console::write($message, $nl);
        }

        $stream = $opts['stream'] ?? \STDIN;

        return \trim(fgets($stream));
    }