#1 2012-08-19 20:16:18

mawerick
Člen
Registrován: 2012-02-20
Příspěvky: 15

Re: Status Generátor

Zdravim. Chcel som si spraviť generátor statusu na hru gta san andreas. Robil som všetko podla navodu na tejto stranke http://pawno.cz/generator-statusu-t6416.html
Podla navodu som mal vytvorit 2 subory.

samp_query.php

<?php
/*********************************************
*
* SA-MP Query Server Version 0.3
*
* This class provides you with an easy to use interface to query
* your SA-MP 0.2 servers. Usage is simple, but has changed a bit
* since the last version, so be sure to check out the examples
* that come along with this script. It is updated with some of
* the new SA-MP 0.2 query-techniques that can be used.
*
* Author:  Peter Beverloo
*          peter@dmx-network.com
*          Ex SA-MP Developer
*
* Updated: Wouter van Eekelen
*          wouter.van.eekelen@serverffs.com
*          SA-MP Betatester
*********************************************/

class QueryServer
{
    // Private variables used for the query-ing.
    private $szServerIP;
    private $iPort;
    private $rSocketID;

    private $bStatus;

    // The __construct function gets called automatically
    // by PHP once the class gets initialized.
    function __construct( $szServerIP, $iPort )
    {
            $this->szServerIP = $this->VerifyAddress( $szServerIP );
            $this->iPort = $iPort;

            if (empty( $this->szServerIP ) || !is_numeric( $iPort )) {
                    throw new QueryServerException( 'Either the ip-address or the port isn\'t filled in correctly.' );
            }

            $this->rSocketID = @fsockopen( 'udp://' . $this->szServerIP, $iPort, $iErrorNo, $szErrorStr, 5 );
            if (!$this->rSocketID) {
                    throw new QueryServerException( 'Cannot connect to the server: ' . $szErrorStr );
            }

            socket_set_timeout( $this->rSocketID, 0, 500000 );
            $this->bStatus = true;
    }

    // The VerifyAddress function verifies the given hostname/
    // IP address and returns the actual IP Address.
    function VerifyAddress( $szServerIP )
    {
            if (ip2long( $szServerIP ) !== false && 
                long2ip( ip2long( $szServerIP ) ) == $szServerIP ) {
                    return $szServerIP;
            }

            $szAddress = gethostbyname( $szServerIP );
            if ($szAddress == $szServerIP) {
                    return "";
            }

            return $szAddress;
    }

    // The SendPacket function sends a packet to the server which
    // requests information, based on the type of packet send.
    function SendPacket( $cPacket )
    {
            $szPacket = 'SAMP';
            $aIpChunks = explode( '.', $this->szServerIP );

            foreach( $aIpChunks as $szChunk ) {
                    $szPacket .= chr( $szChunk );
            }

            $szPacket .= chr( $this->iPort & 0xFF );
            $szPacket .= chr( $this->iPort >> 8 & 0xFF );
            $szPacket .= $cPacket;

            return fwrite( $this->rSocketID, $szPacket, strlen( $szPacket ) );
    }

    // The GetPacket() function returns a specific number of bytes
    // read from the socket. This uses a special way of getting stuff.
    function GetPacket( $iBytes )
    {
            $iResponse = fread( $this->rSocketID, $iBytes );
            if ($iResponse === false) {
                    throw new QueryServerException( 'Connection to ' . $this->szServerIP . ' failed or has dropped.' );
            }

            $iLength = ord( $iResponse );
            if ($iLength > 0)
                    return fread( $this->rSocketID, $iLength );

            return "";
    }

    // After we're done, the connection needs to be closed using
    // the Close() function. Otherwise stuff might go wrong.
    function Close( )
    {
            if ($this->rSocketID !== false) {
                    fclose( $this->rSocketID );
            }
    }

