Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Stats
- {
- private $Host;
- private $Socket;
- private $Is_online;
- private $Data;
- private $Version;
- private $Motd;
- private $Players_online;
- private $Slots;
- public function Connect($server){
- $this->Host = explode(':',$server);
- $this->Socket = @fsockopen($this->Host[0], $this->Host[1], $errno, $errstr, 1);
- //Stream_Set_Timeout( $this->Socket, $Timeout );
- //Stream_Set_Blocking( $this->Socket, true );
- if( $errno || $this->Socket === false )
- {
- return false;
- }
- else{
- return true;
- fwrite($this->Socket, "\xFE\x01");
- $this->Data = fread($this->Socket, 1024);
- if ($this->Data != false AND substr($this->Data, 0, 1) == "\xFF") {
- $this->Data = substr($this->Data, 3);
- $this->Data = mb_convert_encoding($this->Data, 'auto', 'UCS-2');
- $this->Data = explode("\x00", $this->Data);
- fclose($this->Socket);
- }
- }
- }
- public function Version()
- {
- return $this->Version = $this->Data[2];
- }
- public function Motd()
- {
- return $this->Motd = $this->Data[3];
- }
- public function Players_online()
- {
- return $this->Players_online = $this->Data[4];
- }
- public function Slots()
- {
- return $this->Slots = $this->Data[5];
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment