summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2008-03-21 15:14:41 +0100
committerPierre Schmitz <pierre@archlinux.de>2008-03-21 15:14:41 +0100
commitf357e68495b8624d9cfe383b55e681a0c35cc18f (patch)
tree0319332f3c4e1d6b7615d02698e32fca243eaf05 /extensions
parent086ae52d12011746a75f5588e877347bc0457352 (diff)
FunnyDot-Verbesserungen von LL übernommen
Diffstat (limited to 'extensions')
-rw-r--r--extensions/FunnyDot.php64
1 files changed, 48 insertions, 16 deletions
diff --git a/extensions/FunnyDot.php b/extensions/FunnyDot.php
index df81129e..db62b148 100644
--- a/extensions/FunnyDot.php
+++ b/extensions/FunnyDot.php
@@ -1,6 +1,7 @@
<?php
-$wgHooks['ArticleSave'][] = 'FunnyDot::checkAntiSpamHash';
+$wgHooks['EditPage::showEditForm:fields'][] = 'FunnyDot::addAntiSpamCheck';
+$wgHooks['EditFilter'][] = 'FunnyDot::checkAntiSpamHash';
$wgExtensionCredits['other'][] = array(
'name' => 'FunnyDot',
@@ -11,34 +12,65 @@ $wgExtensionCredits['other'][] = array(
class FunnyDot {
-public static function checkAntiSpamHash()
+public static function addAntiSpamCheck($editpage, $outputpage)
{
- global $wgAntiSpamHash, $wgAntiSpamTimeout, $wgAntiSpamWait;
+ global $wgAntiSpamHash, $wgUser;
- $now = time();
-
- if (!empty($_COOKIE['AntiSpamTime']) && !empty($_COOKIE['AntiSpamHash']))
+ if (!$wgUser->isLoggedIn())
{
- $time = intval($_COOKIE['AntiSpamTime']);
+ $outputpage->addHTML('<div style="background-image:url(FunnyDotImage.php);background-repeat:no-repeat;visibility:hidden;width:1px;height:1px;">&nbsp;</div>');
+
+ $time = time();
+ $hash = sha1($time.$wgAntiSpamHash);
+ setCookie('AlternateAntiSpamTime', $time);
+ setCookie('AlternateAntiSpamHashTail', substr($hash, 4));
+
+ $outputpage->addHTML('<div style="display:none;"><label for="AlternateAntiSpamHashHeadField">Sicherheitscode bestätigen: <strong>'.substr($hash, 0, 4).'</strong></label>&nbsp;<input id="AlternateAntiSpamHashHeadField" type="text" name="AlternateAntiSpamHashHead" size="4" value="" /></div>');
+ }
+
+ return true;
+ }
- if ($_COOKIE['AntiSpamHash'] != sha1($time.$wgAntiSpamHash))
+public static function checkAntiSpamHash($editpage, $text, $section, $error)
+ {
+ global $wgAntiSpamHash, $wgAntiSpamTimeout, $wgAntiSpamWait, $wgUser;
+
+ if (!$wgUser->isLoggedIn())
+ {
+ if (!empty($_COOKIE['AntiSpamTime']) && !empty($_COOKIE['AntiSpamHash']))
{
- return false;
+ $time = $_COOKIE['AntiSpamTime'];
+ $hash = $_COOKIE['AntiSpamHash'];
}
+ elseif (!empty($_COOKIE['AlternateAntiSpamTime']) && !empty($_COOKIE['AlternateAntiSpamHashTail']) && !empty($_POST['AlternateAntiSpamHashHead']))
+ {
+ $time = $_COOKIE['AlternateAntiSpamTime'];
+ $hash = $_POST['AlternateAntiSpamHashHead'].$_COOKIE['AlternateAntiSpamHashTail'];
+ }
+ else
+ {
+ sleep($wgAntiSpamWait);
+ $error = '<div class="mw-warning error">Ungültige Formulardaten empfangen. Stelle sicher, daß Cookies für diese Domain angenommen werden.</div>';
+ return true;
+ }
+
+ $now = time();
- if ($now - $time > $wgAntiSpamTimeout)
+ if ($hash != sha1($time.$wgAntiSpamHash))
{
- return false;
+ sleep($wgAntiSpamWait);
+ $error = '<div class="mw-warning error">Fehlerhafte Formulardaten empfangen. Überprüfe den Sicherheitscode!</div>';
+ }
+ elseif ($now - $time > $wgAntiSpamTimeout)
+ {
+ $error = '<div class="mw-warning error">Deine Zeit ist abgelaufen. Schicke das Formular bitte erneut ab, und zwar innherlab der nächsten '.$wgAntiSpamTimeout.' Sekunden.</div>';
}
elseif ($now - $time < $wgAntiSpamWait)
{
- return false;
+ sleep($wgAntiSpamWait);
+ $error = '<div class="mw-warning error">Du warst zu schnell. Schicke das Formular bitte erneut ab. Laße Dir diesmal mindestens '.$wgAntiSpamWait.' Sekunden Zeit.</div>';
}
}
- else
- {
- return false;
- }
return true;
}