From: brockhaus Date: Mon, 20 Aug 2007 21:00:01 +0000 (+0000) Subject: Made pingback receiving better working with WordPress Pingbacks X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4aa01bf160fc4728ce620e25c1bdbd235ed3f739;p=s9y.git Made pingback receiving better working with WordPress Pingbacks --- diff --git a/comment.php b/comment.php index f849e14..192d173 100644 --- a/comment.php +++ b/comment.php @@ -2,8 +2,8 @@ # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team) # All rights reserved. See LICENSE file for licensing details -include_once('serendipity_config.inc.php'); -include_once S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php'; +include('serendipity_config.inc.php'); +include S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php'; header('Content-Type: text/html; charset=' . LANG_CHARSET); @@ -20,11 +20,33 @@ if (isset($serendipity['GET']['switch'], $serendipity['GET']['entry'])) { serendipity_rememberComment(); -if (!($type = @$_REQUEST['type'])) { - $type = 'normal'; +// Trackback logging. For developers: can be switched to true! +$tb_logging = false; +// Pingback logging. For developers: can be switched to true! +$pb_logging = false; + +if ($pb_logging) { + log_pingback('CONTENT_TYPE: ' . $_SERVER['CONTENT_TYPE']); + log_pingback('HTTP_RAW_POST_DATA: ' . $tmp); } -$tb_logging = false; // for developers: can be switched to true! +if (!($type = @$_REQUEST['type'])) { + if ($pb_logging) { + ob_start(); + print_r($HTTP_RAW_POST_DATA); + $tmp = ob_get_contents(); + ob_end_clean(); + log_pingback('NO TYPE HANDED!'); + } + + // WordPress pingbacks don't give any parameter. If it is a XML POST asume it's a pigback + if ($_SERVER['CONTENT_TYPE'] == 'text/xml' && isset($HTTP_RAW_POST_DATA)) { + $type = 'pingback'; + } + else { + $type = 'normal'; + } +} if ($type == 'trackback') { if ($tb_logging) { @@ -73,9 +95,20 @@ if ($type == 'trackback') { fclose($fp); } } else if ($type == 'pingback') { + if ($pb_logging) { + log_pingback('RECEIVED PINGBACK'); + # PHP 4.2.2 way of doing things + ob_start(); + print_r($HTTP_RAW_POST_DATA); + $tmp = ob_get_contents(); + ob_end_clean(); + log_pingback('HTTP_RAW_POST_DATA: ' .$tmp); + } if (add_pingback($_REQUEST['entry_id'], $HTTP_RAW_POST_DATA)) { + log_pingback('PINGBACK SUCCESS');; report_pingback_success(); } else { + log_pingback('PINGBACK FAILURE');; report_pingback_failure(); } } else { @@ -162,5 +195,15 @@ if ($type == 'trackback') { $serendipity['smarty']->display(serendipity_getTemplateFile($serendipity['smarty_file'], 'serendipityPath')); } + +// Debug logging for pingback receiving +function log_pingback($message){ + global $pb_logging; + if ($pb_logging) { + $fp = fopen('pingback.log', 'a'); + fwrite($fp, '[' . date('d.m.Y H:i') . '] ' . $message . "\n"); + fclose($fp); + } +} /* vim: set sts=4 ts=4 expandtab : */ ?>