Custom read() function

@access private
1964
function read($session_id)
    {

        // get the lock name, associated with the current session
        $this->session_lock = $this->_mysql_real_escape_string('session_' . $session_id);

        // try to obtain a lock with the given name and timeout
        $result = $this->_mysql_query('SELECT GET_LOCK("' . $this->session_lock . '", ' . $this->_mysql_real_escape_string($this->lock_timeout) . ')');

        // if there was an error
        // stop execution
        if (!is_object($result) || strtolower(get_class($result)) != 'mysqli_result' || @mysqli_num_rows($result) != 1 || !($row = mysqli_fetch_array($result)) || $row[0] != 1) die('Session Worker: Could not obtain session lock!');

        //  reads session data associated with a session id, but only if
        //  -   the session ID exists;
        //  -   the session has not expired;
        //  -   if lock_to_user_agent is TRUE and the HTTP_USER_AGENT is the same as the one who had previously been associated with this particular session;
        //  -   if lock_to_ip is TRUE and the host is the same as the one who had previously been associated with this particular session;
        $hash = '';

        // if we need to identify sessions by also checking the user agent
        if ($this->lock_to_user_agent && isset($_SERVER['HTTP_USER_AGENT']))

            $hash .= $_SERVER['HTTP_USER_AGENT'];

        // if we need to identify sessions by also checking the host
        if ($this->lock_to_ip && isset($_SERVER['REMOTE_ADDR']))

            $hash .= $_SERVER['REMOTE_ADDR'];

        // append this to the end
        $hash .= $this->security_code;

        $result = $this->_mysql_query('

            SELECT
                session_data
            FROM
                ' . $this->table_name . '
            WHERE
                session_id = "' . $this->_mysql_real_escape_string($session_id) . '" AND
                session_expire > "' . time() . '" AND
                hash = "' . $this->_mysql_real_escape_string(md5($hash)) . '"
            LIMIT 1

        ') or die($this->_mysql_error());

        // if anything was found
        if (is_object($result) && strtolower(get_class($result)) == 'mysqli_result' && @mysqli_num_rows($result) > 0) {

            // return found data
            $fields = @mysqli_fetch_assoc($result);

            // don't bother with the unserialization - PHP handles this automatically
            return $fields['session_data'];

        }

        $this->regenerate_id();

        // on error return an empty string - this HAS to be an empty string
        return '';

    }
1216160
public function read() {
		$data = get_option( $this->name, [] );

		$this->data = is_array( $data ) ? $data : [];
	}
73393
public function onRead()
    {
        if (($head = $this->lookExact(static::HEADER_LENGTH)) === false) {
            return;
        }

        list($magic, $typeInt, $size) = unpack(static::HEADER_READ_FORMAT, $head);

        if ($this->getInputLength() < static::HEADER_LENGTH + $size) {
            return;
        }

        $this->drain(static::HEADER_LENGTH);
        $pct = $this->read($size);

        if ($magic === static::MAGIC_RESPONSE) {
            $this->responseType = static::$responseCommandListFlipped[$typeInt];
            $this->response = explode(static::ARGS_DELIMITER, $pct);
            $this->onResponse->executeOne($this);
            $this->responseType = null;
            $this->responseCommand = null;
            $this->responseType = null;
            $this->checkFree();
            return;
        } else {
            $type = static::$requestCommandListFlipped[$typeInt];
            // @TODO
        }
    }
1271956
function stream_read($count) {
        $ret = substr($this->_data, $this->_position, $count);
        $this->_position += strlen($ret);
        return $ret;
    }
606603
public function read()
    {
        $data = @fread($this->stream, 30000);

        if($data === false) return;
        $this->buffer .= $data;

        if(!is_null($this->status)) return;
        if(strlen($this->buffer) < 4) return;
        $end = strpos($this->buffer, "\r\n\r\n", 4);
        if($end === false) return;

        list($request, $headers) = $this->parse_header(substr($this->buffer, 0, $end));
        list($version, $status, $phrase) = explode(' ', $request, 3);
        $this->status = $status;
        $this->response_length = isset($headers['content-length'])? (int)$headers['content-length'][0] : 0;
    }
292693
public function read($max = null)
    {
        $max = min($max ?: PHP_INT_MAX, $this->remaining);
        if ($this->remaining <= 0 || feof($this->data)) {
            $this->close();
            return '';
        }
        $this->remaining -= $max;

        return fread($this->data, $max);
    }
774461
public function read()
    {
        // First, read headers only
        $response = '';
        $gotStatus = false;
        while ($line = @fgets($this->socket)) {
            $gotStatus = $gotStatus || (strpos($line, 'HTTP') !== false);
            if ($gotStatus) {
                $response .= $line;
                if (!chop($line)) { break;
                }
            }
        }

        $statusCode = Zend_Http_Response::extractCode($response);
         
        // Handle 100 and 101 responses internally by restarting the read again
        if ($statusCode == 100 || $statusCode == 101) { return $this->read();
        }

        /**
         * Responses to HEAD requests and 204 or 304 responses are not expected
         * to have a body - stop reading here
         */
        if ($statusCode == 304 || $statusCode == 204  
            || $this->method == Zend_Http_Client::HEAD
        ) { return $response;
        }

        // Check headers to see what kind of connection / transfer encoding we have
        $headers = Zend_Http_Response::extractHeaders($response);

        // if the connection is set to close, just read until socket closes
        if (isset($headers['connection']) && $headers['connection'] == 'close') {
            while ($buff = @fread($this->socket, 8192)) {
                $response .= $buff;
            }

            $this->close();

            // Else, if we got a transfer-encoding header (chunked body)
        } elseif (isset($headers['transfer-encoding'])) {
            if ($headers['transfer-encoding'] == 'chunked') {
                do {
                    $chunk = '';
                    $line = @fgets($this->socket);
                    $chunk .= $line;

                    $hexchunksize = ltrim(chop($line), '0');
                    $hexchunksize = strlen($hexchunksize) ? strtolower($hexchunksize) : 0;

                    $chunksize = hexdec(chop($line));
                    if (dechex($chunksize) != $hexchunksize) {
                        @fclose($this->socket);
                        include_once 'Zend/Http/Client/Adapter/Exception.php';
                        throw new Zend_Http_Client_Adapter_Exception(
                            'Invalid chunk size "' .
                            $hexchunksize . '" unable to read chunked body'
                        );
                    }

                    $left_to_read = $chunksize;
                    while ($left_to_read > 0) {
                        $line = @fread($this->socket, $left_to_read);
                        $chunk .= $line;
                        $left_to_read -= strlen($line);
                    }

                    $chunk .= @fgets($this->socket);
                    $response .= $chunk;
                } while ($chunksize > 0);
            } else {
                throw new Zend_Http_Client_Adapter_Exception(
                    'Cannot handle "' .
                    $headers['transfer-encoding'] . '" transfer encoding'
                );
            }

            // Else, if we got the content-length header, read this number of bytes
        } elseif (isset($headers['content-length'])) {
            $left_to_read = $headers['content-length'];
            $chunk = '';
            while ($left_to_read > 0) {
                $chunk = @fread($this->socket, $left_to_read);
                $left_to_read -= strlen($chunk);
                $response .= $chunk;
            }
        
            // Fallback: just read the response (should not happen)
        } else {
            while ($buff = @fread($this->socket, 8192)) {
                $response .= $buff;
            }

            $this->close();
        }

        return $response;
    }
1086752
public function read()
	{
		$this->position++;
		if ( $this->position >= count( $this->buffer ) ) return false;

		return $this->buffer[ $this->position ];
	}
334009
private function forceRead($length)
    {
        $read = '';

        do {
            $read .= $this->stream->read($length - \strlen($read));
        } while (\strlen($read) < $length && !$this->stream->eof());

        return $read;
    }
1137722
public function read($read)
	{
		$data = null;
		if (isset($_REQUEST[$read])) {
			$data = (string) preg_replace('/[^A-Z_]/i', '', $_REQUEST[$read]);
		}
		return $data;
	}
38353
protected function readFrame(): void
    {
        $header = $this->forceRead(8);

        if (\strlen($header) < 8) {
            return;
        }

        $decoded = \unpack('C1type/C3/N1size', $header);
        $output = $this->forceRead($decoded['size']);
        $callbackList = [];

        if (0 === $decoded['type']) {
            $callbackList = $this->onStdinCallables;
        }

        if (1 === $decoded['type']) {
            $callbackList = $this->onStdoutCallables;
        }

        if (2 === $decoded['type']) {
            $callbackList = $this->onStderrCallables;
        }

        foreach ($callbackList as $callback) {
            $callback($output);
        }
    }
892159
public function stream_read($length)
    {
        assert(null !== $this->handle);

        return fread($this->handle, $length);
    }
11398
protected function Read()
	{
		$ch;
		if ( count( $this->m_buffer ) > 0 )
		{
		    $ch = array_shift( $this->m_buffer );
		}
		else
		{
		    $c = $this->m_reader->read();
		    if ( $c == -1 )
		        return '\0';
		    else
		        $ch = $c;
		}
		if ( $ch != '\r' )
		{
		    if ( $ch == '\n' )
		    {
		        $this->LineNo++;
		        $this->ColNo = 1;
		    }
		    else
		        ++$this->ColNo;
		}
		$this->m_position++;
		return $ch;
	}
577052
protected function onRead()
    {
        while (($line = $this->readline()) !== null) {
            $e = explode(' , ', $line);
            if ((sizeof($e) !== 2) || !ctype_digit($e[0]) || !ctype_digit($e[1])) {
                $this->writeln($line . ' : ERROR : INVALID-PORT');
                $this->finish();
                return;
            }
            $local = (int)$e[0];
            $foreign = (int)$e[1];
            if ($user = $this->pool->findPair($local, $foreign)) {
                $this->writeln($line . ' : USERID : ' . $user);
            } else {
                $this->writeln($line . ' : ERROR : NO-USER');
            }
        }
    }
459967
protected function readLine()
    {
        $buffer = '';

        while ($buffer === '') {
            $buffer = fgets($this->getFileHandler());

            if ($buffer === false) {
                $this->currentLine = null;

                return;
            }

            $buffer = trim($buffer);
        }

        if ($buffer === ']') {
            $this->currentLine = null;

            return;
        }

        $data = json_decode(rtrim($buffer, ','), true);
        $this->currentLine = $this->getOptionsResolver()->resolve($data);
    }
890764
function Read($arr)
	{
		foreach (get_object_vars($this) as $prop)
		{
			if (array_key_exists($prop,$arr))
			{
				$this->$prop = $arr[$prop];
			}
		}
	}
770869
public function doRead()
    {
        $data = fread($this->stream, static::READ_CHUNK_SIZE);

        if ($data === '') {
            fclose($this->stream);
            $this->stream = null; //fclose() will only leave stream resource in unknown state

        } elseif ($this->isDegenerated === false) {
            $this->readBuffer .= $data;

            //For explanation read "important note" for processInputBuffer()
            //@formatter:off
            while ($this->processInputBuffer() === false);
            //@formatter:on
        }
    }