Simple status box for the sidebar.
[elgg_plugins.git] / trackback / index.php
blob96d247e5332acbe04cf24bfc7f0bb0e4513eb139
1 <?php
2 /*
3 Trackback plugin for Elgg
4 Initial author: Marcus Povey <marcus@dushka.co.uk>
5 */
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>
13 // Run includes
14 require_once("../../includes.php");
15 global $messages;
17 // Identity of the entry being pinged
18 $id = optional_param('id','', PARAM_INT);
20 // Trackback data
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");
29 // Sanity check input
30 if ($url=="")
32 trackback_Error("URL has not been given!");
35 if ($id=="")
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";
46 $comment->owner = -1;
47 $comment->posted = time();
49 // Post the comment
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);
58 // Any errors?
59 if ($comment===false)
61 if (count($messages)>0)
62 $message = $messages[count($messages)-1];
63 else
64 $message = "Could not post message.";
66 $errormessage = $message;
67 trackback_Error($errormessage);
70 trackback_Ok();