wiki.techinc.nl/trackback.php
Tim Starling ff1dc8a175 HipHop improvements:
* Added the ability to compile extensions. The build process is bootstrapped by running MediaWiki in interpreted mode. Extension setup file inclusions are slightly modified in a way that makes them register themselves for compilation. Then the same LocalSettings.php uses the compiled extension setup file when the compiled binary runs.
* Tested with Cite and ParserFunctions. The code which lets you have an extensions directory in a place other than $IP/../extensions is untested.
* Simplified WebStart.php slightly by using a custom $_SERVER variable to mark compiled mode. It will break if you don't use the supplied server.conf, but that will break a lot of things so don't do that.
* Fixed the core web entry points to include WebStart.php in compiled mode instead of interpreted.
* Made the build directory configurable. This is mostly so that I can grep the source tree without seeing loads of generated C++.
* In server.conf, added a rewrite rule allowing a /wiki/$1 article path.
* Removed server.conf log file location "/dev/stdout", breaks when you switch user
* Disable static content cache, breaks horribly when you set SourceRoot to a directory containing 7GB of files.
* Rewrote the run-server script in PHP, mostly to support the configurable build directory feature.
* Added an option to the run-server script to allow running in interpreted (hphpi) mode.
2011-05-30 13:49:09 +00:00

89 lines
1.9 KiB
PHP

<?php
/**
* Provide functions to handle article trackbacks.
* @file
* @ingroup SpecialPage
*/
if ( isset( $_SERVER['MW_COMPILED'] ) ) {
require ( 'phase3/includes/WebStart.php' );
} else {
require ( dirname( __FILE__ ) . '/includes/WebStart.php' );
}
class TrackBack {
private $r, $url, $title = null;
private function XMLsuccess() {
header( "Content-Type: application/xml; charset=utf-8" );
echo <<<XML
<?xml version="1.0" encoding="utf-8"?>
<response>
<error>0</error>
</response>
XML;
exit;
}
private function XMLerror( $err = "Invalid request." ) {
header( "HTTP/1.0 400 Bad Request" );
header( "Content-Type: application/xml; charset=utf-8" );
echo <<<XML
<?xml version="1.0" encoding="utf-8"?>
<response>
<error>1</error>
<message>Invalid request: $err</message>
</response>
XML;
exit;
}
public function __construct() {
global $wgUseTrackbacks, $wgRequest;
if( !$wgUseTrackbacks )
$this->XMLerror( "Trackbacks are disabled" );
$this->r = $wgRequest;
if( !$this->r->wasPosted() ) {
$this->XMLerror( "Must be posted" );
}
$this->url = $wgRequest->getText( 'url' );
$article = $wgRequest->getText( 'article' );
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();
}
}
$tb = new TrackBack();
$tb->write();