wiki.techinc.nl/trackback.php

65 lines
1.4 KiB
PHP
Raw Normal View History

2005-07-23 05:47:25 +00:00
<?php
/**
* Provide functions to handle article trackbacks.
* @addtogroup SpecialPage
2005-07-23 05:47:25 +00:00
*/
require_once( './includes/WebStart.php' );
Prevent some unnecessary lstat system calls, generated by include or require directives. This can be done either by: * Using explicit full paths, using the $IP global for the installation directory full path, and then working down the tree from there. * Using explicit full paths, using the "dirname(__FILE__)" directive to get a full directory path for the includer file. * Occasionally removing the line altogether, and then for some files the inclusion is handled by the autoloader. For example, if the "extensions/wikihiero/wh_main.php" file does an include or require on "wh_list.php", then PHP does the following: * tries to open "wiki/wh_list.php", and fails. * tries to open "wiki/includes/wh_list.php", and fails. * tries to open "wiki/languages/wh_list.php", and fails. * tries to open "wiki/extensions/wikihiero/wh_list.php", and succeeds. So in this example, the first 3 calls can be prevented if PHP is told where the file is. Testing Method: On a Linux box, run these commands to attach strace to all the apache2 processes, and log their system calls to a temporary file, then generate some activity, and then stop the strace: ----------------------------------- rm /tmp/strace-log.txt strace -tt -o /tmp/strace-log.txt -p `pidof apache2 | sed 's/ / -p /g'` & php maintenance/fuzz-tester.php --keep-passed-tests --include-binary --max-runtime=3 > /tmp/strace-tests.txt killall -9 strace grep "No such file or directory" /tmp/strace-log.txt | sort -u ----------------------------------- Any failed file stats will be marked with: "-1 ENOENT (No such file or directory)". Also: * Strict Standards: Undefined offset: 230 in includes/normal/UtfNormal.php on line 637 * Strict Standards: iconv() [<a href='function.iconv'>function.iconv</a>]: Detected an illegal character in input string in languages/Language.php on line 776 [Note: Partial only - despite adding "//IGNORE", it still seems to be possible with some messed- up binary input to cause PHP 5.1.2's iconv() function to squeal like a stuck pig]. * Update one $fname variable (method belongs to HistoryBlobStub class).
2007-02-09 05:36:56 +00:00
require_once( './includes/DatabaseFunctions.php' );
2005-07-23 05:47:25 +00:00
/**
*
*/
function XMLsuccess() {
header("Content-Type: application/xml; charset=utf-8");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
2005-07-23 05:47:25 +00:00
<response>
<error>0</error>
</response>
";
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\"?>
2005-07-23 05:47:25 +00:00
<response>
<error>1</error>
<message>Invalid request: $err</message>
</response>
";
exit;
}
if (!$wgUseTrackbacks)
XMLerror("Trackbacks are disabled.");
if ( !isset($_POST['url'])
|| !isset($_REQUEST['article']))
XMLerror("Required field not specified");
$dbw = wfGetDB(DB_MASTER);
2005-07-23 05:47:25 +00:00
$tbtitle = strval( @$_POST['title'] );
$tbex = strval( @$_POST['excerpt'] );
$tburl = strval( $_POST['url'] );
$tbname = strval( @$_POST['blog_name'] );
$tbarticle = strval( $_REQUEST['article'] );
2005-07-23 05:47:25 +00:00
$title = Title::newFromText($tbarticle);
if (!isset($title) || !$title->exists())
2005-07-23 05:47:25 +00:00
XMLerror("Specified article does not exist.");
$dbw->insert('trackbacks', array(
2005-07-23 06:30:26 +00:00
'tb_page' => $title->getArticleID(),
'tb_title' => $tbtitle,
'tb_url' => $tburl,
'tb_ex' => $tbex,
'tb_name' => $tbname
2005-07-23 05:47:25 +00:00
));
$dbw->commit();
2005-07-23 05:47:25 +00:00
XMLsuccess();
2006-03-07 13:32:27 +00:00
?>