    // A little function that's needed to properly convert the
    // four bytes we're recieving to integers to an actual PHP
    // integer. ord() can't handle value's higher then 255.
    function toInteger( $szData )
    {
            $iInteger = 0;

            $iInteger += ( ord( @$szData[ 0 ] ) );
            $iInteger += ( ord( @$szData[ 1 ] ) << 8 );
            $iInteger += ( ord( @$szData[ 2 ] ) << 16 );
            $iInteger += ( ord( @$szData[ 3 ] ) << 24 );

            if( $iInteger >= 4294967294 )
                    $iInteger -= 4294967296;

            return $iInteger;
    }

    // The GetInfo() function returns basic information about the
    // server, like the hostname, number of players online etc.
    function GetInfo( )
    {
            if ($this->SendPacket('i') === false) {
                    throw new QueryServerException( 'Connection to ' . $this->szServerIP . ' failed or has dropped.' );
            }

            $szFirstData = fread( $this->rSocketID, 4 );
            if (empty( $szFirstData ) || $szFirstData != 'SAMP') {
                    throw new QueryServerException( 'The server at ' . $this->szServerIP . ' is not an SA-MP Server.' );
            }

            // Pop the first seven characters returned.
            fread( $this->rSocketID, 7 );

            return array (
                    'Password'   =>   ord( fread( $this->rSocketID, 1 ) ),
                    'Players'    =>   $this->toInteger( fread( $this->rSocketID, 2 ) ),
                    'MaxPlayers' =>   $this->toInteger( fread( $this->rSocketID, 2 ) ),
                    'Hostname'   =>   $this->GetPacket( 4 ),
                    'Gamemode'   =>   $this->GetPacket( 4 ),
                    'Map'        =>   $this->GetPacket( 4 )
            );
    }

    // The GetRules() function returns the rules which are set
    // on the server, e.g. the gravity, version etcetera.
    function GetRules( )
    {
            if ($this->SendPacket('r') === false) {
                    throw new QueryServerException( 'Connection to ' . $this->szServerIP . ' failed or has dropped.' );
            }

            // Pop the first 11 bytes from the response;
            fread( $this->rSocketID, 11 );

            $iRuleCount = ord( fread( $this->rSocketID, 2 ) );
            $aReturnArray = array( );

            for( $i = 0; $i < $iRuleCount; $i ++ ) {
                    $szRuleName = $this->GetPacket( 1 );
                    $aReturnArray[ $szRuleName ] = $this->GetPacket( 1 );
            }

            return $aReturnArray;
    }

    // The GetPlayers() function is pretty much simelar to the
    // detailed function, but faster and contains less information.
    function GetPlayers( )
    {
            if ($this->SendPacket('c') === false) {
                    throw new QueryServerException( 'Connection to ' . $this->szServerIP . ' failed or has dropped.' );
            }

            // Again, pop the first eleven bytes send;
            fread( $this->rSocketID, 11 );

            $iPlayerCount = ord( fread( $this->rSocketID, 2 ) );
            $aReturnArray = array( );

            for( $i = 0; $i < $iPlayerCount; $i ++ )
            {
                    $aReturnArray[ ] = array (
                            'Nickname' => $this->GetPacket( 1 ),
                            'Score'    => $this->toInteger( fread( $this->rSocketID, 4 ) )
                    );
            }

            return $aReturnArray;
    }

    // The GetDetailedPlayers() function returns the player list,
    // but in a detailed form inclusing the score and the ping.
    function GetDetailedPlayers( )
    {
            if ($this->SendPacket('d') === false) {
                    throw new QueryServerException( 'Connection to ' . $this->szServerIP . ' failed or has dropped.' );
            }

            // Skip the first 11 bytes of the response;
            fread( $this->rSocketID, 11 );

            $iPlayerCount = ord( fread( $this->rSocketID, 2 ) );
            $aReturnArray = array( );

            for( $i = 0; $i < $iPlayerCount; $i ++ ) {
                    $aReturnArray[ ] = array(
                            'PlayerID'   =>  $this->toInteger( fread( $this->rSocketID, 1 ) ),
                            'Nickname'   =>  $this->GetPacket( 1 ),
                            'Score'      =>  $this->toInteger( fread( $this->rSocketID, 4 ) ),
                            'Ping'       =>  $this->toInteger( fread( $this->rSocketID, 4 ) )
                    );
            }

            return $aReturnArray;
    }

function RCON($rcon, $command)
    {
            echo 'Password '.$rcon.' with '.$command;
            if ($this->SendPacket('x '.$rcon.' '.$command) === false) {
                    throw new QueryServerException( 'Connection to ' . $this->szServerIP . ' failed or has dropped.' );
            }

            // Pop the first 11 bytes from the response;
            $aReturnArray = fread( $this->rSocketID, 11 );

            echo fread( $this->rSocketID, 11 );

            return $aReturnArray;
    }

}

