(bug 769) OutputPage::permissionRequired() should suggest groups with the needed...
[mediawiki.git] / trackback.php
blobae1e32b25ad14c76d914ca89b1d07a1aa4ba7f28
1 <?php
2 /**
3 * Provide functions to handle article trackbacks.
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7 require_once( './includes/WebStart.php' );
9 require_once('DatabaseFunctions.php');
11 /**
14 function XMLsuccess() {
15 echo "
16 <?xml version=\"1.0\" encoding=\"utf-8\"?>
17 <response>
18 <error>0</error>
19 </response>
21 exit;
24 function XMLerror($err = "Invalid request.") {
25 header("HTTP/1.0 400 Bad Request");
26 echo "
27 <?xml version=\"1.0\" encoding=\"utf-8\"?>
28 <response>
29 <error>1</error>
30 <message>Invalid request: $err</message>
31 </response>
33 exit;
36 if (!$wgUseTrackbacks)
37 XMLerror("Trackbacks are disabled.");
39 if ( !isset($_POST['url'])
40 || !isset($_POST['blog_name'])
41 || !isset($_REQUEST['article']))
42 XMLerror("Required field not specified");
44 $dbw =& wfGetDB(DB_MASTER);
46 $tbtitle = $_POST['title'];
47 $tbex = $_POST['excerpt'];
48 $tburl = $_POST['url'];
49 $tbname = $_POST['blog_name'];
50 $tbarticle = $_REQUEST['article'];
52 $title = Title::newFromText($tbarticle);
53 if (!$title->exists())
54 XMLerror("Specified article does not exist.");
56 $dbw->insert('trackbacks', array(
57 'tb_page' => $title->getArticleID(),
58 'tb_title' => $tbtitle,
59 'tb_url' => $tburl,
60 'tb_ex' => $tbex,
61 'tb_name' => $tbname
62 ));
64 XMLsuccess();
65 exit;