3 Trackback plugin for Elgg
4 Initial author: Marcus Povey <marcus@dushka.co.uk>
7 /** @file trackback/index.php Trackback endpoint.
8 * This file receives trackback requests for entries and stores them in a database, based on the
9 * code written for dushka.co.uk.
10 * @author Marcus Povey <marcus@dushka.co.uk>
14 require_once("../../includes.php");
17 // Identity of the entry being pinged
18 $id = optional_param('id','', PARAM_INT
);
21 $url = optional_param('url','');
22 $title = optional_param('title','');
23 $excerpt = optional_param('excerpt','');
24 $blog_name = optional_param('blog_name','');
26 // Output the header before anything else
27 header("Content-Type: application/xml; charset=charset=iso-8859-15");
32 trackback_Error("URL has not been given!");
37 trackback_Error("ID of article not specified, trackback URL is incomplete");
40 // Construct and post the comment
41 $comment = new stdClass
;
42 $comment->post_id
= $id;
43 $comment->postedname
= $blog_name;
44 //$comment->profile_url = $url; // This might be a nice future enhancement
45 $comment->body
= "<a href=\"$url\">$title</a><br />$excerpt";
47 $comment->posted
= time();
50 $comment = plugin_hook("weblog_comment","create",$comment);
51 if ( ($comment!==false) && (!empty($comment)) )
53 $insert_id = insert_record('weblog_comments',$comment);
54 $comment->ident
= $insert_id;
55 $comment = plugin_hook("weblog_comment","publish",$comment);
61 if (count($messages)>0)
62 $message = $messages[count($messages)-1];
64 $message = "Could not post message.";
66 $errormessage = $message;
67 trackback_Error($errormessage);