예제 #1
0
/**
 * A function to handle XML-RPC advertisement view requests. 2.3 version
 *
 * @deprecated
 *
 * @param XML_RPC_Message $params An XML_RPC_Message containing the parameters. The expected parameters
 *                              are (in order):
 *                              - An XML_RPC_Value of type "string" containing the "what" value;
 *                              - An XML_RPC_Value of type "string" containing the "target" value;
 *                              - An XML_RPC_Value of type "string" containing the "source" value;
 *                              - An XML_RPC_Value of type "boolean" containing the "withText" value;
 *                              - An XML_RPC_Value of type "string" containing the viewer's IP address; and
 *                              - An XML_RPC_Value of type "struct" containing the viewer's cookie values
 *                                (indexed by cookie name);
 *                              - An XML_RPC_Value of type "array" containing the "context" value.
 * @return XML_RPC_Response The response. The XML_RPC_Value of the response can be one of
 *                          a number of different values:
 *                          - Error Code 1: The $params variable was not an XML_RPC_Value of
 *                            type "array".
 *                          - Error Code 2: The $params XML_RPC_Value "array" did not have 6
 *                            elements.
 *                          - An XML_RPC_Value of type "array" containing:
 *                            - An XML_RPC_Value of type "struct" with the HTML details required
 *                              for displaying the advertisement stored as in XML_RPC_Value of
 *                              type "string" in the "html" index, or an empty XML_RPC_Value if
 *                              there is no advertisement to display; and
 *                            - An empty XML_RPC_Value if there are no cookies to be set, or an
 *                              XML_RPC_Value of type "array", containing a number of
 *                              XML_RPC_Values of tpye "array", each with 3 items:
 *                              - An XML_RPC_Value of type "string" with the cookie name;
 *                              - An XML_RPC_Value of type "string" with the cookie value; and
 *                              - An XML_RPC_Value of type "string" with the cookie expiration time.
 */
function OA_Delivery_XmlRpc_View_Max($params)
{
    global $XML_RPC_erruser;
    global $XML_RPC_String, $XML_RPC_Struct, $XML_RPC_Array, $XML_RPC_Int;
    // Check the parameters exist
    $numParams = $params->getNumParams();
    if ($numParams < 6) {
        // Return an error
        $errorCode = $XML_RPC_erruser + 2;
        $errorMsg = 'Incorrect number of parameters';
        return new XML_RPC_Response(0, $errorCode, $errorMsg);
    }
    // Extract the what parameter
    $whatXmlRpcValue = $params->getParam(0);
    // Extract the target parameter
    $targetXmlRpcValue = $params->getParam(1);
    // Extract the source parameter
    $sourceXmlRpcValue = $params->getParam(2);
    // Extract the withText parameter
    $withTextXmlRpcValue = $params->getParam(3);
    // Extract the remoteAddress parameter
    $remoteAddressXmlRpcValue = $params->getParam(4);
    // Extract the tunnelled cookies
    $cookiesXmlRpcValue = $params->getParam(5);
    // Extract the context parameter, if any
    if ($numParams >= 7) {
        $contextXmlRpcValue = $params->getParam(6);
    } else {
        $contextXmlRpcValue = new XML_RPC_Value(array(), $XML_RPC_Array);
    }
    // Generate 0 campaignid parameter
    $campaignidXmlRpcValue = new XML_RPC_Value(0, $XML_RPC_Int);
    // Create environment array
    $remoteInfoXmlRpcValue = new XML_RPC_Value(array('remote_addr' => $remoteAddressXmlRpcValue, 'cookies' => $cookiesXmlRpcValue), $XML_RPC_Struct);
    // Recreate XML-RPC message
    $msg = new XML_RPC_Message('openads.view', array($remoteInfoXmlRpcValue, $whatXmlRpcValue, $campaignidXmlRpcValue, $targetXmlRpcValue, $sourceXmlRpcValue, $withTextXmlRpcValue, $contextXmlRpcValue));
    // Relay call to openads.view
    $xmlResponse = OA_Delivery_XmlRpc_View($msg);
    // Check for errors
    if (XML_RPC_Base::isError($xmlResponse)) {
        // Return error
        return $xmlResponse;
    }
    // Change the response
    $output = XML_RPC_decode($xmlResponse->value());
    $cookies = $output['cookies'];
    unset($output['cookies']);
    // Return XML-RPC response
    return new XML_RPC_Response(new XML_RPC_Value(array(XML_RPC_encode($output), XML_RPC_encode($cookies)), $XML_RPC_Array));
}
예제 #2
0
function OA_Delivery_XmlRpc_View_Max($params)
{
    global $XML_RPC_erruser;
    global $XML_RPC_String, $XML_RPC_Struct, $XML_RPC_Array, $XML_RPC_Int;
    $numParams = $params->getNumParams();
    if ($numParams < 6) {
        $errorCode = $XML_RPC_erruser + 2;
        $errorMsg = 'Incorrect number of parameters';
        return new XML_RPC_Response(0, $errorCode, $errorMsg);
    }
    $whatXmlRpcValue = $params->getParam(0);
    $targetXmlRpcValue = $params->getParam(1);
    $sourceXmlRpcValue = $params->getParam(2);
    $withTextXmlRpcValue = $params->getParam(3);
    $remoteAddressXmlRpcValue = $params->getParam(4);
    $cookiesXmlRpcValue = $params->getParam(5);
    if ($numParams >= 7) {
        $contextXmlRpcValue = $params->getParam(6);
    } else {
        $contextXmlRpcValue = new XML_RPC_Value(array(), $XML_RPC_Array);
    }
    $campaignidXmlRpcValue = new XML_RPC_Value(0, $XML_RPC_Int);
    $remoteInfoXmlRpcValue = new XML_RPC_Value(array('remote_addr' => $remoteAddressXmlRpcValue, 'cookies' => $cookiesXmlRpcValue), $XML_RPC_Struct);
    $msg = new XML_RPC_Message('openads.view', array($remoteInfoXmlRpcValue, $whatXmlRpcValue, $campaignidXmlRpcValue, $targetXmlRpcValue, $sourceXmlRpcValue, $withTextXmlRpcValue, $contextXmlRpcValue));
    $xmlResponse = OA_Delivery_XmlRpc_View($msg);
    if (XML_RPC_Base::isError($xmlResponse)) {
        return $xmlResponse;
    }
    $output = XML_RPC_decode($xmlResponse->value());
    $cookies = $output['cookies'];
    unset($output['cookies']);
    return new XML_RPC_Response(new XML_RPC_Value(array(XML_RPC_encode($output), XML_RPC_encode($cookies)), $XML_RPC_Array));
}