Account creation throttle
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 26 Jun 2004 04:00:03 +0000 (04:00 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 26 Jun 2004 04:00:03 +0000 (04:00 +0000)
includes/DefaultSettings.php
includes/SpecialUserlogin.php
languages/Language.php

index 6c244bf..202c4d0 100644 (file)
@@ -182,6 +182,7 @@ $wgProxyScriptPath = "$IP/proxy_check.php";
 $wgProxyMemcExpiry = 86400;
 $wgProxyKey = 'W1svekXc5u6lZllTZOwnzEk1nbs';
 $wgProxyList = array();  # big list of banned IP addresses, in the keys not the values
+$wgAccountCreationThrottle = 0; # Number of accounts each IP address may create, 0 to disable. Requires memcached
 
 # Client-side caching:
 $wgCachePages       = true; # Allow client-side caching of pages
index e68f66e..d98f6bc 100644 (file)
@@ -126,6 +126,19 @@ class LoginForm {
        {
                global $wgUser, $wgOut;
                global $wgMaxNameChars;
+               global $wgMemc, $wgAccountCreationThrottle, $wgDBname, $wgIP;
+
+               if ( $wgAccountCreationThrottle ) {
+                       $key = "$wgDBname:acctcreate:ip:$wgIP";
+                       $value = $wgMemc->incr( $key );
+                       if ( !$value ) {
+                               $wgMemc->set( $key, 0, 86400 );
+                       }
+                       if ( $value > $wgAccountCreationThrottle ) ) {
+                               $this->throttleHit();
+                               return;
+                       }
+               }
 
                if (!$wgUser->isAllowedToCreateAccount()) {
                        $this->userNotPrivilegedMessage();
@@ -468,5 +481,11 @@ class LoginForm {
                        return $this->successfulLogin( wfMsg( "loginsuccess", $wgUser->getName() ) );
                }
        }
+
+       /* private */ function throttleHit( $limit ) {
+               global $wgOut;
+
+               $wgOut->addWikiText( wfMsg( 'acct_creation_throttle_hit', $limit ) );
+       }
 }
 ?>
index dfff3d1..d88b9b5 100644 (file)
@@ -466,6 +466,7 @@ registered for \"$1\".
 Please log in again after you receive it.",
 'loginend'             => '&nbsp;',
 'mailerror' => "Error sending mail: $1",
+'acct_creation_throttle_hit' => 'Sorry, you have already created $1 accounts. You can\'t make any more.',
 
 # Edit page toolbar
 'bold_sample'=>'Bold text',