POT
POT
POT
Main menu

Download

Forum

SVN

Class: OTS_Admin

Source Location: /classes/OTS_Admin.php

Class OTS_Admin

Class Overview

OTAdmin protocol client.

OTAdmin protocol client.

Located in /classes/OTS_Admin.php [line 32]



		
				Author(s):
		
API Tags:
Property-read:  bool $requiresLogin: requiresLogin() wrapper.
Property-read:  bool $requiresEncryption: requiresEncryption() wrapper.
Property-read:  bool $usesRSA1024XTEA: usesRSA1024XTEA() wrapper.
Property-read:  int $ping: Ping time.
Property-write:  string $login: Logs in with given password.
Property-write:  string $broadcast: Sends given broadcast message.
Property-write:  string $kick: Kicks player with given name from server.
Example:  save.php
Example:  admin.php

Information Tags:
Tutorial:  OTAdmin client
Version:  0.1.6
Version:  0.1.2
Since:  0.1.2

Methods

[ Top ]
Constant Summary
COMMAND_BAN_MANAGER   Not supported in current OTAdmin imlpementation.
COMMAND_BROADCAST   Broadcast message.
COMMAND_CLOSE_SERVER   Closes server.
COMMAND_GETHOUSE   Not supported in current OTAdmin imlpementation.
COMMAND_GETONLINE   Not supported in current OTAdmin imlpementation.
COMMAND_KICK   Not supported in current OTAdmin imlpementation.
COMMAND_OPEN_SERVER   Opens server for players.
COMMAND_PAY_HOUSES   Pays all rented shouses.
COMMAND_PLAYER_INFO   Not supported in current OTAdmin imlpementation.
COMMAND_RELOAD_SCRIPTS   Not supported in current OTAdmin imlpementation.
COMMAND_SAVE_SERVER   Calls server save.
COMMAND_SERVER_INFO   Not supported in current OTAdmin imlpementation.
COMMAND_SHUTDOWN_SERVER   Shutdowns the server.
ENCRYPTION_RSA1024XTEA   Server uses XTEA encryption, XTEA key is being sent in 1024bit RSA encrypted packet.
REQUEST_COMMAND   OTAdmin commnd.
REQUEST_ENCRYPTION   Encryption packet.
REQUEST_KEY_EXCHANGE   RSA key exchange.
REQUEST_LOGIN   User login.
REQUEST_PING   Ping.
REQUIRE_ENCRYPTION   Server requires encryption.
REQUIRE_LOGIN   Server requires login.
RESPOND_COMMAND_FAILED   Command failed.
RESPOND_COMMAND_OK   Command success.
RESPOND_ENCRYPTION_FAILED   Encryption initialization failed.
RESPOND_ENCRYPTION_OK   Encryption initialization success.
RESPOND_ERROR   Error.
RESPOND_HELLO   Hello respond.
RESPOND_KEY_EXCHANGE_FAILED   Keys exchange failed.
RESPOND_KEY_EXCHANGE_OK   Keys exchange success.
RESPOND_LOGIN_FAILED   Login incorrect.
RESPOND_LOGIN_OK   Login success.
RESPOND_MESSAGE   Message.
RESPOND_PING_OK   Ping success.

[ Top ]
Method Summary
static void   __set_state()   Magic PHP5 method.
void   broadcast()   Sends COMMAND_BROADCAST command with given parameter.
void   close()   Sends COMMAND_CLOSE_SERVER command.
void   kick()   Sends COMMAND_KICK command with given parameter.
void   login()   Logs into server.
void   open()   Sends COMMAND_OPEN_SERVER command.
void   payHouses()   Sends COMMAND_PAY_HOUSES command.
int   ping()   Ping command.
bool   requiresEncryption()   Checks if protocol requires encryption.
bool   requiresLogin()   Checks if protocol requires login.
OTS_Admin   __construct()   Creates new connection to OTServ administration backend.
void   __destruct()   Closes connection.
void   save()   Sends COMMAND_SAVE_SERVER command.
OTS_Buffer   send()   Sends OTAdmin packet.
void   shutdown()   Sends COMMAND_SHUTDOWN_SERVER command.
bool   usesRSA1024XTEA()   Checks if protocol requires XTEA encryption with RSA-encrypted key.
void   __clone()   Magic PHP5 method.
void   __get()   Magic PHP5 method.
void   __set()   Magic PHP5 method.
array   __sleep()   Magic PHP5 method.
void   __wakeup()   Magic PHP5 method.