/*********************************************
*
* The QueryServerException is used to throw errors when querying
* a specific server. That way we force the user to use proper
* error-handling, and preferably even a try-/catch statement.
*
**********************************************/

class QueryServerException extends Exception
{
    // The actual error message is stored in this variable.
    private $szMessage;

    // Again, the __construct function gets called as soon
    // as the exception is being thrown, in here we copy the message.
    function __construct( $szMessage )
    {
            $this->szMessage = $szMessage;
    }

    // In order to read the exception being thrown, we have
    // a .NET-like toString() function, which returns the message.
    function toString( )
    {
            return $this->szMessage;
    }
}
?>

a

generator.php

<?php
header("Content-type: image/png");
$ip = $_GET["ip"]; 
$port = $_GET["port"];
$bg = $_GET["bg"];
require "samp_query.php";

$img = ImageCreateFrompng("./img/nic.png");
$bila = ImageColorAllocate($img, 255, 255, 255);
$modra = ImageColorAllocate($img, 0, 20, 255);
$cerna = ImageColorAllocate($img, 255, 0, 0);



if (!empty( $ip ) && !empty( $port ) && !empty( $bg ))
{  
  if($bg == "1")
   {
    $img = ImageCreateFrompng("./img/1.png");   
   }
   else if($bg == "2")
   {
    $img = ImageCreateFrompng("./img/2.png");
   }
   else if($bg == "3")
   {
    $img = ImageCreateFrompng("./img/3.png");
   }
   else if($bg == "4")
   {
    $img = ImageCreateFrompng("./img/4.gif");   
   }
   else if($bg == "5")
   {
      $img = ImageCreateFrompng("./img/5.png");
   }
   else if($bg == "6")
   {
      $img = ImageCreateFrompng("./img/6.png");
   }
   else if($bg == "7")
   {
      $img = ImageCreateFrompng("./img/7.png");
   }
   else if($bg == "8")
   {
      $img = ImageCreateFrompng("./img/8.png");
   }
  try
  {
    $rQuery = new QueryServer( $ip, $port );
    $aInformation  = $rQuery->GetInfo( );
    $aServerRules  = $rQuery->GetRules( );
    $aBasicPlayer  = $rQuery->GetPlayers( );
    $aTotalPlayers = $rQuery->GetDetailedPlayers( );
    $rQuery->Close( );
  }
  catch (QueryServerException $pError)
  { 
    ImageString($img, 3, 5, 5, "IP: $ip:$port", $cerna); 
    ImageString($img, 3, 5, 17, "Tento server není aktuálně zapnutý.", $cerna); 
  }
  if(isset($aInformation) && is_array($aInformation))
  {
      $hostname = $aInformation['Hostname'];
      $maxplayers = $aInformation['MaxPlayers'];
     $ping = $aInformation['Ping'];
     $players = $aInformation['Players'];
      $map = $aInformation['Map'];
     $gamemode = $aInformation['Gamemode'];
     $mapname = $aInformation['Map'];
     $verze = $aServerRules['version'];
     $pocasi = $aServerRules['weather'];
     $cas = $aServerRules['worldtime'];
     $gravity = $aServerRules['gravity'];
     $web = $aServerRules['weburl'];
     $pass = $aInformation['Password'] ? 'Zamčeno' : 'Odemčeno';
      //atd
      
     ImageString($img, 3, 10, 5, "$hostname", $bila);
     
     ImageString($img, 3, 10, 20, "Gamemode:", $modra);
     ImageString($img, 3, 80, 20, "$gamemode", $bila);
     ImageString($img, 3, 10, 35, "Mapname:", $modra);
     ImageString($img, 3, 80, 35, "$mapname", $bila);
     ImageString($img, 3, 10, 50, "Hráči:", $modra);
     ImageString($img, 3, 80, 50, "$players/$maxplayers", $bila);
     ImageString($img, 3, 10, 65, "IP:", $modra);
     ImageString($img, 3, 80, 65, "$ip:$port", $bila);
     ImageString($img, 3, 270, 20, "Počasí / Čas:", $modra);
     ImageString($img, 3, 370, 20, "$pocasi / $cas", $bila);
     ImageString($img, 3, 270, 35, "Verze:", $modra);
     ImageString($img, 3, 320, 35, "$verze", $bila);
     ImageString($img, 3, 270, 50, "Gravity:", $modra);
     ImageString($img, 3, 330, 50, "$gravity", $bila);
     ImageString($img, 3, 270, 65, "Web:", $modra);
     ImageString($img, 3, 310, 65, "$web", $bila);
     if($pass == 'Zamčeno')
     {
      ImageString($img, 3, 460, 5, "LOCK", $cerna);
     }
     
     
      
     
  }
}
else
{
  ImageString($img, 3, 5, 5, "Nevyplnil si port, adresu atd", $cerna);
}
imagepng($img);
imagedestroy($img);
?>

