Get server information

@throws InvalidPacketException
@throws SocketException

@return array Returns an array with information on success
187090
public function GetInfo( )
		{
			if( !$this->Connected )
			{
				throw new SocketException( 'Not connected.', SocketException::NOT_CONNECTED );
			}
			
			$this->Socket->Write( self::A2S_INFO, "Source Engine Query\0" );
			$Buffer = $this->Socket->Read( );
			
			$Type = $Buffer->GetByte( );
			
			// Old GoldSource protocol, HLTV still uses it
			if( $Type === self::S2A_INFO_OLD && $this->Socket->Engine === self::GOLDSOURCE )
			{
				/**
				 * If we try to read data again, and we get the result with type S2A_INFO (0x49)
				 * That means this server is running dproto,
				 * Because it sends answer for both protocols
				 */
				
				$Server[ 'Address' ]    = $Buffer->GetString( );
				$Server[ 'HostName' ]   = $Buffer->GetString( );
				$Server[ 'Map' ]        = $Buffer->GetString( );
				$Server[ 'ModDir' ]     = $Buffer->GetString( );
				$Server[ 'ModDesc' ]    = $Buffer->GetString( );
				$Server[ 'Players' ]    = $Buffer->GetByte( );
				$Server[ 'MaxPlayers' ] = $Buffer->GetByte( );
				$Server[ 'Protocol' ]   = $Buffer->GetByte( );
				$Server[ 'Dedicated' ]  = Chr( $Buffer->GetByte( ) );
				$Server[ 'Os' ]         = Chr( $Buffer->GetByte( ) );
				$Server[ 'Password' ]   = $Buffer->GetByte( ) === 1;
				$Server[ 'IsMod' ]      = $Buffer->GetByte( ) === 1;
				
				if( $Server[ 'IsMod' ] )
				{
					$Mod[ 'Url' ]        = $Buffer->GetString( );
					$Mod[ 'Download' ]   = $Buffer->GetString( );
					$Buffer->Get( 1 ); // NULL byte
					$Mod[ 'Version' ]    = $Buffer->GetLong( );
					$Mod[ 'Size' ]       = $Buffer->GetLong( );
					$Mod[ 'ServerSide' ] = $Buffer->GetByte( ) === 1;
					$Mod[ 'CustomDLL' ]  = $Buffer->GetByte( ) === 1;
				}
				
				$Server[ 'Secure' ]   = $Buffer->GetByte( ) === 1;
				$Server[ 'Bots' ]     = $Buffer->GetByte( );
				
				if( isset( $Mod ) )
				{
					$Server[ 'Mod' ] = $Mod;
				}
				
				return $Server;
			}
			
			if( $Type !== self::S2A_INFO )
			{
				throw new InvalidPacketException( 'GetInfo: Packet header mismatch. (0x' . DecHex( $Type ) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH );
			}
			
			$Server[ 'Protocol' ]   = $Buffer->GetByte( );
			$Server[ 'HostName' ]   = $Buffer->GetString( );
			$Server[ 'Map' ]        = $Buffer->GetString( );
			$Server[ 'ModDir' ]     = $Buffer->GetString( );
			$Server[ 'ModDesc' ]    = $Buffer->GetString( );
			$Server[ 'AppID' ]      = $Buffer->GetShort( );
			$Server[ 'Players' ]    = $Buffer->GetByte( );
			$Server[ 'MaxPlayers' ] = $Buffer->GetByte( );
			$Server[ 'Bots' ]       = $Buffer->GetByte( );
			$Server[ 'Dedicated' ]  = Chr( $Buffer->GetByte( ) );
			$Server[ 'Os' ]         = Chr( $Buffer->GetByte( ) );
			$Server[ 'Password' ]   = $Buffer->GetByte( ) === 1;
			$Server[ 'Secure' ]     = $Buffer->GetByte( ) === 1;
			
			// The Ship (they violate query protocol spec by modifying the response)
			if( $Server[ 'AppID' ] === 2400 )
			{
				$Server[ 'GameMode' ]     = $Buffer->GetByte( );
				$Server[ 'WitnessCount' ] = $Buffer->GetByte( );
				$Server[ 'WitnessTime' ]  = $Buffer->GetByte( );
			}
			
			$Server[ 'Version' ] = $Buffer->GetString( );
			
			// Extra Data Flags
			if( $Buffer->Remaining( ) > 0 )
			{
				$Server[ 'ExtraDataFlags' ] = $Flags = $Buffer->GetByte( );
				
				// The server's game port
				if( $Flags & 0x80 )
				{
					$Server[ 'GamePort' ] = $Buffer->GetShort( );
				}
				
				// The server's steamid
				// Want to play around with this?
				// You can use https://github.com/xPaw/SteamID.php
				if( $Flags & 0x10 )
				{
					$SteamIDLower    = $Buffer->GetUnsignedLong( );
					$SteamIDInstance = $Buffer->GetUnsignedLong( ); // This gets shifted by 32 bits, which should be steamid instance
					$SteamID = 0;
					
					if( PHP_INT_SIZE === 4 )
					{
						if( extension_loaded( 'gmp' ) )
						{
							$SteamIDLower    = gmp_abs( $SteamIDLower );
							$SteamIDInstance = gmp_abs( $SteamIDInstance );
							$SteamID         = gmp_strval( gmp_or( $SteamIDLower, gmp_mul( $SteamIDInstance, gmp_pow( 2, 32 ) ) ) );
						}
						else
						{
							throw new \RuntimeException( 'Either 64-bit PHP installation or "gmp" module is required to correctly parse server\'s steamid.' );
						}
					}
					else
					{
						$SteamID = $SteamIDLower | ( $SteamIDInstance << 32 );
					}
					
					$Server[ 'SteamID' ] = $SteamID;
					
					unset( $SteamIDLower, $SteamIDInstance, $SteamID );
				}
				
				// The spectator port and then the spectator server name
				if( $Flags & 0x40 )
				{
					$Server[ 'SpecPort' ] = $Buffer->GetShort( );
					$Server[ 'SpecName' ] = $Buffer->GetString( );
				}
				
				// The game tag data string for the server
				if( $Flags & 0x20 )
				{
					$Server[ 'GameTags' ] = $Buffer->GetString( );
				}
				
				// GameID -- alternative to AppID?
				if( $Flags & 0x01 )
				{
					$Server[ 'GameID' ] = $Buffer->GetUnsignedLong( ) | ( $Buffer->GetUnsignedLong( ) << 32 ); 
				}
				
				if( $Buffer->Remaining( ) > 0 )
				{
					throw new InvalidPacketException( 'GetInfo: unread data? ' . $Buffer->Remaining( ) . ' bytes remaining in the buffer. Please report it to the library developer.',
						InvalidPacketException::BUFFER_NOT_EMPTY );
				}
			}
			
			return $Server;
		}
