00001 <?php
00008 require_once( './includes/WebStart.php' );
00009
00010 function XMLsuccess() {
00011 header( "Content-Type: application/xml; charset=utf-8" );
00012 echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
00013 <response>
00014 <error>0</error>
00015 </response>
00016 ";
00017 exit;
00018 }
00019
00020 function XMLerror( $err = "Invalid request." ) {
00021 header( "HTTP/1.0 400 Bad Request" );
00022 header( "Content-Type: application/xml; charset=utf-8" );
00023 echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
00024 <response>
00025 <error>1</error>
00026 <message>Invalid request: $err</message>
00027 </response>
00028 ";
00029 exit;
00030 }
00031
00032 if( !$wgUseTrackbacks )
00033 XMLerror("Trackbacks are disabled.");
00034
00035 if( !isset( $_POST['url'] )
00036 || !isset( $_REQUEST['article'] ) )
00037 XMLerror("Required field not specified");
00038
00039 $dbw = wfGetDB( DB_MASTER );
00040
00041 $tbtitle = strval( @$_POST['title'] );
00042 $tbex = strval( @$_POST['excerpt'] );
00043 $tburl = strval( $_POST['url'] );
00044 $tbname = strval( @$_POST['blog_name'] );
00045 $tbarticle = strval( $_REQUEST['article'] );
00046
00047 $title = Title::newFromText($tbarticle);
00048 if( !$title || !$title->exists() )
00049 XMLerror( "Specified article does not exist." );
00050
00051 $dbw->insert('trackbacks', array(
00052 'tb_page' => $title->getArticleID(),
00053 'tb_title' => $tbtitle,
00054 'tb_url' => $tburl,
00055 'tb_ex' => $tbex,
00056 'tb_name' => $tbname
00057 ));
00058
00059 $dbw->commit();
00060
00061 XMLsuccess();