I investigated the problem further. The problem is: Pingbacks are not evaluated correctly in Serendipity using the internal pingback functionality (the first link in my HTML code)! I coded a "test pingbacker" for testing the pingback functionality and all my pingbacks were rejected, because s9y didn't find (in its opinion) valid pingback XML.
The wrong code is found in functions_trackback.inc::add_pingback. The pregmatch there is wrong, as it doesn't accept line feeds and searches for <param><value/></param>, but pingback is sent (valid) as <param><name/><value/></param>.
So I changed the add_pingback function like this:
Code: Select all
/**
* Receive a pingback
*
* @access public
* @param int The entryid to receive a pingback for
* @param string The foreign postdata to add
* @return boolean
*/
function add_pingback ($id, $postdata) {
global $serendipity;
$sourceURI = getPingbackParam('sourceURI', $postdata);
$targetURI = getPingbackParam('targetURI', $postdata);
if (isset($sourceURI) && isset($targetURI)) {
$path = parse_url($sourceURI);
$local = $targetURI;
$comment['title'] = 'PingBack';
$comment['url'] = $sourceURI;
$comment['comment'] = '';
$comment['name'] = $path['host'];
serendipity_saveComment($id, $comment, 'PINGBACK');
return 1;
}
if(preg_match('@<methodCall>\s*<methodName>\s*pingback.ping\s*</methodName>\s*' . '<params>\s*<param>\s*<value>\s*<string>([^<]*)</string>\s*</value>\s*</param>\s*' . '<param>\s*<value>\s*<string>([^<]*)</string>\s*</value>\s*</param>\s*</params>\s*' . '</methodCall>@is', $postdata, $matches)) {
$remote = $matches[1];
$local = $matches[2];
$comment['title'] = '';
$comment['url'] = $remote;
$comment['comment'] = '';
$comment['name'] = '';
serendipity_saveComment($id, $comment, 'PINGBACK');
return 1;
}
return 0;
}
/**
* Gets a XML-RPC pingback.ping value by given parameter name
* @access private
* @param string Name of the paramameter
* @param string Buffer containing the pingback XML
*/
function getPingbackParam($paramName, $data)
{
$pattern = "<methodCall>.*?<methodName>\s*pingback.ping\s*</methodName>.*?<params>.*?<param>\s*" . "((<name>\s*$paramName\s*</name>\s*<value>\s*<string>([^<]*)</string>\s*</value>)|" . "(<value>\s*<string>([^<]*)</string>\s*</value>\s*<name>\s*$paramName\s*</name>))\s*" . "</param>.*?</params>.*?</methodCall>";
if (preg_match('@' . $pattern .'@is',$data, $matches)) {
return $matches[3];
} else {
return null;
}
}
(I broke the patterns to make the display nice here..)
Now Serendipity receives PingBacks, too.
Som stuff is missing:
1.) I don't fetch the page yet where the pingback is coming from. This is the only way to fill comments titel and comment while processing a pingback. I will add this soon, too.
2.) The AntiSpam plugin is not processing Pingbacks in any way. But it shoud do it in the same way as it is done with trackbacks.
3.) Serendipity is not able yet to display pingbacks! They won't be loaded by any smarty function I found. So I patched functions_smarty.inc.php::serendipity_fetchTrackbacks in that way, that it does not only load trackbacks but pingbacks, too:
Code: Select all
/**
* Fetch a list of trackbacks for an entry
*
* @access public
* @param int The ID of the entry
* @param string How many trackbacks to show
* @param boolean If true, also non-approved trackbacks will be shown
* @return
*/
function &serendipity_fetchTrackbacks($id, $limit = null, $showAll = false) {
global $serendipity;
if (!$showAll) {
$and = "AND status = 'approved'";
}
$query = "SELECT * FROM {$serendipity['dbPrefix']}comments WHERE entry_id = '". (int)$id ."' AND (type = 'TRACKBACK' OR type = 'PINGBACK') $and ORDER BY id";
if (isset($limit)) {
$limit = serendipity_db_limit_sql($limit);
$query .= " $limit";
}
$comments = serendipity_db_query($query);
if (!is_array($comments)) {
return array();
}
return $comments;
}
Now PingBacks are displayed in normal templates in the trackback section.