$permalink = get_permalink(get_the_ID()); if (!wp_verify_nonce($_REQUEST['name_of_nonce_field_checkstep2'], 'checkstep2')) { echo 'Sorry, your nonce did not verify.'; } else { $site_url = isset($_REQUEST['site_url']) ? $_REQUEST['site_url'] : ''; $xmlrpc_url = isset($_REQUEST['xmlrpc_url']) ? $_REQUEST['xmlrpc_url'] : ''; $client = new Blog_Validator(esc_url_raw($site_url)); $client->xmlrpc_endpoint_URL = esc_url_raw($xmlrpc_url); $client->setWPCredential($_REQUEST['user_login'], $_REQUEST['user_pass']); //Set the UserAgent $user_agent_selected = esc_attr($_REQUEST['user_agent']); $client->setUserAgent($user_agent_selected); //Enable HTTP Auth if selected $enable_401_auth = !empty($_REQUEST['enable_401_auth']); if ($enable_401_auth) { xml_rpc_validator_logIO("O", "HTTP auth enabled"); $client->setHTTPCredential($_REQUEST['HTTP_auth_user_login'], $_REQUEST['HTTP_auth_user_pass']); } $basicCallsRes = $client->getUsersBlogs(); if (is_wp_error($basicCallsRes)) { echo $xml_rpc_validator_utils->printErrors($basicCallsRes); } else { if (!empty($client->userBlogs)) { ?> <form name="xml_rpc_single_site_form" id="xml_rpc_single_site_form" action="#" method="post" onsubmit="return false;"> <p>Please select the blog you wanna test:</p> <?php foreach ($client->userBlogs as $blog) { echo '<p style="margin-top:10px"><input type="radio" name="single_site_xmlrpc_url" value="' . $blog['xmlrpc'] . '"> ' . $blog['blogName'] . ' - ' . $blog['xmlrpc'] . '</input></p>'; } //end foreach
function open() { global $xml_rpc_validator_errors; $args = func_get_args(); $method = array_shift($args); $request = new IXR_Request($method, $args); $length = $request->getLength(); $xml = $request->getXml(); $this->headers['Content-Type'] = 'text/xml'; $this->headers['User-Agent'] = $this->useragent; $this->headers['Content-Length'] = $length; $this->headers['Accept'] = '*/*'; if (!empty($this->HTTP_auth_user_login)) { xml_rpc_validator_logIO("I", "HTTP auth header set " . $this->HTTP_auth_user_login . ':' . $this->HTTP_auth_user_pass); $this->headers['Authorization'] = 'Basic ' . base64_encode($this->HTTP_auth_user_login . ':' . $this->HTTP_auth_user_pass); } $requestParameter = array(); $requestParameter = array('headers' => $this->headers); $requestParameter['method'] = 'POST'; $requestParameter['body'] = $xml; $requestParameter['timeout'] = REQUEST_HTTP_TIMEOUT; xml_rpc_validator_logIO("I", "HTTP Request headers: " . print_r($this->headers, TRUE)); xml_rpc_validator_logIO("I", "XML-RPC Request: "); if (strpos($method, 'metaWeblog.newMediaObject') === false) { //do not log the whole picture upload request document xml_rpc_validator_logXML("I", $xml); } else { xml_rpc_validator_logXML("I", substr($xml, 0, 100)); } $xmlrpc_request = new WP_Http(); $this->response = $xmlrpc_request->request($this->URL, $requestParameter); xml_rpc_validator_logIO("O", "Response details below ->"); //xml_rpc_validator_logIO("O", "RAW response: ". print_r ($this->response, TRUE)); xml_rpc_validator_logIO("O", "HTTP Response code: " . print_r($this->response['response']['code'] . ' - ' . $this->response['response']['message'], TRUE)); xml_rpc_validator_logIO("O", "HTTP Response headers: " . print_r($this->response['headers'], TRUE)); // Handle error here. if (is_wp_error($this->response)) { return $this->response; } elseif (strcmp($this->response['response']['code'], '200') != 0) { return new WP_Error($this->response['response']['code'], $this->response['response']['message']); } xml_rpc_validator_logIO("O", "HTTP Response Body:", TRUE); $contents = trim($this->response['body']); xml_rpc_validator_logXML("O", $contents); if (empty($contents)) { $error_obj = $xml_rpc_validator_errors['MISSING_XMLRPC_METHODS']; $this->error = new WP_Error($error_obj['code'], $error_obj['message']); return $this->error; } else { //check the first character if ($contents[0] !== '<') { $error_obj = $xml_rpc_validator_errors['XMLRPC_RESPONSE_MALFORMED_1']; $this->error = new WP_Error($error_obj['code'], $error_obj['message']); return $this->error; } } //check the characters within the response if ($this->check_UTF8($contents) !== true) { $error_obj = $xml_rpc_validator_errors['XMLRPC_RESPONSE_CONTAINS_INVALID_CHARACTERS']; $this->error = new WP_Error($error_obj['code'], $error_obj['message']); return $this->error; } // Now parse what we've got back $this->message = new IXR_Message($contents); if (!$this->message->parse()) { // XML error $error_obj = $xml_rpc_validator_errors['XMLRPC_RESPONSE_MALFORMED_2']; $this->error = new WP_Error($error_obj['code'], $error_obj['message']); return $this->error; } // Is the message a fault? if ($this->message->messageType == 'fault') { $this->error = new WP_Error($this->message->faultCode, $this->message->faultString); return $this->error; } return $this->message->params[0]; }