Navigacija

Vartotojų tinkle

Prisijungusių svečių: 34
Prisijungusių narių: 0
Prisijungusių narių nėra

Registruoti nariai: 25,952
Naujausias narys: tomeem

Naujausi straipsniai

Paskutiniai nariai

asirija 3 savaitės
tomeem 5 savaitės
Reikalas 6 savaitės
weberiz 8 savaitės
mRokass11 savaitės
kartoonas12 savaitės
iaescortsmap12 savaitės
ozzWANTED13 savaitės
grunskiz14 savaitės
Bruksnys15 savaitės
illusion15 savaitės
ordo16 savaitės
Jurgaila17 savaitės
originalcs1617 savaitės
Rytis17 savaitės
halis19 savaitės
junkus22 savaitės
morlis22 savaitės
Majakas23 savaitės
andsoft24 savaitės

Informacija:


OS: Unknown
Naršyklė: Nežinoma
IP: 3.145.169.78
Naujienų: 529
Straipsnių: 235
Temų: 52,585
Postų: 522,523
Postų pask. parą: 0
Shout'ų pask. parą: 0
P.S.C. pask. parą: 0
Nuorodų kataloge: 13

Lankomumo Statistika

Peržiūrų šiandien: 22

Iš viso peržiūrų: 22948724

Prisijungti

REGISTRUOTIS
Nario vardas

Slaptažodis



Pamiršai slaptažodį?
Paprašyk naujo

Aktyvuoti save

Šaukykla

Jei norite rašyti žinutes, turite prisijungti.

ozzWANTED
2024 Sau. 17 01:01:00
Desperatiškus komentarus šaukykloje su accountu po mėnesio prasibuvimo, ištryniau. Pasaulis ir taip juodas. Įjungiam šviesą, prašviesės. šypsosi

Majakas
2023 Gru. 10 19:12:39
Negaliu patikėti jog žinutės/pranešimai visi yra nuo 2008 m akinanti šypsen

Žmogus
2023 Rugs. 7 21:09:14
O gal BloodKiller pasijungs?

Apocal
2023 Rugs. 2 18:09:23
Nu davai nuveikiam kažką akinanti šypsen. Prisijungti kada visi čia akinanti šypsen.

Apocal
2023 Rugs. 2 00:09:18
Šiaip atėjau pažiūrėti ar dar lopas nesby yra ar koks ten buvo.

Šaukyklos archyvas

Apklausa

Ar esate patenkinti lietuviško vertimo kokybe?

Taip!

Taip, bet yra ką taisyti (parašysiu komentaruose)

Ne

Norėdamas balsuoti turite prisijungti.
Archyvas
Reklama 400x60
del php kodo
Forumas | PHP-Fusion, WordPress, Shopify, PHP ir MySQL (PROGRAMAVIMAS) | Kitos TVS

Autorius: GooUn Peržiūrų: 1112      Spausdinti temą
2008 Lap. 7 20:11:28          1 žinutė iš 3
Spausdinti pranešimą
Kas galetu si koda pritaikyti phpbb2

/*
 *
 * SA:MP Query Script
 * by delux himself
 *
 * make sure to buy your server at delux-host.com
 *
 */

// Server to query
$sConfig['ip'] = "86.100.95.94";
$serverConf['port'] = 8888;

// Query Server classes by the SA:MP team or someone else
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, 100000 );
       $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'    =>   ord( fread( $this->rSocketID, 2 ) ),
          'MaxPlayers' =>   ord( 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'   =>  ord( fread( $this->rSocketID, 1 ) ),
             'Nickname'   =>  $this->GetPacket( 1 ),
             'Score'      =>  $this->toInteger( fread( $this->rSocketID, 4 ) ),
             'Ping'       =>  ord( fread( $this->rSocketID, 4 ) )
          );
       }
       
       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;
    }
 }

// ##################################################################################
 
// Display server type specific info on status screen
$serverIp = $sConfig['ip'] . ":" . $serverConf['port'];

// Status herausfinden

try {
   $rQuery = new QueryServer( $sConfig['ip'], $serverConf['port'] );
   // $rQuery = new QueryServer( "87.230.89.21", 8002 );
   
   $aInformation  = $rQuery->GetInfo( );
   $aServerRules  = $rQuery->GetRules( );
   // $aBasicPlayer  = $rQuery->GetPlayers( );
   $aTotalPlayers = $rQuery->GetDetailedPlayers( );
   
   $rQuery->Close( );
   
   // $return .= $aInformation . "<hr />";
   
   $serverState = true;
}
catch (QueryServerException $pError) {
   // $return .= $pError->toString( ) . "<hr />";
   
   $serverState = false;
}

if ($serverState == true) {
   echo "<table border=\"0\">";
      echo "<tr>";
         echo "<td>";
            echo "Hostname";
         echo "</td><td>";
            echo "<a href=\"samp://" . $serverIp . "\">" . $aInformation['Hostname'] . "</a>";
         echo "</td>";
      echo "</tr><tr>";
         echo "<td>";
            echo "IP";
         echo "</td><td>";
            echo "<a href=\"samp://" . $serverIp . "\">" . $serverIp . "</a>";
         echo "</td>";
      echo "</tr><tr>";
         echo "<td valign=\"top\">";
            echo "Players";
         echo "</td><td valign=\"top\">";
            echo $aInformation['Players'] . "/" . $aInformation['MaxPlayers'];
            if ($aInformation['Players'] > 0) {
               echo "<table border=\"0\">";
                  echo "<tr>";
                     echo "<th>ID</th><th>Nickname</th><th>Score</th><th>Ping</th>";
                  echo "</tr>";
                  foreach( $aTotalPlayers as $aPlayer ) {
                     echo "<tr>";
                        echo "<td>" . $aPlayer['PlayerID'] . "</td>";
                        echo "<td>" . $aPlayer['Nickname'] . "</td>";
                        echo "<td>" . $aPlayer['Score'] . "</td>";
                        echo "<td>" . $aPlayer['Ping'] . "</td>";
                     echo "</tr>";
                  }
               echo "</table>";
            }
         echo "</td>";
      echo "</tr>";
   echo "</table>";
}
else {
   echo "Server offline - buy a delux one next time";
}
?>





Redagavo GooUn 2008 Lap. 7 20:11:28
2008 Lap. 7 20:11:49          2 žinutė iš 3
Spausdinti pranešimą
Smailus off

2008 Lap. 7 21:11:38          3 žinutė iš 3
Spausdinti pranešimą
jau off gal padesit

Alio


Redagavo GooUn 2008 Lap. 7 22:11:01
Peršokti į forumą: