/**
* This is the core XML-RPC client it takes the parameters passed in and bundles them up
* and sends them as an XML-RPC request to the origin server, which processes them against
* the central database and passes the results back to this client
*
* @param string $function The name of the remote origin function to be called
* @param array $params An array of the parameters to be passed to the origin function
* @return mixed The decoded response from the origin server
*/
function getFromOrigin($function, $params)
{
/**
* @package MaxDal
* @subpackage Delivery
* @author Chris Nutting <*****@*****.**>
*
*/
$conf = $GLOBALS['_MAX']['CONF'];
// Create an XML-RPC client to talk to the XML-RPC server
$client = new XML_RPC_Client($conf['origin']['script'], $conf['origin']['host'], $conf['origin']['port']);
$message = new XML_RPC_Message($function, array());
// Add the parameters to the message
$message->addParam(new XML_RPC_Value($params, $GLOBALS['XML_RPC_String']));
// Send the XML-RPC message to the server
$response = $client->send($message, $conf['origin']['timeout'], $conf['origin']['protocol']);
if (!$response || $response->faultCode() != 0) {
if (defined('OA_DELIVERY_CACHE_FUNCTION_ERROR')) {
return OA_DELIVERY_CACHE_FUNCTION_ERROR;
} else {
return null;
}
} else {
// Decode the serialized response
$value = $response->value();
$value = $value->scalarval();
$value = unserialize($value);
}
return $value;
}