Parser tests: output article name in duplicate article message
[mediawiki.git] / trackback.php
blob398cc794bed03ffcaa8edc87a5c11a661ef83e61
1 <?php
2 /**
3 * Provide functions to handle article trackbacks.
4 * @file
5 * @ingroup SpecialPage
6 */
8 require_once( './includes/WebStart.php' );
10 function XMLsuccess() {
11 header( "Content-Type: application/xml; charset=utf-8" );
12 echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
13 <response>
14 <error>0</error>
15 </response>
17 exit;
20 function XMLerror( $err = "Invalid request." ) {
21 header( "HTTP/1.0 400 Bad Request" );
22 header( "Content-Type: application/xml; charset=utf-8" );
23 echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
24 <response>
25 <error>1</error>
26 <message>Invalid request: $err</message>
27 </response>
29 exit;
32 if( !$wgUseTrackbacks )
33 XMLerror("Trackbacks are disabled.");
35 if( !isset( $_POST['url'] )
36 || !isset( $_REQUEST['article'] ) )
37 XMLerror("Required field not specified");
39 $dbw = wfGetDB( DB_MASTER );
41 $tbtitle = strval( @$_POST['title'] );
42 $tbex = strval( @$_POST['excerpt'] );
43 $tburl = strval( $_POST['url'] );
44 $tbname = strval( @$_POST['blog_name'] );
45 $tbarticle = strval( $_REQUEST['article'] );
47 $title = Title::newFromText($tbarticle);
48 if( !$title || !$title->exists() )
49 XMLerror( "Specified article does not exist." );
51 $dbw->insert('trackbacks', array(
52 'tb_page' => $title->getArticleID(),
53 'tb_title' => $tbtitle,
54 'tb_url' => $tburl,
55 'tb_ex' => $tbex,
56 'tb_name' => $tbname
57 ));
59 $dbw->commit();
61 XMLsuccess();