/** * End element handler for the XML parser * * @return void */ function XML_RPC_ee($parser_resource, $name) { global $XML_RPC_xh; $parser = (int) $parser_resource; if ($XML_RPC_xh[$parser]['isf'] >= 2) { return; } // push this element from stack // NB: if XML validates, correct opening/closing is guaranteed and // we do not have to check for $name == $curr_elem. // we also checked for proper nesting at start of elements... $curr_elem = array_shift($XML_RPC_xh[$parser]['stack']); switch ($name) { case 'STRUCT': case 'ARRAY': $cur_val = array_shift($XML_RPC_xh[$parser]['valuestack']); $XML_RPC_xh[$parser]['value'] = $cur_val['value']; $XML_RPC_xh[$parser]['vt'] = strtolower($name); $XML_RPC_xh[$parser]['cm']--; break; case 'NAME': $XML_RPC_xh[$parser]['valuestack'][0]['name'] = $XML_RPC_xh[$parser]['ac']; break; case 'BOOLEAN': // special case here: we translate boolean 1 or 0 into PHP // constants true or false if ($XML_RPC_xh[$parser]['ac'] == '1') { $XML_RPC_xh[$parser]['ac'] = 'true'; } else { $XML_RPC_xh[$parser]['ac'] = 'false'; } $XML_RPC_xh[$parser]['vt'] = strtolower($name); // Drop through intentionally. // Drop through intentionally. case 'I4': case 'INT': case 'STRING': case 'DOUBLE': case 'DATETIME.ISO8601': case 'BASE64': if ($XML_RPC_xh[$parser]['qt'] == 1) { // we use double quotes rather than single so backslashification works OK $XML_RPC_xh[$parser]['value'] = $XML_RPC_xh[$parser]['ac']; } elseif ($XML_RPC_xh[$parser]['qt'] == 2) { $XML_RPC_xh[$parser]['value'] = base64_decode($XML_RPC_xh[$parser]['ac']); } elseif ($name == 'BOOLEAN') { $XML_RPC_xh[$parser]['value'] = $XML_RPC_xh[$parser]['ac']; } else { // we have an I4, INT or a DOUBLE // we must check that only 0123456789-.<space> are characters here if (!$GLOBALS['XML_RPC_func_ereg']("^[+-]?[0123456789 \t\\.]+\$", $XML_RPC_xh[$parser]['ac'])) { XML_RPC_Base::raiseError('Non-numeric value received in INT or DOUBLE', XML_RPC_ERROR_NON_NUMERIC_FOUND); $XML_RPC_xh[$parser]['value'] = XML_RPC_ERROR_NON_NUMERIC_FOUND; } else { // it's ok, add it on $XML_RPC_xh[$parser]['value'] = $XML_RPC_xh[$parser]['ac']; } } $XML_RPC_xh[$parser]['ac'] = ''; $XML_RPC_xh[$parser]['qt'] = 0; $XML_RPC_xh[$parser]['lv'] = 3; // indicate we've found a value break; case 'VALUE': if ($XML_RPC_xh[$parser]['vt'] == $GLOBALS['XML_RPC_String']) { if (strlen($XML_RPC_xh[$parser]['ac']) > 0) { $XML_RPC_xh[$parser]['value'] = $XML_RPC_xh[$parser]['ac']; } elseif ($XML_RPC_xh[$parser]['lv'] == 1) { // The <value> element was empty. $XML_RPC_xh[$parser]['value'] = ''; } } $temp = new XML_RPC_Value($XML_RPC_xh[$parser]['value'], $XML_RPC_xh[$parser]['vt']); $cur_val = array_shift($XML_RPC_xh[$parser]['valuestack']); if (is_array($cur_val)) { if ($cur_val['members'] == 0) { $cur_val['value'][] = $temp; } else { $XML_RPC_xh[$parser]['value'] = $temp; } array_unshift($XML_RPC_xh[$parser]['valuestack'], $cur_val); } else { $XML_RPC_xh[$parser]['value'] = $temp; } break; case 'MEMBER': $XML_RPC_xh[$parser]['ac'] = ''; $XML_RPC_xh[$parser]['qt'] = 0; $cur_val = array_shift($XML_RPC_xh[$parser]['valuestack']); if (is_array($cur_val)) { if ($cur_val['members'] == 1) { $cur_val['value'][$cur_val['name']] = $XML_RPC_xh[$parser]['value']; } array_unshift($XML_RPC_xh[$parser]['valuestack'], $cur_val); } break; case 'DATA': $XML_RPC_xh[$parser]['ac'] = ''; $XML_RPC_xh[$parser]['qt'] = 0; break; case 'PARAM': $XML_RPC_xh[$parser]['params'][] = $XML_RPC_xh[$parser]['value']; break; case 'METHODNAME': case 'RPCMETHODNAME': $XML_RPC_xh[$parser]['method'] = $GLOBALS['XML_RPC_func_ereg_replace']("^[\n\r\t ]+", '', $XML_RPC_xh[$parser]['ac']); break; } // if it's a valid type name, set the type if (isset($GLOBALS['XML_RPC_Types'][strtolower($name)])) { $XML_RPC_xh[$parser]['vt'] = strtolower($name); } }
/** * 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)); }
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)); }
/** * End element handler for the XML parser * * @return void */ function XML_RPC_ee($parser, $name) { global $XML_RPC_xh, $XML_RPC_Types, $XML_RPC_String; switch ($name) { case 'STRUCT': case 'ARRAY': if ($XML_RPC_xh[$parser]['cm'] && substr($XML_RPC_xh[$parser]['st'], -1) == ',') { $XML_RPC_xh[$parser]['st'] = substr($XML_RPC_xh[$parser]['st'], 0, -1); } $XML_RPC_xh[$parser]['st'] .= ')'; $XML_RPC_xh[$parser]['vt'] = strtolower($name); $XML_RPC_xh[$parser]['cm']--; break; case 'NAME': $XML_RPC_xh[$parser]['st'] .= $XML_RPC_xh[$parser]['ac'] . "' => "; break; case 'BOOLEAN': // special case here: we translate boolean 1 or 0 into PHP // constants true or false if ($XML_RPC_xh[$parser]['ac'] == '1') { $XML_RPC_xh[$parser]['ac'] = 'true'; } else { $XML_RPC_xh[$parser]['ac'] = 'false'; } $XML_RPC_xh[$parser]['vt'] = strtolower($name); // Drop through intentionally. // Drop through intentionally. case 'I4': case 'INT': case 'STRING': case 'DOUBLE': case 'DATETIME.ISO8601': case 'BASE64': if ($XML_RPC_xh[$parser]['qt'] == 1) { // we use double quotes rather than single so backslashification works OK $XML_RPC_xh[$parser]['st'] .= '"' . $XML_RPC_xh[$parser]['ac'] . '"'; } elseif ($XML_RPC_xh[$parser]['qt'] == 2) { $XML_RPC_xh[$parser]['st'] .= "base64_decode('" . $XML_RPC_xh[$parser]['ac'] . "')"; } elseif ($name == 'BOOLEAN') { $XML_RPC_xh[$parser]['st'] .= $XML_RPC_xh[$parser]['ac']; } else { // we have an I4, INT or a DOUBLE // we must check that only 0123456789-.<space> are characters here if (!ereg("^[+-]?[0123456789 \t\\.]+\$", $XML_RPC_xh[$parser]['ac'])) { XML_RPC_Base::raiseError('Non-numeric value received in INT or DOUBLE', XML_RPC_ERROR_NON_NUMERIC_FOUND); $XML_RPC_xh[$parser]['st'] .= 'XML_RPC_ERROR_NON_NUMERIC_FOUND'; } else { // it's ok, add it on $XML_RPC_xh[$parser]['st'] .= $XML_RPC_xh[$parser]['ac']; } } $XML_RPC_xh[$parser]['ac'] = ''; $XML_RPC_xh[$parser]['qt'] = 0; $XML_RPC_xh[$parser]['lv'] = 3; // indicate we've found a value break; case 'VALUE': // deal with a string value if (strlen($XML_RPC_xh[$parser]['ac']) > 0 && $XML_RPC_xh[$parser]['vt'] == $XML_RPC_String) { $XML_RPC_xh[$parser]['st'] .= '"' . $XML_RPC_xh[$parser]['ac'] . '"'; } // This if () detects if no scalar was inside <VALUE></VALUE> // and pads an empty "". if ($XML_RPC_xh[$parser]['st'][strlen($XML_RPC_xh[$parser]['st']) - 1] == '(') { $XML_RPC_xh[$parser]['st'] .= '""'; } $XML_RPC_xh[$parser]['st'] .= ", '" . $XML_RPC_xh[$parser]['vt'] . "')"; if ($XML_RPC_xh[$parser]['cm']) { $XML_RPC_xh[$parser]['st'] .= ','; } break; case 'MEMBER': $XML_RPC_xh[$parser]['ac'] = ''; $XML_RPC_xh[$parser]['qt'] = 0; break; case 'DATA': $XML_RPC_xh[$parser]['ac'] = ''; $XML_RPC_xh[$parser]['qt'] = 0; break; case 'PARAM': $XML_RPC_xh[$parser]['params'][] = $XML_RPC_xh[$parser]['st']; break; case 'METHODNAME': $XML_RPC_xh[$parser]['method'] = ereg_replace("^[\n\r\t ]+", '', $XML_RPC_xh[$parser]['ac']); break; case 'BOOLEAN': // special case here: we translate boolean 1 or 0 into PHP // constants true or false if ($XML_RPC_xh[$parser]['ac'] == '1') { $XML_RPC_xh[$parser]['ac'] = 'true'; } else { $XML_RPC_xh[$parser]['ac'] = 'false'; } $XML_RPC_xh[$parser]['vt'] = strtolower($name); } // if it's a valid type name, set the type if (isset($XML_RPC_Types[strtolower($name)])) { $XML_RPC_xh[$parser]['vt'] = strtolower($name); } }
function XML_RPC_ee($parser, $name) { global $XML_RPC_xh, $XML_RPC_Types, $XML_RPC_String; if ($XML_RPC_xh[$parser]['isf'] >= 2) { return; } // push this element from stack // NB: if XML validates, correct opening/closing is guaranteed and // we do not have to check for $name == $curr_elem. // we also checked for proper nesting at start of elements... $curr_elem = array_shift($XML_RPC_xh[$parser]['stack']); switch ($name) { case "STRUCT": case "ARRAY": $cur_val = array_shift($XML_RPC_xh[$parser]['valuestack']); $XML_RPC_xh[$parser]['value'] = $cur_val['values']; $XML_RPC_xh[$parser]['st'] .= ")"; $XML_RPC_xh[$parser]['vt'] = strtolower($name); break; case "NAME": $XML_RPC_xh[$parser]['valuestack'][0]['name'] = $XML_RPC_xh[$parser]['ac']; break; case "BOOLEAN": // special case here: we translate boolean 1 or 0 into PHP // constants true or false if ($XML_RPC_xh[$parser]['ac'] == '1') { $XML_RPC_xh[$parser]['value'] = "true"; } else { $XML_RPC_xh[$parser]['value'] = "false"; } $XML_RPC_xh[$parser]['vt'] = $GLOBALS['XML_RPC_Boolean']; $XML_RPC_xh[$parser]['ac'] = ''; $XML_RPC_xh[$parser]['lv'] = 3; // indicate we've found a value break; case "I4": case "INT": // we have an I4, INT // we must check that only 0123456789-.<space> are characters here if (!ereg("^[+-]?[0123456789 \t\\.]+\$", $XML_RPC_xh[$parser]['ac'])) { XML_RPC_Base::raiseError('Non-numeric value received in INT: ' . $XML_RPC_xh[$parser]['ac'], XML_RPC_ERROR_NON_NUMERIC_FOUND); $XML_RPC_xh[$parser]['value'] = XML_RPC_ERROR_NON_NUMERIC_FOUND; } else { // it's ok, add it on $XML_RPC_xh[$parser]['value'] = (int) $XML_RPC_xh[$parser]['ac']; } $XML_RPC_xh[$parser]['vt'] = strtolower($name); $XML_RPC_xh[$parser]['ac'] = ''; $XML_RPC_xh[$parser]['lv'] = 3; // indicate we've found a value break; case "DOUBLE": // we have an DOUBLE // we must check that only eE0123456789-.<space> are characters here if (!ereg("^[+-]?[eE0123456789 \t\\.]+\$", $XML_RPC_xh[$parser]['ac'])) { XML_RPC_Base::raiseError('Non-numeric value received in DOUBLE: ' . $XML_RPC_xh[$parser]['ac'], XML_RPC_ERROR_NON_NUMERIC_FOUND); $XML_RPC_xh[$parser]['value'] = XML_RPC_ERROR_NON_NUMERIC_FOUND; } else { // it's ok, add it on $XML_RPC_xh[$parser]['value'] = (double) $XML_RPC_xh[$parser]['ac']; } $XML_RPC_xh[$parser]['vt'] = $GLOBALS['XML_RPC_Double']; $XML_RPC_xh[$parser]['ac'] = ''; $XML_RPC_xh[$parser]['lv'] = 3; // indicate we've found a value break; case 'STRING': $XML_RPC_xh[$parser]['vt'] = $GLOBALS['XML_RPC_String']; $XML_RPC_xh[$parser]['value'] = $XML_RPC_xh[$parser]['ac']; $XML_RPC_xh[$parser]['ac'] = ''; $XML_RPC_xh[$parser]['lv'] = 3; // indicate we've found a value break; case 'DATETIME.ISO8601': $XML_RPC_xh[$parser]['vt'] = $GLOBALS['XML_RPC_DateTime']; $XML_RPC_xh[$parser]['value'] = $XML_RPC_xh[$parser]['ac']; $XML_RPC_xh[$parser]['ac'] = ''; $XML_RPC_xh[$parser]['lv'] = 3; // indicate we've found a value break; case 'BASE64': $XML_RPC_xh[$parser]['vt'] = $GLOBALS['XML_RPC_Base64']; $XML_RPC_xh[$parser]['value'] = base64_decode($XML_RPC_xh[$parser]['ac']); $XML_RPC_xh[$parser]['ac'] = ''; $XML_RPC_xh[$parser]['lv'] = 3; // indicate we've found a value break; case "VALUE": if ($XML_RPC_xh[$parser]['vt'] == 'value') { $XML_RPC_xh[$parser]['value'] = $XML_RPC_xh[$parser]['ac']; $XML_RPC_xh[$parser]['vt'] == $XML_RPC_String; } $temp = new XML_RPC_Value($XML_RPC_xh[$parser]['value'], $XML_RPC_xh[$parser]['vt']); if (count($XML_RPC_xh[$parser]['valuestack']) && $XML_RPC_xh[$parser]['valuestack'][0]['type'] == 'ARRAY') { $XML_RPC_xh[$parser]['valuestack'][0]['values'][] = $temp; } else { $XML_RPC_xh[$parser]['value'] = $temp; } break; case "MEMBER": $XML_RPC_xh[$parser]['ac'] = ""; if ($XML_RPC_xh[$parser]['value']) { $XML_RPC_xh[$parser]['valuestack'][0]['values'][$XML_RPC_xh[$parser]['valuestack'][0]['name']] = $XML_RPC_xh[$parser]['value']; } break; case "DATA": $XML_RPC_xh[$parser]['ac'] = ""; break; case "PARAM": if ($XML_RPC_xh[$parser]['value']) { $XML_RPC_xh[$parser]['params'][] = $XML_RPC_xh[$parser]['value']; } break; case "METHODNAME": $XML_RPC_xh[$parser]['method'] = ereg_replace("^[\n\r\t ]+", "", $XML_RPC_xh[$parser]['ac']); break; case "BOOLEAN": // special case here: we translate boolean 1 or 0 into PHP // constants true or false if ($XML_RPC_xh[$parser]['ac'] == '1') { $XML_RPC_xh[$parser]['ac'] = "true"; } else { $XML_RPC_xh[$parser]['ac'] = "false"; } $XML_RPC_xh[$parser]['vt'] = strtolower($name); break; default: break; } // if it's a valid type name, set the typ*e if (isset($XML_RPC_Types[strtolower($name)])) { $XML_RPC_xh[$parser]['vt'] = strtolower($name); } }