Tu je kod ktory som zlozil do tych suborov a pisu tam ze treba mat este nejaky $_Get a td. Mozete my poradit co stim ? Ked si dam stranku <!-- w --><a class="postlink" href="http://www.neco.tl/generator.php">www.neco.tl/generator.php</a><!-- w --> alebo samp_query.php tak na jednej iba ostane biela stranka a na druhej iba endra reklama.

Offline

#2 2012-08-19 20:49:49

kksmirice
Endora rádce
Místo: Vrchovnice
Registrován: 2011-11-20
Příspěvky: 6,023
Web

Re: Status Generátor

Sice chybí konkrétní doména, nicméně co takhle generátoru zadat údaje, nepomůže to?

www.neco.tl/generator.php?ip=89.187.142.117&port=7777

1. Murphyho zákon:
Na počátku nebylo nic. I to se pokazilo!

stránky: CMS test
kontakt - instalace systémů, MySQL, FTP přístup, ...
Instalační balíky vybraných CSM

Problémy spojené s provozem služeb Endora, řešte na tomto fóru.

Offline

#3 2012-08-20 18:17:51

JF
Endora rádce
Místo: ....nice u Plzně
Registrován: 2010-06-22
Příspěvky: 11,911

Re: Status Generátor

UDP porty sú blokované!


Ján Fačkovec - Endora.cz by Webglobe
Email, Web, Webadmin, Webmail, Nápověda, Ceník

Offline

#4 2012-11-22 16:00:07

DJgollum
Člen
Registrován: 2012-08-22
Příspěvky: 155

Re: Status Generátor

Bože...nejlepší webhosting a máte blokované UDF porty


Chcete se naučit s PHP,HTML,CSS ?
Určitě nejlepší stránka http://www.jakpsatweb.cz

Offline

#5 2012-11-22 20:11:21

JF
Endora rádce
Místo: ....nice u Plzně
Registrován: 2010-06-22
Příspěvky: 11,911

Re: Status Generátor

DJgollum napsal:

Bože...nejlepší webhosting a máte blokované UDF porty

blokované sú pre bezpečnosť, cez tieto porty prebiehali a prebiehajú útoky a preto sú blokované - týmto je zamedzené preťažovanie serverov a nedostupnosť stránok všetkých zákazníkov

