'FunnyDot', 'version' => '2.0', 'description' => 'Automated CAPTCHA', 'author' => 'Pierre Schmitz', 'url' => 'http://www.archlinux.de' ); if ($wgGroupPermissions['*']['edit']) { $wgHooks['EditPage::showEditForm:fields'][] = 'FunnyDot::addFunnyDotToEditPage'; $wgHooks['EditFilter'][] = 'FunnyDot::checkFunnyDotOnEditPage'; } if (empty($wgAuth)) { $wgHooks['UserLoginForm'][] = 'FunnyDot::addFunnyDotToUserLoginForm'; $wgHooks['AbortLogin'][] = 'FunnyDot::checkFunnyDotOnAbortLogin'; } if ($wgGroupPermissions['*']['createaccount'] && (empty($wgAuth) || $wgAuth->canCreateAccounts())) { $wgHooks['UserCreateForm'][] = 'FunnyDot::addFunnyDotToUserCreateForm'; $wgHooks['AbortNewAccount'][] = 'FunnyDot::checkFunnyDotOnAbortNewAccount'; } $wgSpecialPages['FunnyDotImage'] = 'SpecialFunnyDotImage'; class FunnyDot { private static function getFunnyDot() { global $wgFunnyDotHash, $wgScript; !isset($wgFunnyDotHash) && $wgFunnyDotHash = ''; $time = time(); $hash = substr(sha1($time.$wgFunnyDotHash), 0, 4); setCookie('FunnyDotTime', $time); return '
'; } private static function checkFunnyDot() { global $wgFunnyDotHash, $wgFunnyDotTimeout, $wgFunnyDotWait; # set some sane defaults # can be overridden in LocalSettings.php !isset($wgFunnyDotHash) && $wgFunnyDotHash = ''; !isset($wgFunnyDotTimeout) && $wgFunnyDotTimeout = 3600; !isset($wgFunnyDotWait) && $wgFunnyDotWait = 2; if (!empty($_COOKIE['FunnyDotTime']) && (!empty($_COOKIE['FunnyDotHash']) || !empty($_POST['FunnyDotHash']))) { $now = time(); $time = $_COOKIE['FunnyDotTime']; $hash = !empty($_POST['FunnyDotHash']) ? $_POST['FunnyDotHash'] : $_COOKIE['FunnyDotHash']; } else { return false; } if ($hash != substr(sha1($time.$wgFunnyDotHash), 0, 4)) { return false; } elseif ($now - $time > $wgFunnyDotTimeout) { return false; } elseif ($now - $time < $wgFunnyDotWait) { return false; } else { return true; } } public static function addFunnyDotToEditPage($editpage, $output) { global $wgUser; if (!$wgUser->isLoggedIn()) { $editpage->editFormTextAfterWarn .= self::getFunnyDot(); } return true; } public static function checkFunnyDotOnEditPage($editpage, $text, $section, $error) { global $wgUser; if (!$wgUser->isLoggedIn() && !self::checkFunnyDot()) { $error = '