AutoLoad Title.php, move global cache arrays to static Title:: variables
[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('DatabaseFunctions.php');
24
25 /**
26 *
27 */
28 function XMLsuccess() {
29 echo "
30 <?xml version=\"1.0\" encoding=\"utf-8\"?>
31 <response>
32 <error>0</error>
33 </response>
34 ";
35 exit;
36 }
37
38 function XMLerror($err = "Invalid request.") {
39 header("HTTP/1.0 400 Bad Request");
40 echo "
41 <?xml version=\"1.0\" encoding=\"utf-8\"?>
42 <response>
43 <error>1</error>
44 <message>Invalid request: $err</message>
45 </response>
46 ";
47 exit;
48 }
49
50 if (!$wgUseTrackbacks)
51 XMLerror("Trackbacks are disabled.");
52
53 if ( !isset($_POST['url'])
54 || !isset($_POST['blog_name'])
55 || !isset($_REQUEST['article']))
56 XMLerror("Required field not specified");
57
58 $dbw =& wfGetDB(DB_MASTER);
59
60 $tbtitle = $_POST['title'];
61 $tbex = $_POST['excerpt'];
62 $tburl = $_POST['url'];
63 $tbname = $_POST['blog_name'];
64 $tbarticle = $_REQUEST['article'];
65
66 $title = Title::newFromText($tbarticle);
67 if (!$title->exists())
68 XMLerror("Specified article does not exist.");
69
70 $dbw->insert('trackbacks', array(
71 'tb_page' => $title->getArticleID(),
72 'tb_title' => $tbtitle,
73 'tb_url' => $tburl,
74 'tb_ex' => $tbex,
75 'tb_name' => $tbname
76 ));
77
78 XMLsuccess();
79 exit;
80 ?>