From: Tim Starling Date: Sat, 26 Jun 2004 04:00:03 +0000 (+0000) Subject: Account creation throttle X-Git-Tag: 1.5.0alpha1~2770 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=1211a3bb39381390c921d89ae849581d77571142;p=lhc%2Fweb%2Fwiklou.git Account creation throttle --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 6c244bf318..202c4d0486 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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 diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index e68f66e2e0..d98f6bc111 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -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 ) ); + } } ?> diff --git a/languages/Language.php b/languages/Language.php index dfff3d190c..d88b9b5aca 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -466,6 +466,7 @@ registered for \"$1\". Please log in again after you receive it.", 'loginend' => ' ', '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',