- <?php
- $title = "Banery Serwerów EvoGamers.pl";
- require 'SourceQuery/SourceQuery.class.php';
- define( "DEF__TIME_OUT", 3 );
- // ****
- define( "DEF__IMAGE_NAME", "server_banner.png" );
- // ****
- define( "DEF__COLOR_RED", 255 );
- define( "DEF__COLOR_GREEN", 255 );
- define( "DEF__COLOR_BLUE", 255 );
- // ****
- define( "DEF__HOSTNAME_MAX_TEXT_LEN", 55 );
- define( "DEF__HOSTNAME_TEXT_SIZE", 0 );
- define( "DEF__HOSTNAME_X", 6 );
- define( "DEF__HOSTNAME_Y", 6 );
- // ****
- define( "DEF__ADDRESS_TEXT_SIZE", 2 );
- define( "DEF__ADDRESS_X", 40 );
- define( "DEF__ADDRESS_Y", 200 );
- // ****
- define( "DEF__PLAYERS_TEXT_SIZE", 3 );
- define( "DEF__PLAYERS_X", 40 );
- define( "DEF__PLAYERS_Y", 90 );
- // ****
- define( "DEF__MAP_MAX_TEXT_LEN", 16 );
- define( "DEF__MAP_TEXT_SIZE", 2 );
- define( "DEF__MAP_X", 24 );
- define( "DEF__MAP_Y", 90 );
- // ****
- define( "DEF__ICON_X", 8 );
- define( "DEF__ICON_Y", 7 );
- if( isSet( $_GET[ 'Address' ] ) AND isSet( $_GET[ 'Engine' ] ) )
- {
- $iEngine = $_GET[ 'Engine' ]; // 0 -> GOLDSRC / 1 -> SOURCE
- $szAddress = $_GET[ 'Address' ];
- $szExploded = explode( ":", $szAddress );
- $szServerIP = $szExploded[ 0 ];
- $szServerPort = $szExploded[ 1 ];
- $Query = new SourceQuery( );
- $Info = Array( );
- $Rules = Array( );
- $Players = Array( );
- try
- {
- $Query -> Connect( $szServerIP, $szServerPort, DEF__TIME_OUT, $iEngine );
- $Info = $Query -> GetInfo( );
- $Players = $Query -> GetPlayers( );
- $Rules = $Query -> GetRules( );
- }
- catch( Exception $e )
- {
- $Exception = $e;
- }
- $Query -> Disconnect( );
- header( "Content-type: image/png" );
- $rImage = imagecreatefrompng( DEF__IMAGE_NAME );
- $iColor = imagecolorallocate( $rImage, DEF__COLOR_RED, DEF__COLOR_GREEN, DEF__COLOR_BLUE );
- // bool imagestring ( resource $image , int $font , int $x , int $y , string $string , int $color )
- imagestring( $rImage, DEF__ADDRESS_TEXT_SIZE, DEF__ADDRESS_X, DEF__ADDRESS_Y, $szAddress, $iColor );
- if( $Info[ 'MaxPlayers' ] != 0 )
- {
- if( strlen( $szHostName ) > DEF__HOSTNAME_MAX_TEXT_LEN )
- {
- $szHostName = substr( $Info[ 'HostName' ], 0, DEF__HOSTNAME_MAX_TEXT_LEN ). ' ...';
- }
- if( strlen( $szMapName ) > DEF__MAP_MAX_TEXT_LEN )
- {
- $szMapName = substr( $szMapName, 0, DEF__MAP_MAX_TEXT_LEN ). '..';
- }
- imagestring( $rImage, DEF__HOSTNAME_TEXT_SIZE, DEF__HOSTNAME_X, DEF__HOSTNAME_Y, $szHostName, $iColor );
- imagestring( $rImage, DEF__MAP_TEXT_SIZE, DEF__MAP_X, DEF__MAP_Y, $szMapName, $iColor );
- imagestring( $rImage, DEF__PLAYERS_TEXT_SIZE, DEF__PLAYERS_X, DEF__PLAYERS_Y, $Info[ 'Players' ]. '/' .$Info[ 'MaxPlayers' ], $iColor );
- }
- else
- {
- imagestring( $rImage, DEF__PLAYERS_TEXT_SIZE, DEF__PLAYERS_X, DEF__PLAYERS_Y, "TS-Big.pl", $iColor );
- }
- imagepng( $rImage );
- imagedestroy( $rImage );
- imagedestroy( $rIcon );
- }
- ?>