589725
public function getFromClient() {
		$returner = [];

		// Example string
		// en-ca,en;q=0.8,en-us;q=0.6,de-de;q=0.4,de;q=0.2

		if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
			$parts = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);

			foreach ($parts as $part) {
				preg_match("|^
					(.*?)		# the language part
					([-].*?)?	# the country part (optional)
					(;q=(.*))?	# the quality part (optional)
				$|x", $part, $matches);

				// set quality to 1.0 if not given
				$quality	= isset($matches[4]) ? $matches[4] : '1.0';

				$returner[$quality] = strtolower(trim($matches[1]));
			}
			krsort($returner);
		}
		return $returner;
	}
487739
function getServerParams()
    {
        if ($this->_server === null) {
            $params = PhpServer::_($this->httpMessage)->getServer();
            $this->_server = \Poirot\Std\cast($params)->toArray();
        }

        return $this->_server;
    }
900360
public function getSockName()
    {
        $ret = @socket_getsockname($this->resource, $address, $port);
        if ($ret === false) {
            throw Exception::createFromSocketResource($this->resource);
        }
        return $this->formatAddress($address, $port);
    }
544780
public function serverInfo()
    {
        $url = $this->service_url . '/serverInfo';
        $data = $this->service->prepAndSend($url, array(200), 'GET', null, true, 'application/json', 'application/json');
        return json_decode($data, true);
    }
