# 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);
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) {
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 {
$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 : */
?>