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