function error($code, $desc = "") { global $XML_RPC_erruser; // import user errcode value //definition of error strings $str = array(1 => $desc, 2 => "MUST_LOGIN", 3 => "UNKNOWN_USER", 4 => "USER_NOT_ADMIN", 5 => "WRONG_PASSWORD", 6 => "USER_ALREADY_EXISTS", 7 => "REGISTERING_NOT_ALLOWED", 10 => "TRACK_NOT_FOUND", 11 => "RATING_MISSING", 12 => "BAD_INPUT"); $error = new XML_RPC_Response(0, $XML_RPC_erruser + $code, $str[$code]); //quite dirty todo $payload = "<?xml version=\"1.0\"?>\n" . $error->serialize(); header('Content-Length: ' . strlen($payload)); header('Content-Type: text/xml'); print $payload; die; }
/** * Echos back the input packet as a string value * * @return void * * Useful for debugging. */ function echoInput() { global $HTTP_RAW_POST_DATA; $r = new XML_RPC_Response(0); $r->xv = new XML_RPC_Value("'Aha said I: '" . $HTTP_RAW_POST_DATA, 'string'); print $r->serialize(); }
function pearErrorHandler($oError) { $aConf = $GLOBALS['_MAX']['CONF']; // Log message $message = $oError->getMessage(); $debugInfo = $oError->getDebugInfo(); OA::debug('PEAR' . " :: {$message} : {$debugInfo}", PEAR_LOG_ERR); // If sesssion debug, send error info to screen $msg = ''; if (empty($aConf['debug']['production'])) { $GLOBALS['_MAX']['ERRORS'][] = $oError; } // Add backtrace info if (!empty($aConf['debug']['showBacktrace'])) { $msg .= 'PEAR backtrace: <div onClick="if (this.style.height) {this.style.height = null;this.style.width = null;} else {this.style.height = \'8px\'; this.style.width=\'8px\'}"'; $msg .= 'style="float:left; cursor: pointer; border: 1px dashed #FF0000; background-color: #EFEFEF; height: 8px; width: 8px; overflow: hidden; margin-bottom: 2px;">'; $msg .= '<pre wrap style="margin: 5px; background-color: #EFEFEF">'; ob_start(); print_r($oError->getBacktrace()); $msg .= ob_get_clean(); $msg .= '<hr></pre></div>'; $msg .= '<div style="clear:both"></div>'; } if (defined('TEST_ENVIRONMENT_RUNNING')) { // It's a test, stop execution echo $message; exit(1); } elseif (defined('OA_WEBSERVICES_API_XMLRPC')) { // It's an XML-RPC response $oResponse = new XML_RPC_Response('', 99999, $message); echo $oResponse->serialize(); exit; } else { // Send the error to the screen echo MAX::errorObjToString($oError, $msg); } }
function echoInput() { global $HTTP_RAW_POST_DATA; // a debugging routine: just echos back the input // packet as a string value $r = new XML_RPC_Response(); $r->xv = new XML_RPC_Value("'Aha said I: '" . $HTTP_RAW_POST_DATA, "string"); print $r->serialize(); }
function phpAds_Die($title = "Error", $message = "Unknown error") { if (defined('OA_WEBSERVICES_API_XMLRPC')) { // It's an XML-RPC response if (class_exists('XmlRpcUtils')) { $oResponse = XmlRpcUtils::generateError($message); } else { $oResponse = new XML_RPC_Response('', 99999, $message); } echo $oResponse->serialize(); exit; } $conf = $GLOBALS['_MAX']['CONF']; global $phpAds_GUIDone, $phpAds_TextDirection; $header = $title == $GLOBALS['strAccessDenied'] ? phpAds_Login : phpAds_Error; // Header if ($phpAds_GUIDone == false) { if (!isset($phpAds_TextDirection)) { $phpAds_TextDirection = 'ltr'; } phpAds_PageHeader(phpAds_Error); } echo "<br>"; echo "<div class='errormessage'><img class='errormessage' src='" . OX::assetPath() . "/images/errormessage.gif' align='absmiddle'> "; echo "<span class='tab-r'>" . $title . "</span><br><br>" . $message . "</div><br>"; // Die if ($header == phpAds_Login) { $_COOKIE['sessionID'] = phpAds_SessionStart(); OA_Auth::displayLogin('', $_COOKIE['sessionID'], true); } phpAds_PageFooter(); exit; }
/** * @param string $data * @return XML_RPC_Response */ private function parseResponse($data = '') { global $XML_RPC_xh, $XML_RPC_err, $XML_RPC_str; $encoding = self::getEncoding($data); $parser_resource = xml_parser_create($encoding); $parser = (int) $parser_resource; $XML_RPC_xh = array(); $XML_RPC_xh[$parser] = array(); $XML_RPC_xh[$parser]['cm'] = 0; $XML_RPC_xh[$parser]['isf'] = 0; $XML_RPC_xh[$parser]['ac'] = ''; $XML_RPC_xh[$parser]['qt'] = ''; $XML_RPC_xh[$parser]['stack'] = array(); $XML_RPC_xh[$parser]['valuestack'] = array(); xml_parser_set_option($parser_resource, XML_OPTION_CASE_FOLDING, true); xml_set_element_handler($parser_resource, 'XML_RPC::startElement', 'XML_RPC::endElement'); xml_set_character_data_handler($parser_resource, 'XML_RPC::cd'); $hdrfnd = 0; if ($this->debug) { echo "\n<pre>---GOT---\n"; echo isset($_SERVER['SERVER_PROTOCOL']) ? htmlspecialchars($data) : $data; echo "\n---END---</pre>\n"; } // See if response is a 200 or a 100 then a 200, else raise error. // But only do this if we're using the HTTP protocol. if (preg_match('@^HTTP@', $data) && !preg_match('@^HTTP/[0-9\\.]+ 200 @', $data) && !preg_match('@^HTTP/[0-9\\.]+ 10[0-9]([A-Z ]+)?[\\r\\n]+HTTP/[0-9\\.]+ 200@', $data)) { $errorString = substr($data, 0, strpos($data, "\n") - 1); error_log('HTTP error, got response: ' . $errorString); $r = new XML_RPC_Response(0, $XML_RPC_err['http_error'], $XML_RPC_str['http_error'] . ' (' . $errorString . ')'); xml_parser_free($parser_resource); return $r; } // gotta get rid of headers here if (!$hdrfnd && ($brpos = strpos($data, "\r\n\r\n"))) { $XML_RPC_xh[$parser]['ha'] = substr($data, 0, $brpos); $data = substr($data, $brpos + 4); $hdrfnd = 1; } /* * be tolerant of junk after methodResponse * (e.g. javascript automatically inserted by free hosts) * thanks to Luca Mariano <*****@*****.**> */ $data = substr($data, 0, strpos($data, '</methodResponse>') + strlen('</methodResponse>')); $this->response_payload = $data; if (!xml_parse($parser_resource, $data, sizeof($data))) { // thanks to Peter Kocks <*****@*****.**> if (xml_get_current_line_number($parser_resource) == 1) { $errorString = 'XML error at line 1, check URL'; } else { $errorString = sprintf('XML error: %s at line %d', xml_error_string(xml_get_error_code($parser_resource)), xml_get_current_line_number($parser_resource)); } error_log($errorString); $r = new XML_RPC_Response(0, $XML_RPC_err['invalid_return'], $XML_RPC_str['invalid_return']); xml_parser_free($parser_resource); return $r; } xml_parser_free($parser_resource); if ($this->debug) { echo "\n<pre>---PARSED---\n"; var_dump($XML_RPC_xh[$parser]['value']); echo "---END---</pre>\n"; } if ($XML_RPC_xh[$parser]['isf'] > 1) { $r = new XML_RPC_Response(0, $XML_RPC_err['invalid_return'], $XML_RPC_str['invalid_return'] . ' ' . $XML_RPC_xh[$parser]['isf_reason']); } elseif (!is_object($XML_RPC_xh[$parser]['value'])) { // then something odd has happened // and it's time to generate a client side error // indicating something odd went on $r = new XML_RPC_Response(0, $XML_RPC_err['invalid_return'], $XML_RPC_str['invalid_return']); } else { $v = $XML_RPC_xh[$parser]['value']; if ($XML_RPC_xh[$parser]['isf']) { $f = $v->structMem('faultCode'); $fs = $v->structMem('faultString'); $r = new XML_RPC_Response($v, $f->scalarValue(), $fs->scalarValue()); } else { $r = new XML_RPC_Response($v); } } $r->setHeaders(preg_split("@\r?\n@", $XML_RPC_xh[$parser]['ha'])); return $r; }