Extend lockout time; new activation method
-
Here’s a recommend diff … I wanted the ability to extend the lockout period for someone who repeatedly tries to log in, even while they are locked out. In addition, I changed the activation to use register_activiation_hook() which seems a bit cleaner.
Here are the proposed changes:
182,188d181 < // If this IP is already locked-down, then just extend the time of the lockdown! < $lockID = isCurrentlyLockedDown(); < if($lockID != "") { < $results = $wpdb->query("UPDATE $table_name SET release_date = date_add(now(), INTERVAL " . < $loginlockdownOptions['lockout_length'] . " MINUTE) " . < "WHERE lockdown_ID = " . $wpdb->escape($lockID) . ""); < } else { 196d188 < } 214,223d205 < function isCurrentlyLockedDown() { < global $wpdb; < $table_name = $wpdb->prefix . "lockdowns"; < $ip = $_SERVER['REMOTE_ADDR']; < $lockID = $wpdb->get_var("SELECT lockdown_ID FROM $table_name " . < "WHERE release_date > now() AND " . < "lockdown_IP = '" . $wpdb->escape($ip) . "'"); < return $lockID; < } < 393c375,376 < register_activation_hook( __FILE__, 'loginLockdown_install' ); --- > $activatestr = str_replace(WP_PLUGIN_DIR . "/", "activate_", __FILE__); > add_action($activatestr, 'loginLockdown_install'); 443,447c426,429 < // Commented so we can extend the lockout period if they are already locked out (now handled in lockDown()) < // if ( "" != isLockedDown() ) { < // return new WP_Error('incorrect_password', "<strong>ERROR</strong>: We're sorry, but this IP range has been blocked due to too many recent " . < // "failed login attempts.<br /><br />Please try again later."); < // } --- > if ( "" != isLockedDown() ) { > return new WP_Error('incorrect_password', "<strong>ERROR</strong>: We're sorry, but this IP range has been blocked due to too many recent " . > "failed login attempts.<br /><br />Please try again later."); > }
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Extend lockout time; new activation method’ is closed to new replies.