updated pingback() to use IXR -- now we aren't using phpxmlrpc anywhere anymore
git-svn-id: http://svn.automattic.com/wordpress/trunk@1682 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b28a9e34b0
commit
1ae5d673e4
|
@ -495,7 +495,7 @@ function weblog_ping($server = '', $path = '') {
|
||||||
// using a timeout of 3 seconds should be enough to cover slow servers
|
// using a timeout of 3 seconds should be enough to cover slow servers
|
||||||
$client = new IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path));
|
$client = new IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path));
|
||||||
$client->timeout = 3;
|
$client->timeout = 3;
|
||||||
$client->useragent .= ' / WordPress '.$wp_version;
|
$client->useragent .= ' -- WordPress/'.$wp_version;
|
||||||
|
|
||||||
// when set to true, this outputs debug messages by itself
|
// when set to true, this outputs debug messages by itself
|
||||||
$client->debug = false;
|
$client->debug = false;
|
||||||
|
@ -631,10 +631,11 @@ function debug_fclose($fp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function pingback($content, $post_ID) {
|
function pingback($content, $post_ID) {
|
||||||
include_once (ABSPATH . WPINC . '/class-xmlrpc.php');
|
|
||||||
include_once (ABSPATH . WPINC . '/class-xmlrpcs.php');
|
|
||||||
// original code by Mort (http://mort.mine.nu:8080)
|
|
||||||
global $wp_version;
|
global $wp_version;
|
||||||
|
include_once (ABSPATH . WPINC . '/class-IXR.php');
|
||||||
|
|
||||||
|
// original code by Mort (http://mort.mine.nu:8080)
|
||||||
$log = debug_fopen('./pingback.log', 'a');
|
$log = debug_fopen('./pingback.log', 'a');
|
||||||
$post_links = array();
|
$post_links = array();
|
||||||
debug_fwrite($log, 'BEGIN '.time()."\n");
|
debug_fwrite($log, 'BEGIN '.time()."\n");
|
||||||
|
@ -750,22 +751,6 @@ include_once (ABSPATH . WPINC . '/class-xmlrpcs.php');
|
||||||
debug_fwrite($log, "Pingback server not found\n\n*************************\n\n");
|
debug_fwrite($log, "Pingback server not found\n\n*************************\n\n");
|
||||||
@fclose($fp);
|
@fclose($fp);
|
||||||
} else {
|
} else {
|
||||||
debug_fwrite($log,"\n\nPingback server data\n");
|
|
||||||
|
|
||||||
// Assuming there's a "http://" bit, let's get rid of it
|
|
||||||
$host_clear = substr($pingback_server_url, 7);
|
|
||||||
|
|
||||||
// the trailing slash marks the end of the server name
|
|
||||||
$host_end = strpos($host_clear, '/');
|
|
||||||
|
|
||||||
// Another clear cut
|
|
||||||
$host_len = $host_end-$host_start;
|
|
||||||
$host = substr($host_clear, 0, $host_len);
|
|
||||||
debug_fwrite($log, 'host: '.$host."\n");
|
|
||||||
|
|
||||||
// If we got the server name right, the rest of the string is the server path
|
|
||||||
$path = substr($host_clear,$host_end);
|
|
||||||
debug_fwrite($log, 'path: '.$path."\n\n");
|
|
||||||
|
|
||||||
// Now, the RPC call
|
// Now, the RPC call
|
||||||
$method = 'pingback.ping';
|
$method = 'pingback.ping';
|
||||||
|
@ -774,26 +759,18 @@ include_once (ABSPATH . WPINC . '/class-xmlrpcs.php');
|
||||||
$pagelinkedfrom = get_permalink($post_ID);
|
$pagelinkedfrom = get_permalink($post_ID);
|
||||||
debug_fwrite($log, $pagelinkedfrom."\n");
|
debug_fwrite($log, $pagelinkedfrom."\n");
|
||||||
|
|
||||||
$client = new xmlrpc_client($path, $host, 80);
|
// using a timeout of 3 seconds should be enough to cover slow servers
|
||||||
$message = new xmlrpcmsg($method, array(new xmlrpcval($pagelinkedfrom), new xmlrpcval($pagelinkedto)));
|
$client = new IXR_Client($pingback_server_url);
|
||||||
$result = $client->send($message);
|
$client->timeout = 3;
|
||||||
if ($result){
|
$client->useragent .= ' -- WordPress/'.$wp_version;
|
||||||
if (!$result->value()){
|
|
||||||
debug_fwrite($log, $result->faultCode().' -- '.$result->faultString());
|
// when set to true, this outputs debug messages by itself
|
||||||
} else {
|
$client->debug = false;
|
||||||
$value = phpxmlrpc_decode($result->value());
|
$client->query('pingback.ping', array($pagelinkedfrom, $pagelinkedto));
|
||||||
if (is_array($value)) {
|
|
||||||
$value_arr = '';
|
if (!$client->query('pingback.ping', array($pagelinkedfrom, $pagelinkedto))) {
|
||||||
foreach($value as $blah) {
|
debug_fwrite($log, "Error.\n Fault code: ".$client->getErrorCode()." : ".$client->getErrorMessage()."\n");
|
||||||
$value_arr .= $blah.' |||| ';
|
|
||||||
}
|
|
||||||
debug_fwrite($log, $value_arr);
|
|
||||||
} else {
|
|
||||||
debug_fwrite($log, $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@fclose($fp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue