ToastFreeware
/
toast
/
cookiecaptcha.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
72064bd
)
Verify IP whitelisting on login and account creation as well.
author
Bryan Tong Minh
<btongminh@users.mediawiki.org>
Sat, 9 May 2009 14:00:13 +0000
(14:00 +0000)
committer
Bryan Tong Minh
<btongminh@users.mediawiki.org>
Sat, 9 May 2009 14:00:13 +0000
(14:00 +0000)
ConfirmEdit_body.php
patch
|
blob
|
history
diff --git
a/ConfirmEdit_body.php
b/ConfirmEdit_body.php
index e5b975fb6d7d46b45e7acd2bea30bbfd0c15cd33..57655c681023ea56f4d4290919666a621bee7a3b 100644
(file)
--- a/
ConfirmEdit_body.php
+++ b/
ConfirmEdit_body.php
@@
-213,6
+213,22
@@
class SimpleCaptcha {
return intval( $wgMemc->get( $this->badLoginKey() ) ) >= $wgCaptchaBadLoginAttempts;
}
return intval( $wgMemc->get( $this->badLoginKey() ) ) >= $wgCaptchaBadLoginAttempts;
}
+ /**
+ * Check if the IP is allowed to skip captchas
+ */
+ function isIPWhitelisted() {
+ global $wgCaptchaWhitelistIP;
+ if( !empty( $wgCaptchaWhitelistIP ) ) {
+ $ip = wfGetIp();
+ foreach ( $wgCaptchaWhitelistIP as $range ) {
+ if ( IP::isInRange( $ip, $range ) ) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
/**
* Internal cache key for badlogin checks.
* @return string
/**
* Internal cache key for badlogin checks.
* @return string
@@
-268,15
+284,8
@@
class SimpleCaptcha {
wfDebug( "ConfirmEdit: user group allows skipping captcha\n" );
return false;
}
wfDebug( "ConfirmEdit: user group allows skipping captcha\n" );
return false;
}
- global $wgCaptchaWhitelistIP;
- if( !empty( $wgCaptchaWhitelistIP ) ) {
- $ip = wfGetIp();
- foreach ( $wgCaptchaWhitelistIP as $range ) {
- if ( IP::isInRange( $ip, $range ) ) {
- return false;
- }
- }
- }
+ if( $this->isIPWhitelisted() )
+ return false;
global $wgEmailAuthentication, $ceAllowConfirmedEmail;
global $wgEmailAuthentication, $ceAllowConfirmedEmail;
@@
-523,6
+532,9
@@
class SimpleCaptcha {
wfDebug( "ConfirmEdit: user group allows skipping captcha on account creation\n" );
return true;
}
wfDebug( "ConfirmEdit: user group allows skipping captcha on account creation\n" );
return true;
}
+ if( $this->isIPWhitelisted() )
+ return true;
+
$this->trigger = "new account '" . $u->getName() . "'";
if( !$this->passCaptcha() ) {
$message = wfMsg( 'captcha-createaccount-fail' );
$this->trigger = "new account '" . $u->getName() . "'";
if( !$this->passCaptcha() ) {
$message = wfMsg( 'captcha-createaccount-fail' );
@@
-540,6
+552,9
@@
class SimpleCaptcha {
*/
function confirmUserLogin( $u, $pass, &$retval ) {
if( $this->isBadLoginTriggered() ) {
*/
function confirmUserLogin( $u, $pass, &$retval ) {
if( $this->isBadLoginTriggered() ) {
+ if( $this->isIPWhitelisted() )
+ return true;
+
$this->trigger = "post-badlogin login '" . $u->getName() . "'";
if( !$this->passCaptcha() ) {
$message = wfMsg( 'captcha-badlogin-fail' );
$this->trigger = "post-badlogin login '" . $u->getName() . "'";
if( !$this->passCaptcha() ) {
$message = wfMsg( 'captcha-badlogin-fail' );