3 * Provide functions to handle article trackbacks.
8 if ( isset( $_SERVER['MW_COMPILED'] ) ) {
9 require ( 'phase3/includes/WebStart.php' );
11 require ( dirname( __FILE__
) . '/includes/WebStart.php' );
16 private $r, $url, $title = null;
18 private function XMLsuccess() {
19 header( "Content-Type: application/xml; charset=utf-8" );
21 <?xml version="1.0" encoding="utf-8"?>
32 private function XMLerror( $err = "Invalid request." ) {
33 header( "HTTP/1.0 400 Bad Request" );
34 header( "Content-Type: application/xml; charset=utf-8" );
36 <?xml version="1.0" encoding="utf-8"?>
39 <message>Invalid request: $err</message>
45 public function __construct() {
46 global $wgUseTrackbacks, $wgRequest;
48 if( !$wgUseTrackbacks )
49 $this->XMLerror( "Trackbacks are disabled" );
51 $this->r
= $wgRequest;
53 if( !$this->r
->wasPosted() ) {
54 $this->XMLerror( "Must be posted" );
57 $this->url
= $wgRequest->getText( 'url' );
58 $article = $wgRequest->getText( 'article' );
60 if( !$this->url ||
!$article ) {
61 $this->XMLerror( "Required field not specified" );
64 $this->title
= Title
::newFromText( $article );
65 if( !$this->title ||
!$this->title
->exists() ) {
66 $this->XMLerror( "Specified article does not exist." );
70 public function write() {
71 $dbw = wfGetDB( DB_MASTER
);
73 $tbtitle = $this->r
->getText( 'title' );
74 $tbex = $this->r
->getText( 'excerpt' );
75 $tbname = $this->r
->getText( 'blog_name' );
77 $dbw->insert('trackbacks', array(
78 'tb_page' => $this->title
->getArticleID(),
79 'tb_title' => $tbtitle,
80 'tb_url' => $this->url
,
91 $tb = new TrackBack();