summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FunnyDotImage.php22
-rw-r--r--extensions/FunnyDot.php8
2 files changed, 24 insertions, 6 deletions
diff --git a/FunnyDotImage.php b/FunnyDotImage.php
index d89fdcf7..aa954134 100644
--- a/FunnyDotImage.php
+++ b/FunnyDotImage.php
@@ -1,17 +1,29 @@
<?php
-define( 'MEDIAWIKI', true );
-require ('LocalSettings.php');
+
+require ('includes/WebStart.php');
$time = time();
setCookie('AntiSpamTime', $time);
setCookie('AntiSpamHash', sha1($time.$wgAntiSpamHash));
-header("Cache-Control: no-cache, must-revalidate");
-header('Content-type: image/png');
$im = imagecreatetruecolor(1, 1);
+
+ob_start();
+
+header('HTTP/1.1 200 OK');
+header("Cache-Control: no-cache, must-revalidate");
+header('Content-Type: image/png');
+header('Content-Length: '.ob_get_length());
+
imagepng($im);
imagedestroy($im);
-exit();
+
+while (ob_get_level() > 0)
+ {
+ ob_end_flush();
+ }
+
+exit;
?> \ No newline at end of file
diff --git a/extensions/FunnyDot.php b/extensions/FunnyDot.php
index 81636bb4..93a66f08 100644
--- a/extensions/FunnyDot.php
+++ b/extensions/FunnyDot.php
@@ -6,6 +6,12 @@ global $wgHooks;
$wgHooks['ArticleSave'][] = 'checkAntiSpamHash';
+function hexVal($in)
+ {
+ $result = preg_replace('/[^0-9a-fA-F]/', '', $in);
+ return (empty($result) ? 0 : $result);
+ }
+
function checkAntiSpamHash()
{
global $wgAntiSpamHash, $wgAntiSpamTimeout, $wgAntiSpamWait;
@@ -15,7 +21,7 @@ function checkAntiSpamHash()
if (!empty($_COOKIE['AntiSpamTime']) && !empty($_COOKIE['AntiSpamHash']))
{
$time = intval($_COOKIE['AntiSpamTime']);
- $hash = $_COOKIE['AntiSpamHash'];
+ $hash = hexVal($_COOKIE['AntiSpamHash']);
if ($hash != sha1($time.$wgAntiSpamHash))
{