Update of /cvsroot/php-blog/jBlog
In directory sc8-pr-cvs1:/tmp/cvs-serv31811
Modified Files:
comment.php jBlog_functions.inc.php
Log Message:
pingbacks can be recieved now. largely untested
Index: comment.php
===================================================================
RCS file: /cvsroot/php-blog/jBlog/comment.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- comment.php 7 Mar 2003 19:32:43 -0000 1.7
+++ comment.php 8 Mar 2003 01:54:05 -0000 1.8
@@ -21,6 +21,12 @@
report_trackback_failure();
}
} else if ($type == 'pingback') {
+ if(add_pingback($_POST['entry_id'],$HTTP_RAW_POST_DATA)) {
+ report_pingback_success();
+ }
+ else {
+ report_pingback_failure();
+ }
} else {
$id = $jBlog['GET']['entry_id'];
?>
Index: jBlog_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/jBlog/jBlog_functions.inc.php,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- jBlog_functions.inc.php 7 Mar 2003 23:55:24 -0000 1.36
+++ jBlog_functions.inc.php 8 Mar 2003 01:54:06 -0000 1.37
@@ -678,6 +678,24 @@
return 1;
}
+function
+add_pingback ($id, $postdata)
+{
+ global $jBlog;
+
+ 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>@i', $postdata, $matches)) {
+ $remote = $matches[1];
+ $local = $matches[2];
+ $comment['title'] = '';
+ $comment['url'] = $remote;
+ $comment['comment'] = '';
+ $comment['name'] = '';
+ jBlog_saveComment($id, $comment, 'PINGBACK');
+ return 1;
+ }
+ return 0;
+}
+
/**
* Cut text
*/
@@ -708,6 +726,31 @@
FAILURE;
}
+function report_pingback_success ()
+{
+print <<<SUCCESS
+<?xml version="1.0"?>
+<methodResponse>
+ <params>
+ <param>
+ <value><string>success</string></value>
+ </param>
+ </params>
+ </methodResponse>
+SUCCESS;
+}
+
+function report_pingback_failure ()
+{
+print <<<FAILURE
+<?xml version="1.0"?>
+<methodResponse>
+ <fault>
+ <value><i4>0</i4></value>
+ </fault>
+</methodResponse>
+FAILURE;
+}
/**
* search through link body, and automatically send a trackback ping.
|