[ Top ]
Methods
static method __set_state  [line 719]

  static void __set_state( array $properties  )

Magic PHP5 method.

Magic PHP5 method. Allows object importing from var_export().

Parameters:
array   $properties:  List of object properties.

API Tags:
Access:  public

Information Tags:
Version:  0.1.2
Throws:  E_OTS_ErrorCode When receive failed respond or unexpected message.
Throws:  E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
Since:  0.1.2

[ Top ]
broadcast  [line 583]

  void broadcast( string $message  )

Sends COMMAND_BROADCAST command with given parameter.

Sends COMMAND_BROADCAST command with given parameter. Sends broadcast message to all players.

Parameters:
string   $message:  Broadcast to be sent.

API Tags:
Access:  public

Information Tags:
Version:  0.1.2
Throws:  E_OTS_ErrorCode If failure respond received.
Throws:  E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
Since:  0.1.2

[ Top ]
close  [line 622]

  void close( )

Sends COMMAND_CLOSE_SERVER command.

Sends COMMAND_CLOSE_SERVER command. Closes server. This command closes server for connections to enable maintenance but doesn't shut it down.


API Tags:
Access:  public

Information Tags:
Version:  0.1.2
Throws:  E_OTS_ErrorCode If failure respond received.
Throws:  E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
Since:  0.1.2

[ Top ]
kick  [line 679]

  void kick( string $name  )

Sends COMMAND_KICK command with given parameter.

Sends COMMAND_KICK command with given parameter. Kicks given player from server.

Parameters:
string   $name:  Name of player to be kicked.

API Tags:
Access:  public

Information Tags:
Version:  0.1.4
Version:  0.1.2
Throws:  E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
Throws:  E_OTS_ErrorCode If failure respond received.
Since:  0.1.2
Since:  0.1.4

[ Top ]
login  [line 484]

  void login( string $password  )

Logs into server.

Logs into server. Call this method if after connection is established login required flag is set.

Parameters:
string   $password:  Admin password.

API Tags:
Access:  public

Information Tags:
Version:  0.1.2
Throws:  E_OTS_ErrorCode When receive failed respond or unexpected message.
Throws:  E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
Since:  0.1.2

[ Top ]
open  [line 604]

  void open( )

Sends COMMAND_OPEN_SERVER command.

Sends COMMAND_OPEN_SERVER command. Opens server. This command enables server for connections.


API Tags:
Access:  public

Information Tags:
Version:  0.1.6
Version:  0.1.2
Throws:  E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
Throws:  E_OTS_ErrorCode If failure respond received.
Since:  0.1.2
Since:  0.1.6

[ Top ]
payHouses  [line 640]

  void payHouses( )

Sends COMMAND_PAY_HOUSES command.

Sends COMMAND_PAY_HOUSES command. Takes fees for all rented houses.


API Tags:
Access:  public

Information Tags:
Version:  0.1.2
Throws:  E_OTS_ErrorCode If failure respond received.
Throws:  E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
Since:  0.1.2

[ Top ]
ping  [line 514]

  int ping( )

Ping command.

Ping command. Note: This methods calculates ping time based on OTS_Admin::send() sub-call. This means ping time will be time used for entire seding operation including packet encryption, packing, unpacking and decryption.


API Tags:
Return:  Ping time.
Access:  public

Information Tags:
Version:  0.1.2
Throws:  E_OTS_ErrorCode When receive failed respond or unexpected message.
Throws:  E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
Since:  0.1.2

[ Top ]
requiresEncryption  [line 340]

  bool requiresEncryption( )

Checks if protocol requires encryption.

Checks if protocol requires encryption.


API Tags:
Return:  True if protocol requires encryption.
Access:  public

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
requiresLogin  [line 330]

  bool requiresLogin( )

Checks if protocol requires login.

Checks if protocol requires login.


API Tags:
Return:  True if protocol requires user login.
Access:  public

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
Constructor __construct  [line 232]

  OTS_Admin __construct( string $host, [int $port = 7171]  )