1037481
public static function getallheaders()
    {
        if (function_exists('getallheaders')) {
            $return = getallheaders();
        } else {
            $return = array();
            foreach ($_SERVER as $name => $value) {
               if (substr($name, 0, 5) == 'HTTP_') {
                   $return[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
               }
            }
        }
        return !empty($return) ? $return : array();
    }
420487
public function toArray()
    {
        return [
            'success'          => $this->isSuccess(),
            'hostname'         => $this->getHostname(),
            'challenge_ts'     => $this->getChallengeTs(),
            'apk_package_name' => $this->getApkPackageName(),
            'error-codes'      => $this->getErrorCodes(),
        ];
    }
268605
protected function obtainConnectedServerList(): array
    {
        $serversList = $this->getServerList();
        $servers     = [];
        
        foreach ($serversList as $serverInfos) {
            $servers[] = $serverInfos['host'].':'.$serverInfos['port'];
        }
        
        return $servers;
    }
98755
public function getPacket()
    {
        if ($packet = $this->redis->hgetall(self::redisKey($this))) {
            return $packet;
        }

        return false;
    }
508830
public function socketGet()
    {

        $socket = null;

        if (count($this->sockets) > 0) {
            $socket = array_pop($this->sockets);
        }

        return $socket;
    }
1197887
public function getIndices(): array
    {
        $response = $this
            ->httpClient
            ->get(
                sprintf(
                    '/%s/indices',
                    $this->getAppUUID()->getId()
                ),
                'get',
                [],
                [],
                Http::getApisearchHeaders($this)
            );

        self::throwTransportableExceptionIfNeeded($response);

        $result = [];
        foreach ($response['body'] as $index) {
            $result[] = Index::createFromArray($index);
        }

        return $result;
    }
252704
protected function getWebsocketConnections(): array
    {
        return array_filter(iterator_to_array($this->server->connections), function ($fd) {
            return $this->server->isEstablished($fd);
        });
    }
822812
public function getSortedServersArray()
    {
        $servers = empty($this->config->getServers()) ? $this->getServersFromDns() : $this->config->getServers();

        if (self::SELECT_RANDOM == $this->selectionMethod) {
            $servers = $this->shuffleServers($servers);
        }

        return $servers;
    }
1154025
public function getIp(): string
    {
        $name = $this->getName();

        if ($name) {
            return self::getNamePart($name, self::NAME_PART_IP);
        } else {
            throw new SocketException('Cannot get socket IP address');
        }
    }
1080125
public function GetRules( )
		{
			if( !$this->Connected )
			{
				throw new SocketException( 'Not connected.', SocketException::NOT_CONNECTED );
			}
			
			$this->GetChallenge( self::A2S_RULES, self::S2A_RULES );
			
			$this->Socket->Write( self::A2S_RULES, $this->Challenge );
			$Buffer = $this->Socket->Read( );
			
			$Type = $Buffer->GetByte( );
			
			if( $Type !== self::S2A_RULES )
			{
				throw new InvalidPacketException( 'GetRules: Packet header mismatch. (0x' . DecHex( $Type ) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH );
			}
			
			$Rules = [];
			$Count = $Buffer->GetShort( );
			
			while( $Count-- > 0 && $Buffer->Remaining( ) > 0 )
			{
				$Rule  = $Buffer->GetString( );
				$Value = $Buffer->GetString( );
				
				if( !Empty( $Rule ) )
				{
					$Rules[ $Rule ] = $Value;
				}
			}
			
			return $Rules;
		}
1309134
public function get_server_info() {
        static $info;
        if (!$info) {
            $this->query_start("--pg_version()", null, SQL_QUERY_AUX);
            $info = pg_version($this->pgsql);
            $this->query_end(true);
        }
        return array('description'=>$info['server'], 'version'=>$info['server']);
    }
241615
protected function getServer()
    {
        $servers = array();

        if (isset($this->globals['production']) && (true === $this->globals['production'])) {
            $servers[] = $this->servers['primary'];
            $servers[] = $this->servers['secondary'];
        } else {
            $servers[] = $this->servers['preprod'];
        }

        foreach ($servers as $server) {
            $doc = new \DOMDocument();
            $doc->loadHTML($this->getWebPage(sprintf(
                '%s://%s%s',
                $server['protocol'],
                $server['host'],
                $server['test_path']
            )));
            $element = $doc->getElementById('server_status');

            if ($element && 'OK' == $element->textContent) {
                return $server;
            }
        }

        throw new RuntimeException('No server available.');
    }