]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - trackback.php
MediaWiki 1.5.8 (initial commit)
[autoinstallsdev/mediawiki.git] / trackback.php
1 <?php
2 /**
3  * Provide functions to handle article trackbacks.
4  * @package MediaWiki
5  * @subpackage SpecialPage
6  */
7
8 unset($IP);
9 define('MEDIAWIKI', true);
10 require_once('./includes/Defines.php');
11
12 if (!file_exists('LocalSettings.php'))
13         exit;
14
15 require_once('./LocalSettings.php');
16 require_once('includes/Setup.php');
17
18 require_once('Title.php');
19 require_once('DatabaseFunctions.php');
20
21 /**
22  *
23  */
24 function XMLsuccess() {
25         echo "
26 <?xml version=\"1.0\" encoding=\"utf-8\"?>
27 <response>
28 <error>0</error>
29 </response>
30         ";
31         exit;
32 }
33
34 function XMLerror($err = "Invalid request.") {
35         header("HTTP/1.0 400 Bad Request");
36         echo "
37 <?xml version=\"1.0\" encoding=\"utf-8\"?>
38 <response>
39 <error>1</error>
40 <message>Invalid request: $err</message>
41 </response>
42 ";
43                 exit;
44 }
45
46 if (!$wgUseTrackbacks)
47         XMLerror("Trackbacks are disabled.");
48
49 if (   !isset($_POST['url'])
50     || !isset($_POST['blog_name'])
51     || !isset($_REQUEST['article']))
52         XMLerror("Required field not specified");
53
54 $dbw =& wfGetDB(DB_MASTER);
55
56 $tbtitle = $_POST['title'];
57 $tbex = $_POST['excerpt'];
58 $tburl = $_POST['url'];
59 $tbname = $_POST['blog_name'];
60 $tbarticle = $_REQUEST['article'];
61
62 $title = Title::newFromText($tbarticle);
63 if (!$title->exists())
64         XMLerror("Specified article does not exist.");
65
66 $dbw->insert('trackbacks', array(
67         'tb_page'       => $title->getArticleID(),
68         'tb_title'      => $tbtitle,
69         'tb_url'        => $tburl,
70         'tb_ex'         => $tbex,
71         'tb_name'       => $tbname
72 ));
73
74 XMLsuccess();
75 exit;