Ak máte herný server tak istotne je možné na strane herného servery si vytvoriť skript ktorý bude dávať výstup na porte 80 v textovej podobe ktorú si môžete spracovať na svojej stránke.


Ján Fačkovec - Endora.cz by Webglobe
Email, Web, Webadmin, Webmail, Nápověda, Ceník

Offline

#6 2013-05-02 16:44:41

ruberninja1
Endora uživatel
Registrován: 2012-12-01
Příspěvky: 416

Re: Status Generátor

A opravdu, ty UDP porty nechcete povolit ? Dá se to přeci nějak omezit u těch útoků

Offline

#7 2013-05-02 16:48:52

Trade
Endora rádce
Místo: Česká republika
Registrován: 2013-01-22
Příspěvky: 3,596
Web

Re: Status Generátor

Není zapotřebí zbytečně riskovat bezpečnost a UDP porty povolit. Je zde několik možností, jak se dají obejít.


Kontaktujte nás | FAQ
Email: fk@endora.cz

Offline

#8 2013-05-02 16:50:13

ruberninja1
Endora uživatel
Registrován: 2012-12-01
Příspěvky: 416

Re: Status Generátor

mawerick napsal:

Zdravim. Chcel som si spraviť generátor statusu na hru gta san andreas. Robil som všetko podla navodu na tejto stranke [url]http://pawno.cz/generator-statusu-t6416.html[/url:2x9hpp0g]
Podla navodu som mal vytvorit 2 subory.

samp_query.php

<?php
/*********************************************
*
* SA-MP Query Server Version 0.3
*
* This class provides you with an easy to use interface to query
* your SA-MP 0.2 servers. Usage is simple, but has changed a bit
* since the last version, so be sure to check out the examples
* that come along with this script. It is updated with some of
* the new SA-MP 0.2 query-techniques that can be used.
*
* Author:  Peter Beverloo
*          peter@dmx-network.com
*          Ex SA-MP Developer
*
* Updated: Wouter van Eekelen
*          wouter.van.eekelen@serverffs.com
*          SA-MP Betatester
*********************************************/

class QueryServer
{
    // Private variables used for the query-ing.
    private $szServerIP;
    private $iPort;
    private $rSocketID;

    private $bStatus;

    // The __construct function gets called automatically
    // by PHP once the class gets initialized.
    function __construct( $szServerIP, $iPort )
    {
            $this->szServerIP = $this->VerifyAddress( $szServerIP );
            $this->iPort = $iPort;

            if (empty( $this->szServerIP ) || !is_numeric( $iPort )) {
                    throw new QueryServerException( 'Either the ip-address or the port isn\'t filled in correctly.' );
            }

            $this->rSocketID = @fsockopen( 'udp://' . $this->szServerIP, $iPort, $iErrorNo, $szErrorStr, 5 );
            if (!$this->rSocketID) {
                    throw new QueryServerException( 'Cannot connect to the server: ' . $szErrorStr );
            }

            socket_set_timeout( $this->rSocketID, 0, 500000 );
            $this->bStatus = true;
    }

    // The VerifyAddress function verifies the given hostname/
    // IP address and returns the actual IP Address.
    function VerifyAddress( $szServerIP )
    {
            if (ip2long( $szServerIP ) !== false && 
                long2ip( ip2long( $szServerIP ) ) == $szServerIP ) {
                    return $szServerIP;
            }

            $szAddress = gethostbyname( $szServerIP );
            if ($szAddress == $szServerIP) {
                    return "";
            }

            return $szAddress;
    }

    // The SendPacket function sends a packet to the server which
    // requests information, based on the type of packet send.
    function SendPacket( $cPacket )
    {
            $szPacket = 'SAMP';
            $aIpChunks = explode( '.', $this->szServerIP );

            foreach( $aIpChunks as $szChunk ) {
                    $szPacket .= chr( $szChunk );
            }

            $szPacket .= chr( $this->iPort & 0xFF );
            $szPacket .= chr( $this->iPort >> 8 & 0xFF );
            $szPacket .= $cPacket;

            return fwrite( $this->rSocketID, $szPacket, strlen( $szPacket ) );
    }

