dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make SpecialUpload members public again
[lhc/web/wiklou.git]
/
trackback.php
diff --git
a/trackback.php
b/trackback.php
index
3985030
..
b996ba6
100644
(file)
--- a/
trackback.php
+++ b/
trackback.php
@@
-1,65
+1,85
@@
<?php
/**
* Provide functions to handle article trackbacks.
<?php
/**
* Provide functions to handle article trackbacks.
- * @addtogroup SpecialPage
+ * @file
+ * @ingroup SpecialPage
*/
*/
+
require_once( './includes/WebStart.php' );
require_once( './includes/WebStart.php' );
-require_once( './includes/DatabaseFunctions.php' );
-/**
- *
- */
-function XMLsuccess() {
- header("Content-Type: application/xml; charset=utf-8");
- echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
+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>
<response>
-<error>0</error>
+
<error>0</error>
</response>
</response>
-
"
;
- exit;
-}
+
XML
;
+
exit;
+
}
-function XMLerror($err = "Invalid request.") {
- header("HTTP/1.0 400 Bad Request");
- header("Content-Type: application/xml; charset=utf-8");
- echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
+ 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>
<response>
-<error>1</error>
-<message>Invalid request: $err</message>
+
<error>1</error>
+
<message>Invalid request: $err</message>
</response>
</response>
-";
- exit;
-}
+XML;
+ exit;
+ }
+
+ public function __construct() {
+ global $wgUseTrackbacks, $wgRequest;
+
+ if( !$wgUseTrackbacks && false )
+ $this->XMLerror( "Trackbacks are disabled" );
+
+ $this->r = $wgRequest;
-if (!$wgUseTrackbacks)
- XMLerror("Trackbacks are disabled.");
+ if( !$this->r->wasPosted() ) {
+ $this->XMLerror( "Must be posted" );
+ }
-if ( !isset($_POST['url'])
- || !isset($_POST['blog_name'])
- || !isset($_REQUEST['article']))
- XMLerror("Required field not specified");
+ $this->url = $wgRequest->getText( 'url' );
+ $article = $wgRequest->getText( 'article' );
-$dbw = wfGetDB(DB_MASTER);
+ if( !$this->url || !$article ) {
+ $this->XMLerror( "Required field not specified" );
+ }
-
$tbtitle = $_POST['title']
;
-$tbex = $_POST['excerpt'];
-
$tburl = $_POST['url']
;
-$tbname = $_POST['blog_name'];
-$tbarticle = $_REQUEST['article'];
+
$this->title = Title::newFromText( $article )
;
+ if( !$this->title || !$this->title->exists() ) {
+
$this->XMLerror( "Specified article does not exist." )
;
+ }
+ }
-$title = Title::newFromText($tbarticle);
-if (!isset($title) || !$title->exists())
- XMLerror("Specified article does not exist.");
+ public function write() {
+ $dbw = wfGetDB( DB_MASTER );
-$dbw->insert('trackbacks', array(
- 'tb_page' => $title->getArticleID(),
- 'tb_title' => $tbtitle,
- 'tb_url' => $tburl,
- 'tb_ex' => $tbex,
- 'tb_name' => $tbname
-));
-$dbw->commit();
+ $tbtitle = $this->r->getText( 'title' );
+ $tbex = $this->r->getText( 'excerpt' );
+ $tbname = $this->r->getText( 'blog_name' );
-XMLsuccess();
+ $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();