WP-Ban - Version 1.65

Version Description

N/A

Download this release

Release Info

Developer GamerZ
Plugin Icon WP-Ban
Version 1.65
Comparing to
See all releases

Code changes from version 1.64 to 1.65

Files changed (4) hide show
  1. ban-options.php +74 -159
  2. readme.txt +7 -3
  3. uninstall.php +52 -0
  4. wp-ban.php +17 -12
ban-options.php CHANGED
@@ -4,14 +4,10 @@ if(!current_user_can('manage_options')) {
4
  die('Access Denied');
5
  }
6
 
7
-
8
  ### Variables
9
  $base_name = plugin_basename('wp-ban/ban-options.php');
10
  $base_page = 'admin.php?page='.$base_name;
11
  $admin_login = trim($current_user->user_login);
12
- $mode = (isset($_GET['mode']) ? trim($_GET['mode']) : '');
13
- $ban_settings = array('banned_ips', 'banned_hosts', 'banned_stats', 'banned_message', 'banned_referers', 'banned_exclude_ips', 'banned_ips_range', 'banned_user_agents');
14
-
15
 
16
  ### Form Processing
17
  // Update Options
@@ -20,7 +16,7 @@ if(!empty($_POST['Submit'])) {
20
  $text = '';
21
 
22
  $banned_options = array();
23
- $banned_options['reverse_proxy'] = intval( $_POST['banned_option_reverse_proxy'] );
24
 
25
  $banned_ips_post = explode("\n", trim($_POST['banned_ips']));
26
  $banned_ips_range_post = explode("\n", trim($_POST['banned_ips_range']));
@@ -34,22 +30,24 @@ if(!empty($_POST['Submit'])) {
34
  $banned_ips = array();
35
  foreach($banned_ips_post as $banned_ip) {
36
  if($admin_login == 'admin' && ($banned_ip == ban_get_ip() || is_admin_ip($banned_ip))) {
37
- $text .= '<font color="blue">'.sprintf(__('This IP \'%s\' Belongs To The Admin And Will Not Be Added To Ban List', 'wp-ban'),$banned_ip).'</font><br />';
38
  } else {
39
  $banned_ips[] = trim($banned_ip);
40
  }
41
  }
42
  }
43
- if(!empty($banned_ips_range_post)) {
44
  $banned_ips_range = array();
45
- foreach($banned_ips_range_post as $banned_ip_range) {
46
- $range = explode('-', $banned_ip_range);
47
- $range_start = trim($range[0]);
48
- $range_end = trim($range[1]);
49
- if($admin_login == 'admin' && (check_ip_within_range(ban_get_ip(), $range_start, $range_end))) {
50
- $text .= '<font color="blue">'.sprintf(__('The Admin\'s IP \'%s\' Fall Within This Range (%s - %s) And Will Not Be Added To Ban List', 'wp-ban'), ban_get_ip(), $range_start, $range_end).'</font><br />';
51
- } else {
52
- $banned_ips_range[] = trim($banned_ip_range);
 
 
53
  }
54
  }
55
  }
@@ -57,7 +55,7 @@ if(!empty($_POST['Submit'])) {
57
  $banned_hosts = array();
58
  foreach($banned_hosts_post as $banned_host) {
59
  if($admin_login == 'admin' && ($banned_host == @gethostbyaddr(ban_get_ip()) || is_admin_hostname($banned_host))) {
60
- $text .= '<font color="blue">'.sprintf(__('This Hostname \'%s\' Belongs To The Admin And Will Not Be Added To Ban List', 'wp-ban'), $banned_host).'</font><br />';
61
  } else {
62
  $banned_hosts[] = trim($banned_host);
63
  }
@@ -67,7 +65,7 @@ if(!empty($_POST['Submit'])) {
67
  $banned_referers = array();
68
  foreach($banned_referers_post as $banned_referer) {
69
  if(is_admin_referer($banned_referer)) {
70
- $text .= '<font color="blue">'.sprintf(__('This Referer \'%s\' Belongs To This Site And Will Not Be Added To Ban List', 'wp-ban'), $banned_referer).'</font><br />';
71
  } else {
72
  $banned_referers[] = trim($banned_referer);
73
  }
@@ -77,7 +75,7 @@ if(!empty($_POST['Submit'])) {
77
  $banned_user_agents = array();
78
  foreach($banned_user_agents_post as $banned_user_agent) {
79
  if(is_admin_user_agent($banned_user_agent)) {
80
- $text .= '<font color="blue">'.sprintf(__('This User Agent \'%s\' Is Used By The Current Admin And Will Not Be Added To Ban List', 'wp-ban'), $banned_user_agent).'</font><br />';
81
  } else {
82
  $banned_user_agents[] = trim($banned_user_agent);
83
  }
@@ -110,12 +108,12 @@ if(!empty($_POST['Submit'])) {
110
  $i=0;
111
  foreach($update_ban_queries as $update_ban_query) {
112
  if($update_ban_query) {
113
- $text .= '<font color="green">'.$update_ban_text[$i].' '.__('Updated', 'wp-ban').'</font><br />';
114
  }
115
  $i++;
116
  }
117
  if(empty($text)) {
118
- $text = '<font color="red">'.__('No Ban Option Updated', 'wp-ban').'</font>';
119
  }
120
  }
121
  if(!empty($_POST['do'])) {
@@ -127,7 +125,7 @@ if(!empty($_POST['do'])) {
127
  if($_POST['reset_ban_stats'] == 'yes') {
128
  $banned_stats = array('users' => array(), 'count' => 0);
129
  update_option('banned_stats', $banned_stats);
130
- $text = '<font color="green">'.__('All IP Ban Stats And Total Ban Stat Reseted', 'wp-ban').'</font>';
131
  } else {
132
  $banned_stats = get_option('banned_stats');
133
  $delete_ips = (array) $_POST['delete_ips'];
@@ -135,101 +133,62 @@ if(!empty($_POST['do'])) {
135
  unset($banned_stats['users'][$delete_ip]);
136
  }
137
  update_option('banned_stats', $banned_stats);
138
- $text = '<font color="green">'.__('Selected IP Ban Stats Reseted', 'wp-ban').'</font>';
139
- }
140
- break;
141
- // Uninstall WP-Ban
142
- case __('UNINSTALL WP-Ban', 'wp-ban') :
143
- check_admin_referer('wp-ban_uninstall');
144
- if(trim($_POST['uninstall_ban_yes']) == 'yes') {
145
- echo '<div id="message" class="updated fade">';
146
- echo '<p>';
147
- foreach($ban_settings as $setting) {
148
- $delete_setting = delete_option($setting);
149
- if($delete_setting) {
150
- echo '<font color="green">';
151
- printf(__('Setting Key \'%s\' has been deleted.', 'wp-ban'), "<strong><em>{$setting}</em></strong>");
152
- echo '</font><br />';
153
- } else {
154
- echo '<font color="red">';
155
- printf(__('Error deleting Setting Key \'%s\'.', 'wp-ban'), "<strong><em>{$setting}</em></strong>");
156
- echo '</font><br />';
157
- }
158
- }
159
- echo '</p>';
160
- echo '</div>';
161
- $mode = 'end-UNINSTALL';
162
  }
163
  break;
164
  }
165
  }
166
 
167
-
168
- ### Determines Which Mode It Is
169
- switch($mode) {
170
- // Deactivating WP-Ban
171
- case 'end-UNINSTALL':
172
- $deactivate_url = 'plugins.php?action=deactivate&amp;plugin=wp-ban/wp-ban.php';
173
- if(function_exists('wp_nonce_url')) {
174
- $deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_wp-ban/wp-ban.php');
175
- }
176
- echo '<div class="wrap">';
177
- echo '<h2>'.__('Uninstall WP-Ban', 'wp-ban').'</h2>';
178
- echo '<p><strong>'.sprintf(__('<a href="%s">Click Here</a> To Finish The Uninstallation And WP-Ban Will Be Deactivated Automatically.', 'wp-ban'), $deactivate_url).'</strong></p>';
179
- echo '</div>';
180
- break;
181
- // Main Page
182
- default:
183
- $banned_ips = get_option('banned_ips');
184
- $banned_ips_range = get_option('banned_ips_range');
185
- $banned_hosts = get_option('banned_hosts');
186
- $banned_referers = get_option('banned_referers');
187
- $banned_user_agents = get_option('banned_user_agents');
188
- $banned_exclude_ips = get_option('banned_exclude_ips');
189
- $banned_ips_display = '';
190
- $banned_ips_range_display = '';
191
- $banned_hosts_display = '';
192
- $banned_referers_display = '';
193
- $banned_user_agents_display = '';
194
- $banned_exclude_ips_display = '';
195
- if(!empty($banned_ips)) {
196
- foreach($banned_ips as $banned_ip) {
197
- $banned_ips_display .= $banned_ip."\n";
198
- }
199
- }
200
- if(!empty($banned_ips_range)) {
201
- foreach($banned_ips_range as $banned_ip_range) {
202
- $banned_ips_range_display .= $banned_ip_range."\n";
203
- }
204
- }
205
- if(!empty($banned_hosts)) {
206
- foreach($banned_hosts as $banned_host) {
207
- $banned_hosts_display .= $banned_host."\n";
208
- }
209
- }
210
- if(!empty($banned_referers)) {
211
- foreach($banned_referers as $banned_referer) {
212
- $banned_referers_display .= $banned_referer."\n";
213
- }
214
- }
215
- if(!empty($banned_user_agents)) {
216
- foreach($banned_user_agents as $banned_user_agent) {
217
- $banned_user_agents_display .= $banned_user_agent."\n";
218
- }
219
- }
220
- if(!empty($banned_exclude_ips)) {
221
- foreach($banned_exclude_ips as $banned_exclude_ip) {
222
- $banned_exclude_ips_display .= $banned_exclude_ip."\n";
223
- }
224
- }
225
- $banned_ips_display = trim($banned_ips_display);
226
- $banned_ips_range_display = trim($banned_ips_range_display);
227
- $banned_hosts_display = trim($banned_hosts_display);
228
- $banned_referers_display = trim($banned_referers_display);
229
- $banned_user_agents_display = trim($banned_user_agents_display);
230
- $banned_exclude_ips_display = trim($banned_exclude_ips_display);
231
- $banned_stats = get_option( 'banned_stats' );
232
- $banned_options = get_option( 'banned_options' );
233
  ?>
234
  <script type="text/javascript">
235
  /* <![CDATA[*/
@@ -323,15 +282,15 @@ switch($mode) {
323
  <tr>
324
  <td width="40%" valign="top">
325
  <strong><?php _e('Reverse Proxy Check', 'wp-ban'); ?>:</strong><br />
326
- <?php _e( 'This will assume that incoming requests include the user\'s IP address in the HTTP_X_FORWARDED_FOR (and the request IP will be from your proxy).' ); ?>
327
  </td>
328
  <td width="60%">
329
  <label>
330
  <input type="checkbox" name="banned_option_reverse_proxy" value="1"<?php echo ( intval( $banned_options['reverse_proxy'] ) === 1 ) ? ' checked="checked"' : ''; ?> />
331
- <?php _e( 'I am using a reverse proxy.' ); ?>
332
  </label>
333
  <p>
334
- <?php _e( 'If you\'re not sure, leave this uncheck. Ticking this box when you don\'t have a reverse proxy will make it easy to bypass the IP ban.' ); ?>
335
  </p>
336
  </td>
337
  </tr>
@@ -493,48 +452,4 @@ switch($mode) {
493
  <p style="text-align: center;"><input type="submit" name="do" value="<?php _e('Reset Ban Stats', 'wp-ban'); ?>" class="button" onclick="return confirm('<?php _e('You Are About To Reset Ban Stats.', 'wp-ban'); ?>\n\n<?php _e('This Action Is Not Reversible. Are you sure?', 'wp-ban'); ?>')" /></p>
494
  </div>
495
  </form>
496
- <p>&nbsp;</p>
497
-
498
- <!-- Uninstall WP-Ban -->
499
- <form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
500
- <?php wp_nonce_field('wp-ban_uninstall'); ?>
501
- <div class="wrap">
502
- <h3><?php _e('Uninstall WP-Ban', 'wp-ban'); ?></h3>
503
- <p>
504
- <?php _e('Deactivating WP-Ban plugin does not remove any data that may have been created, such as the ban options. To completely remove this plugin, you can uninstall it here.', 'wp-ban'); ?>
505
- </p>
506
- <p style="color: red">
507
- <strong><?php _e('WARNING:', 'wp-ban'); ?></strong><br />
508
- <?php _e('Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to back up all the data first.', 'wp-ban'); ?>
509
- </p>
510
- <p style="color: red">
511
- <strong><?php _e('The following WordPress Options will be DELETED:', 'wp-ban'); ?></strong><br />
512
- </p>
513
- <table class="widefat">
514
- <thead>
515
- <tr>
516
- <th><?php _e('WordPress Options', 'wp-ban'); ?></th>
517
- </tr>
518
- </thead>
519
- <tr>
520
- <td valign="top">
521
- <ol>
522
- <?php
523
- foreach($ban_settings as $settings) {
524
- echo '<li>'.$settings.'</li>'."\n";
525
- }
526
- ?>
527
- </ol>
528
- </td>
529
- </tr>
530
- </table>
531
- <p>&nbsp;</p>
532
- <p style="text-align: center;">
533
- <input type="checkbox" name="uninstall_ban_yes" value="yes" />&nbsp;<?php _e('Yes', 'wp-ban'); ?><br /><br />
534
- <input type="submit" name="do" value="<?php _e('UNINSTALL WP-Ban', 'wp-ban'); ?>" class="button" onclick="return confirm('<?php _e('You Are About To Uninstall WP-Ban From WordPress.\nThis Action Is Not Reversible.\n\n Choose [Cancel] To Stop, [OK] To Uninstall.', 'wp-ban'); ?>')" />
535
- </p>
536
- </div>
537
- </form>
538
- <?php
539
- } // End switch($mode)
540
- ?>
4
  die('Access Denied');
5
  }
6
 
 
7
  ### Variables
8
  $base_name = plugin_basename('wp-ban/ban-options.php');
9
  $base_page = 'admin.php?page='.$base_name;
10
  $admin_login = trim($current_user->user_login);
 
 
 
11
 
12
  ### Form Processing
13
  // Update Options
16
  $text = '';
17
 
18
  $banned_options = array();
19
+ $banned_options['reverse_proxy'] = isset( $_POST['banned_option_reverse_proxy'] ) ? intval( $_POST['banned_option_reverse_proxy'] ) : 0;
20
 
21
  $banned_ips_post = explode("\n", trim($_POST['banned_ips']));
22
  $banned_ips_range_post = explode("\n", trim($_POST['banned_ips_range']));
30
  $banned_ips = array();
31
  foreach($banned_ips_post as $banned_ip) {
32
  if($admin_login == 'admin' && ($banned_ip == ban_get_ip() || is_admin_ip($banned_ip))) {
33
+ $text .= '<p style="color: blue;">'.sprintf(__('This IP \'%s\' Belongs To The Admin And Will Not Be Added To Ban List', 'wp-ban'),$banned_ip).'</p>';
34
  } else {
35
  $banned_ips[] = trim($banned_ip);
36
  }
37
  }
38
  }
39
+ if( ! empty( $banned_ips_range_post ) ) {
40
  $banned_ips_range = array();
41
+ foreach( $banned_ips_range_post as $banned_ip_range ) {
42
+ $range = explode( '-', $banned_ip_range );
43
+ if( sizeof( $range ) === 2 ) {
44
+ $range_start = trim( $range[0] );
45
+ $range_end = trim( $range[1] );
46
+ if( $admin_login === 'admin' && ( check_ip_within_range( ban_get_ip(), $range_start, $range_end ) ) ) {
47
+ $text .= '<p style="color: blue;">'.sprintf( __( 'The Admin\'s IP \'%s\' Fall Within This Range (%s - %s) And Will Not Be Added To Ban List', 'wp-ban' ), ban_get_ip(), $range_start, $range_end ).'</p>';
48
+ } else {
49
+ $banned_ips_range[] = trim( $banned_ip_range );
50
+ }
51
  }
52
  }
53
  }
55
  $banned_hosts = array();
56
  foreach($banned_hosts_post as $banned_host) {
57
  if($admin_login == 'admin' && ($banned_host == @gethostbyaddr(ban_get_ip()) || is_admin_hostname($banned_host))) {
58
+ $text .= '<p style="color: blue;">'.sprintf(__('This Hostname \'%s\' Belongs To The Admin And Will Not Be Added To Ban List', 'wp-ban'), $banned_host).'</p>';
59
  } else {
60
  $banned_hosts[] = trim($banned_host);
61
  }
65
  $banned_referers = array();
66
  foreach($banned_referers_post as $banned_referer) {
67
  if(is_admin_referer($banned_referer)) {
68
+ $text .= '<p style="color: blue;">'.sprintf(__('This Referer \'%s\' Belongs To This Site And Will Not Be Added To Ban List', 'wp-ban'), $banned_referer).'</p>';
69
  } else {
70
  $banned_referers[] = trim($banned_referer);
71
  }
75
  $banned_user_agents = array();
76
  foreach($banned_user_agents_post as $banned_user_agent) {
77
  if(is_admin_user_agent($banned_user_agent)) {
78
+ $text .= '<p style="color: blue;">'.sprintf(__('This User Agent \'%s\' Is Used By The Current Admin And Will Not Be Added To Ban List', 'wp-ban'), $banned_user_agent).'</p>';
79
  } else {
80
  $banned_user_agents[] = trim($banned_user_agent);
81
  }
108
  $i=0;
109
  foreach($update_ban_queries as $update_ban_query) {
110
  if($update_ban_query) {
111
+ $text .= '<p style="color: green;">'.$update_ban_text[$i].' '.__('Updated', 'wp-ban').'</p>';
112
  }
113
  $i++;
114
  }
115
  if(empty($text)) {
116
+ $text = '<p style="color: red;">'.__('No Ban Option Updated', 'wp-ban').'</p>';
117
  }
118
  }
119
  if(!empty($_POST['do'])) {
125
  if($_POST['reset_ban_stats'] == 'yes') {
126
  $banned_stats = array('users' => array(), 'count' => 0);
127
  update_option('banned_stats', $banned_stats);
128
+ $text = '<p style="color: green;">'.__('All IP Ban Stats And Total Ban Stat Reseted', 'wp-ban').'</p>';
129
  } else {
130
  $banned_stats = get_option('banned_stats');
131
  $delete_ips = (array) $_POST['delete_ips'];
133
  unset($banned_stats['users'][$delete_ip]);
134
  }
135
  update_option('banned_stats', $banned_stats);
136
+ $text = '<p style="color: green;">'.__('Selected IP Ban Stats Reseted', 'wp-ban').'</p>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  }
138
  break;
139
  }
140
  }
141
 
142
+ $banned_ips = get_option('banned_ips');
143
+ $banned_ips_range = get_option('banned_ips_range');
144
+ $banned_hosts = get_option('banned_hosts');
145
+ $banned_referers = get_option('banned_referers');
146
+ $banned_user_agents = get_option('banned_user_agents');
147
+ $banned_exclude_ips = get_option('banned_exclude_ips');
148
+ $banned_ips_display = '';
149
+ $banned_ips_range_display = '';
150
+ $banned_hosts_display = '';
151
+ $banned_referers_display = '';
152
+ $banned_user_agents_display = '';
153
+ $banned_exclude_ips_display = '';
154
+ if(!empty($banned_ips)) {
155
+ foreach($banned_ips as $banned_ip) {
156
+ $banned_ips_display .= $banned_ip."\n";
157
+ }
158
+ }
159
+ if(!empty($banned_ips_range)) {
160
+ foreach($banned_ips_range as $banned_ip_range) {
161
+ $banned_ips_range_display .= $banned_ip_range."\n";
162
+ }
163
+ }
164
+ if(!empty($banned_hosts)) {
165
+ foreach($banned_hosts as $banned_host) {
166
+ $banned_hosts_display .= $banned_host."\n";
167
+ }
168
+ }
169
+ if(!empty($banned_referers)) {
170
+ foreach($banned_referers as $banned_referer) {
171
+ $banned_referers_display .= $banned_referer."\n";
172
+ }
173
+ }
174
+ if(!empty($banned_user_agents)) {
175
+ foreach($banned_user_agents as $banned_user_agent) {
176
+ $banned_user_agents_display .= $banned_user_agent."\n";
177
+ }
178
+ }
179
+ if(!empty($banned_exclude_ips)) {
180
+ foreach($banned_exclude_ips as $banned_exclude_ip) {
181
+ $banned_exclude_ips_display .= $banned_exclude_ip."\n";
182
+ }
183
+ }
184
+ $banned_ips_display = trim($banned_ips_display);
185
+ $banned_ips_range_display = trim($banned_ips_range_display);
186
+ $banned_hosts_display = trim($banned_hosts_display);
187
+ $banned_referers_display = trim($banned_referers_display);
188
+ $banned_user_agents_display = trim($banned_user_agents_display);
189
+ $banned_exclude_ips_display = trim($banned_exclude_ips_display);
190
+ $banned_stats = get_option( 'banned_stats' );
191
+ $banned_options = get_option( 'banned_options' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  ?>
193
  <script type="text/javascript">
194
  /* <![CDATA[*/
282
  <tr>
283
  <td width="40%" valign="top">
284
  <strong><?php _e('Reverse Proxy Check', 'wp-ban'); ?>:</strong><br />
285
+ <?php _e( 'This will assume that incoming requests include the user\'s IP address in the HTTP_X_FORWARDED_FOR (and the request IP will be from your proxy).', 'wp-ban' ); ?>
286
  </td>
287
  <td width="60%">
288
  <label>
289
  <input type="checkbox" name="banned_option_reverse_proxy" value="1"<?php echo ( intval( $banned_options['reverse_proxy'] ) === 1 ) ? ' checked="checked"' : ''; ?> />
290
+ <?php _e( 'I am using a reverse proxy.', 'wp-ban' ); ?>
291
  </label>
292
  <p>
293
+ <?php _e( 'If you\'re not sure, leave this uncheck. Ticking this box when you don\'t have a reverse proxy will make it easy to bypass the IP ban.', 'wp-ban' ); ?>
294
  </p>
295
  </td>
296
  </tr>
452
  <p style="text-align: center;"><input type="submit" name="do" value="<?php _e('Reset Ban Stats', 'wp-ban'); ?>" class="button" onclick="return confirm('<?php _e('You Are About To Reset Ban Stats.', 'wp-ban'); ?>\n\n<?php _e('This Action Is Not Reversible. Are you sure?', 'wp-ban'); ?>')" /></p>
453
  </div>
454
  </form>
455
+ <p>&nbsp;</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: GamerZ
3
  Donate link: http://lesterchan.net/site/donation/
4
  Tags: banned, ban, deny, denied, permission, ip, hostname, host, spam, bots, bot, exclude, referrer, url, referral, range
5
  Requires at least: 2.8
6
- Tested up to: 4.0
7
- Stable tag: 1.64
8
 
9
  Ban users by IP, IP Range, host name, user agent and referrer url from visiting your WordPress's blog.
10
 
@@ -27,8 +27,12 @@ It will display a custom ban message when the banned IP, IP range, host name or
27
  * I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks, I will really appreciate it. If not feel free to use it without any obligations.
28
 
29
  == Changelog ==
 
 
 
 
30
  = Version 1.64 =
31
- * NEW: Added a new ban option 'reverse proxy' to allow user to choose whether to check against HTTP_X_FORWARDED_FOR header for IP. Props Tom Adams at dxw. This fixes CVE-2014-6230
32
 
33
  = Version 1.63 =
34
  * FIXED: Notices
3
  Donate link: http://lesterchan.net/site/donation/
4
  Tags: banned, ban, deny, denied, permission, ip, hostname, host, spam, bots, bot, exclude, referrer, url, referral, range
5
  Requires at least: 2.8
6
+ Tested up to: 4.3
7
+ Stable tag: 1.65
8
 
9
  Ban users by IP, IP Range, host name, user agent and referrer url from visiting your WordPress's blog.
10
 
27
  * I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks, I will really appreciate it. If not feel free to use it without any obligations.
28
 
29
  == Changelog ==
30
+ = Version 1.65 =
31
+ * NEW: Supports WordPress Multisite Network Activation
32
+ * NEW: Uses native WordPress uninstall.php
33
+
34
  = Version 1.64 =
35
+ * NEW: Added a new ban option 'reverse proxy' to allow user to choose whether to check against HTTP_X_FORWARDED_FOR header for IP. Props Tom Adams at dxw. This fixes [CVE-2014-6230](https://security.dxw.com/advisories/vulnerability-in-wp-ban-allows-visitors-to-bypass-the-ip-blacklist-in-some-configurations/)
36
 
37
  = Version 1.63 =
38
  * FIXED: Notices
uninstall.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Uninstall plugin
4
+ */
5
+ if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
6
+ exit ();
7
+
8
+ $option_names = array(
9
+ 'banned_ips'
10
+ , 'banned_hosts'
11
+ , 'banned_stats'
12
+ , 'banned_message'
13
+ , 'banned_referers'
14
+ , 'banned_exclude_ips'
15
+ , 'banned_ips_range'
16
+ , 'banned_user_agents'
17
+ );
18
+
19
+ if ( is_multisite() ) {
20
+ $ms_sites = wp_get_sites();
21
+
22
+ if( 0 < sizeof( $ms_sites ) ) {
23
+ foreach ( $ms_sites as $ms_site ) {
24
+ switch_to_blog( $ms_site['blog_id'] );
25
+ if( sizeof( $option_names ) > 0 ) {
26
+ foreach( $option_names as $option_name ) {
27
+ delete_option( $option_name );
28
+ plugin_uninstalled();
29
+ }
30
+ }
31
+ }
32
+ }
33
+
34
+ restore_current_blog();
35
+ } else {
36
+ if( sizeof( $option_names ) > 0 ) {
37
+ foreach( $option_names as $option_name ) {
38
+ delete_option( $option_name );
39
+ plugin_uninstalled();
40
+ }
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Delete plugin table when uninstalled
46
+ *
47
+ * @access public
48
+ * @return void
49
+ */
50
+ function plugin_uninstalled() {
51
+ global $wpdb;
52
+ }
wp-ban.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP-Ban
4
  Plugin URI: http://lesterchan.net/portfolio/programming/php/
5
  Description: Ban users by IP, IP Range, host name, user agent and referer url from visiting your WordPress's blog. It will display a custom ban message when the banned IP, IP range, host name, user agent or referer url tries to visit you blog. You can also exclude certain IPs from being banned. There will be statistics recordered on how many times they attemp to visit your blog. It allows wildcard matching too.
6
- Version: 1.64
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  Text Domain: wp-ban
@@ -177,17 +177,22 @@ function banned() {
177
  }
178
  }
179
 
180
- if(!$is_excluded) {
181
- if(!empty($banned_ips))
182
- process_ban($banned_ips, $ip);
183
- if(!empty($banned_ips_range))
184
- process_ban_ip_range($banned_ips_range);
185
- if(!empty($banned_hosts))
186
- process_ban($banned_hosts, @gethostbyaddr($ip));
187
- if(!empty($banned_referers))
188
- process_ban($banned_referers, $_SERVER['HTTP_REFERER']);
189
- if(!empty($banned_user_agents))
190
- process_ban($banned_user_agents, $_SERVER['HTTP_USER_AGENT']);
 
 
 
 
 
191
  }
192
  }
193
 
3
  Plugin Name: WP-Ban
4
  Plugin URI: http://lesterchan.net/portfolio/programming/php/
5
  Description: Ban users by IP, IP Range, host name, user agent and referer url from visiting your WordPress's blog. It will display a custom ban message when the banned IP, IP range, host name, user agent or referer url tries to visit you blog. You can also exclude certain IPs from being banned. There will be statistics recordered on how many times they attemp to visit your blog. It allows wildcard matching too.
6
+ Version: 1.65
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  Text Domain: wp-ban
177
  }
178
  }
179
 
180
+ if( ! $is_excluded ) {
181
+ if( ! empty( $banned_ips ) ) {
182
+ process_ban( $banned_ips, $ip );
183
+ }
184
+ if( ! empty( $banned_ips_range ) ) {
185
+ process_ban_ip_range( $banned_ips_range );
186
+ }
187
+ if( ! empty( $banned_hosts ) ) {
188
+ process_ban( $banned_hosts, @gethostbyaddr( $ip ) );
189
+ }
190
+ if( ! empty( $banned_referers ) && ! empty( $_SERVER['HTTP_REFERER'] ) ) {
191
+ process_ban( $banned_referers, $_SERVER['HTTP_REFERER'] );
192
+ }
193
+ if( ! empty( $banned_user_agents ) && ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
194
+ process_ban( $banned_user_agents, $_SERVER['HTTP_USER_AGENT'] );
195
+ }
196
  }
197
  }
198