From 8be9f5438d73da114fc7755108637728e6f27b2e Mon Sep 17 00:00:00 2001 From: Garvin Hicking Date: Sun, 8 Jul 2007 18:10:33 +0000 Subject: [PATCH] Correct patch from brockhaus, thanks a lot --- include/functions_trackbacks.inc.php | 29 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/include/functions_trackbacks.inc.php b/include/functions_trackbacks.inc.php index d55d2208..1429a2b5 100644 --- a/include/functions_trackbacks.inc.php +++ b/include/functions_trackbacks.inc.php @@ -53,22 +53,30 @@ function serendipity_pingback_is_success($resp) { * Perform a HTTP query for autodiscovering a pingback URL * * @access public - * @param string (deprecated) The URL to try autodiscovery - * @param string The response of the original URL + * @param string The URL to try autodiscovery + * @param string The HTML of the source URL + * @param string The URL of our blog article * @return */ -function serendipity_pingback_autodiscover($loc, $body) { +function serendipity_pingback_autodiscover($loc, $body, $url=null) { global $serendipity; + + // This is the old way, sending pingbacks, for downward compatibility. + // But this is wrong, as it does link from the main blog URL instead of the article URL + if (!isset($url)) { + $url = $serendipity['baseURL']; + } + if (!empty($_SERVER['X-PINGBACK'])) { $pingback = $_SERVER['X-PINGBACK']; } elseif (preg_match('@@i', $body, $matches)) { $pingback = $matches[1]; } else { echo '
• ' . sprintf(PINGBACK_FAILED, PINGBACK_NOT_FOUND) . '
'; - return; + return false; } - // xml-rpc hack + // xml-rpc pingback call $query = " @@ -76,7 +84,7 @@ global $serendipity; sourceURI - {$serendipity['baseURL']} + $url targetURI @@ -87,16 +95,15 @@ global $serendipity; echo '
• ' . sprintf(PINGBACK_SENDING, htmlspecialchars($pingback)) . '
'; flush(); - + $response = _serendipity_send($pingback, $query, 'text/html'); $success = serendipity_pingback_is_success($response); - if ($success == true) { - echo '
• ' . 'PINGBACK: ' . PINGBACK_SENT .'
'; + echo '
• ' . PINGBACK_SENT .'
'; } else { echo '
• ' . sprintf(PINGBACK_FAILED, $response) . '
'; } - return $success; + return $success; } /** @@ -281,7 +288,7 @@ global $serendipity; if (strlen($fContent) != 0) { $trackback_result = serendipity_trackback_autodiscover($fContent, $parsed_loc, $url, $author, $title, $text, $loc); if ($trackback_result == false) { - serendipity_pingback_autodiscover($loc, $fContent); + serendipity_pingback_autodiscover($parsed_loc, $fContent, $url); } } else { echo '
• ' . TRACKBACK_NO_DATA . '
';