    // The GetPacket() function returns a specific number of bytes
    // read from the socket. This uses a special way of getting stuff.
    function GetPacket( $iBytes )
    {
            $iResponse = fread( $this->rSocketID, $iBytes );
            if ($iResponse === false) {
                    throw new QueryServerException( 'Connection to ' . $this->szServerIP . ' failed or has dropped.' );
            }

            $iLength = ord( $iResponse );
            if ($iLength > 0)
                    return fread( $this->rSocketID, $iLength );

            return "";
    }

    // After we're done, the connection needs to be closed using
    // the Close() function. Otherwise stuff might go wrong.
    function Close( )
    {
            if ($this->rSocketID !== false) {
                    fclose( $this->rSocketID );
            }
    }

    // A little function that's needed to properly convert the
    // four bytes we're recieving to integers to an actual PHP
    // integer. ord() can't handle value's higher then 255.
    function toInteger( $szData )
    {
            $iInteger = 0;

            $iInteger += ( ord( @$szData[ 0 ] ) );
            $iInteger += ( ord( @$szData[ 1 ] ) << 8 );
            $iInteger += ( ord( @$szData[ 2 ] ) << 16 );
            $iInteger += ( ord( @$szData[ 3 ] ) << 24 );

            if( $iInteger >= 4294967294 )
                    $iInteger -= 4294967296;

            return $iInteger;
    }

    // The GetInfo() function returns basic information about the
    // server, like the hostname, number of players online etc.
    function GetInfo( )
    {
            if ($this->SendPacket('i') === false) {
                    throw new QueryServerException( 'Connection to ' . $this->szServerIP . ' failed or has dropped.' );
            }

            $szFirstData = fread( $this->rSocketID, 4 );
            if (empty( $szFirstData ) || $szFirstData != 'SAMP') {
                    throw new QueryServerException( 'The server at ' . $this->szServerIP . ' is not an SA-MP Server.' );
            }

            // Pop the first seven characters returned.
            fread( $this->rSocketID, 7 );

            return array (
                    'Password'   =>   ord( fread( $this->rSocketID, 1 ) ),
                    'Players'    =>   $this->toInteger( fread( $this->rSocketID, 2 ) ),
                    'MaxPlayers' =>   $this->toInteger( fread( $this->rSocketID, 2 ) ),
                    'Hostname'   =>   $this->GetPacket( 4 ),
                    'Gamemode'   =>   $this->GetPacket( 4 ),
                    'Map'        =>   $this->GetPacket( 4 )
            );
    }

    // The GetRules() function returns the rules which are set
    // on the server, e.g. the gravity, version etcetera.
    function GetRules( )
    {
            if ($this->SendPacket('r') === false) {
                    throw new QueryServerException( 'Connection to ' . $this->szServerIP . ' failed or has dropped.' );
            }

            // Pop the first 11 bytes from the response;
            fread( $this->rSocketID, 11 );

            $iRuleCount = ord( fread( $this->rSocketID, 2 ) );
            $aReturnArray = array( );

            for( $i = 0; $i < $iRuleCount; $i ++ ) {
                    $szRuleName = $this->GetPacket( 1 );
                    $aReturnArray[ $szRuleName ] = $this->GetPacket( 1 );
            }

            return $aReturnArray;
    }

    // The GetPlayers() function is pretty much simelar to the
    // detailed function, but faster and contains less information.
    function GetPlayers( )
    {
            if ($this->SendPacket('c') === false) {
                    throw new QueryServerException( 'Connection to ' . $this->szServerIP . ' failed or has dropped.' );
            }

            // Again, pop the first eleven bytes send;
            fread( $this->rSocketID, 11 );

            $iPlayerCount = ord( fread( $this->rSocketID, 2 ) );
            $aReturnArray = array( );

            for( $i = 0; $i < $iPlayerCount; $i ++ )
            {
                    $aReturnArray[ ] = array (
                            'Nickname' => $this->GetPacket( 1 ),
                            'Score'    => $this->toInteger( fread( $this->rSocketID, 4 ) )
                    );
            }

            return $aReturnArray;
    }

