summaryrefslogtreecommitdiff
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
parent086ae52d12011746a75f5588e877347bc0457352 (diff)
FunnyDot-Verbesserungen von LL übernommen
-rw-r--r--extensions/FunnyDot.php64
-rw-r--r--skins/ArchLinux.php8
-rw-r--r--skins/archlinux/archlinux.css4
3 files changed, 53 insertions, 23 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;
}
diff --git a/skins/ArchLinux.php b/skins/ArchLinux.php
index c16c2b7d..dcc6d8d3 100644
--- a/skins/ArchLinux.php
+++ b/skins/ArchLinux.php
@@ -124,13 +124,7 @@ class ArchLinuxTemplate extends QuickTemplate {
</ul>
</div>
<div id="subnav_bar"></div>
-
- <?php if (!empty($_REQUEST['action']) && ($_REQUEST['action'] == 'edit' || $_REQUEST['action'] == 'submit') ) { ?>
- <div style="clear:both;background-image:url(FunnyDotImage.php);background-repeat:no-repeat;visibility:hidden;">&nbsp;</div>
- <?php } else { ?>
- <div style="clear:both;visibility:hidden;">&nbsp;</div>
- <?php }
- } ?>
+ <?php } ?>
<div id="globalWrapper">
<div id="column-content">
diff --git a/skins/archlinux/archlinux.css b/skins/archlinux/archlinux.css
index e34e8926..a1a11909 100644
--- a/skins/archlinux/archlinux.css
+++ b/skins/archlinux/archlinux.css
@@ -95,6 +95,10 @@ a:hover {
/* MediaWiki: */
+#globalWrapper {
+ padding-top: 13px;
+}
+
#content {
background-color: #F0F0F0;
border-right: 1px solid;