dedi lib update

This commit is contained in:
kremsy 2014-04-20 18:00:40 +02:00 committed by Steffen Schröder
parent 9dc3ba395b
commit 10bbd5383f
2 changed files with 14 additions and 12 deletions

View File

@ -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)

View File

@ -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 = '<?xml version="1.0" encoding="utf-8"?><methodCall><methodName>'.$method.'</methodName><params>';
$xml = '<?xml version="1.0" encoding="utf-8"?><methodCall><methodName><![CDATA['.$method.']]></methodName><params>';
foreach($args as $arg)
$xml .= '<param><value>'.self::encodeValue($arg).'</value></param>';
$xml .= '</params></methodCall>';
@ -77,24 +77,24 @@ else
switch(gettype($v))
{
case 'boolean':
return '<boolean>'.((int) $v).'</boolean>';
return '<boolean><![CDATA['.((int) $v).']]></boolean>';
case 'integer':
return '<int>'.$v.'</int>';
return '<int><![CDATA['.$v.']]></int>';
case 'double':
return '<double>'.$v.'</double>';
return '<double><![CDATA['.$v.']]></double>';
case 'string':
return '<string>'.htmlspecialchars($v).'</string>';
return '<string><![CDATA['.$v.']]></string>';
case 'object':
if($v instanceof Base64)
return '<base64>'.base64_encode($v->scalar).'</base64>';
return '<base64><![CDATA['.base64_encode($v->scalar).']]></base64>';
if($v instanceof \DateTime)
return '<dateTime.iso8601>'.$v->format(self::DATE_FORMAT).'</dateTime.iso8601>';
return '<dateTime.iso8601><![CDATA['.$v->format(self::DATE_FORMAT).']]></dateTime.iso8601>';
$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 .= '<value>'.self::encodeValue($item).'</value>';
@ -102,7 +102,7 @@ else
}
// else it's a struct
foreach($v as $name => $value)
$return .= '<member><name>'.$name.'</name><value>'.self::encodeValue($value).'</value></member>';
$return .= '<member><name><![CDATA['.$name.']]></name><value>'.self::encodeValue($value).'</value></member>';
return '<struct>'.$return.'</struct>';
}
return '';