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"?>
29 private function XMLerror( $err = "Invalid request." ) {
30 header( "HTTP/1.0 400 Bad Request" );
31 header( "Content-Type: application/xml; charset=utf-8" );
33 <?xml version="1.0" encoding="utf-8"?>
36 <message>Invalid request: $err</message>
42 public function __construct() {
43 global $wgUseTrackbacks, $wgRequest;
45 if( !$wgUseTrackbacks )
46 $this->XMLerror( "Trackbacks are disabled" );
48 $this->r
= $wgRequest;
50 if( !$this->r
->wasPosted() ) {
51 $this->XMLerror( "Must be posted" );
54 $this->url
= $wgRequest->getText( 'url' );
55 $article = $wgRequest->getText( 'article' );
57 if( !$this->url ||
!$article ) {
58 $this->XMLerror( "Required field not specified" );
61 $this->title
= Title
::newFromText( $article );
62 if( !$this->title ||
!$this->title
->exists() ) {
63 $this->XMLerror( "Specified article does not exist." );
67 public function write() {
68 $dbw = wfGetDB( DB_MASTER
);
70 $tbtitle = $this->r
->getText( 'title' );
71 $tbex = $this->r
->getText( 'excerpt' );
72 $tbname = $this->r
->getText( 'blog_name' );
74 $dbw->insert('trackbacks', array(
75 'tb_page' => $this->title
->getArticleID(),
76 'tb_title' => $tbtitle,
77 'tb_url' => $this->url
,
88 $tb = new TrackBack();