Add non-identity collation, with migration script
[lhc/web/wiklou.git] / trackback.php
1 <?php
2 /**
3 * Provide functions to handle article trackbacks.
4 * @file
5 * @ingroup SpecialPage
6 */
7
8 require_once( './includes/WebStart.php' );
9
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>
16 ";
17 exit;
18 }
19
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>
28 ";
29 exit;
30 }
31
32 if( !$wgUseTrackbacks )
33 XMLerror("Trackbacks are disabled.");
34
35 if( !isset( $_POST['url'] )
36 || !isset( $_REQUEST['article'] ) )
37 XMLerror("Required field not specified");
38
39 $dbw = wfGetDB( DB_MASTER );
40
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'] );
46
47 $title = Title::newFromText($tbarticle);
48 if( !$title || !$title->exists() )
49 XMLerror( "Specified article does not exist." );
50
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 ));
58
59 $dbw->commit();
60
61 XMLsuccess();