    // The GetDetailedPlayers() function returns the player list,
    // but in a detailed form inclusing the score and the ping.
    function GetDetailedPlayers( )
    {
            if ($this->SendPacket('d') === false) {
                    throw new QueryServerException( 'Connection to ' . $this->szServerIP . ' failed or has dropped.' );
            }

            // Skip the first 11 bytes of the response;
            fread( $this->rSocketID, 11 );

            $iPlayerCount = ord( fread( $this->rSocketID, 2 ) );
            $aReturnArray = array( );

            for( $i = 0; $i < $iPlayerCount; $i ++ ) {
                    $aReturnArray[ ] = array(
                            'PlayerID'   =>  $this->toInteger( fread( $this->rSocketID, 1 ) ),
                            'Nickname'   =>  $this->GetPacket( 1 ),
                            'Score'      =>  $this->toInteger( fread( $this->rSocketID, 4 ) ),
                            'Ping'       =>  $this->toInteger( fread( $this->rSocketID, 4 ) )
                    );
            }

            return $aReturnArray;
    }

function RCON($rcon, $command)
    {
            echo 'Password '.$rcon.' with '.$command;
            if ($this->SendPacket('x '.$rcon.' '.$command) === false) {
                    throw new QueryServerException( 'Connection to ' . $this->szServerIP . ' failed or has dropped.' );
            }

            // Pop the first 11 bytes from the response;
            $aReturnArray = fread( $this->rSocketID, 11 );

            echo fread( $this->rSocketID, 11 );

            return $aReturnArray;
    }

}

/*********************************************
*
* The QueryServerException is used to throw errors when querying
* a specific server. That way we force the user to use proper
* error-handling, and preferably even a try-/catch statement.
*
**********************************************/

class QueryServerException extends Exception
{
    // The actual error message is stored in this variable.
    private $szMessage;

    // Again, the __construct function gets called as soon
    // as the exception is being thrown, in here we copy the message.
    function __construct( $szMessage )
    {
            $this->szMessage = $szMessage;
    }

    // In order to read the exception being thrown, we have
    // a .NET-like toString() function, which returns the message.
    function toString( )
    {
            return $this->szMessage;
    }
}
?>

a

generator.php

<?php
header("Content-type: image/png");
$ip = $_GET["ip"]; 
$port = $_GET["port"];
$bg = $_GET["bg"];
require "samp_query.php";

$img = ImageCreateFrompng("./img/nic.png");
$bila = ImageColorAllocate($img, 255, 255, 255);
$modra = ImageColorAllocate($img, 0, 20, 255);
$cerna = ImageColorAllocate($img, 255, 0, 0);



