2005-07-23 05:47:25 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Provide functions to handle article trackbacks.
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup SpecialPage
|
2005-07-23 05:47:25 +00:00
|
|
|
*/
|
2008-11-05 16:54:48 +00:00
|
|
|
|
2006-07-14 05:35:31 +00:00
|
|
|
require_once( './includes/WebStart.php' );
|
2005-07-23 05:47:25 +00:00
|
|
|
|
2010-08-10 18:50:34 +00:00
|
|
|
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"?>
|
2005-07-23 05:47:25 +00:00
|
|
|
<response>
|
2010-08-10 18:50:34 +00:00
|
|
|
<error>0</error>
|
2005-07-23 05:47:25 +00:00
|
|
|
</response>
|
2010-08-10 18:50:34 +00:00
|
|
|
XML;
|
|
|
|
|
exit;
|
|
|
|
|
}
|
2005-07-23 05:47:25 +00:00
|
|
|
|
2010-08-10 18:50:34 +00:00
|
|
|
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"?>
|
2005-07-23 05:47:25 +00:00
|
|
|
<response>
|
2010-08-10 18:50:34 +00:00
|
|
|
<error>1</error>
|
|
|
|
|
<message>Invalid request: $err</message>
|
2005-07-23 05:47:25 +00:00
|
|
|
</response>
|
2010-08-10 18:50:34 +00:00
|
|
|
XML;
|
|
|
|
|
exit;
|
|
|
|
|
}
|
2005-07-23 05:47:25 +00:00
|
|
|
|
2010-08-10 18:50:34 +00:00
|
|
|
public function __construct() {
|
|
|
|
|
global $wgUseTrackbacks, $wgRequest;
|
2005-07-23 05:47:25 +00:00
|
|
|
|
2010-12-07 20:13:47 +00:00
|
|
|
if( !$wgUseTrackbacks )
|
2010-08-10 18:50:34 +00:00
|
|
|
$this->XMLerror( "Trackbacks are disabled" );
|
2005-07-23 05:47:25 +00:00
|
|
|
|
2010-08-10 18:50:34 +00:00
|
|
|
$this->r = $wgRequest;
|
2005-07-23 05:47:25 +00:00
|
|
|
|
2010-08-10 18:50:34 +00:00
|
|
|
if( !$this->r->wasPosted() ) {
|
|
|
|
|
$this->XMLerror( "Must be posted" );
|
|
|
|
|
}
|
2005-07-23 05:47:25 +00:00
|
|
|
|
2010-08-10 18:50:34 +00:00
|
|
|
$this->url = $wgRequest->getText( 'url' );
|
|
|
|
|
$article = $wgRequest->getText( 'article' );
|
2005-07-23 05:47:25 +00:00
|
|
|
|
2010-08-10 18:50:34 +00:00
|
|
|
if( !$this->url || !$article ) {
|
|
|
|
|
$this->XMLerror( "Required field not specified" );
|
|
|
|
|
}
|
2008-11-05 16:54:48 +00:00
|
|
|
|
2010-08-10 18:50:34 +00:00
|
|
|
$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();
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-07-23 05:47:25 +00:00
|
|
|
|
2010-08-10 18:50:34 +00:00
|
|
|
$tb = new TrackBack();
|
|
|
|
|
$tb->write();
|