| Current File : /home/k/a/r/karenpetzb/www/items/category/XmlRpc.zip |
PK �:H[�W4�@ �@
Server.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Server
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Server.php 12195 2008-10-30 13:34:35Z matthew $
*/
/**
* Extends Zend_Server_Abstract
*/
require_once 'Zend/Server/Abstract.php';
/**
* Exception this class throws
*/
require_once 'Zend/XmlRpc/Server/Exception.php';
/**
* XMLRPC Request
*/
require_once 'Zend/XmlRpc/Request.php';
/**
* XMLRPC Response
*/
require_once 'Zend/XmlRpc/Response.php';
/**
* XMLRPC HTTP Response
*/
require_once 'Zend/XmlRpc/Response/Http.php';
/**
* XMLRPC server fault class
*/
require_once 'Zend/XmlRpc/Server/Fault.php';
/**
* XMLRPC server system methods class
*/
require_once 'Zend/XmlRpc/Server/System.php';
/**
* Convert PHP to and from xmlrpc native types
*/
require_once 'Zend/XmlRpc/Value.php';
/**
* Reflection API for function/method introspection
*/
require_once 'Zend/Server/Reflection.php';
/**
* Zend_Server_Reflection_Function_Abstract
*/
require_once 'Zend/Server/Reflection/Function/Abstract.php';
/**
* Specifically grab the Zend_Server_Reflection_Method for manually setting up
* system.* methods and handling callbacks in {@link loadFunctions()}.
*/
require_once 'Zend/Server/Reflection/Method.php';
/**
* An XML-RPC server implementation
*
* Example:
* <code>
* require_once 'Zend/XmlRpc/Server.php';
* require_once 'Zend/XmlRpc/Server/Cache.php';
* require_once 'Zend/XmlRpc/Server/Fault.php';
* require_once 'My/Exception.php';
* require_once 'My/Fault/Observer.php';
*
* // Instantiate server
* $server = new Zend_XmlRpc_Server();
*
* // Allow some exceptions to report as fault responses:
* Zend_XmlRpc_Server_Fault::attachFaultException('My_Exception');
* Zend_XmlRpc_Server_Fault::attachObserver('My_Fault_Observer');
*
* // Get or build dispatch table:
* if (!Zend_XmlRpc_Server_Cache::get($filename, $server)) {
* require_once 'Some/Service/Class.php';
* require_once 'Another/Service/Class.php';
*
* // Attach Some_Service_Class in 'some' namespace
* $server->setClass('Some_Service_Class', 'some');
*
* // Attach Another_Service_Class in 'another' namespace
* $server->setClass('Another_Service_Class', 'another');
*
* // Create dispatch table cache file
* Zend_XmlRpc_Server_Cache::save($filename, $server);
* }
*
* $response = $server->handle();
* echo $response;
* </code>
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Server
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Server extends Zend_Server_Abstract
{
/**
* Character encoding
* @var string
*/
protected $_encoding = 'UTF-8';
/**
* Request processed
* @var null|Zend_XmlRpc_Request
*/
protected $_request = null;
/**
* Class to use for responses; defaults to {@link Zend_XmlRpc_Response_Http}
* @var string
*/
protected $_responseClass = 'Zend_XmlRpc_Response_Http';
/**
* Dispatch table of name => method pairs
* @var Zend_XmlRpc_Server_ServerDefinition
*/
protected $_table;
/**
* PHP types => XML-RPC types
* @var array
*/
protected $_typeMap = array(
'i4' => 'i4',
'int' => 'int',
'integer' => 'int',
'double' => 'double',
'float' => 'double',
'real' => 'double',
'boolean' => 'boolean',
'bool' => 'boolean',
'true' => 'boolean',
'false' => 'boolean',
'string' => 'string',
'str' => 'string',
'base64' => 'base64',
'dateTime.iso8601' => 'dateTime.iso8601',
'date' => 'dateTime.iso8601',
'time' => 'dateTime.iso8601',
'time' => 'dateTime.iso8601',
'array' => 'array',
'struct' => 'struct',
'null' => 'nil',
'nil' => 'nil',
'void' => 'void',
'mixed' => 'struct'
);
/**
* Constructor
*
* Creates system.* methods.
*
* @return void
*/
public function __construct()
{
$this->_table = new Zend_Server_Definition();
$this->_registerSystemMethods();
}
/**
* Proxy calls to system object
*
* @param string $method
* @param array $params
* @return mixed
* @throws Zend_XmlRpc_Server_Exception
*/
public function __call($method, $params)
{
$system = $this->getSystem();
if (!method_exists($system, $method)) {
throw new Zend_XmlRpc_Server_Exception('Unknown instance method called on server: ' . $method);
}
return call_user_func_array(array($system, $method), $params);
}
/**
* Attach a callback as an XMLRPC method
*
* Attaches a callback as an XMLRPC method, prefixing the XMLRPC method name
* with $namespace, if provided. Reflection is done on the callback's
* docblock to create the methodHelp for the XMLRPC method.
*
* Additional arguments to pass to the function at dispatch may be passed;
* any arguments following the namespace will be aggregated and passed at
* dispatch time.
*
* @param string|array $function Valid callback
* @param string $namespace Optional namespace prefix
* @return void
* @throws Zend_XmlRpc_Server_Exception
*/
public function addFunction($function, $namespace = '')
{
if (!is_string($function) && !is_array($function)) {
throw new Zend_XmlRpc_Server_Exception('Unable to attach function; invalid', 611);
}
$argv = null;
if (2 < func_num_args()) {
$argv = func_get_args();
$argv = array_slice($argv, 2);
}
$function = (array) $function;
foreach ($function as $func) {
if (!is_string($func) || !function_exists($func)) {
throw new Zend_XmlRpc_Server_Exception('Unable to attach function; invalid', 611);
}
$reflection = Zend_Server_Reflection::reflectFunction($func, $argv, $namespace);
$this->_buildSignature($reflection);
}
}
/**
* Attach class methods as XMLRPC method handlers
*
* $class may be either a class name or an object. Reflection is done on the
* class or object to determine the available public methods, and each is
* attached to the server as an available method; if a $namespace has been
* provided, that namespace is used to prefix the XMLRPC method names.
*
* Any additional arguments beyond $namespace will be passed to a method at
* invocation.
*
* @param string|object $class
* @param string $namespace Optional
* @param mixed $argv Optional arguments to pass to methods
* @return void
* @throws Zend_XmlRpc_Server_Exception on invalid input
*/
public function setClass($class, $namespace = '', $argv = null)
{
if (is_string($class) && !class_exists($class)) {
if (!class_exists($class)) {
throw new Zend_XmlRpc_Server_Exception('Invalid method class', 610);
}
}
$argv = null;
if (3 < func_num_args()) {
$argv = func_get_args();
$argv = array_slice($argv, 3);
}
$dispatchable = Zend_Server_Reflection::reflectClass($class, $argv, $namespace);
foreach ($dispatchable->getMethods() as $reflection) {
$this->_buildSignature($reflection, $class);
}
}
/**
* Raise an xmlrpc server fault
*
* @param string|Exception $fault
* @param int $code
* @return Zend_XmlRpc_Server_Fault
*/
public function fault($fault = null, $code = 404)
{
if (!$fault instanceof Exception) {
$fault = (string) $fault;
if (empty($fault)) {
$fault = 'Unknown error';
}
$fault = new Zend_XmlRpc_Server_Exception($fault, $code);
}
return Zend_XmlRpc_Server_Fault::getInstance($fault);
}
/**
* Handle an xmlrpc call
*
* @param Zend_XmlRpc_Request $request Optional
* @return Zend_XmlRpc_Response|Zend_XmlRpc_Fault
*/
public function handle($request = false)
{
// Get request
if ((!$request || !$request instanceof Zend_XmlRpc_Request)
&& (null === ($request = $this->getRequest()))
) {
require_once 'Zend/XmlRpc/Request/Http.php';
$request = new Zend_XmlRpc_Request_Http();
$request->setEncoding($this->getEncoding());
}
$this->setRequest($request);
if ($request->isFault()) {
$response = $request->getFault();
} else {
try {
$response = $this->_handle($request);
} catch (Exception $e) {
$response = $this->fault($e);
}
}
// Set output encoding
$response->setEncoding($this->getEncoding());
return $response;
}
/**
* Load methods as returned from {@link getFunctions}
*
* Typically, you will not use this method; it will be called using the
* results pulled from {@link Zend_XmlRpc_Server_Cache::get()}.
*
* @param array|Zend_Server_Definition $definition
* @return void
* @throws Zend_XmlRpc_Server_Exception on invalid input
*/
public function loadFunctions($definition)
{
if (!is_array($definition) && (!$definition instanceof Zend_Server_Definition)) {
if (is_object($definition)) {
$type = get_class($definition);
} else {
$type = gettype($definition);
}
throw new Zend_XmlRpc_Server_Exception('Unable to load server definition; must be an array or Zend_Server_Definition, received ' . $type, 612);
}
$this->_table->clearMethods();
$this->_registerSystemMethods();
if ($definition instanceof Zend_Server_Definition) {
$definition = $definition->getMethods();
}
foreach ($definition as $key => $method) {
if ('system.' == substr($key, 0, 7)) {
continue;
}
$this->_table->addMethod($method, $key);
}
}
/**
* Set encoding
*
* @param string $encoding
* @return Zend_XmlRpc_Server
*/
public function setEncoding($encoding)
{
$this->_encoding = $encoding;
return $this;
}
/**
* Retrieve current encoding
*
* @return string
*/
public function getEncoding()
{
return $this->_encoding;
}
/**
* Do nothing; persistence is handled via {@link Zend_XmlRpc_Server_Cache}
*
* @param mixed $mode
* @return void
*/
public function setPersistence($mode)
{
}
/**
* Set the request object
*
* @param string|Zend_XmlRpc_Request $request
* @return Zend_XmlRpc_Server
* @throws Zend_XmlRpc_Server_Exception on invalid request class or object
*/
public function setRequest($request)
{
if (is_string($request) && class_exists($request)) {
$request = new $request();
if (!$request instanceof Zend_XmlRpc_Request) {
throw new Zend_XmlRpc_Server_Exception('Invalid request class');
}
$request->setEncoding($this->getEncoding());
} elseif (!$request instanceof Zend_XmlRpc_Request) {
throw new Zend_XmlRpc_Server_Exception('Invalid request object');
}
$this->_request = $request;
return $this;
}
/**
* Return currently registered request object
*
* @return null|Zend_XmlRpc_Request
*/
public function getRequest()
{
return $this->_request;
}
/**
* Set the class to use for the response
*
* @param string $class
* @return boolean True if class was set, false if not
*/
public function setResponseClass($class)
{
if (class_exists($class)) {
$reflection = new ReflectionClass($class);
if ($reflection->isSubclassOf(new ReflectionClass('Zend_XmlRpc_Response'))) {
$this->_responseClass = $class;
return true;
}
}
return false;
}
/**
* Retrieve current response class
*
* @return string
*/
public function getResponseClass()
{
return $this->_responseClass;
}
/**
* Retrieve dispatch table
*
* @return array
*/
public function getDispatchTable()
{
return $this->_table;
}
/**
* Returns a list of registered methods
*
* Returns an array of dispatchables (Zend_Server_Reflection_Function,
* _Method, and _Class items).
*
* @return array
*/
public function getFunctions()
{
return $this->_table->toArray();
}
/**
* Retrieve system object
*
* @return Zend_XmlRpc_Server_System
*/
public function getSystem()
{
return $this->_system;
}
/**
* Map PHP type to XML-RPC type
*
* @param string $type
* @return string
*/
protected function _fixType($type)
{
if (isset($this->_typeMap[$type])) {
return $this->_typeMap[$type];
}
return 'void';
}
/**
* Handle an xmlrpc call (actual work)
*
* @param Zend_XmlRpc_Request $request
* @return Zend_XmlRpc_Response
* @throws Zend_XmlRpcServer_Exception|Exception
* Zend_XmlRpcServer_Exceptions are thrown for internal errors; otherwise,
* any other exception may be thrown by the callback
*/
protected function _handle(Zend_XmlRpc_Request $request)
{
$method = $request->getMethod();
// Check for valid method
if (!$this->_table->hasMethod($method)) {
throw new Zend_XmlRpc_Server_Exception('Method "' . $method . '" does not exist', 620);
}
$info = $this->_table->getMethod($method);
$params = $request->getParams();
$argv = $info->getInvokeArguments();
if (0 < count($argv)) {
$params = array_merge($params, $argv);
}
// Check calling parameters against signatures
$matched = false;
$sigCalled = $request->getTypes();
$sigLength = count($sigCalled);
$paramsLen = count($params);
if ($sigLength < $paramsLen) {
for ($i = $sigLength; $i < $paramsLen; ++$i) {
$xmlRpcValue = Zend_XmlRpc_Value::getXmlRpcValue($params[$i]);
$sigCalled[] = $xmlRpcValue->getType();
}
}
$signatures = $info->getPrototypes();
foreach ($signatures as $signature) {
$sigParams = $signature->getParameters();
if ($sigCalled === $sigParams) {
$matched = true;
break;
}
}
if (!$matched) {
throw new Zend_XmlRpc_Server_Exception('Calling parameters do not match signature', 623);
}
$return = $this->_dispatch($info, $params);
$responseClass = $this->getResponseClass();
return new $responseClass($return);
}
/**
* Register system methods with the server
*
* @return void
*/
protected function _registerSystemMethods()
{
$system = new Zend_XmlRpc_Server_System($this);
$this->_system = $system;
$this->setClass($system, 'system');
}
}
PK �:H[�18 18 Value.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Value.php 12721 2008-11-20 18:21:58Z matthew $
*/
/** Zend_XmlRpc_Value_Exception */
require_once 'Zend/XmlRpc/Value/Exception.php';
/** Zend_XmlRpc_Value_Scalar */
require_once 'Zend/XmlRpc/Value/Scalar.php';
/** Zend_XmlRpc_Value_Base64 */
require_once 'Zend/XmlRpc/Value/Base64.php';
/** Zend_XmlRpc_Value_Boolean */
require_once 'Zend/XmlRpc/Value/Boolean.php';
/** Zend_XmlRpc_Value_DateTime */
require_once 'Zend/XmlRpc/Value/DateTime.php';
/** Zend_XmlRpc_Value_Double */
require_once 'Zend/XmlRpc/Value/Double.php';
/** Zend_XmlRpc_Value_Integer */
require_once 'Zend/XmlRpc/Value/Integer.php';
/** Zend_XmlRpc_Value_String */
require_once 'Zend/XmlRpc/Value/String.php';
/** Zend_XmlRpc_Value_Nil */
require_once 'Zend/XmlRpc/Value/Nil.php';
/** Zend_XmlRpc_Value_Collection */
require_once 'Zend/XmlRpc/Value/Collection.php';
/** Zend_XmlRpc_Value_Array */
require_once 'Zend/XmlRpc/Value/Array.php';
/** Zend_XmlRpc_Value_Struct */
require_once 'Zend/XmlRpc/Value/Struct.php';
/**
* Represent a native XML-RPC value entity, used as parameters for the methods
* called by the Zend_XmlRpc_Client object and as the return value for those calls.
*
* This object as a very important static function Zend_XmlRpc_Value::getXmlRpcValue, this
* function acts likes a factory for the Zend_XmlRpc_Value objects
*
* Using this function, users/Zend_XmlRpc_Client object can create the Zend_XmlRpc_Value objects
* from PHP variables, XML string or by specifing the exact XML-RPC natvie type
*
* @package Zend_XmlRpc
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_XmlRpc_Value
{
/**
* The native XML-RPC representation of this object's value
*
* If the native type of this object is array or struct, this will be an array
* of Zend_XmlRpc_Value objects
*/
protected $_value;
/**
* The native XML-RPC type of this object
* One of the XMLRPC_TYPE_* constants
*/
protected $_type;
/**
* XML code representation of this object (will be calculated only once)
*/
protected $_as_xml;
/**
* DOMElement representation of object (will be calculated only once)
*/
protected $_as_dom;
/**
* Specify that the XML-RPC native type will be auto detected from a PHP variable type
*/
const AUTO_DETECT_TYPE = 'auto_detect';
/**
* Specify that the XML-RPC value will be parsed out from a given XML code
*/
const XML_STRING = 'xml';
/**
* All the XML-RPC native types
*/
const XMLRPC_TYPE_I4 = 'i4';
const XMLRPC_TYPE_INTEGER = 'int';
const XMLRPC_TYPE_DOUBLE = 'double';
const XMLRPC_TYPE_BOOLEAN = 'boolean';
const XMLRPC_TYPE_STRING = 'string';
const XMLRPC_TYPE_DATETIME = 'dateTime.iso8601';
const XMLRPC_TYPE_BASE64 = 'base64';
const XMLRPC_TYPE_ARRAY = 'array';
const XMLRPC_TYPE_STRUCT = 'struct';
const XMLRPC_TYPE_NIL = 'nil';
/**
* Get the native XML-RPC type (the type is one of the Zend_XmlRpc_Value::XMLRPC_TYPE_* constants)
*
* @return string
*/
public function getType()
{
return $this->_type;
}
/**
* Return the value of this object, convert the XML-RPC native value into a PHP variable
*
* @return mixed
*/
abstract public function getValue();
/**
* Return the XML code that represent a native MXL-RPC value
*
* @return string
*/
abstract public function saveXML();
/**
* Return DOMElement representation of object
*
* @return DOMElement
*/
public function getAsDOM()
{
if (!$this->_as_dom) {
$doc = new DOMDocument('1.0');
$doc->loadXML($this->saveXML());
$this->_as_dom = $doc->documentElement;
}
return $this->_as_dom;
}
protected function _stripXmlDeclaration(DOMDocument $dom)
{
return preg_replace('/<\?xml version="1.0"( encoding="[^\"]*")?\?>\n/u', '', $dom->saveXML());
}
/**
* Creates a Zend_XmlRpc_Value* object, representing a native XML-RPC value
* A XmlRpcValue object can be created in 3 ways:
* 1. Autodetecting the native type out of a PHP variable
* (if $type is not set or equal to Zend_XmlRpc_Value::AUTO_DETECT_TYPE)
* 2. By specifing the native type ($type is one of the Zend_XmlRpc_Value::XMLRPC_TYPE_* constants)
* 3. From a XML string ($type is set to Zend_XmlRpc_Value::XML_STRING)
*
* By default the value type is autodetected according to it's PHP type
*
* @param mixed $value
* @param Zend_XmlRpc_Value::constant $type
*
* @return Zend_XmlRpc_Value
* @static
*/
public static function getXmlRpcValue($value, $type = self::AUTO_DETECT_TYPE)
{
switch ($type) {
case self::AUTO_DETECT_TYPE:
// Auto detect the XML-RPC native type from the PHP type of $value
return self::_phpVarToNativeXmlRpc($value);
case self::XML_STRING:
// Parse the XML string given in $value and get the XML-RPC value in it
return self::_xmlStringToNativeXmlRpc($value);
case self::XMLRPC_TYPE_I4:
// fall through to the next case
case self::XMLRPC_TYPE_INTEGER:
return new Zend_XmlRpc_Value_Integer($value);
case self::XMLRPC_TYPE_DOUBLE:
return new Zend_XmlRpc_Value_Double($value);
case self::XMLRPC_TYPE_BOOLEAN:
return new Zend_XmlRpc_Value_Boolean($value);
case self::XMLRPC_TYPE_STRING:
return new Zend_XmlRpc_Value_String($value);
case self::XMLRPC_TYPE_BASE64:
return new Zend_XmlRpc_Value_Base64($value);
case self::XMLRPC_TYPE_NIL:
return new Zend_XmlRpc_Value_Nil();
case self::XMLRPC_TYPE_DATETIME:
return new Zend_XmlRpc_Value_DateTime($value);
case self::XMLRPC_TYPE_ARRAY:
return new Zend_XmlRpc_Value_Array($value);
case self::XMLRPC_TYPE_STRUCT:
return new Zend_XmlRpc_Value_Struct($value);
default:
throw new Zend_XmlRpc_Value_Exception('Given type is not a '. __CLASS__ .' constant');
}
}
/**
* Transform a PHP native variable into a XML-RPC native value
*
* @param mixed $value The PHP variable for convertion
*
* @return Zend_XmlRpc_Value
* @static
*/
private static function _phpVarToNativeXmlRpc($value)
{
switch (gettype($value)) {
case 'object':
// Check to see if it's an XmlRpc value
if ($value instanceof Zend_XmlRpc_Value) {
return $value;
}
// Otherwise, we convert the object into a struct
$value = get_object_vars($value);
// Break intentionally omitted
case 'array':
// Default native type for a PHP array (a simple numeric array) is 'array'
$obj = 'Zend_XmlRpc_Value_Array';
// Determine if this is an associative array
if (!empty($value) && is_array($value) && (array_keys($value) !== range(0, count($value) - 1))) {
$obj = 'Zend_XmlRpc_Value_Struct';
}
return new $obj($value);
case 'integer':
return new Zend_XmlRpc_Value_Integer($value);
case 'double':
return new Zend_XmlRpc_Value_Double($value);
case 'boolean':
return new Zend_XmlRpc_Value_Boolean($value);
case 'NULL':
case 'null':
return new Zend_XmlRpc_Value_Nil();
case 'string':
// Fall through to the next case
default:
// If type isn't identified (or identified as string), it treated as string
return new Zend_XmlRpc_Value_String($value);
}
}
/**
* Transform an XML string into a XML-RPC native value
*
* @param string|SimpleXMLElement $simple_xml A SimpleXMLElement object represent the XML string
* It can be also a valid XML string for convertion
*
* @return Zend_XmlRpc_Value
* @static
*/
private static function _xmlStringToNativeXmlRpc($simple_xml)
{
if (!$simple_xml instanceof SimpleXMLElement) {
try {
$simple_xml = @new SimpleXMLElement($simple_xml);
} catch (Exception $e) {
// The given string is not a valid XML
throw new Zend_XmlRpc_Value_Exception('Failed to create XML-RPC value from XML string: '.$e->getMessage(),$e->getCode());
}
}
// Get the key (tag name) and value from the simple xml object and convert the value to an XML-RPC native value
list($type, $value) = each($simple_xml);
if (!$type) { // If no type was specified, the default is string
$type = self::XMLRPC_TYPE_STRING;
}
switch ($type) {
// All valid and known XML-RPC native values
case self::XMLRPC_TYPE_I4:
// Fall through to the next case
case self::XMLRPC_TYPE_INTEGER:
$xmlrpc_val = new Zend_XmlRpc_Value_Integer($value);
break;
case self::XMLRPC_TYPE_DOUBLE:
$xmlrpc_val = new Zend_XmlRpc_Value_Double($value);
break;
case self::XMLRPC_TYPE_BOOLEAN:
$xmlrpc_val = new Zend_XmlRpc_Value_Boolean($value);
break;
case self::XMLRPC_TYPE_STRING:
$xmlrpc_val = new Zend_XmlRpc_Value_String($value);
break;
case self::XMLRPC_TYPE_DATETIME: // The value should already be in a iso8601 format
$xmlrpc_val = new Zend_XmlRpc_Value_DateTime($value);
break;
case self::XMLRPC_TYPE_BASE64: // The value should already be base64 encoded
$xmlrpc_val = new Zend_XmlRpc_Value_Base64($value ,true);
break;
case self::XMLRPC_TYPE_NIL: // The value should always be NULL
$xmlrpc_val = new Zend_XmlRpc_Value_Nil();
break;
case self::XMLRPC_TYPE_ARRAY:
// If the XML is valid, $value must be an SimpleXML element and contain the <data> tag
if (!$value instanceof SimpleXMLElement) {
throw new Zend_XmlRpc_Value_Exception('XML string is invalid for XML-RPC native '. self::XMLRPC_TYPE_ARRAY .' type');
}
// PHP 5.2.4 introduced a regression in how empty($xml->value)
// returns; need to look for the item specifically
$data = null;
foreach ($value->children() as $key => $value) {
if ('data' == $key) {
$data = $value;
break;
}
}
if (null === $data) {
throw new Zend_XmlRpc_Value_Exception('Invalid XML for XML-RPC native '. self::XMLRPC_TYPE_ARRAY .' type: ARRAY tag must contain DATA tag');
}
$values = array();
// Parse all the elements of the array from the XML string
// (simple xml element) to Zend_XmlRpc_Value objects
foreach ($data->value as $element) {
$values[] = self::_xmlStringToNativeXmlRpc($element);
}
$xmlrpc_val = new Zend_XmlRpc_Value_Array($values);
break;
case self::XMLRPC_TYPE_STRUCT:
// If the XML is valid, $value must be an SimpleXML
if ((!$value instanceof SimpleXMLElement)) {
throw new Zend_XmlRpc_Value_Exception('XML string is invalid for XML-RPC native '. self::XMLRPC_TYPE_STRUCT .' type');
}
$values = array();
// Parse all the memebers of the struct from the XML string
// (simple xml element) to Zend_XmlRpc_Value objects
foreach ($value->member as $member) {
// @todo? If a member doesn't have a <value> tag, we don't add it to the struct
// Maybe we want to throw an exception here ?
if ((!$member->value instanceof SimpleXMLElement)) {
continue;
//throw new Zend_XmlRpc_Value_Exception('Member of the '. self::XMLRPC_TYPE_STRUCT .' XML-RPC native type must contain a VALUE tag');
}
$values[(string)$member->name] = self::_xmlStringToNativeXmlRpc($member->value);
}
$xmlrpc_val = new Zend_XmlRpc_Value_Struct($values);
break;
default:
throw new Zend_XmlRpc_Value_Exception('Value type \''. $type .'\' parsed from the XML string is not a known XML-RPC native type');
break;
}
$xmlrpc_val->_setXML($simple_xml->asXML());
return $xmlrpc_val;
}
private function _setXML($xml)
{
$this->_as_xml = $xml;
}
}
PK �:H[G���T/ T/ Request.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Controller
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Zend_XmlRpc_Exception
*/
require_once 'Zend/XmlRpc/Exception.php';
/**
* Zend_XmlRpc_Value
*/
require_once 'Zend/XmlRpc/Value.php';
/**
* Zend_XmlRpc_Fault
*/
require_once 'Zend/XmlRpc/Fault.php';
/**
* XmlRpc Request object
*
* Encapsulates an XmlRpc request, holding the method call and all parameters.
* Provides accessors for these, as well as the ability to load from XML and to
* create the XML request string.
*
* Additionally, if errors occur setting the method or parsing XML, a fault is
* generated and stored in {@link $_fault}; developers may check for it using
* {@link isFault()} and {@link getFault()}.
*
* @category Zend
* @package Zend_XmlRpc
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Request.php 8997 2008-03-22 17:17:05Z matthew $
*/
class Zend_XmlRpc_Request
{
/**
* Request character encoding
* @var string
*/
protected $_encoding = 'UTF-8';
/**
* Method to call
* @var string
*/
protected $_method;
/**
* XML request
* @var string
*/
protected $_xml;
/**
* Method parameters
* @var array
*/
protected $_params = array();
/**
* Fault object, if any
* @var Zend_XmlRpc_Fault
*/
protected $_fault = null;
/**
* XML-RPC type for each param
* @var array
*/
protected $_types = array();
/**
* XML-RPC request params
* @var array
*/
protected $_xmlRpcParams = array();
/**
* Create a new XML-RPC request
*
* @param string $method (optional)
* @param array $params (optional)
*/
public function __construct($method = null, $params = null)
{
if ($method !== null) {
$this->setMethod($method);
}
if ($params !== null) {
$this->setParams($params);
}
}
/**
* Set encoding to use in request
*
* @param string $encoding
* @return Zend_XmlRpc_Request
*/
public function setEncoding($encoding)
{
$this->_encoding = $encoding;
return $this;
}
/**
* Retrieve current request encoding
*
* @return string
*/
public function getEncoding()
{
return $this->_encoding;
}
/**
* Set method to call
*
* @param string $method
* @return boolean Returns true on success, false if method name is invalid
*/
public function setMethod($method)
{
if (!is_string($method) || !preg_match('/^[a-z0-9_.:\/]+$/i', $method)) {
$this->_fault = new Zend_XmlRpc_Fault(634, 'Invalid method name ("' . $method . '")');
$this->_fault->setEncoding($this->getEncoding());
return false;
}
$this->_method = $method;
return true;
}
/**
* Retrieve call method
*
* @return string
*/
public function getMethod()
{
return $this->_method;
}
/**
* Add a parameter to the parameter stack
*
* Adds a parameter to the parameter stack, associating it with the type
* $type if provided
*
* @param mixed $value
* @param string $type Optional; type hinting
* @return void
*/
public function addParam($value, $type = null)
{
$this->_params[] = $value;
if (null === $type) {
// Detect type if not provided explicitly
if ($value instanceof Zend_XmlRpc_Value) {
$type = $value->getType();
} else {
$xmlRpcValue = Zend_XmlRpc_Value::getXmlRpcValue($value);
$type = $xmlRpcValue->getType();
}
}
$this->_types[] = $type;
$this->_xmlRpcParams[] = array('value' => $value, 'type' => $type);
}
/**
* Set the parameters array
*
* If called with a single, array value, that array is used to set the
* parameters stack. If called with multiple values or a single non-array
* value, the arguments are used to set the parameters stack.
*
* Best is to call with array of the format, in order to allow type hinting
* when creating the XMLRPC values for each parameter:
* <code>
* $array = array(
* array(
* 'value' => $value,
* 'type' => $type
* )[, ... ]
* );
* </code>
*
* @access public
* @return void
*/
public function setParams()
{
$argc = func_num_args();
$argv = func_get_args();
if (0 == $argc) {
return;
}
if ((1 == $argc) && is_array($argv[0])) {
$params = array();
$types = array();
$wellFormed = true;
foreach ($argv[0] as $arg) {
if (!is_array($arg) || !isset($arg['value'])) {
$wellFormed = false;
break;
}
$params[] = $arg['value'];
if (!isset($arg['type'])) {
$xmlRpcValue = Zend_XmlRpc_Value::getXmlRpcValue($arg['value']);
$arg['type'] = $xmlRpcValue->getType();
}
$types[] = $arg['type'];
}
if ($wellFormed) {
$this->_xmlRpcParams = $argv[0];
$this->_params = $params;
$this->_types = $types;
} else {
$this->_params = $argv[0];
$this->_types = array();
$xmlRpcParams = array();
foreach ($argv[0] as $arg) {
if ($arg instanceof Zend_XmlRpc_Value) {
$type = $arg->getType();
} else {
$xmlRpcValue = Zend_XmlRpc_Value::getXmlRpcValue($arg);
$type = $xmlRpcValue->getType();
}
$xmlRpcParams[] = array('value' => $arg, 'type' => $type);
$this->_types[] = $type;
}
$this->_xmlRpcParams = $xmlRpcParams;
}
return;
}
$this->_params = $argv;
$this->_types = array();
$xmlRpcParams = array();
foreach ($argv as $arg) {
if ($arg instanceof Zend_XmlRpc_Value) {
$type = $arg->getType();
} else {
$xmlRpcValue = Zend_XmlRpc_Value::getXmlRpcValue($arg);
$type = $xmlRpcValue->getType();
}
$xmlRpcParams[] = array('value' => $arg, 'type' => $type);
$this->_types[] = $type;
}
$this->_xmlRpcParams = $xmlRpcParams;
}
/**
* Retrieve the array of parameters
*
* @return array
*/
public function getParams()
{
return $this->_params;
}
/**
* Return parameter types
*
* @return array
*/
public function getTypes()
{
return $this->_types;
}
/**
* Load XML and parse into request components
*
* @param string $request
* @return boolean True on success, false if an error occurred.
*/
public function loadXml($request)
{
if (!is_string($request)) {
$this->_fault = new Zend_XmlRpc_Fault(635);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
try {
$xml = @new SimpleXMLElement($request);
} catch (Exception $e) {
// Not valid XML
$this->_fault = new Zend_XmlRpc_Fault(631);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
// Check for method name
if (empty($xml->methodName)) {
// Missing method name
$this->_fault = new Zend_XmlRpc_Fault(632);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
$this->_method = (string) $xml->methodName;
// Check for parameters
if (!empty($xml->params)) {
$types = array();
$argv = array();
foreach ($xml->params->children() as $param) {
if (! $param->value instanceof SimpleXMLElement) {
$this->_fault = new Zend_XmlRpc_Fault(633);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
try {
$param = Zend_XmlRpc_Value::getXmlRpcValue($param->value, Zend_XmlRpc_Value::XML_STRING);
$types[] = $param->getType();
$argv[] = $param->getValue();
} catch (Exception $e) {
$this->_fault = new Zend_XmlRpc_Fault(636);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
}
$this->_types = $types;
$this->_params = $argv;
}
$this->_xml = $request;
return true;
}
/**
* Does the current request contain errors and should it return a fault
* response?
*
* @return boolean
*/
public function isFault()
{
return $this->_fault instanceof Zend_XmlRpc_Fault;
}
/**
* Retrieve the fault response, if any
*
* @return null|Zend_XmlRpc_Fault
*/
public function getFault()
{
return $this->_fault;
}
/**
* Retrieve method parameters as XMLRPC values
*
* @return array
*/
protected function _getXmlRpcParams()
{
$params = array();
if (is_array($this->_xmlRpcParams)) {
foreach ($this->_xmlRpcParams as $param) {
$value = $param['value'];
$type = isset($param['type']) ? $param['type'] : Zend_XmlRpc_Value::AUTO_DETECT_TYPE;
if (!$value instanceof Zend_XmlRpc_Value) {
$value = Zend_XmlRpc_Value::getXmlRpcValue($value, $type);
}
$params[] = $value;
}
}
return $params;
}
/**
* Create XML request
*
* @return string
*/
public function saveXML()
{
$args = $this->_getXmlRpcParams();
$method = $this->getMethod();
$dom = new DOMDocument('1.0', $this->getEncoding());
$mCall = $dom->appendChild($dom->createElement('methodCall'));
$mName = $mCall->appendChild($dom->createElement('methodName', $method));
if (is_array($args) && count($args)) {
$params = $mCall->appendChild($dom->createElement('params'));
foreach ($args as $arg) {
/* @var $arg Zend_XmlRpc_Value */
$argDOM = new DOMDocument('1.0', $this->getEncoding());
$argDOM->loadXML($arg->saveXML());
$param = $params->appendChild($dom->createElement('param'));
$param->appendChild($dom->importNode($argDOM->documentElement, 1));
}
}
return $dom->saveXML();
}
/**
* Return XML request
*
* @return string
*/
public function __toString()
{
return $this->saveXML();
}
}
PK �:H[V�I�m m Value/Collection.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Collection.php 9096 2008-03-30 19:04:05Z thomas $
*/
/**
* Zend_XmlRpc_Value
*/
require_once 'Zend/XmlRpc/Value.php';
/**
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_XmlRpc_Value_Collection extends Zend_XmlRpc_Value
{
/**
* Set the value of a collection type (array and struct) native types
*
* @param array $value
*/
public function __construct($value)
{
$values = (array)$value; // Make sure that the value is an array
foreach ($values as $key => $value) {
// If the elements of the given array are not Zend_XmlRpc_Value objects,
// we need to convert them as such (using auto-detection from PHP value)
if (!$value instanceof parent) {
$value = self::getXmlRpcValue($value, self::AUTO_DETECT_TYPE);
}
$this->_value[$key] = $value;
}
}
/**
* Return the value of this object, convert the XML-RPC native collection values into a PHP array
*
* @return arary
*/
public function getValue()
{
$values = (array)$this->_value;
foreach ($values as $key => $value) {
/* @var $value Zend_XmlRpc_Value */
if (!$value instanceof parent) {
throw new Zend_XmlRpc_Value_Exception('Values of '. get_class($this) .' type must be Zend_XmlRpc_Value objects');
}
$values[$key] = $value->getValue();
}
return $values;
}
}
PK �:H[;�s Value/String.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: String.php 9095 2008-03-30 18:52:31Z thomas $
*/
/**
* Zend_XmlRpc_Value_Scalar
*/
require_once 'Zend/XmlRpc/Value/Scalar.php';
/**
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Value_String extends Zend_XmlRpc_Value_Scalar
{
/**
* Set the value of a string native type
*
* @param string $value
*/
public function __construct($value)
{
$this->_type = self::XMLRPC_TYPE_STRING;
// Make sure this value is string and all XML characters are encoded
$this->_value = $this->_xml_entities($value);
}
/**
* Return the value of this object, convert the XML-RPC native string value into a PHP string
* Decode all encoded risky XML entities back to normal characters
*
* @return string
*/
public function getValue()
{
return html_entity_decode($this->_value, ENT_QUOTES, 'UTF-8');
}
/**
* Make sure a string will be safe for XML, convert risky characters to HTML entities
*
* @param string $str
* @return string
*/
private function _xml_entities($str)
{
return htmlentities($str, ENT_QUOTES, 'UTF-8');
}
}
PK �:H[�oP�. .
Value/Nil.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Nil.php 9095 2008-03-30 18:52:31Z thomas $
*/
/**
* Zend_XmlRpc_Value_Scalar
*/
require_once 'Zend/XmlRpc/Value/Scalar.php';
/**
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Value_Nil extends Zend_XmlRpc_Value_Scalar
{
/**
* Set the value of a nil native type
*
*/
public function __construct()
{
$this->_type = self::XMLRPC_TYPE_NIL;
$this->_value = null;
}
/**
* Return the value of this object, convert the XML-RPC native nill value into a PHP NULL
*
* @return null
*/
public function getValue()
{
return null;
}
/**
* Return the XML code representing the nil
*
* @return string
*/
public function saveXML()
{
if (! $this->_as_xml) { // The XML was not generated yet
$dom = new DOMDocument('1.0', 'UTF-8');
$value = $dom->appendChild($dom->createElement('value'));
$type = $value->appendChild($dom->createElement($this->_type));
$this->_as_dom = $value;
$this->_as_xml = $this->_stripXmlDeclaration($dom);
}
return $this->_as_xml;
}
}
PK �:H[`wյ� � Value/Boolean.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Boolean.php 9096 2008-03-30 19:04:05Z thomas $
*/
/**
* Zend_XmlRpc_Value_Scalar
*/
require_once 'Zend/XmlRpc/Value/Scalar.php';
/**
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Value_Boolean extends Zend_XmlRpc_Value_Scalar
{
/**
* Set the value of a boolean native type
* We hold the boolean type as an integer (0 or 1)
*
* @param bool $value
*/
public function __construct($value)
{
$this->_type = self::XMLRPC_TYPE_BOOLEAN;
// Make sure the value is boolean and then convert it into a integer
// The double convertion is because a bug in the ZendOptimizer in PHP version 5.0.4
$this->_value = (int)(bool)$value;
}
/**
* Return the value of this object, convert the XML-RPC native boolean value into a PHP boolean
*
* @return bool
*/
public function getValue()
{
return (bool)$this->_value;
}
/**
* Return the XML-RPC serialization of the boolean value
*
* @return string
*/
public function saveXML()
{
if (! $this->_as_xml) { // The XML was not generated yet
$dom = new DOMDocument('1.0', 'UTF-8');
$value = $dom->appendChild($dom->createElement('value'));
$type = $value->appendChild($dom->createElement($this->_type));
$type->appendChild($dom->createTextNode($this->_value));
$this->_as_dom = $value;
$this->_as_xml = $this->_stripXmlDeclaration($dom);
}
return $this->_as_xml;
}
}
PK �:H[aN�n
n
Value/Base64.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Base64.php 9096 2008-03-30 19:04:05Z thomas $
*/
/**
* Zend_XmlRpc_Value_Scalar
*/
require_once 'Zend/XmlRpc/Value/Scalar.php';
/**
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Value_Base64 extends Zend_XmlRpc_Value_Scalar
{
/**
* Set the value of a base64 native type
* We keep this value in base64 encoding
*
* @param string $value
* @param bool $already_encoded If set, it means that the given string is already base64 encoded
*/
public function __construct($value, $already_encoded=false)
{
$this->_type = self::XMLRPC_TYPE_BASE64;
$value = (string)$value; // Make sure this value is string
if (!$already_encoded) {
$value = base64_encode($value); // We encode it in base64
}
$this->_value = $value;
}
/**
* Return the value of this object, convert the XML-RPC native base64 value into a PHP string
* We return this value decoded (a normal string)
*
* @return string
*/
public function getValue()
{
return base64_decode($this->_value);
}
/**
* Return the XML code representing the base64-encoded value
*
* @return string
*/
public function saveXML()
{
if (! $this->_as_xml) { // The XML was not generated yet
$dom = new DOMDocument('1.0', 'UTF-8');
$value = $dom->appendChild($dom->createElement('value'));
$type = $value->appendChild($dom->createElement($this->_type));
$type->appendChild($dom->createTextNode($this->_value));
$this->_as_dom = $value;
$this->_as_xml = $this->_stripXmlDeclaration($dom);
}
return $this->_as_xml;
}
}
PK �:H[S;�'0
0
Value/DateTime.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DateTime.php 9096 2008-03-30 19:04:05Z thomas $
*/
/**
* Zend_XmlRpc_Value_Scalar
*/
require_once 'Zend/XmlRpc/Value/Scalar.php';
/**
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Value_DateTime extends Zend_XmlRpc_Value_Scalar
{
/**
* Set the value of a dateTime.iso8601 native type
*
* The value is in iso8601 format, minus any timezone information or dashes
*
* @param mixed $value Integer of the unix timestamp or any string that can be parsed
* to a unix timestamp using the PHP strtotime() function
*/
public function __construct($value)
{
$this->_type = self::XMLRPC_TYPE_DATETIME;
// If the value is not numeric, we try to convert it to a timestamp (using the strtotime function)
if (is_numeric($value)) { // The value is numeric, we make sure it is an integer
$value = (int)$value;
} else {
$value = strtotime($value);
if ($value === false || $value == -1) { // cannot convert the value to a timestamp
throw new Zend_XmlRpc_Value_Exception('Cannot convert given value \''. $value .'\' to a timestamp');
}
}
$value = date('c', $value); // Convert the timestamp to iso8601 format
// Strip out TZ information and dashes
$value = preg_replace('/(\+|-)\d{2}:\d{2}$/', '', $value);
$value = str_replace('-', '', $value);
$this->_value = $value;
}
/**
* Return the value of this object as iso8601 dateTime value
*
* @return int As a Unix timestamp
*/
public function getValue()
{
return $this->_value;
}
}
PK �:H[-��C� � Value/Exception.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 9096 2008-03-30 19:04:05Z thomas $
*/
/**
* Zend_XmlRpc_Exception
*/
require_once 'Zend/XmlRpc/Exception.php';
/**
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Value_Exception extends Zend_XmlRpc_Exception
{}
PK �:H[G���d d Value/Struct.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Struct.php 9095 2008-03-30 18:52:31Z thomas $
*/
/**
* Zend_XmlRpc_Value_Collection
*/
require_once 'Zend/XmlRpc/Value/Collection.php';
/**
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Value_Struct extends Zend_XmlRpc_Value_Collection
{
/**
* Set the value of an struct native type
*
* @param array $value
*/
public function __construct($value)
{
$this->_type = self::XMLRPC_TYPE_STRUCT;
parent::__construct($value);
}
/**
* Return the XML code that represent struct native MXL-RPC value
*
* @return string
*/
public function saveXML()
{
if (!$this->_as_xml) { // The XML code was not calculated yet
$dom = new DOMDocument('1.0');
$value = $dom->appendChild($dom->createElement('value'));
$struct = $value->appendChild($dom->createElement('struct'));
if (is_array($this->_value)) {
foreach ($this->_value as $name => $val) {
/* @var $val Zend_XmlRpc_Value */
$member = $struct->appendChild($dom->createElement('member'));
$member->appendChild($dom->createElement('name', $name));
$member->appendChild($dom->importNode($val->getAsDOM(), 1));
}
}
$this->_as_dom = $value;
$this->_as_xml = $this->_stripXmlDeclaration($dom);
}
return $this->_as_xml;
}
}
PK �:H[����u u Value/Integer.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Integer.php 9095 2008-03-30 18:52:31Z thomas $
*/
/**
* Zend_XmlRpc_Value_Scalar
*/
require_once 'Zend/XmlRpc/Value/Scalar.php';
/**
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Value_Integer extends Zend_XmlRpc_Value_Scalar
{
/**
* Set the value of an integer native type
*
* @param int $value
*/
public function __construct($value)
{
$this->_type = self::XMLRPC_TYPE_INTEGER;
$this->_value = (int)$value; // Make sure this value is integer
}
/**
* Return the value of this object, convert the XML-RPC native integer value into a PHP integer
*
* @return int
*/
public function getValue()
{
return $this->_value;
}
}
PK �:H[�
(� � Value/Double.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Double.php 9096 2008-03-30 19:04:05Z thomas $
*/
/**
* Zend_XmlRpc_Value_Scalar
*/
require_once 'Zend/XmlRpc/Value/Scalar.php';
/**
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Value_Double extends Zend_XmlRpc_Value_Scalar
{
/**
* Set the value of a double native type
*
* @param float $value
*/
public function __construct($value)
{
$this->_type = self::XMLRPC_TYPE_DOUBLE;
$this->_value = sprintf('%f',(float)$value); // Make sure this value is float (double) and without the scientific notation
}
/**
* Return the value of this object, convert the XML-RPC native double value into a PHP float
*
* @return float
*/
public function getValue()
{
return (float)$this->_value;
}
}
PK �:H[-&:� � Value/Array.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Array.php 9096 2008-03-30 19:04:05Z thomas $
*/
/**
* Zend_XmlRpc_Value_Collection
*/
require_once 'Zend/XmlRpc/Value/Collection.php';
/**
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Value_Array extends Zend_XmlRpc_Value_Collection
{
/**
* Set the value of an array native type
*
* @param array $value
*/
public function __construct($value)
{
$this->_type = self::XMLRPC_TYPE_ARRAY;
parent::__construct($value);
}
/**
* Return the XML code that represent an array native MXL-RPC value
*
* @return string
*/
public function saveXML()
{
if (!$this->_as_xml) { // The XML code was not calculated yet
$dom = new DOMDocument('1.0');
$value = $dom->appendChild($dom->createElement('value'));
$array = $value->appendChild($dom->createElement('array'));
$data = $array->appendChild($dom->createElement('data'));
if (is_array($this->_value)) {
foreach ($this->_value as $val) {
/* @var $val Zend_XmlRpc_Value */
$data->appendChild($dom->importNode($val->getAsDOM(), true));
}
}
$this->_as_dom = $value;
$this->_as_xml = $this->_stripXmlDeclaration($dom);
}
return $this->_as_xml;
}
}
PK �:H[�i�� � Value/Scalar.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Scalar.php 9095 2008-03-30 18:52:31Z thomas $
*/
/**
* Zend_XmlRpc_Value
*/
require_once 'Zend/XmlRpc/Value.php';
/**
* @category Zend
* @package Zend_XmlRpc
* @subpackage Value
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_XmlRpc_Value_Scalar extends Zend_XmlRpc_Value
{
/**
* Return the XML code that represent a scalar native MXL-RPC value
*
* @return string
*/
public function saveXML()
{
if (!$this->_as_xml) { // The XML code was not calculated yet
$dom = new DOMDocument('1.0');
$value = $dom->appendChild($dom->createElement('value'));
$type = $value->appendChild($dom->createElement($this->_type));
$type->appendChild($dom->createTextNode($this->getValue()));
$this->_as_dom = $value;
$this->_as_xml = $this->_stripXmlDeclaration($dom);
}
return $this->_as_xml;
}
}
PK �:H[�9� Response.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Controller
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Zend_XmlRpc_Value
*/
require_once 'Zend/XmlRpc/Value.php';
/**
* Zend_XmlRpc_Fault
*/
require_once 'Zend/XmlRpc/Fault.php';
/**
* XmlRpc Response
*
* Container for accessing an XMLRPC return value and creating the XML response.
*
* @category Zend
* @package Zend_XmlRpc
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Response.php 8064 2008-02-16 10:58:39Z thomas $
*/
class Zend_XmlRpc_Response
{
/**
* Return value
* @var mixed
*/
protected $_return;
/**
* Return type
* @var string
*/
protected $_type;
/**
* Response character encoding
* @var string
*/
protected $_encoding = 'UTF-8';
/**
* Fault, if response is a fault response
* @var null|Zend_XmlRpc_Fault
*/
protected $_fault = null;
/**
* Constructor
*
* Can optionally pass in the return value and type hinting; otherwise, the
* return value can be set via {@link setReturnValue()}.
*
* @param mixed $return
* @param string $type
* @return void
*/
public function __construct($return = null, $type = null)
{
$this->setReturnValue($return, $type);
}
/**
* Set encoding to use in response
*
* @param string $encoding
* @return Zend_XmlRpc_Response
*/
public function setEncoding($encoding)
{
$this->_encoding = $encoding;
return $this;
}
/**
* Retrieve current response encoding
*
* @return string
*/
public function getEncoding()
{
return $this->_encoding;
}
/**
* Set the return value
*
* Sets the return value, with optional type hinting if provided.
*
* @param mixed $value
* @param string $type
* @return void
*/
public function setReturnValue($value, $type = null)
{
$this->_return = $value;
$this->_type = (string) $type;
}
/**
* Retrieve the return value
*
* @return mixed
*/
public function getReturnValue()
{
return $this->_return;
}
/**
* Retrieve the XMLRPC value for the return value
*
* @return Zend_XmlRpc_Value
*/
protected function _getXmlRpcReturn()
{
return Zend_XmlRpc_Value::getXmlRpcValue($this->_return);
}
/**
* Is the response a fault response?
*
* @return boolean
*/
public function isFault()
{
return $this->_fault instanceof Zend_XmlRpc_Fault;
}
/**
* Returns the fault, if any.
*
* @return null|Zend_XmlRpc_Fault
*/
public function getFault()
{
return $this->_fault;
}
/**
* Load a response from an XML response
*
* Attempts to load a response from an XMLRPC response, autodetecting if it
* is a fault response.
*
* @param string $response
* @return boolean True if a valid XMLRPC response, false if a fault
* response or invalid input
*/
public function loadXml($response)
{
if (!is_string($response)) {
$this->_fault = new Zend_XmlRpc_Fault(650);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
try {
$xml = @new SimpleXMLElement($response);
} catch (Exception $e) {
// Not valid XML
$this->_fault = new Zend_XmlRpc_Fault(651);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
if (!empty($xml->fault)) {
// fault response
$this->_fault = new Zend_XmlRpc_Fault();
$this->_fault->setEncoding($this->getEncoding());
$this->_fault->loadXml($response);
return false;
}
if (empty($xml->params)) {
// Invalid response
$this->_fault = new Zend_XmlRpc_Fault(652);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
try {
if (!isset($xml->params) || !isset($xml->params->param) || !isset($xml->params->param->value)) {
throw new Zend_XmlRpc_Value_Exception('Missing XML-RPC value in XML');
}
$valueXml = $xml->params->param->value->asXML();
$valueXml = preg_replace('/<\?xml version=.*?\?>/i', '', $valueXml);
$value = Zend_XmlRpc_Value::getXmlRpcValue(trim($valueXml), Zend_XmlRpc_Value::XML_STRING);
} catch (Zend_XmlRpc_Value_Exception $e) {
$this->_fault = new Zend_XmlRpc_Fault(653);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
$this->setReturnValue($value->getValue());
return true;
}
/**
* Return response as XML
*
* @return string
*/
public function saveXML()
{
$value = $this->_getXmlRpcReturn();
$valueDOM = new DOMDocument('1.0', $this->getEncoding());
$valueDOM->loadXML($value->saveXML());
$dom = new DOMDocument('1.0', $this->getEncoding());
$response = $dom->appendChild($dom->createElement('methodResponse'));
$params = $response->appendChild($dom->createElement('params'));
$param = $params->appendChild($dom->createElement('param'));
$param->appendChild($dom->importNode($valueDOM->documentElement, true));
return $dom->saveXML();
}
/**
* Return XML response
*
* @return string
*/
public function __toString()
{
return $this->saveXML();
}
}
PK �:H[l��Uc c Fault.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_XmlRpc
* @subpackage Server
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Zend_XmlRpc_Value
*/
require_once 'Zend/XmlRpc/Value.php';
/**
* Zend_XmlRpc_Exception
*/
require_once 'Zend/XmlRpc/Exception.php';
/**
* XMLRPC Faults
*
* Container for XMLRPC faults, containing both a code and a message;
* additionally, has methods for determining if an XML response is an XMLRPC
* fault, as well as generating the XML for an XMLRPC fault response.
*
* To allow method chaining, you may only use the {@link getInstance()} factory
* to instantiate a Zend_XmlRpc_Server_Fault.
*
* @category Zend
* @package Zend_XmlRpc
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Fault
{
/**
* Fault code
* @var int
*/
protected $_code;
/**
* Fault character encoding
* @var string
*/
protected $_encoding = 'UTF-8';
/**
* Fault message
* @var string
*/
protected $_message;
/**
* Internal fault codes => messages
* @var array
*/
protected $_internal = array(
404 => 'Unknown Error',
// 610 - 619 reflection errors
610 => 'Invalid method class',
611 => 'Unable to attach function or callback; not callable',
612 => 'Unable to load array; not an array',
613 => 'One or more method records are corrupt or otherwise unusable',
// 620 - 629 dispatch errors
620 => 'Method does not exist',
621 => 'Error instantiating class to invoke method',
622 => 'Method missing implementation',
623 => 'Calling parameters do not match signature',
// 630 - 639 request errors
630 => 'Unable to read request',
631 => 'Failed to parse request',
632 => 'Invalid request, no method passed; request must contain a \'methodName\' tag',
633 => 'Param must contain a value',
634 => 'Invalid method name',
635 => 'Invalid XML provided to request',
636 => 'Error creating xmlrpc value',
// 640 - 649 system.* errors
640 => 'Method does not exist',
// 650 - 659 response errors
650 => 'Invalid XML provided for response',
651 => 'Failed to parse response',
652 => 'Invalid response',
653 => 'Invalid XMLRPC value in response',
);
/**
* Constructor
*
* @return Zend_XmlRpc_Fault
*/
public function __construct($code = 404, $message = '')
{
$this->setCode($code);
$code = $this->getCode();
if (empty($message) && isset($this->_internal[$code])) {
$message = $this->_internal[$code];
} elseif (empty($message)) {
$message = 'Unknown error';
}
$this->setMessage($message);
}
/**
* Set the fault code
*
* @param int $code
* @return Zend_XmlRpc_Fault
*/
public function setCode($code)
{
$this->_code = (int) $code;
return $this;
}
/**
* Return fault code
*
* @return int
*/
public function getCode()
{
return $this->_code;
}
/**
* Retrieve fault message
*
* @param string
* @return Zend_XmlRpc_Fault
*/
public function setMessage($message)
{
$this->_message = (string) $message;
return $this;
}
/**
* Retrieve fault message
*
* @return string
*/
public function getMessage()
{
return $this->_message;
}
/**
* Set encoding to use in fault response
*
* @param string $encoding
* @return Zend_XmlRpc_Fault
*/
public function setEncoding($encoding)
{
$this->_encoding = $encoding;
return $this;
}
/**
* Retrieve current fault encoding
*
* @return string
*/
public function getEncoding()
{
return $this->_encoding;
}
/**
* Load an XMLRPC fault from XML
*
* @param string $fault
* @return boolean Returns true if successfully loaded fault response, false
* if response was not a fault response
* @throws Zend_XmlRpc_Exception if no or faulty XML provided, or if fault
* response does not contain either code or message
*/
public function loadXml($fault)
{
if (!is_string($fault)) {
throw new Zend_XmlRpc_Exception('Invalid XML provided to fault');
}
try {
$xml = @new SimpleXMLElement($fault);
} catch (Exception $e) {
// Not valid XML
throw new Zend_XmlRpc_Exception('Failed to parse XML fault: ' . $e->getMessage(), 500);
}
// Check for fault
if (!$xml->fault) {
// Not a fault
return false;
}
if (!$xml->fault->value->struct) {
// not a proper fault
throw new Zend_XmlRpc_Exception('Invalid fault structure', 500);
}
$structXml = $xml->fault->value->asXML();
$structXml = preg_replace('/<\?xml version=.*?\?>/i', '', $structXml);
$struct = Zend_XmlRpc_Value::getXmlRpcValue(trim($structXml), Zend_XmlRpc_Value::XML_STRING);
$struct = $struct->getValue();
if (isset($struct['faultCode'])) {
$code = $struct['faultCode'];
}
if (isset($struct['faultString'])) {
$message = $struct['faultString'];
}
if (empty($code) && empty($message)) {
throw new Zend_XmlRpc_Exception('Fault code and string required');
}
if (empty($code)) {
$code = '404';
}
if (empty($message)) {
if (isset($this->_internal[$code])) {
$message = $this->_internal[$code];
} else {
$message = 'Unknown Error';
}
}
$this->setCode($code);
$this->setMessage($message);
return true;
}
/**
* Determine if an XML response is an XMLRPC fault
*
* @param string $xml
* @return boolean
*/
public static function isFault($xml)
{
$fault = new self();
try {
$isFault = $fault->loadXml($xml);
} catch (Zend_XmlRpc_Exception $e) {
$isFault = false;
}
return $isFault;
}
/**
* Serialize fault to XML
*
* @return string
*/
public function saveXML()
{
// Create fault value
$faultStruct = array(
'faultCode' => $this->getCode(),
'faultString' => $this->getMessage()
);
$value = Zend_XmlRpc_Value::getXmlRpcValue($faultStruct);
$valueDOM = new DOMDocument('1.0', $this->getEncoding());
$valueDOM->loadXML($value->saveXML());
// Build response XML
$dom = new DOMDocument('1.0', $this->getEncoding());
$r = $dom->appendChild($dom->createElement('methodResponse'));
$f = $r->appendChild($dom->createElement('fault'));
$f->appendChild($dom->importNode($valueDOM->documentElement, 1));
return $dom->saveXML();
}
/**
* Return XML fault response
*
* @return string
*/
public function __toString()
{
return $this->saveXML();
}
}
PK �:H[��o o Client/ServerProxy.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* The namespace decorator enables object chaining to permit
* calling XML-RPC namespaced functions like "foo.bar.baz()"
* as "$remote->foo->bar->baz()".
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Client_ServerProxy
{
/**
* @var Zend_XmlRpc_Client
*/
private $_client = null;
/**
* @var string
*/
private $_namespace = '';
/**
* @var array of Zend_XmlRpc_Client_ServerProxy
*/
private $_cache = array();
/**
* Class constructor
*
* @param string $namespace
* @param Zend_XmlRpc_Client $client
*/
public function __construct($client, $namespace = '')
{
$this->_namespace = $namespace;
$this->_client = $client;
}
/**
* Get the next successive namespace
*
* @param string $name
* @return Zend_XmlRpc_Client_ServerProxy
*/
public function __get($namespace)
{
$namespace = ltrim("$this->_namespace.$namespace", '.');
if (!isset($this->_cache[$namespace])) {
$this->_cache[$namespace] = new $this($this->_client, $namespace);
}
return $this->_cache[$namespace];
}
/**
* Call a method in this namespace.
*
* @param string $methodN
* @param array $args
* @return mixed
*/
public function __call($method, $args)
{
$method = ltrim("$this->_namespace.$method", '.');
return $this->_client->call($method, $args);
}
}
PK �:H[n��� � Client/FaultException.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_XmlRpc_Client_Exception */
require_once 'Zend/XmlRpc/Client/Exception.php';
/**
* Thrown by Zend_XmlRpc_Client when an XML-RPC fault response is returned.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Client_FaultException extends Zend_XmlRpc_Client_Exception
{}
PK �:H[��k�{ { Client/Exception.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Zend_XmlRpc_Exception
*/
require_once 'Zend/XmlRpc/Exception.php';
/**
* Base class for all Zend_XmlRpc_Client_* exceptions
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Client_Exception extends Zend_XmlRpc_Exception
{}
PK �:H[�!K6� � Client/IntrospectException.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Zend_XmlRpc_Client_Exception
*/
require_once 'Zend/XmlRpc/Client/Exception.php';
/**
* Thrown by Zend_XmlRpc_Client_Introspection when any error occurs.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Client_IntrospectException extends Zend_XmlRpc_Client_Exception
{}
PK �:H[Њ)� � Client/HttpException.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* Zend_XmlRpc_Exception
*/
require_once 'Zend/XmlRpc/Client/Exception.php';
/**
* Thrown by Zend_XmlRpc_Client when an HTTP error occurs during an
* XML-RPC method call.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Client_HttpException extends Zend_XmlRpc_Client_Exception
{}
PK �:H[��� � Client/ServerIntrospection.phpnu &1i� <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_XmlRpc_Client_IntrospectException */
require_once 'Zend/XmlRpc/Client/IntrospectException.php';
/**
* Wraps the XML-RPC system.* introspection methods
*
* @category Zend
* @package Zend_XmlRpc
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_XmlRpc_Client_ServerIntrospection
{
/**
* @var Zend_XmlRpc_Client_ServerProxy
*/
private $_system = null;
/**
* @param Zend_XmlRpc_Client $client
*/
public function __construct(Zend_XmlRpc_Client $client)
{
$this->_system = $client->getProxy('system');
}
/**
* Returns the signature for each method on the server,
* autodetecting whether system.multicall() is supported and
* using it if so.
*
* @return array
*/
public function getSignatureForEachMethod()
{
$methods = $this->listMethods();
try {
$signatures = $this->getSignatureForEachMethodByMulticall($methods);
} catch (Zend_XmlRpc_Client_FaultException $e) {
// degrade to looping
}
if (empty($signatures)) {
$signatures = $this->getSignatureForEachMethodByLooping($methods);
}
return $signatures;
}
/**
* Attempt to get the method signatures in one request via system.multicall().
* This is a boxcar feature of XML-RPC and is found on fewer servers. However,
* can significantly improve performance if present.
*
* @param array $methods
* @return array array(array(return, param, param, param...))
*/
public function getSignatureForEachMethodByMulticall($methods = null)
{
if ($methods === null) {
$methods = $this->listMethods();
}
$multicallParams = array();
foreach ($methods as $method) {
$multicallParams[] = array('methodName' => 'system.methodSignature',
'params' => array($method));
}
$serverSignatures = $this->_system->multicall($multicallParams);
if (! is_array($serverSignatures)) {
$type = gettype($serverSignatures);
$error = "Multicall return is malformed. Expected array, got $type";
throw new Zend_XmlRpc_Client_IntrospectException($error);
}
if (count($serverSignatures) != count($methods)) {
$error = 'Bad number of signatures received from multicall';
throw new Zend_XmlRpc_Client_IntrospectException($error);
}
// Create a new signatures array with the methods name as keys and the signature as value
$signatures = array();
foreach ($serverSignatures as $i => $signature) {
$signatures[$methods[$i]] = $signature;
}
return $signatures;
}
/**
* Get the method signatures for every method by
* successively calling system.methodSignature
*
* @param array $methods
* @return array
*/
public function getSignatureForEachMethodByLooping($methods = null)
{
if ($methods === null) {
$methods = $this->listMethods();
}
$signatures = array();
foreach ($methods as $method) {
$signatures[$method] = $this->getMethodSignature($method);
}
return $signatures;
}
/**
* Call system.methodSignature() for the given method
*
* @param array $method
* @return array array(array(return, param, param, param...))
*/
public function getMethodSignature($method)
{
$signature = $this->_system->methodSignature($method);
return $signature;
}
/**
* Call system.listMethods()
*
* @param array $method
* @return array array(method, method, method...)
*/
public function listMethods()
{
return $this->_system->listMethods();
}
}
PK �:H[@L'#'