Creates new connection to OTServ administration backend.

Creates new connection to OTServ administration backend. This method automaticly handles RSA and XTEA encryption if such method is required by server including keys negotiations.

After connecting you should check if server requires login.

Parameters:
string   $host:  Target server.
int   $port:  Port (7171 by default).

API Tags:
Access:  public

Information Tags:
Version:  0.1.2
Throws:  E_OTS_ErrorCode When receive failed respond or unexpected message.
Throws:  E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
Since:  0.1.2

[ Top ]
Destructor __destruct  [line 404]

  void __destruct( )

Closes connection.

Closes connection.


API Tags:
Access:  public

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
save  [line 700]

  void save( )

Sends COMMAND_SAVE_SERVER command.

Sends COMMAND_SAVE_SERVER command. Proceeds server save.


API Tags:
Access:  public

Information Tags:
Version:  0.1.6
Version:  0.1.2
Throws:  E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
Throws:  E_OTS_ErrorCode If failure respond received.
Since:  0.1.2
Since:  0.1.6

[ Top ]
send  [line 363]

  OTS_Buffer send( OTS_Buffer $message  )

Sends OTAdmin packet.

Sends OTAdmin packet.

Parameters:
OTS_Buffer   $message:  Packet to be sent.

API Tags:
Return:  Server respond.
Access:  public

Information Tags:
Version:  0.1.2
Throws:  E_OTS_ErrorCode When receive RESPOND_ERROR message.
Throws:  E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
Since:  0.1.2

[ Top ]
shutdown  [line 658]

  void shutdown( )

Sends COMMAND_SHUTDOWN_SERVER command.

Sends COMMAND_SHUTDOWN_SERVER command. Shutdowns server. This command closes server thread.


API Tags:
Access:  public

Information Tags:
Version:  0.1.2
Throws:  E_OTS_ErrorCode If failure respond received.
Throws:  E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
Since:  0.1.2

[ Top ]
usesRSA1024XTEA  [line 350]

  bool usesRSA1024XTEA( )

Checks if protocol requires XTEA encryption with RSA-encrypted key.

Checks if protocol requires XTEA encryption with RSA-encrypted key.


API Tags:
Return:  True if protocol requires that encryption.
Access:  public

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
__clone  [line 734]

  void __clone( )

Magic PHP5 method.

Magic PHP5 method. Creates new socket connection to server.


API Tags:
Access:  public

Information Tags:
Version:  0.1.2
Throws:  E_OTS_ErrorCode When receive failed respond or unexpected message.
Throws:  E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
Since:  0.1.2

[ Top ]
__get  [line 420]

  void __get( string $name, mixed $value  )

Magic PHP5 method.

Magic PHP5 method.

Parameters:
string   $name:  Property name.
mixed   $value:  Property value.

API Tags:
Access:  public

Information Tags:
Version:  0.1.3
Version:  0.1.2
Throws:  E_OTS_ErrorCode When receive failed respond or unexpected message.
Throws:  OutOfBoundsException For non-supported properties.
Since:  0.1.2
Throws:  E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
Since:  0.1.3

[ Top ]
__set  [line 452]

  void __set( string $name, mixed $value  )

Magic PHP5 method.

Magic PHP5 method.

Parameters:
string   $name:  Property name.
mixed   $value:  Property value.

API Tags:
Access:  public

Information Tags:
Version:  0.1.4
Version:  0.1.2
Throws:  E_OTS_ErrorCode When receive failed respond or unexpected message.
Throws:  OutOfBoundsException For non-supported properties.
Since:  0.1.2
Throws:  E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
Since:  0.1.3

[ Top ]
__sleep  [line 748]

  array __sleep( )

Magic PHP5 method.

Magic PHP5 method. Allows object serialisation.


API Tags:
Return:  List of properties that should be saved.
Access:  public

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
__wakeup  [line 763]

  void __wakeup( )

Magic PHP5 method.

Magic PHP5 method. Allows object unserialisation.


API Tags:
Access:  public

Information Tags:
Version:  0.1.2
Throws:  E_OTS_ErrorCode When receive failed respond or unexpected message.
Throws:  E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
Since:  0.1.2

