reCAPTCHA - Version 1.6

Version Description

  • Support for bypassing the captcha for specific IP addresses when behind a proxy. Props to Daniel Mann
Download this release

Release Info

Developer ash.matadeen
Plugin Icon wp plugin reCAPTCHA
Version 1.6
Comparing to
See all releases

Code changes from version 1.5 to 1.6

Files changed (2) hide show
  1. no-captcha.php +10 -2
  2. readme.txt +4 -1
no-captcha.php CHANGED
@@ -7,7 +7,7 @@
7
  * @package login-form-recaptcha
8
  * Author: Ash Matadeen
9
  * Author URI: http://ashmatadeen.com
10
- * Version: 1.5
11
  */
12
 
13
  add_action( 'admin_menu', 'wr_no_captcha_menu' );
@@ -63,7 +63,7 @@ function wr_no_captcha_options_page() {
63
  submit_button();
64
  ?>
65
  </form>
66
-
67
  <form method="post" action="options.php">
68
  <?php
69
  settings_fields( 'exlude_ips_section' );
@@ -141,7 +141,9 @@ function wr_no_captcha_display_options() {
141
 
142
  add_settings_section( 'exlude_ips_section', 'Exclude IP addresses', 'wr_no_captcha_display_recaptcha_exlude_ips_content', 'recaptcha-exlude_ips-options' );
143
  add_settings_field( 'wr_no_captcha_exlude_ips', 'Exclude IP addresses', 'wr_no_captcha_exlude_ips_input', 'recaptcha-exlude_ips-options', 'exlude_ips_section' );
 
144
  register_setting( 'exlude_ips_section', 'wr_no_captcha_exlude_ips' );
 
145
  }
146
 
147
  function wr_no_captcha_display_recaptcha_error_message_content() {
@@ -172,6 +174,10 @@ function wr_no_captcha_secret_key_input() {
172
  echo '<input type="text" name="wr_no_captcha_secret_key" id="captcha_secret_key" value="' . get_option( 'wr_no_captcha_secret_key' ) . '" />';
173
  }
174
 
 
 
 
 
175
  function wr_no_captcha_login_form_script() {
176
  if ( ! wr_no_captcha_is_ip_excluded() ) {
177
  wp_register_script( 'no_captcha_login', 'https://www.google.com/recaptcha/api.js' );
@@ -238,6 +244,8 @@ function wr_no_captcha_get_client_ip() {
238
  $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
239
  } elseif ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
240
  $ipaddress = $_SERVER['REMOTE_ADDR'];
 
 
241
  } else {
242
  $ipaddress = 'UNKNOWN';
243
  }
7
  * @package login-form-recaptcha
8
  * Author: Ash Matadeen
9
  * Author URI: http://ashmatadeen.com
10
+ * Version: 1.6
11
  */
12
 
13
  add_action( 'admin_menu', 'wr_no_captcha_menu' );
63
  submit_button();
64
  ?>
65
  </form>
66
+
67
  <form method="post" action="options.php">
68
  <?php
69
  settings_fields( 'exlude_ips_section' );
141
 
142
  add_settings_section( 'exlude_ips_section', 'Exclude IP addresses', 'wr_no_captcha_display_recaptcha_exlude_ips_content', 'recaptcha-exlude_ips-options' );
143
  add_settings_field( 'wr_no_captcha_exlude_ips', 'Exclude IP addresses', 'wr_no_captcha_exlude_ips_input', 'recaptcha-exlude_ips-options', 'exlude_ips_section' );
144
+ add_settings_field( 'wr_no_captcha_exlude_ips_forwarded_for', 'Website is behind a proxy', 'wr_no_captcha_exlude_ips_forwarded_for_input', 'recaptcha-exlude_ips-options', 'exlude_ips_section' );
145
  register_setting( 'exlude_ips_section', 'wr_no_captcha_exlude_ips' );
146
+ register_setting( 'exlude_ips_section', 'wr_no_captcha_exlude_ips_forwarded_for' );
147
  }
148
 
149
  function wr_no_captcha_display_recaptcha_error_message_content() {
174
  echo '<input type="text" name="wr_no_captcha_secret_key" id="captcha_secret_key" value="' . get_option( 'wr_no_captcha_secret_key' ) . '" />';
175
  }
176
 
177
+ function wr_no_captcha_exlude_ips_forwarded_for_input() {
178
+ echo '<input type="checkbox" id="wr_no_captcha_exlude_ips_forwarded_for" name="wr_no_captcha_exlude_ips_forwarded_for" value="1"' . checked( 1, get_option( 'wr_no_captcha_exlude_ips_forwarded_for' ), false ) . '/>';
179
+ }
180
+
181
  function wr_no_captcha_login_form_script() {
182
  if ( ! wr_no_captcha_is_ip_excluded() ) {
183
  wp_register_script( 'no_captcha_login', 'https://www.google.com/recaptcha/api.js' );
244
  $ipaddress = $_SERVER['HTTP_CLIENT_IP'];
245
  } elseif ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
246
  $ipaddress = $_SERVER['REMOTE_ADDR'];
247
+ } elseif ( get_option( 'wr_no_captcha_exlude_ips_forwarded_for' ) === '1' && isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
248
+ $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
249
  } else {
250
  $ipaddress = 'UNKNOWN';
251
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: ash.matadeen
3
  Donate link: http://ashmatadeen.com/donate
4
  Tags: security, bots, recaptcha, nocaptcha, google, login
5
  Requires at least: 4.2.2
6
- Tested up to: 4.7.4
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -31,6 +31,9 @@ This plugin prevents brute force logins on your WordPress website by adding Goog
31
 
32
  == Changelog ==
33
 
 
 
 
34
  = 1.5 =
35
  * Support for bypassing the captcha for specific IP addresses. Props to [Daniel Mann](https://github.com/dnlm)
36
 
3
  Donate link: http://ashmatadeen.com/donate
4
  Tags: security, bots, recaptcha, nocaptcha, google, login
5
  Requires at least: 4.2.2
6
+ Tested up to: 4.8
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
31
 
32
  == Changelog ==
33
 
34
+ = 1.6 =
35
+ * Support for bypassing the captcha for specific IP addresses when behind a proxy. Props to [Daniel Mann](https://github.com/dnlm)
36
+
37
  = 1.5 =
38
  * Support for bypassing the captcha for specific IP addresses. Props to [Daniel Mann](https://github.com/dnlm)
39