* Added wfDie() wrapper, and some manual die(-1), to force the return code
[lhc/web/wiklou.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 if ( isset( $_REQUEST['GLOBALS'] ) ) {
11 echo '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>';
12 die( -1 );
13 }
14
15 require_once('./includes/Defines.php');
16
17 if (!file_exists('LocalSettings.php'))
18 exit;
19
20 require_once('./LocalSettings.php');
21 require_once('includes/Setup.php');
22
23 require_once('Title.php');
24 require_once('DatabaseFunctions.php');
25
26 /**
27 *
28 */
29 function XMLsuccess() {
30 echo "
31 <?xml version=\"1.0\" encoding=\"utf-8\"?>
32 <response>
33 <error>0</error>
34 </response>
35 ";
36 exit;
37 }
38
39 function XMLerror($err = "Invalid request.") {
40 header("HTTP/1.0 400 Bad Request");
41 echo "
42 <?xml version=\"1.0\" encoding=\"utf-8\"?>
43 <response>
44 <error>1</error>
45 <message>Invalid request: $err</message>
46 </response>
47 ";
48 exit;
49 }
50
51 if (!$wgUseTrackbacks)
52 XMLerror("Trackbacks are disabled.");
53
54 if ( !isset($_POST['url'])
55 || !isset($_POST['blog_name'])
56 || !isset($_REQUEST['article']))
57 XMLerror("Required field not specified");
58
59 $dbw =& wfGetDB(DB_MASTER);
60
61 $tbtitle = $_POST['title'];
62 $tbex = $_POST['excerpt'];
63 $tburl = $_POST['url'];
64 $tbname = $_POST['blog_name'];
65 $tbarticle = $_REQUEST['article'];
66
67 $title = Title::newFromText($tbarticle);
68 if (!$title->exists())
69 XMLerror("Specified article does not exist.");
70
71 $dbw->insert('trackbacks', array(
72 'tb_page' => $title->getArticleID(),
73 'tb_title' => $tbtitle,
74 'tb_url' => $tburl,
75 'tb_ex' => $tbex,
76 'tb_name' => $tbname
77 ));
78
79 XMLsuccess();
80 exit;