[ Top ]
Constants
COMMAND_BAN_MANAGER = 10 [line 143]

Not supported in current OTAdmin imlpementation.

Not supported in current OTAdmin imlpementation.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
COMMAND_BROADCAST = 1 [line 107]

Broadcast message.

Broadcast message.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
COMMAND_CLOSE_SERVER = 2 [line 111]

Closes server.

Closes server.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
COMMAND_GETHOUSE = 12 [line 151]

Not supported in current OTAdmin imlpementation.

Not supported in current OTAdmin imlpementation.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
COMMAND_GETONLINE = 8 [line 135]

Not supported in current OTAdmin imlpementation.

Not supported in current OTAdmin imlpementation.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
COMMAND_KICK = 9 [line 139]

Not supported in current OTAdmin imlpementation.

Not supported in current OTAdmin imlpementation.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
COMMAND_OPEN_SERVER = 4 [line 119]

Opens server for players.

Opens server for players.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
COMMAND_PAY_HOUSES = 3 [line 115]

Pays all rented shouses.

Pays all rented shouses.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
COMMAND_PLAYER_INFO = 7 [line 131]

Not supported in current OTAdmin imlpementation.

Not supported in current OTAdmin imlpementation.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
COMMAND_RELOAD_SCRIPTS = 6 [line 127]

Not supported in current OTAdmin imlpementation.

Not supported in current OTAdmin imlpementation.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
COMMAND_SAVE_SERVER = 13 [line 158]

Calls server save.

Calls server save.

Information Tags:
Version:  0.1.6
Version:  0.1.2
Since:  0.1.2
Since:  0.1.6

[ Top ]
COMMAND_SERVER_INFO = 11 [line 147]

Not supported in current OTAdmin imlpementation.

Not supported in current OTAdmin imlpementation.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
COMMAND_SHUTDOWN_SERVER = 5 [line 123]

Shutdowns the server.

Shutdowns the server.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
ENCRYPTION_RSA1024XTEA = 1 [line 172]

Server uses XTEA encryption, XTEA key is being sent in 1024bit RSA encrypted packet.

Server uses XTEA encryption, XTEA key is being sent in 1024bit RSA encrypted packet.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
REQUEST_COMMAND = 4 [line 49]

OTAdmin commnd.

OTAdmin commnd.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
REQUEST_ENCRYPTION = 2 [line 41]

Encryption packet.

Encryption packet.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
REQUEST_KEY_EXCHANGE = 3 [line 45]

RSA key exchange.

RSA key exchange.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
REQUEST_LOGIN = 1 [line 37]

User login.

User login.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
REQUEST_PING = 5 [line 53]

Ping.

Ping.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
REQUIRE_ENCRYPTION = 2 [line 167]

Server requires encryption.

Server requires encryption.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
REQUIRE_LOGIN = 1 [line 163]

Server requires login.

Server requires login.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
RESPOND_COMMAND_FAILED = 7 [line 82]

Command failed.

Command failed.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
RESPOND_COMMAND_OK = 6 [line 78]

Command success.

Command success.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
RESPOND_ENCRYPTION_FAILED = 9 [line 90]

Encryption initialization failed.

Encryption initialization failed.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
RESPOND_ENCRYPTION_OK = 8 [line 86]

Encryption initialization success.

Encryption initialization success.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
RESPOND_ERROR = 12 [line 102]

Error.

Error.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
RESPOND_HELLO = 1 [line 58]

Hello respond.

Hello respond.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
RESPOND_KEY_EXCHANGE_FAILED = 3 [line 66]

Keys exchange failed.

Keys exchange failed.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
RESPOND_KEY_EXCHANGE_OK = 2 [line 62]

Keys exchange success.

Keys exchange success.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
RESPOND_LOGIN_FAILED = 5 [line 74]

Login incorrect.

Login incorrect.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
RESPOND_LOGIN_OK = 4 [line 70]

Login success.

Login success.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
RESPOND_MESSAGE = 11 [line 98]

Message.

Message.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]
RESPOND_PING_OK = 10 [line 94]

Ping success.

Ping success.

Information Tags:
Version:  0.1.2
Since:  0.1.2

[ Top ]