X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=trackback.php;h=0e2036a92c25063842f47e4ad178c0a6bb0dee31;hb=bd49ce9d433030ebb61e60fb16773979cb8067bc;hp=90a22e4bd552822d8c5d2ff1f5e418dffd6e9d2f;hpb=c3497e2880ee73fd1edf7300156e3ef2e83e055b;p=lhc%2Fweb%2Fwiklou.git
diff --git a/trackback.php b/trackback.php
index 90a22e4bd5..0e2036a92c 100644
--- a/trackback.php
+++ b/trackback.php
@@ -1,64 +1,89 @@
-
-0
-
- ";
- exit;
+if ( isset( $_SERVER['MW_COMPILED'] ) ) {
+ require ( 'phase3/includes/WebStart.php' );
+} else {
+ require ( dirname( __FILE__ ) . '/includes/WebStart.php' );
}
-function XMLerror($err = "Invalid request.") {
- header("HTTP/1.0 400 Bad Request");
- header("Content-Type: application/xml; charset=utf-8");
- echo "
+class TrackBack {
+
+ private $r, $url, $title = null;
+
+ private function XMLsuccess() {
+ header( "Content-Type: application/xml; charset=utf-8" );
+ echo <<
-1
-Invalid request: $err
+ 0
-";
+XML;
exit;
-}
+ }
+
+ private function XMLerror( $err = "Invalid request." ) {
+ header( "HTTP/1.0 400 Bad Request" );
+ header( "Content-Type: application/xml; charset=utf-8" );
+ echo <<
+
+ 1
+ Invalid request: $err
+
+XML;
+ exit;
+ }
+
+ public function __construct() {
+ global $wgUseTrackbacks, $wgRequest;
+
+ if( !$wgUseTrackbacks )
+ $this->XMLerror( "Trackbacks are disabled" );
-if (!$wgUseTrackbacks)
- XMLerror("Trackbacks are disabled.");
+ $this->r = $wgRequest;
-if ( !isset($_POST['url'])
- || !isset($_REQUEST['article']))
- XMLerror("Required field not specified");
+ if( !$this->r->wasPosted() ) {
+ $this->XMLerror( "Must be posted" );
+ }
-$dbw = wfGetDB(DB_MASTER);
+ $this->url = $wgRequest->getText( 'url' );
+ $article = $wgRequest->getText( 'article' );
-$tbtitle = strval( @$_POST['title'] );
-$tbex = strval( @$_POST['excerpt'] );
-$tburl = strval( $_POST['url'] );
-$tbname = strval( @$_POST['blog_name'] );
-$tbarticle = strval( $_REQUEST['article'] );
+ if( !$this->url || !$article ) {
+ $this->XMLerror( "Required field not specified" );
+ }
-$title = Title::newFromText($tbarticle);
-if (!isset($title) || !$title->exists())
- XMLerror("Specified article does not exist.");
+ $this->title = Title::newFromText( $article );
+ if( !$this->title || !$this->title->exists() ) {
+ $this->XMLerror( "Specified article does not exist." );
+ }
+ }
-$dbw->insert('trackbacks', array(
- 'tb_page' => $title->getArticleID(),
- 'tb_title' => $tbtitle,
- 'tb_url' => $tburl,
- 'tb_ex' => $tbex,
- 'tb_name' => $tbname
-));
-$dbw->commit();
+ public function write() {
+ $dbw = wfGetDB( DB_MASTER );
-XMLsuccess();
+ $tbtitle = $this->r->getText( 'title' );
+ $tbex = $this->r->getText( 'excerpt' );
+ $tbname = $this->r->getText( 'blog_name' );
+
+ $dbw->insert('trackbacks', array(
+ 'tb_page' => $this->title->getArticleID(),
+ 'tb_title' => $tbtitle,
+ 'tb_url' => $this->url,
+ 'tb_ex' => $tbex,
+ 'tb_name' => $tbname
+ ));
+
+ $dbw->commit();
+
+ $this->XMLsuccess();
+ }
+}
-?>
+$tb = new TrackBack();
+$tb->write();