removed 'application' folder to have everything in the root directory
This commit is contained in:
4274
libs/Maniaplanet/DedicatedServer/Connection.php
Executable file
4274
libs/Maniaplanet/DedicatedServer/Connection.php
Executable file
File diff suppressed because it is too large
Load Diff
54
libs/Maniaplanet/DedicatedServer/Structures/AbstractStructure.php
Executable file
54
libs/Maniaplanet/DedicatedServer/Structures/AbstractStructure.php
Executable file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
abstract class AbstractStructure
|
||||
{
|
||||
static public function fromArray($array)
|
||||
{
|
||||
if(!is_array($array))
|
||||
return $array;
|
||||
|
||||
$object = new static;
|
||||
foreach($array as $key => $value)
|
||||
$object->{lcfirst($key)} = $value;
|
||||
return $object;
|
||||
}
|
||||
|
||||
static public function fromArrayOfArray($array)
|
||||
{
|
||||
if(!is_array($array))
|
||||
return $array;
|
||||
|
||||
$result = array();
|
||||
foreach($array as $key => $value)
|
||||
$result[$key] = static::fromArray($value);
|
||||
return $result;
|
||||
}
|
||||
|
||||
static public function getPropertyFromArray($array, $property)
|
||||
{
|
||||
return array_map(get_called_class().'::extractProperty', $array, array_fill(0, count($array), $property));
|
||||
}
|
||||
|
||||
static protected function extractProperty($element, $property)
|
||||
{
|
||||
if(!is_a($element, get_called_class()) || !property_exists($element, $property))
|
||||
throw new \InvalidArgumentException('property '.$property.' does not exists in class: '.get_called_class());
|
||||
|
||||
return $element->$property;
|
||||
}
|
||||
|
||||
function toArray()
|
||||
{
|
||||
$out = array();
|
||||
foreach(get_object_vars($this) as $key => $value)
|
||||
$out[ucfirst($key)] = $value;
|
||||
return $out;
|
||||
}
|
||||
}
|
25
libs/Maniaplanet/DedicatedServer/Structures/Bill.php
Executable file
25
libs/Maniaplanet/DedicatedServer/Structures/Bill.php
Executable file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Bill extends AbstractStructure
|
||||
{
|
||||
const STATE_CREATING_TRANSACTION = 1;
|
||||
const STATE_ISSUED = 2;
|
||||
const STATE_VALIDATING_PAYMENT = 3;
|
||||
const STATE_PAYED = 4;
|
||||
const STATE_REFUSED = 5;
|
||||
const STATE_ERROR = 6;
|
||||
|
||||
/** @var int */
|
||||
public $state;
|
||||
/** @var string */
|
||||
public $stateName;
|
||||
/** @var int */
|
||||
public $transactionId;
|
||||
}
|
20
libs/Maniaplanet/DedicatedServer/Structures/Command.php
Executable file
20
libs/Maniaplanet/DedicatedServer/Structures/Command.php
Executable file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Command extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $name;
|
||||
/** @var string */
|
||||
public $desc;
|
||||
/** @var string */
|
||||
public $type;
|
||||
/** @var string */
|
||||
public $default;
|
||||
}
|
26
libs/Maniaplanet/DedicatedServer/Structures/FileDesc.php
Executable file
26
libs/Maniaplanet/DedicatedServer/Structures/FileDesc.php
Executable file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class FileDesc extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $fileName;
|
||||
/** @var string */
|
||||
public $checksum;
|
||||
|
||||
/**
|
||||
* @return FileDesc
|
||||
*/
|
||||
public static function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
$object->fileName = str_replace("\xEF\xBB\xBF", '', $object->fileName);
|
||||
return $object;
|
||||
}
|
||||
}
|
20
libs/Maniaplanet/DedicatedServer/Structures/ForcedSkin.php
Executable file
20
libs/Maniaplanet/DedicatedServer/Structures/ForcedSkin.php
Executable file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class ForcedSkin extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $orig;
|
||||
/** @var string */
|
||||
public $name;
|
||||
/** @var string */
|
||||
public $checksum;
|
||||
/** @var string */
|
||||
public $url;
|
||||
}
|
71
libs/Maniaplanet/DedicatedServer/Structures/GameInfos.php
Executable file
71
libs/Maniaplanet/DedicatedServer/Structures/GameInfos.php
Executable file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class GameInfos extends AbstractStructure
|
||||
{
|
||||
/**
|
||||
* Game Modes
|
||||
*/
|
||||
const GAMEMODE_SCRIPT = 0;
|
||||
const GAMEMODE_ROUNDS = 1;
|
||||
const GAMEMODE_TIMEATTACK = 2;
|
||||
const GAMEMODE_TEAM = 3;
|
||||
const GAMEMODE_LAPS = 4;
|
||||
const GAMEMODE_CUP = 5;
|
||||
const GAMEMODE_STUNTS = 6;
|
||||
|
||||
/** @var int */
|
||||
public $gameMode;
|
||||
/** @var string */
|
||||
public $scriptName;
|
||||
/** @var int */
|
||||
public $nbMaps;
|
||||
/** @var int */
|
||||
public $chatTime;
|
||||
/** @var int */
|
||||
public $finishTimeout;
|
||||
/** @var int */
|
||||
public $allWarmUpDuration;
|
||||
/** @var bool */
|
||||
public $disableRespawn;
|
||||
/** @var int */
|
||||
public $forceShowAllOpponents;
|
||||
/** @var int */
|
||||
public $roundsPointsLimit;
|
||||
/** @var int */
|
||||
public $roundsForcedLaps;
|
||||
/** @var bool */
|
||||
public $roundsUseNewRules;
|
||||
/** @var int */
|
||||
public $roundsPointsLimitNewRules;
|
||||
/** @var int */
|
||||
public $teamPointsLimit;
|
||||
/** @var int */
|
||||
public $teamMaxPoints;
|
||||
/** @var bool */
|
||||
public $teamUseNewRules;
|
||||
/** @var int */
|
||||
public $teamPointsLimitNewRules;
|
||||
/** @var int */
|
||||
public $timeAttackLimit;
|
||||
/** @var int */
|
||||
public $timeAttackSynchStartPeriod;
|
||||
/** @var int */
|
||||
public $lapsNbLaps;
|
||||
/** @var int */
|
||||
public $lapsTimeLimit;
|
||||
/** @var int */
|
||||
public $cupPointsLimit;
|
||||
/** @var int */
|
||||
public $cupRoundsPerMap;
|
||||
/** @var int */
|
||||
public $cupNbWinners;
|
||||
/** @var int */
|
||||
public $cupWarmUpDuration;
|
||||
}
|
16
libs/Maniaplanet/DedicatedServer/Structures/LadderLimits.php
Executable file
16
libs/Maniaplanet/DedicatedServer/Structures/LadderLimits.php
Executable file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class LadderLimits extends AbstractStructure
|
||||
{
|
||||
/** @var float */
|
||||
public $ladderServerLimitMin;
|
||||
/** @var float */
|
||||
public $ladderServerLimitMax;
|
||||
}
|
36
libs/Maniaplanet/DedicatedServer/Structures/LadderStats.php
Executable file
36
libs/Maniaplanet/DedicatedServer/Structures/LadderStats.php
Executable file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class LadderStats extends AbstractStructure
|
||||
{
|
||||
/** @var float */
|
||||
public $lastMatchScore;
|
||||
/** @var int */
|
||||
public $nbrMatchWins;
|
||||
/** @var int */
|
||||
public $nbrMatchDraws;
|
||||
/** @var int */
|
||||
public $nbrMatchLosses;
|
||||
/** @var string */
|
||||
public $teamName;
|
||||
/** @var ZoneRanking[] */
|
||||
public $playerRankings;
|
||||
/** @var array */
|
||||
public $teamRankings;
|
||||
|
||||
/**
|
||||
* @return LadderStats
|
||||
*/
|
||||
static function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
$object->playerRankings = ZoneRanking::fromArrayOfArray($object->playerRankings);
|
||||
return $object;
|
||||
}
|
||||
}
|
20
libs/Maniaplanet/DedicatedServer/Structures/LobbyInfo.php
Executable file
20
libs/Maniaplanet/DedicatedServer/Structures/LobbyInfo.php
Executable file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class LobbyInfo extends AbstractStructure
|
||||
{
|
||||
/** var bool */
|
||||
public $isLobby;
|
||||
/** var int */
|
||||
public $lobbyPlayers;
|
||||
/** var int */
|
||||
public $lobbyMaxPlayers;
|
||||
/** var float */
|
||||
public $lobbyPlayersLevel;
|
||||
}
|
54
libs/Maniaplanet/DedicatedServer/Structures/Map.php
Executable file
54
libs/Maniaplanet/DedicatedServer/Structures/Map.php
Executable file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Map extends AbstractStructure
|
||||
{
|
||||
/** var string */
|
||||
public $uId;
|
||||
/** var string */
|
||||
public $name;
|
||||
/** var string */
|
||||
public $fileName;
|
||||
/** var string */
|
||||
public $author;
|
||||
/** var string */
|
||||
public $environnement;
|
||||
/** var string */
|
||||
public $mood;
|
||||
/** var int */
|
||||
public $bronzeTime;
|
||||
/** var int */
|
||||
public $silverTime;
|
||||
/** var int */
|
||||
public $goldTime;
|
||||
/** var int */
|
||||
public $authorTime;
|
||||
/** var int */
|
||||
public $copperPrice;
|
||||
/** var bool */
|
||||
public $lapRace;
|
||||
/** var int */
|
||||
public $nbLaps;
|
||||
/** var int */
|
||||
public $nbCheckpoints;
|
||||
/** var string */
|
||||
public $mapType;
|
||||
/** var string */
|
||||
public $mapStyle;
|
||||
|
||||
/**
|
||||
* @return Map
|
||||
*/
|
||||
public static function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
$object->fileName = str_replace("\xEF\xBB\xBF", '', $object->fileName);
|
||||
return $object;
|
||||
}
|
||||
}
|
16
libs/Maniaplanet/DedicatedServer/Structures/Mod.php
Executable file
16
libs/Maniaplanet/DedicatedServer/Structures/Mod.php
Executable file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Mod extends AbstractStructure
|
||||
{
|
||||
/** var string */
|
||||
public $env;
|
||||
/** var string */
|
||||
public $url;
|
||||
}
|
28
libs/Maniaplanet/DedicatedServer/Structures/Music.php
Executable file
28
libs/Maniaplanet/DedicatedServer/Structures/Music.php
Executable file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Music extends AbstractStructure
|
||||
{
|
||||
/** var bool */
|
||||
public $override;
|
||||
/** var string */
|
||||
public $url;
|
||||
/** var string */
|
||||
public $file;
|
||||
|
||||
/**
|
||||
* @return Music
|
||||
*/
|
||||
public static function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
$object->file = str_replace("\xEF\xBB\xBF", '', $object->file);
|
||||
return $object;
|
||||
}
|
||||
}
|
37
libs/Maniaplanet/DedicatedServer/Structures/NetworkStats.php
Executable file
37
libs/Maniaplanet/DedicatedServer/Structures/NetworkStats.php
Executable file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class NetworkStats extends AbstractStructure
|
||||
{
|
||||
/** @var int */
|
||||
public $uptime;
|
||||
/** @var int */
|
||||
public $nbrConnection;
|
||||
/** @var int */
|
||||
public $meanConnectionTime;
|
||||
/** @var int */
|
||||
public $meanNbrPlayer;
|
||||
/** @var int */
|
||||
public $recvNetRate;
|
||||
/** @var int */
|
||||
public $sendNetRate;
|
||||
/** @var int */
|
||||
public $totalReceivingSize;
|
||||
/** @var int */
|
||||
public $totalSendingSize;
|
||||
/** @var PlayerNetInfo[] */
|
||||
public $playerNetInfos;
|
||||
|
||||
static public function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
$object->playerNetInfos = PlayerNetInfo::fromArrayOfArray($object->playerNetInfos);
|
||||
return $object;
|
||||
}
|
||||
}
|
13
libs/Maniaplanet/DedicatedServer/Structures/Player.php
Executable file
13
libs/Maniaplanet/DedicatedServer/Structures/Player.php
Executable file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Player extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $login;
|
||||
}
|
16
libs/Maniaplanet/DedicatedServer/Structures/PlayerAnswer.php
Executable file
16
libs/Maniaplanet/DedicatedServer/Structures/PlayerAnswer.php
Executable file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class PlayerAnswer extends Player
|
||||
{
|
||||
/** @var int */
|
||||
public $playerId;
|
||||
/** @var int */
|
||||
public $result;
|
||||
}
|
16
libs/Maniaplanet/DedicatedServer/Structures/PlayerBan.php
Executable file
16
libs/Maniaplanet/DedicatedServer/Structures/PlayerBan.php
Executable file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class PlayerBan extends Player
|
||||
{
|
||||
/** @var string */
|
||||
public $clientName;
|
||||
/** @var string */
|
||||
public $iPAddress;
|
||||
}
|
72
libs/Maniaplanet/DedicatedServer/Structures/PlayerDetailedInfo.php
Executable file
72
libs/Maniaplanet/DedicatedServer/Structures/PlayerDetailedInfo.php
Executable file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class PlayerDetailedInfo extends Player
|
||||
{
|
||||
/** @var string */
|
||||
public $nickName;
|
||||
/** @var int */
|
||||
public $playerId;
|
||||
/** @var int */
|
||||
public $teamId;
|
||||
/** @var string */
|
||||
public $path;
|
||||
/** @var string */
|
||||
public $language;
|
||||
/** @var string */
|
||||
public $clientVersion;
|
||||
/** @var string */
|
||||
public $clientTitleVersion;
|
||||
/** @var string */
|
||||
public $iPAddress;
|
||||
/** @var int */
|
||||
public $downloadRate;
|
||||
/** @var int */
|
||||
public $uploadRate;
|
||||
/** @var bool */
|
||||
public $isSpectator;
|
||||
/** @var bool */
|
||||
public $isInOfficialMode;
|
||||
/** @var bool */
|
||||
public $isReferee;
|
||||
/** @var FileDesc */
|
||||
public $avatar;
|
||||
/** @var Skin[] */
|
||||
public $skins;
|
||||
/** @var LadderStats */
|
||||
public $ladderStats;
|
||||
/** @var int */
|
||||
public $hoursSinceZoneInscription;
|
||||
/** @var string */
|
||||
public $broadcasterLogin;
|
||||
/** @var string[] */
|
||||
public $allies = array();
|
||||
/** @var string */
|
||||
public $clubLink;
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
function getArrayFromPath()
|
||||
{
|
||||
return explode('|', $this->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PlayerDetailedInfo
|
||||
*/
|
||||
static public function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
$object->avatar = FileDesc::fromArray($object->avatar);
|
||||
$object->skins = Skin::fromArrayOfArray($object->skins);
|
||||
$object->ladderStats = LadderStats::fromArray($object->ladderStats);
|
||||
return $object;
|
||||
}
|
||||
}
|
87
libs/Maniaplanet/DedicatedServer/Structures/PlayerInfo.php
Executable file
87
libs/Maniaplanet/DedicatedServer/Structures/PlayerInfo.php
Executable file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class PlayerInfo extends Player
|
||||
{
|
||||
/** @var string */
|
||||
public $nickName;
|
||||
/** @var int */
|
||||
public $playerId;
|
||||
/** @var int */
|
||||
public $teamId;
|
||||
/** @var bool */
|
||||
public $isSpectator;
|
||||
/** @var bool */
|
||||
public $isInOfficialMode;
|
||||
/** @var int */
|
||||
public $ladderRanking;
|
||||
/** @var int */
|
||||
public $spectatorStatus;
|
||||
/** @var int */
|
||||
public $flags;
|
||||
|
||||
//Flags details
|
||||
/** @var int */
|
||||
public $forceSpectator;
|
||||
/** @var bool */
|
||||
public $isReferee;
|
||||
/** @var bool */
|
||||
public $isPodiumReady;
|
||||
/** @var bool */
|
||||
public $isUsingStereoscopy;
|
||||
/** @var bool */
|
||||
public $isManagedByAnOtherServer;
|
||||
/** @var bool */
|
||||
public $isServer;
|
||||
/** @var bool */
|
||||
public $hasPlayerSlot;
|
||||
/** @var bool */
|
||||
public $isBroadcasting;
|
||||
/** @var bool */
|
||||
public $hasJoinedGame;
|
||||
|
||||
//SpectatorStatus details
|
||||
/** @var bool */
|
||||
public $spectator;
|
||||
/** @var bool */
|
||||
public $temporarySpectator;
|
||||
/** @var bool */
|
||||
public $pureSpectator;
|
||||
/** @var bool */
|
||||
public $autoTarget;
|
||||
/** @var int */
|
||||
public $currentTargetId;
|
||||
|
||||
/**
|
||||
* @return PlayerInfo
|
||||
*/
|
||||
static public function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
|
||||
//Detail flags
|
||||
$object->forceSpectator = $object->flags % 10; // 0, 1 or 2
|
||||
$object->isReferee = (bool) (intval($object->flags / 10) % 10);
|
||||
$object->isPodiumReady = (bool) (intval($object->flags / 100) % 10);
|
||||
$object->isUsingStereoscopy = (bool) (intval($object->flags / 1000) % 10);
|
||||
$object->isManagedByAnOtherServer = (bool) (intval($object->flags / 10000) % 10);
|
||||
$object->isServer = (bool) (intval($object->flags / 100000) % 10);
|
||||
$object->hasPlayerSlot = (bool) (intval($object->flags / 1000000) % 10);
|
||||
$object->isBroadcasting = (bool) (intval($object->flags / 10000000) % 10);
|
||||
$object->hasJoinedGame = (bool) (intval($object->flags / 100000000) % 10);
|
||||
//Details spectatorStatus
|
||||
$object->spectator = (bool) ($object->spectatorStatus % 10);
|
||||
$object->temporarySpectator = (bool) (intval($object->spectatorStatus / 10) % 10);
|
||||
$object->pureSpectator = (bool) (intval($object->spectatorStatus / 100) % 10);
|
||||
$object->autoTarget = (bool) (intval($object->spectatorStatus / 1000) % 10);
|
||||
$object->currentTargetId = intval($object->spectatorStatus / 10000);
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
22
libs/Maniaplanet/DedicatedServer/Structures/PlayerNetInfo.php
Executable file
22
libs/Maniaplanet/DedicatedServer/Structures/PlayerNetInfo.php
Executable file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class PlayerNetInfo extends Player
|
||||
{
|
||||
/** @var string */
|
||||
public $iPAddress;
|
||||
/** @var int */
|
||||
public $stateUpdateLatency;
|
||||
/** @var int */
|
||||
public $stateUpdatePeriod;
|
||||
/** @var int */
|
||||
public $latestNetworkActivity;
|
||||
/** @var float */
|
||||
public $packetLossRate;
|
||||
}
|
28
libs/Maniaplanet/DedicatedServer/Structures/PlayerRanking.php
Executable file
28
libs/Maniaplanet/DedicatedServer/Structures/PlayerRanking.php
Executable file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class PlayerRanking extends Player
|
||||
{
|
||||
/** @var string */
|
||||
public $nickName;
|
||||
/** @var int */
|
||||
public $playerId;
|
||||
/** @var int */
|
||||
public $rank;
|
||||
/** @var int */
|
||||
public $bestTime;
|
||||
/** @var int[] */
|
||||
public $bestCheckpoints;
|
||||
/** @var int */
|
||||
public $score;
|
||||
/** @var int */
|
||||
public $nbrLapsFinished;
|
||||
/** @var float */
|
||||
public $ladderScore;
|
||||
}
|
35
libs/Maniaplanet/DedicatedServer/Structures/ScriptInfo.php
Executable file
35
libs/Maniaplanet/DedicatedServer/Structures/ScriptInfo.php
Executable file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class ScriptInfo extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $name;
|
||||
/** @var string */
|
||||
public $compatibleMapTypes;
|
||||
/** @var string */
|
||||
public $description;
|
||||
/** @var string */
|
||||
public $version;
|
||||
/** @var ScriptSettings[] */
|
||||
public $paramDescs = array();
|
||||
/** @var Command[] */
|
||||
public $commandDescs = array();
|
||||
|
||||
/**
|
||||
* @return ScriptInfo
|
||||
*/
|
||||
public static function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
$object->paramDescs = ScriptSettings::fromArrayOfArray($object->paramDescs);
|
||||
$object->commandDescs = Command::fromArrayOfArray($object->commandDescs);
|
||||
return $object;
|
||||
}
|
||||
}
|
20
libs/Maniaplanet/DedicatedServer/Structures/ScriptSettings.php
Executable file
20
libs/Maniaplanet/DedicatedServer/Structures/ScriptSettings.php
Executable file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class ScriptSettings extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $name;
|
||||
/** @var string */
|
||||
public $desc;
|
||||
/** @var string */
|
||||
public $type;
|
||||
/** @var string */
|
||||
public $default;
|
||||
}
|
106
libs/Maniaplanet/DedicatedServer/Structures/ServerOptions.php
Executable file
106
libs/Maniaplanet/DedicatedServer/Structures/ServerOptions.php
Executable file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class ServerOptions extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $name;
|
||||
/** @var string */
|
||||
public $comment;
|
||||
/** @var string */
|
||||
public $password;
|
||||
/** @var string */
|
||||
public $passwordForSpectator;
|
||||
/** @var int */
|
||||
public $hideServer;
|
||||
/** @var int */
|
||||
public $currentMaxPlayers;
|
||||
/** @var int */
|
||||
public $nextMaxPlayers;
|
||||
/** @var int */
|
||||
public $currentMaxSpectators;
|
||||
/** @var int */
|
||||
public $nextMaxSpectators;
|
||||
/** @var bool */
|
||||
public $isP2PUpload;
|
||||
/** @var bool */
|
||||
public $isP2PDownload;
|
||||
/** @var bool */
|
||||
public $currentLadderMode;
|
||||
/** @var int */
|
||||
public $nextLadderMode;
|
||||
/** @var float */
|
||||
public $ladderServerLimitMax;
|
||||
/** @var float */
|
||||
public $ladderServerLimitMin;
|
||||
/** @var int */
|
||||
public $currentVehicleNetQuality;
|
||||
/** @var int */
|
||||
public $nextVehicleNetQuality;
|
||||
/** @var int */
|
||||
public $currentCallVoteTimeOut;
|
||||
/** @var int */
|
||||
public $nextCallVoteTimeOut;
|
||||
/** @var float */
|
||||
public $callVoteRatio;
|
||||
/** @var bool */
|
||||
public $allowMapDownload;
|
||||
/** @var bool */
|
||||
public $autoSaveReplays;
|
||||
/** @var bool */
|
||||
public $autoSaveValidationReplays;
|
||||
/** @var string */
|
||||
public $refereePassword;
|
||||
/** @var int */
|
||||
public $refereeMode;
|
||||
/** @var bool */
|
||||
public $currentUseChangingValidationSeed;
|
||||
/** @var bool */
|
||||
public $nextUseChangingValidationSeed;
|
||||
/** @var int */
|
||||
public $clientInputsMaxLatency;
|
||||
/** @var bool */
|
||||
public $keepPlayerSlots;
|
||||
/** @var bool */
|
||||
public $disableHorns;
|
||||
/** @var bool */
|
||||
public $disableServiceAnnounces;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @return bool
|
||||
*/
|
||||
function isValid()
|
||||
{
|
||||
return is_string($this->name)
|
||||
&& is_string($this->comment)
|
||||
&& is_string($this->password)
|
||||
&& is_string($this->passwordForSpectator)
|
||||
&& is_int($this->nextCallVoteTimeOut)
|
||||
&& VoteRatio::isRatio($this->callVoteRatio);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @return mixed[]
|
||||
*/
|
||||
function toSetterArray()
|
||||
{
|
||||
$out = array();
|
||||
foreach(get_object_vars($this) as $key => $value)
|
||||
{
|
||||
if(substr($key, 0, 7) == 'current' || $value === null)
|
||||
continue;
|
||||
if($key == 'nextUseChangingValidationSeed')
|
||||
$key = 'useChangingValidationSeed';
|
||||
$out[ucfirst($key)] = $value;
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
26
libs/Maniaplanet/DedicatedServer/Structures/Skin.php
Executable file
26
libs/Maniaplanet/DedicatedServer/Structures/Skin.php
Executable file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Skin extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $environnement;
|
||||
/** @var FileDesc */
|
||||
public $packDesc;
|
||||
|
||||
/**
|
||||
* @return Skin
|
||||
*/
|
||||
public static function fromArray($array)
|
||||
{
|
||||
$object = parent::fromArray($array);
|
||||
$object->packDesc = FileDesc::fromArray($object->packDesc);
|
||||
return $object;
|
||||
}
|
||||
}
|
24
libs/Maniaplanet/DedicatedServer/Structures/Status.php
Executable file
24
libs/Maniaplanet/DedicatedServer/Structures/Status.php
Executable file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Status extends AbstractStructure
|
||||
{
|
||||
const UNKNOWN = 0;
|
||||
const WAITING = 1;
|
||||
const LAUNCHING = 2;
|
||||
const SYNCHRONIZATION = 3;
|
||||
const PLAY = 4;
|
||||
const EXITING = 6;
|
||||
const LOCAL = 7;
|
||||
|
||||
/** @var int */
|
||||
public $code;
|
||||
/** @var string */
|
||||
public $name;
|
||||
}
|
32
libs/Maniaplanet/DedicatedServer/Structures/SystemInfos.php
Executable file
32
libs/Maniaplanet/DedicatedServer/Structures/SystemInfos.php
Executable file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class SystemInfos extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $publishedIp;
|
||||
/** @var int */
|
||||
public $port;
|
||||
/** @var int */
|
||||
public $p2PPort;
|
||||
/** @var string */
|
||||
public $titleId;
|
||||
/** @var string */
|
||||
public $serverLogin;
|
||||
/** @var int */
|
||||
public $serverPlayerId;
|
||||
/** @var int */
|
||||
public $connectionDownloadRate;
|
||||
/** @var int */
|
||||
public $connectionUploadRate;
|
||||
/** @var bool */
|
||||
public $isServer;
|
||||
/** @var bool */
|
||||
public $isDedicated;
|
||||
}
|
16
libs/Maniaplanet/DedicatedServer/Structures/Tag.php
Executable file
16
libs/Maniaplanet/DedicatedServer/Structures/Tag.php
Executable file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Tag extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $name;
|
||||
/** @var string */
|
||||
public $value;
|
||||
}
|
28
libs/Maniaplanet/DedicatedServer/Structures/Team.php
Executable file
28
libs/Maniaplanet/DedicatedServer/Structures/Team.php
Executable file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Team extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $name;
|
||||
/** @var string */
|
||||
public $zonePath;
|
||||
/** @var string */
|
||||
public $city;
|
||||
/** @var string */
|
||||
public $emblemUrl;
|
||||
/** @var float */
|
||||
public $huePrimary;
|
||||
/** @var float */
|
||||
public $hueSecondary;
|
||||
/** @var string */
|
||||
public $rGB;
|
||||
/** @var string */
|
||||
public $clubLinkUrl;
|
||||
}
|
16
libs/Maniaplanet/DedicatedServer/Structures/TokenInfos.php
Executable file
16
libs/Maniaplanet/DedicatedServer/Structures/TokenInfos.php
Executable file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class TokenInfos extends AbstractStructure
|
||||
{
|
||||
/** @var int */
|
||||
public $tokenCost;
|
||||
/** @var bool */
|
||||
public $canPayToken;
|
||||
}
|
22
libs/Maniaplanet/DedicatedServer/Structures/Version.php
Executable file
22
libs/Maniaplanet/DedicatedServer/Structures/Version.php
Executable file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Version extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $name;
|
||||
/** @var string */
|
||||
public $titleId;
|
||||
/** @var string */
|
||||
public $version;
|
||||
/** @var string */
|
||||
public $build;
|
||||
/** @var string */
|
||||
public $apiVersion;
|
||||
}
|
45
libs/Maniaplanet/DedicatedServer/Structures/Vote.php
Executable file
45
libs/Maniaplanet/DedicatedServer/Structures/Vote.php
Executable file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class Vote extends AbstractStructure
|
||||
{
|
||||
const STATE_NEW = 'NewVote';
|
||||
const STATE_CANCELLED = 'VoteCancelled';
|
||||
const STATE_PASSED = 'VotePassed';
|
||||
const STATE_FAILED = 'VoteFailed';
|
||||
|
||||
/** @var string */
|
||||
public $status;
|
||||
/** @var string */
|
||||
public $callerLogin;
|
||||
/** @var string */
|
||||
public $cmdName;
|
||||
/** @var mixed[] */
|
||||
public $cmdParam;
|
||||
|
||||
/**
|
||||
* @param string $cmdName
|
||||
* @param mixed[] $cmdParam
|
||||
*/
|
||||
function __construct($cmdName='', $cmdParam=array())
|
||||
{
|
||||
$this->cmdName = $cmdName;
|
||||
$this->cmdParam = $cmdParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @return bool
|
||||
*/
|
||||
function isValid()
|
||||
{
|
||||
return is_string($this->cmdName)
|
||||
&& is_array($this->cmdParam);
|
||||
}
|
||||
}
|
60
libs/Maniaplanet/DedicatedServer/Structures/VoteRatio.php
Executable file
60
libs/Maniaplanet/DedicatedServer/Structures/VoteRatio.php
Executable file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class VoteRatio extends AbstractStructure
|
||||
{
|
||||
const COMMAND_DEFAULT = '*';
|
||||
const COMMAND_SCRIPT_SETTINGS = 'SetModeScriptSettingsAndCommands';
|
||||
const COMMAND_NEXT_MAP = 'NextMap';
|
||||
const COMMAND_JUMP_MAP = 'JumpToMapIdent';
|
||||
const COMMAND_SET_NEXT_MAP = 'SetNextMapIdent';
|
||||
const COMMAND_RESTART_MAP = 'RestartMap';
|
||||
const COMMAND_TEAM_BALANCE = 'AutoTeamBalance';
|
||||
const COMMAND_KICK = 'Kick';
|
||||
const COMMAND_BAN = 'Ban';
|
||||
|
||||
/** @var string '*' for default */
|
||||
public $command;
|
||||
/** @var string Empty to match all votes for the command */
|
||||
public $param;
|
||||
/** @var float Must be in range [0,1] or -1 to disable */
|
||||
public $ratio;
|
||||
|
||||
/**
|
||||
* @param string $command
|
||||
* @param float $ratio
|
||||
*/
|
||||
public function __construct($command = '', $ratio = 0.)
|
||||
{
|
||||
$this->command = $command;
|
||||
$this->ratio = $ratio;
|
||||
$this->param = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @return bool
|
||||
*/
|
||||
function isValid()
|
||||
{
|
||||
return is_string($this->command)
|
||||
&& is_string($this->param)
|
||||
&& self::isRatio($this->ratio);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @param float $ratio
|
||||
* @return bool
|
||||
*/
|
||||
static function isRatio($ratio)
|
||||
{
|
||||
return is_float($ratio) && ($ratio === -1. || ($ratio >= 0. && $ratio <= 1.));
|
||||
}
|
||||
}
|
28
libs/Maniaplanet/DedicatedServer/Structures/ZoneRanking.php
Executable file
28
libs/Maniaplanet/DedicatedServer/Structures/ZoneRanking.php
Executable file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Structures;
|
||||
|
||||
class ZoneRanking extends AbstractStructure
|
||||
{
|
||||
/** @var string */
|
||||
public $path;
|
||||
/** @var float */
|
||||
public $score;
|
||||
/** @var int */
|
||||
public $ranking;
|
||||
/** @var int */
|
||||
public $totalCount;
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
function getArrayFromPath()
|
||||
{
|
||||
return explode('|', $this->path);
|
||||
}
|
||||
}
|
30
libs/Maniaplanet/DedicatedServer/Xmlrpc/Base64.php
Executable file
30
libs/Maniaplanet/DedicatedServer/Xmlrpc/Base64.php
Executable file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Xmlrpc;
|
||||
|
||||
class Base64
|
||||
{
|
||||
public $scalar;
|
||||
public $xmlrpc_type = 'base64';
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
*/
|
||||
function __construct($data)
|
||||
{
|
||||
$this->scalar = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function __toString()
|
||||
{
|
||||
return $this->scalar;
|
||||
}
|
||||
}
|
10
libs/Maniaplanet/DedicatedServer/Xmlrpc/Exception.php
Executable file
10
libs/Maniaplanet/DedicatedServer/Xmlrpc/Exception.php
Executable file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Xmlrpc;
|
||||
|
||||
class Exception extends \Exception {}
|
114
libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php
Executable file
114
libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php
Executable file
@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Xmlrpc;
|
||||
|
||||
class FaultException extends Exception
|
||||
{
|
||||
static function create($faultString, $faultCode)
|
||||
{
|
||||
switch($faultString)
|
||||
{
|
||||
case 'Password incorrect.':
|
||||
case 'Permission denied.':
|
||||
return new AuthenticationException($faultString, $faultCode);
|
||||
case 'not connected to the internet':
|
||||
case 'Not connected to the masterserver.':
|
||||
case 'Not a game server.':
|
||||
case 'Not a server.':
|
||||
case 'Couldn\'t create the fake player.':
|
||||
case 'Only server can receive a callvote':
|
||||
case 'No map currently loaded.':
|
||||
case 'No replay to save':
|
||||
case 'Internal error.':
|
||||
return new UnavailableFeatureException($faultString, $faultCode);
|
||||
case 'You must enable the callbacks to be able to do chat routing.':
|
||||
case 'Chat routing not enabled.':
|
||||
case 'Script cloud disabled.':
|
||||
case 'Already waiting for a vote.':
|
||||
case 'You must stop server first.':
|
||||
return new LockedFeatureException($faultString, $faultCode);
|
||||
case 'Login or Uid unknown.':
|
||||
case 'Login unknown.':
|
||||
return new UnknownPlayerException($faultString, $faultCode);
|
||||
case 'The player is not a spectator':
|
||||
case 'The player is not a spectator.':
|
||||
case 'Not a network player.':
|
||||
case 'Player is not a fake player':
|
||||
return new PlayerStateException($faultString, $faultCode);
|
||||
case 'Player already ignored.':
|
||||
case 'Player already black listed.':
|
||||
case 'Player already on guest list.':
|
||||
case 'Map already added.':
|
||||
return new AlreadyInListException($faultString, $faultCode);
|
||||
case 'Login not banned.':
|
||||
case 'Player not ignored.':
|
||||
case 'Player not black listed.':
|
||||
case 'Player not on guest list.':
|
||||
case 'Map not in the selection.':
|
||||
case 'The map isn\'t in the current selection.':
|
||||
case 'Map not found.':
|
||||
return new NotInListException($faultString, $faultCode);
|
||||
case 'Start index out of bound.':
|
||||
case 'invalid index':
|
||||
return new IndexOutOfBoundException($faultString, $faultCode);
|
||||
case 'the next map must be different from the current one.':
|
||||
return new NextMapException($faultString, $faultCode);
|
||||
case 'Change in progress.':
|
||||
return new ChangeInProgressException($faultString, $faultCode);
|
||||
case 'Incompatible map type.':
|
||||
case 'Map not complete.':
|
||||
case 'Map corrupted.':
|
||||
case 'Map lightmap is not up to date.':
|
||||
case 'The map doesn\'t match the server packmask.':
|
||||
return new InvalidMapException($faultString, $faultCode);
|
||||
case 'Ladder mode unknown.':
|
||||
case 'You cannot change the max players count: AllowSpectatorRelays is activated.':
|
||||
case 'You cannot change the max spectators count: AllowSpectatorRelays is activated.':
|
||||
case 'There are too many players':
|
||||
case 'There are too many spectators':
|
||||
return new ServerOptionsException($faultString, $faultCode);
|
||||
case 'New mode unknown.':
|
||||
case 'You need to stop the server to change to/from script mode.':
|
||||
case 'Not in script mode.':
|
||||
case 'Not in Team mode.':
|
||||
case 'Not in Rounds or Laps mode.':
|
||||
case 'The scores must be decreasing.':
|
||||
return new GameModeException($faultString, $faultCode);
|
||||
case 'Unable to write the black list file.':
|
||||
case 'Unable to write the guest list file.':
|
||||
case 'Unable to write the playlist file.':
|
||||
case 'Could not save file.':
|
||||
case 'Map unknown.':
|
||||
case 'The playlist file does not exist.':
|
||||
case 'Invalid url or file.':
|
||||
case 'Invalid url.':
|
||||
return new FileException($faultString, $faultCode);
|
||||
}
|
||||
if(preg_match('~^Unknown setting \'.*\'\.$~iu', $faultString))
|
||||
return new GameModeException($faultString, $faultCode);
|
||||
if(preg_match('~^Couldn\'t load \'.*\'\.$~iu', $faultString))
|
||||
return new FileException($faultString, $faultCode);
|
||||
|
||||
return new self($faultString, $faultCode);
|
||||
}
|
||||
}
|
||||
|
||||
class AuthenticationException extends FaultException {}
|
||||
class UnavailableFeatureException extends FaultException {}
|
||||
class LockedFeatureException extends FaultException {}
|
||||
class UnknownPlayerException extends FaultException {}
|
||||
class PlayerStateException extends FaultException {}
|
||||
class AlreadyInListException extends FaultException {}
|
||||
class NotInListException extends FaultException {}
|
||||
class IndexOutOfBoundException extends FaultException {}
|
||||
class NextMapException extends FaultException{}
|
||||
class ChangeInProgressException extends FaultException {}
|
||||
class InvalidMapException extends FaultException{}
|
||||
class GameModeException extends FaultException {}
|
||||
class ServerOptionsException extends FaultException {}
|
||||
class FileException extends FaultException {}
|
326
libs/Maniaplanet/DedicatedServer/Xmlrpc/GbxRemote.php
Executable file
326
libs/Maniaplanet/DedicatedServer/Xmlrpc/GbxRemote.php
Executable file
@ -0,0 +1,326 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Xmlrpc;
|
||||
|
||||
class GbxRemote
|
||||
{
|
||||
const MAX_REQUEST_SIZE = 0x200000; // 2MB
|
||||
const MAX_RESPONSE_SIZE = 0x400000; // 4MB
|
||||
|
||||
public static $received;
|
||||
public static $sent;
|
||||
|
||||
private $socket;
|
||||
private $readTimeout = array('sec' => 5, 'usec' => 0);
|
||||
private $writeTimeout = array('sec' => 5, 'usec' => 0);
|
||||
private $requestHandle;
|
||||
private $callbacksBuffer = array();
|
||||
private $multicallBuffer = array();
|
||||
private $lastNetworkActivity = 0;
|
||||
|
||||
/**
|
||||
* @param string $host
|
||||
* @param int $port
|
||||
* @param int $timeout Timeout when opening connection
|
||||
*/
|
||||
function __construct($host, $port, $timeout = 5)
|
||||
{
|
||||
$this->requestHandle = (int) 0x80000000;
|
||||
$this->connect($host, $port, $timeout);
|
||||
}
|
||||
|
||||
function __destruct()
|
||||
{
|
||||
$this->terminate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change timeouts
|
||||
* @param int $read read timeout (in ms), 0 to leave unchanged
|
||||
* @param int $write write timeout (in ms), 0 to leave unchanged
|
||||
*/
|
||||
function setTimeouts($read=0, $write=0)
|
||||
{
|
||||
if($read)
|
||||
{
|
||||
$this->readTimeout['sec'] = (int) ($read / 1000);
|
||||
$this->readTimeout['usec'] = ($read % 1000) * 1000;
|
||||
}
|
||||
if($write)
|
||||
{
|
||||
$this->writeTimeout['sec'] = (int) ($write / 1000);
|
||||
$this->writeTimeout['usec'] = ($write % 1000) * 1000;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int Network idle time in seconds
|
||||
*/
|
||||
function getIdleTime()
|
||||
{
|
||||
$this->assertConnected();
|
||||
return time() - $this->lastNetworkActivity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $host
|
||||
* @param int $port
|
||||
* @param int $timeout
|
||||
* @throws TransportException
|
||||
*/
|
||||
private function connect($host, $port, $timeout)
|
||||
{
|
||||
$this->socket = @fsockopen($host, $port, $errno, $errstr, $timeout);
|
||||
if(!$this->socket)
|
||||
throw new TransportException('Cannot open socket', TransportException::NOT_INITIALIZED);
|
||||
|
||||
stream_set_read_buffer($this->socket, 0);
|
||||
stream_set_write_buffer($this->socket, 0);
|
||||
|
||||
// handshake
|
||||
$header = $this->read(15);
|
||||
if($header === false)
|
||||
$this->onIoFailure('during handshake');
|
||||
|
||||
extract(unpack('Vsize/a*protocol', $header));
|
||||
/** @var $size int */
|
||||
/** @var $protocol string */
|
||||
if($size != 11 || $protocol != 'GBXRemote 2')
|
||||
throw new TransportException('Wrong protocol header', TransportException::WRONG_PROTOCOL);
|
||||
$this->lastNetworkActivity = time();
|
||||
}
|
||||
|
||||
function terminate()
|
||||
{
|
||||
if($this->socket)
|
||||
{
|
||||
fclose($this->socket);
|
||||
$this->socket = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param mixed[] $args
|
||||
* @return mixed
|
||||
* @throws MessageException
|
||||
*/
|
||||
function query($method, $args=array())
|
||||
{
|
||||
$this->assertConnected();
|
||||
$xml = Request::encode($method, $args);
|
||||
|
||||
if(strlen($xml) > self::MAX_REQUEST_SIZE-8)
|
||||
{
|
||||
if($method != 'system.multicall' || count($args[0]) < 2)
|
||||
throw new MessageException('Request too large', MessageException::REQUEST_TOO_LARGE);
|
||||
|
||||
$mid = count($args[0]) >> 1;
|
||||
$res1 = $this->query('system.multicall', array(array_slice($args[0], 0, $mid)));
|
||||
$res2 = $this->query('system.multicall', array(array_slice($args[0], $mid)));
|
||||
return array_merge($res1, $res2);
|
||||
}
|
||||
|
||||
$this->writeMessage($xml);
|
||||
return $this->flush(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param mixed[] $args
|
||||
*/
|
||||
function addCall($method, $args)
|
||||
{
|
||||
$this->multicallBuffer[] = array(
|
||||
'methodName' => $method,
|
||||
'params' => $args
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
function multiquery()
|
||||
{
|
||||
switch(count($this->multicallBuffer))
|
||||
{
|
||||
case 0:
|
||||
return array();
|
||||
case 1:
|
||||
$call = array_shift($this->multicallBuffer);
|
||||
return array($this->query($call['methodName'], $call['params']));
|
||||
default:
|
||||
$result = $this->query('system.multicall', array($this->multicallBuffer));
|
||||
foreach($result as &$value)
|
||||
if(isset($value['faultCode']))
|
||||
$value = FaultException::create($value['faultString'], $value['faultCode']);
|
||||
else
|
||||
$value = $value[0];
|
||||
$this->multicallBuffer = array();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
function getCallbacks()
|
||||
{
|
||||
$this->assertConnected();
|
||||
$this->flush();
|
||||
$cb = $this->callbacksBuffer;
|
||||
$this->callbacksBuffer = array();
|
||||
return $cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws TransportException
|
||||
*/
|
||||
private function assertConnected()
|
||||
{
|
||||
if(!$this->socket)
|
||||
throw new TransportException('Connection not initialized', TransportException::NOT_INITIALIZED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $waitResponse
|
||||
* @return mixed
|
||||
* @throws FaultException
|
||||
*/
|
||||
private function flush($waitResponse=false)
|
||||
{
|
||||
$r = array($this->socket);
|
||||
while($waitResponse || @stream_select($r, $w, $e, 0) > 0)
|
||||
{
|
||||
list($handle, $xml) = $this->readMessage();
|
||||
list($type, $value) = Request::decode($xml);
|
||||
switch($type)
|
||||
{
|
||||
case 'fault':
|
||||
throw FaultException::create($value['faultString'], $value['faultCode']);
|
||||
case 'response':
|
||||
if($handle == $this->requestHandle)
|
||||
return $value;
|
||||
break;
|
||||
case 'call':
|
||||
$this->callbacksBuffer[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
* @throws TransportException
|
||||
* @throws MessageException
|
||||
*/
|
||||
private function readMessage()
|
||||
{
|
||||
$header = $this->read(8);
|
||||
if($header === false)
|
||||
$this->onIoFailure('while reading header');
|
||||
|
||||
extract(unpack('Vsize/Vhandle', $header));
|
||||
/** @var $size int */
|
||||
/** @var $handle int */
|
||||
if($size == 0 || $handle == 0)
|
||||
throw new TransportException('Incorrect header', TransportException::PROTOCOL_ERROR);
|
||||
|
||||
if($size > self::MAX_RESPONSE_SIZE)
|
||||
throw new MessageException('Response too large', MessageException::RESPONSE_TOO_LARGE);
|
||||
|
||||
$data = $this->read($size);
|
||||
if($data === false)
|
||||
$this->onIoFailure('while reading data');
|
||||
|
||||
$this->lastNetworkActivity = time();
|
||||
return array($handle, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $xml
|
||||
* @throws TransportException
|
||||
*/
|
||||
private function writeMessage($xml)
|
||||
{
|
||||
if($this->requestHandle == (int) 0xffffffff)
|
||||
$this->requestHandle = (int) 0x80000000;
|
||||
$data = pack('V2', strlen($xml), ++$this->requestHandle).$xml;
|
||||
if(!$this->write($data))
|
||||
$this->onIoFailure('while writing');
|
||||
$this->lastNetworkActivity = time();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $size
|
||||
* @return boolean|string
|
||||
*/
|
||||
private function read($size)
|
||||
{
|
||||
@stream_set_timeout($this->socket, $this->readTimeout['sec'], $this->readTimeout['usec']);
|
||||
|
||||
$data = '';
|
||||
while(strlen($data) < $size)
|
||||
{
|
||||
$buf = @fread($this->socket, $size - strlen($data));
|
||||
if($buf === '' || $buf === false)
|
||||
return false;
|
||||
$data .= $buf;
|
||||
}
|
||||
|
||||
self::$received += $size;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
* @return boolean
|
||||
*/
|
||||
private function write($data)
|
||||
{
|
||||
@stream_set_timeout($this->socket, $this->writeTimeout['sec'], $this->writeTimeout['usec']);
|
||||
self::$sent += strlen($data);
|
||||
|
||||
while(strlen($data) > 0)
|
||||
{
|
||||
$written = @fwrite($this->socket, $data);
|
||||
if($written === 0 || $written === false)
|
||||
return false;
|
||||
|
||||
$data = substr($data, $written);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $when
|
||||
* @throws TransportException
|
||||
*/
|
||||
private function onIoFailure($when)
|
||||
{
|
||||
$meta = stream_get_meta_data($this->socket);
|
||||
if($meta['timed_out'])
|
||||
throw new TransportException('Connection timed out '.$when, TransportException::TIMED_OUT);
|
||||
throw new TransportException('Connection interrupted '.$when, TransportException::INTERRUPTED);
|
||||
}
|
||||
}
|
||||
|
||||
class TransportException extends Exception
|
||||
{
|
||||
const NOT_INITIALIZED = 1;
|
||||
const INTERRUPTED = 2;
|
||||
const TIMED_OUT = 3;
|
||||
const WRONG_PROTOCOL = 4;
|
||||
const PROTOCOL_ERROR = 5;
|
||||
}
|
||||
|
||||
class MessageException extends Exception
|
||||
{
|
||||
const REQUEST_TOO_LARGE = 1;
|
||||
const RESPONSE_TOO_LARGE = 2;
|
||||
}
|
200
libs/Maniaplanet/DedicatedServer/Xmlrpc/Request.php
Executable file
200
libs/Maniaplanet/DedicatedServer/Xmlrpc/Request.php
Executable file
@ -0,0 +1,200 @@
|
||||
<?php
|
||||
/**
|
||||
* ManiaPlanet dedicated server Xml-RPC client
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
|
||||
namespace Maniaplanet\DedicatedServer\Xmlrpc;
|
||||
|
||||
if(extension_loaded('xmlrpc'))
|
||||
{
|
||||
abstract class Request
|
||||
{
|
||||
private static $options = array(
|
||||
'encoding' => 'utf-8',
|
||||
'escaping' => 'markup',
|
||||
'verbosity' => 'no_white_space'
|
||||
);
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param mixed[] $args
|
||||
* @return string
|
||||
*/
|
||||
static function encode($method, $args, $escape=true)
|
||||
{
|
||||
$opts = self::$options;
|
||||
if(!$escape)
|
||||
$opts['escaping'] = array();
|
||||
return xmlrpc_encode_request($method, $args, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @return mixed
|
||||
* @throws ParseException
|
||||
*/
|
||||
static function decode($message)
|
||||
{
|
||||
$value = xmlrpc_decode_request($message, $method, 'utf-8');
|
||||
if($value === null)
|
||||
throw new ParseException();
|
||||
|
||||
if($method === null)
|
||||
{
|
||||
if(is_array($value) && xmlrpc_is_fault($value))
|
||||
return array('fault', $value);
|
||||
return array('response', $value);
|
||||
}
|
||||
return array('call', array($method, $value));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
abstract class Request
|
||||
{
|
||||
const DATE_FORMAT = 'Ymd\TH:i:s';
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param mixed[] $args
|
||||
* @return string
|
||||
*/
|
||||
static function encode($method, $args, $escape=true)
|
||||
{
|
||||
$xml = '<?xml version="1.0" encoding="utf-8"?><methodCall><methodName>'.self::escape($method, $escape).'</methodName>';
|
||||
if(!$args)
|
||||
return $xml.'<params/></methodCall>';
|
||||
|
||||
$xml .= '<params>';
|
||||
foreach($args as $arg)
|
||||
$xml .= '<param><value>'.self::encodeValue($arg, $escape).'</value></param>';
|
||||
return $xml.'</params></methodCall>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $v
|
||||
* @return string
|
||||
*/
|
||||
private static function encodeValue($v, $escape=true)
|
||||
{
|
||||
switch(gettype($v))
|
||||
{
|
||||
case 'boolean':
|
||||
return '<boolean>'.((int) $v).'</boolean>';
|
||||
case 'integer':
|
||||
return '<int>'.$v.'</int>';
|
||||
case 'double':
|
||||
return '<double>'.$v.'</double>';
|
||||
case 'string':
|
||||
case 'NULL':
|
||||
if(!$v)
|
||||
return '<string/>';
|
||||
return '<string>'.self::escape($v, $escape).'</string>';
|
||||
case 'object':
|
||||
if($v instanceof Base64)
|
||||
{
|
||||
if(!$v->scalar)
|
||||
return '<base64/>';
|
||||
return '<base64>'.base64_encode($v->scalar).'</base64>';
|
||||
}
|
||||
if($v instanceof \DateTime)
|
||||
return '<dateTime.iso8601>'.$v->format(self::DATE_FORMAT).'</dateTime.iso8601>';
|
||||
$v = get_object_vars($v);
|
||||
// fallthrough
|
||||
case 'array':
|
||||
// empty array case
|
||||
if(!$v)
|
||||
return '<array><data/></array>';
|
||||
$return = '';
|
||||
// pure array case
|
||||
if(array_keys($v) === range(0, count($v) - 1))
|
||||
{
|
||||
foreach($v as $item)
|
||||
$return .= '<value>'.self::encodeValue($item, $escape).'</value>';
|
||||
return '<array><data>'.$return.'</data></array>';
|
||||
}
|
||||
// else it's a struct
|
||||
foreach($v as $name => $value)
|
||||
$return .= '<member><name>'.self::escape($name, $escape).'</name><value>'.self::encodeValue($value, $escape).'</value></member>';
|
||||
return '<struct>'.$return.'</struct>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $str
|
||||
* @param bool $escape
|
||||
* @return string
|
||||
*/
|
||||
private static function escape($str, $escape=true)
|
||||
{
|
||||
if($escape)
|
||||
return '<![CDATA['.str_replace(']]>', ']]]]><![CDATA[>', $str).']]>';
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @return mixed
|
||||
* @throws ParseException
|
||||
*/
|
||||
static function decode($message)
|
||||
{
|
||||
$xml = @simplexml_load_string($message);
|
||||
if(!$xml)
|
||||
throw new ParseException();
|
||||
|
||||
if($xml->getName() == 'methodResponse')
|
||||
{
|
||||
if($xml->fault)
|
||||
return array('fault', self::decodeValue($xml->fault->value));
|
||||
return array('response', self::decodeValue($xml->params->param->value));
|
||||
}
|
||||
$params = array();
|
||||
foreach($xml->params->param as $param)
|
||||
$params[] = self::decodeValue($param->value);
|
||||
return array('call', array((string) $xml->methodName, $params));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \SimpleXMLElement $elt
|
||||
* @return mixed
|
||||
*/
|
||||
private static function decodeValue($elt)
|
||||
{
|
||||
$elt = $elt->children();
|
||||
$elt = $elt[0];
|
||||
switch($elt->getName())
|
||||
{
|
||||
case 'boolean':
|
||||
return (bool) (int) $elt;
|
||||
case 'i4':
|
||||
case 'int':
|
||||
return (int) $elt;
|
||||
case 'double':
|
||||
return (double) $elt;
|
||||
case 'string':
|
||||
return (string) $elt;
|
||||
case 'base64':
|
||||
return new Base64(base64_decode($elt));
|
||||
case 'dateTime.iso8601':
|
||||
return \DateTime::createFromFormat(self::DATE_FORMAT, (string) $elt);
|
||||
case 'array':
|
||||
$arr = array();
|
||||
foreach($elt->data->value as $v)
|
||||
$arr[] = self::decodeValue($v);
|
||||
return $arr;
|
||||
case 'struct':
|
||||
$struct = array();
|
||||
foreach($elt as $member)
|
||||
$struct[(string) $member->name] = self::decodeValue($member->value);
|
||||
return $struct;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ParseException extends Exception {}
|
Reference in New Issue
Block a user