The war on redundant ampersand usage!
[lhc/web/wiklou.git] / trackback.php
1 <?php
2 /**
3 * Provide functions to handle article trackbacks.
4 * @addtogroup SpecialPage
5 */
6 require_once( './includes/WebStart.php' );
7
8 require_once('DatabaseFunctions.php');
9
10 /**
11 *
12 */
13 function XMLsuccess() {
14 echo "
15 <?xml version=\"1.0\" encoding=\"utf-8\"?>
16 <response>
17 <error>0</error>
18 </response>
19 ";
20 exit;
21 }
22
23 function XMLerror($err = "Invalid request.") {
24 header("HTTP/1.0 400 Bad Request");
25 echo "
26 <?xml version=\"1.0\" encoding=\"utf-8\"?>
27 <response>
28 <error>1</error>
29 <message>Invalid request: $err</message>
30 </response>
31 ";
32 exit;
33 }
34
35 if (!$wgUseTrackbacks)
36 XMLerror("Trackbacks are disabled.");
37
38 if ( !isset($_POST['url'])
39 || !isset($_POST['blog_name'])
40 || !isset($_REQUEST['article']))
41 XMLerror("Required field not specified");
42
43 $dbw = wfGetDB(DB_MASTER);
44
45 $tbtitle = $_POST['title'];
46 $tbex = $_POST['excerpt'];
47 $tburl = $_POST['url'];
48 $tbname = $_POST['blog_name'];
49 $tbarticle = $_REQUEST['article'];
50
51 $title = Title::newFromText($tbarticle);
52 if (!isset($title) || !$title->exists())
53 XMLerror("Specified article does not exist.");
54
55 $dbw->insert('trackbacks', array(
56 'tb_page' => $title->getArticleID(),
57 'tb_title' => $tbtitle,
58 'tb_url' => $tburl,
59 'tb_ex' => $tbex,
60 'tb_name' => $tbname
61 ));
62
63 XMLsuccess();
64 exit;
65 ?>