From 10bbd5383fb52b7b2fbfaf89267517f7fb5d952f Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 20 Apr 2014 18:00:40 +0200 Subject: [PATCH] dedi lib update --- .../DedicatedServer/Xmlrpc/GbxRemote.php | 4 +++- .../DedicatedServer/Xmlrpc/Request.php | 22 +++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/application/core/Libs/Maniaplanet/DedicatedServer/Xmlrpc/GbxRemote.php b/application/core/Libs/Maniaplanet/DedicatedServer/Xmlrpc/GbxRemote.php index 723cf152..5965f913 100644 --- a/application/core/Libs/Maniaplanet/DedicatedServer/Xmlrpc/GbxRemote.php +++ b/application/core/Libs/Maniaplanet/DedicatedServer/Xmlrpc/GbxRemote.php @@ -73,10 +73,12 @@ class GbxRemote private function connect($host, $port) { $this->socket = @fsockopen($host, $port, $errno, $errstr, $this->timeouts['open']); - stream_set_write_buffer($this->socket, 0); + if(!$this->socket) throw new TransportException('Cannot open socket', TransportException::NOT_INITIALIZED); + stream_set_write_buffer($this->socket, 0); + // handshake $header = $this->read(15); if($header === false) diff --git a/application/core/Libs/Maniaplanet/DedicatedServer/Xmlrpc/Request.php b/application/core/Libs/Maniaplanet/DedicatedServer/Xmlrpc/Request.php index a3a69aff..861569d1 100644 --- a/application/core/Libs/Maniaplanet/DedicatedServer/Xmlrpc/Request.php +++ b/application/core/Libs/Maniaplanet/DedicatedServer/Xmlrpc/Request.php @@ -13,7 +13,7 @@ if(extension_loaded('xmlrpc')) { private static $options = array( 'encoding' => 'utf-8', - 'escaping' => 'markup', + 'escaping' => 'cdata', 'verbosity' => 'no_white_space' ); @@ -61,7 +61,7 @@ else */ static function encode($method, $args) { - $xml = ''.$method.''; + $xml = ''; foreach($args as $arg) $xml .= ''.self::encodeValue($arg).''; $xml .= ''; @@ -77,24 +77,24 @@ else switch(gettype($v)) { case 'boolean': - return ''.((int) $v).''; + return ''; case 'integer': - return ''.$v.''; + return ''; case 'double': - return ''.$v.''; + return ''; case 'string': - return ''.htmlspecialchars($v).''; + return ''; case 'object': if($v instanceof Base64) - return ''.base64_encode($v->scalar).''; + return 'scalar).']]>'; if($v instanceof \DateTime) - return ''.$v->format(self::DATE_FORMAT).''; + return 'format(self::DATE_FORMAT).']]>'; $v = get_object_vars($v); - // fallthrough + // fallthrough case 'array': $return = ''; // pure array case - if(array_keys($v) == range(0, count($v) - 1)) + if(array_keys($v) === range(0, count($v) - 1)) { foreach($v as $item) $return .= ''.self::encodeValue($item).''; @@ -102,7 +102,7 @@ else } // else it's a struct foreach($v as $name => $value) - $return .= ''.$name.''.self::encodeValue($value).''; + $return .= ''.self::encodeValue($value).''; return ''.$return.''; } return '';