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