diff --git a/system/libs/pot/OTS_InfoRespond.php b/system/libs/pot/OTS_InfoRespond.php index 6e452371..baea69e0 100644 --- a/system/libs/pot/OTS_InfoRespond.php +++ b/system/libs/pot/OTS_InfoRespond.php @@ -15,11 +15,11 @@ /** * Wrapper for 'info' respond's DOMDocument. - * + * *
* Note: as this class extends DOMDocument class and contains exacly respond XML tree you can work on it as on normal DOM tree. *
- * + * * @package POT * @version 0.1.0 * @property-read string $tspqVersion Root element version. @@ -48,252 +48,252 @@ class OTS_InfoRespond extends DOMDocument { /** * Returns version of root element. - * + * * @return string TSPQ version. * @throws DOMException On DOM operation error. */ - public function getTSPQVersion() - { - return $this->documentElement->getAttribute('version'); - } + public function getTSPQVersion() + { + return $this->documentElement->getAttribute('version'); + } /** * Returns server uptime. - * + * * @return int Uptime. * @throws DOMException On DOM operation error. */ - public function getUptime() - { - return (int) $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('uptime'); - } + public function getUptime() + { + return (int) $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('uptime'); + } /** * Returns server IP. - * + * * @return string IP. * @throws DOMException On DOM operation error. */ - public function getIP() - { - return $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('ip'); - } + public function getIP() + { + return $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('ip'); + } /** * Returns server name. - * + * * @return string Name. * @throws DOMException On DOM operation error. */ - public function getName() - { - return $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('servername'); - } + public function getName() + { + return $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('servername'); + } /** * Returns server port. - * + * * @return int Port. * @throws DOMException On DOM operation error. */ - public function getPort() - { - return (int) $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('port'); - } + public function getPort() + { + return (int) $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('port'); + } /** * Returns server location. - * + * * @return string Location. * @throws DOMException On DOM operation error. */ - public function getLocation() - { - return $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('location'); - } + public function getLocation() + { + return $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('location'); + } /** * Returns server website. - * + * * @return string Website URL. * @throws DOMException On DOM operation error. */ - public function getURL() - { - return $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('url'); - } + public function getURL() + { + return $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('url'); + } /** * Returns server attribute. - * + * * I have no idea what the hell is it representing :P. - * + * * @return string Attribute value. * @throws DOMException On DOM operation error. */ - public function getServer() - { - return $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('server'); - } + public function getServer() + { + return $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('server'); + } /** * Returns server version. - * + * * @return string Version. * @throws DOMException On DOM operation error. */ - public function getServerVersion() - { - return $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('version'); - } + public function getServerVersion() + { + return $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('version'); + } /** * Returns dedicated version of client. - * + * * @return string Version. * @throws DOMException On DOM operation error. */ - public function getClientVersion() - { - return $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('client'); - } + public function getClientVersion() + { + return $this->documentElement->getElementsByTagName('serverinfo')->item(0)->getAttribute('client'); + } /** * Returns owner name. - * + * * @return string Owner name. * @throws DOMException On DOM operation error. */ - public function getOwner() - { - return $this->documentElement->getElementsByTagName('owner')->item(0)->getAttribute('name'); - } + public function getOwner() + { + return $this->documentElement->getElementsByTagName('owner')->item(0)->getAttribute('name'); + } /** * Returns owner e-mail. - * + * * @return string Owner e-mail. * @throws DOMException On DOM operation error. */ - public function getEMail() - { - return $this->documentElement->getElementsByTagName('owner')->item(0)->getAttribute('email'); - } + public function getEMail() + { + return $this->documentElement->getElementsByTagName('owner')->item(0)->getAttribute('email'); + } /** * Returns current amount of players online. - * + * * @return int Count of players. * @throws DOMException On DOM operation error. */ - public function getOnlinePlayers() - { - return (int) $this->documentElement->getElementsByTagName('players')->item(0)->getAttribute('online'); - } + public function getOnlinePlayers() + { + return (int) $this->documentElement->getElementsByTagName('players')->item(0)->getAttribute('online'); + } /** * Returns maximum amount of players online. - * + * * @return int Maximum allowed count of players. * @throws DOMException On DOM operation error. */ - public function getMaxPlayers() - { - return (int) $this->documentElement->getElementsByTagName('players')->item(0)->getAttribute('max'); - } + public function getMaxPlayers() + { + return (int) $this->documentElement->getElementsByTagName('players')->item(0)->getAttribute('max'); + } /** * Returns record of online players. - * + * * @return int Players online record. * @throws DOMException On DOM operation error. */ - public function getPlayersPeak() - { - return (int) $this->documentElement->getElementsByTagName('players')->item(0)->getAttribute('peak'); - } + public function getPlayersPeak() + { + return (int) $this->documentElement->getElementsByTagName('players')->item(0)->getAttribute('peak'); + } /** * Returns number of all monsters on map. - * + * * @return int Count of monsters. * @throws DOMException On DOM operation error. */ - public function getMonstersCount() - { - return (int) $this->documentElement->getElementsByTagName('monsters')->item(0)->getAttribute('total'); - } + public function getMonstersCount() + { + return (int) $this->documentElement->getElementsByTagName('monsters')->item(0)->getAttribute('total'); + } /** * Returns map name. - * + * * @return string Map name. * @throws DOMException On DOM operation error. */ - public function getMapName() - { - return $this->documentElement->getElementsByTagName('map')->item(0)->getAttribute('name'); - } + public function getMapName() + { + return $this->documentElement->getElementsByTagName('map')->item(0)->getAttribute('name'); + } /** * Returns map author. - * + * * @return string Mapper name. * @throws DOMException On DOM operation error. */ - public function getMapAuthor() - { - return $this->documentElement->getElementsByTagName('map')->item(0)->getAttribute('author'); - } + public function getMapAuthor() + { + return $this->documentElement->getElementsByTagName('map')->item(0)->getAttribute('author'); + } /** * Returns map width. - * + * * @return int Map width. * @throws DOMException On DOM operation error. */ - public function getMapWidth() - { - return (int) $this->documentElement->getElementsByTagName('map')->item(0)->getAttribute('width'); - } + public function getMapWidth() + { + return (int) $this->documentElement->getElementsByTagName('map')->item(0)->getAttribute('width'); + } /** * Returns map height. - * + * * @return int Map height. * @throws DOMException On DOM operation error. */ - public function getMapHeight() - { - return (int) $this->documentElement->getElementsByTagName('map')->item(0)->getAttribute('height'); - } + public function getMapHeight() + { + return (int) $this->documentElement->getElementsByTagName('map')->item(0)->getAttribute('height'); + } /** * Returns server's Message Of The Day - * + * * @version 0.1.0 * @return string Server MOTD. * @throws DOMException On DOM operation error. */ - public function getMOTD() - { - // look for text node child - foreach( $this->documentElement->getElementsByTagName('motd')->item(0)->childNodes as $child) - { - if($child->nodeType == XML_TEXT_NODE) - { - // found - return $child->nodeValue; - } - } + public function getMOTD() + { + // look for text node child + foreach( $this->documentElement->getElementsByTagName('motd')->item(0)->childNodes as $child) + { + if($child->nodeType == XML_TEXT_NODE) + { + // found + return $child->nodeValue; + } + } - // strange... - return ''; - } + // strange... + return ''; + } /** * Magic PHP5 method. - * + * * @version 0.1.0 * @since 0.1.0 * @param string $name Property name. @@ -301,89 +301,89 @@ class OTS_InfoRespond extends DOMDocument * @throws OutOfBoundsException For non-supported properties. * @throws DOMException On DOM operation error. */ - public function __get($name) - { - switch($name) - { - case 'tspqVersion': - return $this->getTSPQVersion(); + public function __get($name) + { + switch($name) + { + case 'tspqVersion': + return $this->getTSPQVersion(); - case 'uptime': - return $this->getUptime(); + case 'uptime': + return $this->getUptime(); - case 'ip': - return $this->getIP(); + case 'ip': + return $this->getIP(); - case 'name': - return $this->getName(); + case 'name': + return $this->getName(); - case 'port': - return $this->getPort(); + case 'port': + return $this->getPort(); - case 'location': - return $this->getLocation(); + case 'location': + return $this->getLocation(); - case 'url': - return $this->getURL(); + case 'url': + return $this->getURL(); - case 'server': - return $this->getServer(); + case 'server': + return $this->getServer(); - case 'serverVersion': - return $this->getServerVersion(); + case 'serverVersion': + return $this->getServerVersion(); - case 'clientVersion': - return $this->getClientVersion(); + case 'clientVersion': + return $this->getClientVersion(); - case 'owner': - return $this->getOwner(); + case 'owner': + return $this->getOwner(); - case 'eMail': - return $this->getEMail(); + case 'eMail': + return $this->getEMail(); - case 'onlinePlayers': - return $this->getOnlinePlayers(); + case 'onlinePlayers': + return $this->getOnlinePlayers(); - case 'maxPlayers': - return $this->getMaxPlayers(); + case 'maxPlayers': + return $this->getMaxPlayers(); - case 'playersPeak': - return $this->getPlayersPeak(); + case 'playersPeak': + return $this->getPlayersPeak(); - case 'monstersCount': - return $this->getMonstersCount(); + case 'monstersCount': + return $this->getMonstersCount(); - case 'mapName': - return $this->getMapName(); + case 'mapName': + return $this->getMapName(); - case 'mapAuthor': - return $this->getMapAuthor(); + case 'mapAuthor': + return $this->getMapAuthor(); - case 'mapWidth': - return $this->getMapWidth(); + case 'mapWidth': + return $this->getMapWidth(); - case 'mapHeight': - return $this->getMapHeight(); + case 'mapHeight': + return $this->getMapHeight(); - case 'motd': - return $this->getMOTD(); + case 'motd': + return $this->getMOTD(); - default: - throw new OutOfBoundsException(); - } - } + default: + throw new OutOfBoundsException(); + } + } /** * Returns string representation of XML. - * + * * @version 0.1.0 * @since 0.1.0 * @return string String representation of object. */ - public function __toString() - { - return $this->saveXML(); - } + public function __toString() + { + return $this->saveXML(); + } } /**#@-*/ diff --git a/system/libs/pot/OTS_ServerStatus.php b/system/libs/pot/OTS_ServerStatus.php index e13a0f5b..4ba0035c 100644 --- a/system/libs/pot/OTS_ServerStatus.php +++ b/system/libs/pot/OTS_ServerStatus.php @@ -40,175 +40,175 @@ class OTS_ServerStatus /** * Basic server info. */ - const REQUEST_BASIC_SERVER_INFO = 1; + const REQUEST_BASIC_SERVER_INFO = 1; /** * Server owner info. */ - const REQUEST_OWNER_SERVER_INFO = 2; + const REQUEST_OWNER_SERVER_INFO = 2; /** * Server extra info. */ - const REQUEST_MISC_SERVER_INFO = 4; + const REQUEST_MISC_SERVER_INFO = 4; /** * Players stats info. */ - const REQUEST_PLAYERS_INFO = 8; + const REQUEST_PLAYERS_INFO = 8; /** * Map info. */ - const REQUEST_MAP_INFO = 16; + const REQUEST_MAP_INFO = 16; /** * Extended players info. */ - const REQUEST_EXT_PLAYERS_INFO = 32; + const REQUEST_EXT_PLAYERS_INFO = 32; /** * Player status info. */ - const REQUEST_PLAYER_STATUS_INFO = 64; + const REQUEST_PLAYER_STATUS_INFO = 64; /** * Server software info. */ - const REQUEST_SERVER_SOFTWARE_INFO = 128; + const REQUEST_SERVER_SOFTWARE_INFO = 128; /** * Basic server respond. */ - const RESPOND_BASIC_SERVER_INFO = 0x10; + const RESPOND_BASIC_SERVER_INFO = 0x10; /** * Server owner respond. */ - const RESPOND_OWNER_SERVER_INFO = 0x11; + const RESPOND_OWNER_SERVER_INFO = 0x11; /** * Server extra respond. */ - const RESPOND_MISC_SERVER_INFO = 0x12; + const RESPOND_MISC_SERVER_INFO = 0x12; /** * Players stats respond. */ - const RESPOND_PLAYERS_INFO = 0x20; + const RESPOND_PLAYERS_INFO = 0x20; /** * Map respond. */ - const RESPOND_MAP_INFO = 0x30; + const RESPOND_MAP_INFO = 0x30; /** * Extended players info. */ - const RESPOND_EXT_PLAYERS_INFO = 0x21; + const RESPOND_EXT_PLAYERS_INFO = 0x21; /** * Player status info. */ - const RESPOND_PLAYER_STATUS_INFO = 0x22; + const RESPOND_PLAYER_STATUS_INFO = 0x22; /** * Server software info. */ - const RESPOND_SERVER_SOFTWARE_INFO = 0x23; + const RESPOND_SERVER_SOFTWARE_INFO = 0x23; /** * Server name. * * @var string */ - private $name; + private $name; /** * Server IP. * * @var string */ - private $ip; + private $ip; /** * Server port. * * @var string */ - private $port; + private $port; /** * Owner name. * * @var string */ - private $owner; + private $owner; /** * Owner's e-mail. * * @var string */ - private $eMail; + private $eMail; /** * Message of the day. * * @var string */ - private $motd; + private $motd; /** * Server location. * * @var string */ - private $location; + private $location; /** * Website URL. * * @var string */ - private $url; + private $url; /** * Uptime. * * @var int */ - private $uptime; + private $uptime; /** * Status version. * * @var string */ - private $version; + private $version; /** * Players online. * * @var int */ - private $online; + private $online; /** * Maximum players. * * @var int */ - private $max; + private $max; /** * Players peak. * * @var int */ - private $peak; + private $peak; /** * Map name. * * @var string */ - private $map; + private $map; /** * Map author. * * @var string */ - private $author; + private $author; /** * Map width. * * @var int */ - private $width; + private $width; /** * Map height. * * @var int */ - private $height; + private $height; /** * Players online list. * * @var array */ - private $players = array(); + private $players = array(); /** * Server software. @@ -224,277 +224,277 @@ class OTS_ServerStatus * * @param OTS_Buffer $info Information packet. */ - public function __construct(OTS_Buffer $info) - { - // skips packet length - $info->getShort(); + public function __construct(OTS_Buffer $info) + { + // skips packet length + $info->getShort(); - while( $info->isValid() ) - { - switch( $info->getChar() ) - { - case self::RESPOND_BASIC_SERVER_INFO: - $this->name = $info->getString(); - $this->ip = $info->getString(); - $this->port = (int) $info->getString(); - break; + while( $info->isValid() ) + { + switch( $info->getChar() ) + { + case self::RESPOND_BASIC_SERVER_INFO: + $this->name = $info->getString(); + $this->ip = $info->getString(); + $this->port = (int) $info->getString(); + break; - case self::RESPOND_OWNER_SERVER_INFO: - $this->owner = $info->getString(); - $this->eMail = $info->getString(); - break; + case self::RESPOND_OWNER_SERVER_INFO: + $this->owner = $info->getString(); + $this->eMail = $info->getString(); + break; - case self::RESPOND_MISC_SERVER_INFO: - $this->motd = $info->getString(); - $this->location = $info->getString(); - $this->url = $info->getString(); + case self::RESPOND_MISC_SERVER_INFO: + $this->motd = $info->getString(); + $this->location = $info->getString(); + $this->url = $info->getString(); - $uptime = $info->getLong() << 32; + $uptime = $info->getLong() << 32; - $this->uptime += $info->getLong() + $uptime; - $this->version = $info->getString(); - break; + $this->uptime += $info->getLong() + $uptime; + $this->version = $info->getString(); + break; - case self::RESPOND_PLAYERS_INFO: - $this->online = $info->getLong(); - $this->max = $info->getLong(); - $this->peak = $info->getLong(); - break; + case self::RESPOND_PLAYERS_INFO: + $this->online = $info->getLong(); + $this->max = $info->getLong(); + $this->peak = $info->getLong(); + break; - case self::RESPOND_MAP_INFO: - $this->map = $info->getString(); - $this->author = $info->getString(); - $this->width = $info->getShort(); - $this->height = $info->getShort(); - break; + case self::RESPOND_MAP_INFO: + $this->map = $info->getString(); + $this->author = $info->getString(); + $this->width = $info->getShort(); + $this->height = $info->getShort(); + break; - case self::RESPOND_EXT_PLAYERS_INFO: - $count = $info->getLong(); + case self::RESPOND_EXT_PLAYERS_INFO: + $count = $info->getLong(); - for($i = 0; $i < $count; $i++) - { - $name = $info->getString(); - $this->players[$name] = $info->getLong(); - } - break; + for($i = 0; $i < $count; $i++) + { + $name = $info->getString(); + $this->players[$name] = $info->getLong(); + } + break; case self::RESPOND_SERVER_SOFTWARE_INFO: $this->softwareName = $info->getString(); $this->softwareVersion = $info->getString(); $this->softwareProtocol = $info->getString(); break; - } - } - } + } + } + } /** * Returns server uptime. * * @return int Uptime. */ - public function getUptime() - { - return $this->uptime; - } + public function getUptime() + { + return $this->uptime; + } /** * Returns server IP. * * @return string IP. */ - public function getIP() - { - return $this->ip; - } + public function getIP() + { + return $this->ip; + } /** * Returns server name. * * @return string Name. */ - public function getName() - { - return $this->name; - } + public function getName() + { + return $this->name; + } /** * Returns server port. * * @return int Port. */ - public function getPort() - { - return $this->port; - } + public function getPort() + { + return $this->port; + } /** * Returns server location. * * @return string Location. */ - public function getLocation() - { - return $this->location; - } + public function getLocation() + { + return $this->location; + } /** * Returns server website. * * @return string Website URL. */ - public function getURL() - { - return $this->url; - } + public function getURL() + { + return $this->url; + } /** * Returns server version. * * @return string Version. */ - public function getServerVersion() - { - return $this->version; - } + public function getServerVersion() + { + return $this->version; + } /** * Returns owner name. * * @return string Owner name. */ - public function getOwner() - { - return $this->owner; - } + public function getOwner() + { + return $this->owner; + } /** * Returns owner e-mail. * * @return string Owner e-mail. */ - public function getEMail() - { - return $this->eMail; - } + public function getEMail() + { + return $this->eMail; + } /** * Returns current amount of players online. * * @return int Count of players. */ - public function getOnlinePlayers() - { - return $this->online; - } + public function getOnlinePlayers() + { + return $this->online; + } /** * Returns maximum amount of players online. * * @return int Maximum allowed count of players. */ - public function getMaxPlayers() - { - return $this->max; - } + public function getMaxPlayers() + { + return $this->max; + } /** * Returns record of online players. * * @return int Players online record. */ - public function getPlayersPeak() - { - return $this->peak; - } + public function getPlayersPeak() + { + return $this->peak; + } /** * Returns map name. * * @return string Map name. */ - public function getMapName() - { - return $this->map; - } + public function getMapName() + { + return $this->map; + } /** * Returns map author. * * @return string Mapper name. */ - public function getMapAuthor() - { - return $this->author; - } + public function getMapAuthor() + { + return $this->author; + } /** * Returns map width. * * @return int Map width. */ - public function getMapWidth() - { - return $this->width; - } + public function getMapWidth() + { + return $this->width; + } /** * Returns map height. * * @return int Map height. */ - public function getMapHeight() - { - return $this->height; - } + public function getMapHeight() + { + return $this->height; + } /** * Returns server's Message Of The Day * * @return string Server MOTD. */ - public function getMOTD() - { - return $this->motd; - } + public function getMOTD() + { + return $this->motd; + } /** * Returns list of players currently online. * * @return array List of players in format 'name' => level. */ - public function getPlayers() - { - } + public function getPlayers() + { + } /** * Returns software name. * * @return string Software name. */ - public function getSoftwareName() - { - return $this->softwareName; - } + public function getSoftwareName() + { + return $this->softwareName; + } /** * Returns software version. * * @return string Software version. */ - public function getSoftwareVersion() - { - return $this->softwareVersion; - } + public function getSoftwareVersion() + { + return $this->softwareVersion; + } /** * Returns software protocol. * * @return string Software protocol. */ - public function getSoftwareProtocol() - { - return $this->softwareProtocol; - } + public function getSoftwareProtocol() + { + return $this->softwareProtocol; + } /** * Magic PHP5 method. @@ -503,68 +503,68 @@ class OTS_ServerStatus * @return mixed Property value. * @throws OutOfBoundsException For non-supported properties. */ - public function __get($name) - { - switch($name) - { - case 'uptime': - return $this->getUptime(); + public function __get($name) + { + switch($name) + { + case 'uptime': + return $this->getUptime(); - case 'ip': - return $this->getIP(); + case 'ip': + return $this->getIP(); - case 'name': - return $this->getName(); + case 'name': + return $this->getName(); - case 'port': - return $this->getPort(); + case 'port': + return $this->getPort(); - case 'location': - return $this->getLocation(); + case 'location': + return $this->getLocation(); - case 'url': - return $this->getURL(); + case 'url': + return $this->getURL(); - case 'serverVersion': - return $this->getServerVersion(); + case 'serverVersion': + return $this->getServerVersion(); - case 'owner': - return $this->getOwner(); + case 'owner': + return $this->getOwner(); - case 'eMail': - return $this->getEMail(); + case 'eMail': + return $this->getEMail(); - case 'onlinePlayers': - return $this->getOnlinePlayers(); + case 'onlinePlayers': + return $this->getOnlinePlayers(); - case 'maxPlayers': - return $this->getMaxPlayers(); + case 'maxPlayers': + return $this->getMaxPlayers(); - case 'playersPeak': - return $this->getPlayersPeak(); + case 'playersPeak': + return $this->getPlayersPeak(); - case 'mapName': - return $this->getMapName(); + case 'mapName': + return $this->getMapName(); - case 'mapAuthor': - return $this->getMapAuthor(); + case 'mapAuthor': + return $this->getMapAuthor(); - case 'mapWidth': - return $this->getMapWidth(); + case 'mapWidth': + return $this->getMapWidth(); - case 'mapHeight': - return $this->getMapHeight(); + case 'mapHeight': + return $this->getMapHeight(); - case 'motd': - return $this->getMOTD(); + case 'motd': + return $this->getMOTD(); - case 'players': - return $this->getPlayers(); + case 'players': + return $this->getPlayers(); - default: - throw new OutOfBoundsException(); - } - } + default: + throw new OutOfBoundsException(); + } + } } /**#@-*/