if (!empty( $ip ) && !empty( $port ) && !empty( $bg ))
{  
  if($bg == "1")
   {
    $img = ImageCreateFrompng("./img/1.png");   
   }
   else if($bg == "2")
   {
    $img = ImageCreateFrompng("./img/2.png");
   }
   else if($bg == "3")
   {
    $img = ImageCreateFrompng("./img/3.png");
   }
   else if($bg == "4")
   {
    $img = ImageCreateFrompng("./img/4.gif");   
   }
   else if($bg == "5")
   {
      $img = ImageCreateFrompng("./img/5.png");
   }
   else if($bg == "6")
   {
      $img = ImageCreateFrompng("./img/6.png");
   }
   else if($bg == "7")
   {
      $img = ImageCreateFrompng("./img/7.png");
   }
   else if($bg == "8")
   {
      $img = ImageCreateFrompng("./img/8.png");
   }
  try
  {
    $rQuery = new QueryServer( $ip, $port );
    $aInformation  = $rQuery->GetInfo( );
    $aServerRules  = $rQuery->GetRules( );
    $aBasicPlayer  = $rQuery->GetPlayers( );
    $aTotalPlayers = $rQuery->GetDetailedPlayers( );
    $rQuery->Close( );
  }
  catch (QueryServerException $pError)
  { 
    ImageString($img, 3, 5, 5, "IP: $ip:$port", $cerna); 
    ImageString($img, 3, 5, 17, "Tento server není aktuálně zapnutý.", $cerna); 
  }
  if(isset($aInformation) && is_array($aInformation))
  {
      $hostname = $aInformation['Hostname'];
      $maxplayers = $aInformation['MaxPlayers'];
     $ping = $aInformation['Ping'];
     $players = $aInformation['Players'];
      $map = $aInformation['Map'];
     $gamemode = $aInformation['Gamemode'];
     $mapname = $aInformation['Map'];
     $verze = $aServerRules['version'];
     $pocasi = $aServerRules['weather'];
     $cas = $aServerRules['worldtime'];
     $gravity = $aServerRules['gravity'];
     $web = $aServerRules['weburl'];
     $pass = $aInformation['Password'] ? 'Zamčeno' : 'Odemčeno';
      //atd
      
     ImageString($img, 3, 10, 5, "$hostname", $bila);
     
     ImageString($img, 3, 10, 20, "Gamemode:", $modra);
     ImageString($img, 3, 80, 20, "$gamemode", $bila);
     ImageString($img, 3, 10, 35, "Mapname:", $modra);
     ImageString($img, 3, 80, 35, "$mapname", $bila);
     ImageString($img, 3, 10, 50, "Hráči:", $modra);
     ImageString($img, 3, 80, 50, "$players/$maxplayers", $bila);
     ImageString($img, 3, 10, 65, "IP:", $modra);
     ImageString($img, 3, 80, 65, "$ip:$port", $bila);
     ImageString($img, 3, 270, 20, "Počasí / Čas:", $modra);
     ImageString($img, 3, 370, 20, "$pocasi / $cas", $bila);
     ImageString($img, 3, 270, 35, "Verze:", $modra);
     ImageString($img, 3, 320, 35, "$verze", $bila);
     ImageString($img, 3, 270, 50, "Gravity:", $modra);
     ImageString($img, 3, 330, 50, "$gravity", $bila);
     ImageString($img, 3, 270, 65, "Web:", $modra);
     ImageString($img, 3, 310, 65, "$web", $bila);
     if($pass == 'Zamčeno')
     {
      ImageString($img, 3, 460, 5, "LOCK", $cerna);
     }
     
     
      
     
  }
}
else
{
  ImageString($img, 3, 5, 5, "Nevyplnil si port, adresu atd", $cerna);
}
imagepng($img);
imagedestroy($img);
?>

zde nevím, jak například.

Offline

#9 2013-05-02 16:54:24

Trade
Endora rádce
Místo: Česká republika
Registrován: 2013-01-22
Příspěvky: 3,596
Web

Re: Status Generátor

Už to tu bylo řešeno. Vytvořte si nějaký jiný script, který bude dávat výstup na portu 80 a potom ho propojíte se stránkou.


Kontaktujte nás | FAQ
Email: fk@endora.cz

Offline

#10 2013-05-02 18:17:03

JF
Endora rádce
Místo: ....nice u Plzně
Registrován: 2010-06-22
Příspěvky: 11,911

Re: Status Generátor

Prípadne si na servery kde máte danú hru vytvorte vlastné FTP, vygenerujte si výstup rovno na servery z hrou a potom ten obsah načítajte na svojej stránke.


Ján Fačkovec - Endora.cz by Webglobe
Email, Web, Webadmin, Webmail, Nápověda, Ceník

Offline

#11 2013-05-02 22:01:40

ruberninja1
Endora uživatel
Registrován: 2012-12-01
Příspěvky: 416

Re: Status Generátor

TO je také jedno z řešení, Děkuji JF.

Offline

Zápatí

Založeno na FluxBB | CZ a SK