Facebook
From SnowWolf, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 258
  1. <?php
  2. $title = "Banery Serwerów EvoGamers.pl";
  3.  
  4.  
  5.         require 'SourceQuery/SourceQuery.class.php';
  6.        
  7.         define( "DEF__TIME_OUT", 3 );
  8.         // ****
  9.         define( "DEF__IMAGE_NAME", "server_banner.png" );
  10.         // ****
  11.         define( "DEF__COLOR_RED", 255 );
  12.         define( "DEF__COLOR_GREEN", 255 );
  13.         define( "DEF__COLOR_BLUE", 255 );
  14.         // ****
  15.         define( "DEF__HOSTNAME_MAX_TEXT_LEN", 55 );
  16.         define( "DEF__HOSTNAME_TEXT_SIZE", 0 );
  17.         define( "DEF__HOSTNAME_X", 6 );
  18.         define( "DEF__HOSTNAME_Y", 6 );
  19.         // ****
  20.         define( "DEF__ADDRESS_TEXT_SIZE", 2 );
  21.         define( "DEF__ADDRESS_X", 40 );
  22.         define( "DEF__ADDRESS_Y", 200 );
  23.         // ****
  24.         define( "DEF__PLAYERS_TEXT_SIZE", 3 );
  25.         define( "DEF__PLAYERS_X", 40 );
  26.         define( "DEF__PLAYERS_Y", 90 );
  27.         // ****
  28.         define( "DEF__MAP_MAX_TEXT_LEN", 16 );
  29.         define( "DEF__MAP_TEXT_SIZE", 2 );
  30.         define( "DEF__MAP_X", 24 );
  31.         define( "DEF__MAP_Y", 90 );
  32.         // ****
  33.         define( "DEF__ICON_X", 8 );
  34.         define( "DEF__ICON_Y", 7 );
  35.        
  36.         if( isSet( $_GET[ 'Address' ] ) AND isSet( $_GET[ 'Engine' ] ) )
  37.         {
  38.                 $iEngine = $_GET[ 'Engine' ]; // 0 -> GOLDSRC / 1 -> SOURCE
  39.                 $szAddress = $_GET[ 'Address' ];
  40.                 $szExploded = explode( ":", $szAddress );
  41.                 $szServerIP = $szExploded[ 0 ];
  42.                 $szServerPort = $szExploded[ 1 ];
  43.                
  44.                 $Query = new SourceQuery( );
  45.  
  46.                 $Info    = Array( );
  47.                 $Rules   = Array( );
  48.                 $Players = Array( );
  49.                
  50.                 try
  51.                 {
  52.                         $Query -> Connect( $szServerIP, $szServerPort, DEF__TIME_OUT, $iEngine );
  53.                
  54.                         $Info    = $Query -> GetInfo( );
  55.                         $Players = $Query -> GetPlayers( );
  56.                         $Rules   = $Query -> GetRules( );
  57.                 }
  58.                 catch( Exception $e )
  59.                 {
  60.                         $Exception = $e;
  61.                 }
  62.                
  63.                 $Query -> Disconnect( );
  64.                
  65.                 header( "Content-type: image/png" );
  66.                 $rImage = imagecreatefrompng( DEF__IMAGE_NAME );
  67.                 $iColor = imagecolorallocate( $rImage, DEF__COLOR_RED, DEF__COLOR_GREEN, DEF__COLOR_BLUE );
  68.                
  69.                
  70.                 // bool imagestring ( resource $image , int $font , int $x , int $y , string $string , int $color )
  71.                
  72.                 imagestring( $rImage, DEF__ADDRESS_TEXT_SIZE, DEF__ADDRESS_X, DEF__ADDRESS_Y, $szAddress, $iColor );
  73.                
  74.                 if( $Info[ 'MaxPlayers' ] != 0 )
  75.                 {
  76.                        
  77.                        
  78.                         if( strlen( $szHostName ) > DEF__HOSTNAME_MAX_TEXT_LEN )
  79.                         {
  80.                                 $szHostName = substr( $Info[ 'HostName' ], 0, DEF__HOSTNAME_MAX_TEXT_LEN ). ' ...';
  81.                         }
  82.                        
  83.                         if( strlen( $szMapName ) > DEF__MAP_MAX_TEXT_LEN )
  84.                         {
  85.                                 $szMapName = substr( $szMapName, 0, DEF__MAP_MAX_TEXT_LEN ). '..';
  86.                         }
  87.                        
  88.                         imagestring( $rImage, DEF__HOSTNAME_TEXT_SIZE, DEF__HOSTNAME_X, DEF__HOSTNAME_Y, $szHostName, $iColor );
  89.                         imagestring( $rImage, DEF__MAP_TEXT_SIZE, DEF__MAP_X, DEF__MAP_Y, $szMapName, $iColor );
  90.                        
  91.                         imagestring( $rImage, DEF__PLAYERS_TEXT_SIZE, DEF__PLAYERS_X, DEF__PLAYERS_Y, $Info[ 'Players' ]. '/' .$Info[ 'MaxPlayers' ], $iColor );
  92.                 }
  93.                 else
  94.                 {
  95.                         imagestring( $rImage, DEF__PLAYERS_TEXT_SIZE, DEF__PLAYERS_X, DEF__PLAYERS_Y, "TS-Big.pl", $iColor );
  96.                 }
  97.  
  98.                 imagepng( $rImage );
  99.                 imagedestroy( $rImage );
  100.                 imagedestroy( $rIcon );
  101.         }
  102. ?>