WP-Ban - Version 1.30

Version Description

Download this release

Release Info

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

Code changes from version 1.20 to 1.30

ban/ban-options.php → ban-options.php RENAMED
@@ -2,8 +2,8 @@
2
  /*
3
  +----------------------------------------------------------------+
4
  | |
5
- | WordPress 2.1 Plugin: WP-Ban 1.20 |
6
- | Copyright (c) 2007 Lester "GaMerZ" Chan |
7
  | |
8
  | File Written By: |
9
  | - Lester "GaMerZ" Chan |
@@ -11,7 +11,7 @@
11
  | |
12
  | File Information: |
13
  | - WP-Ban Options |
14
- | - wp-content/plugins/ban/ban-options.php |
15
  | |
16
  +----------------------------------------------------------------+
17
  */
@@ -24,14 +24,110 @@ if(!current_user_can('manage_options')) {
24
 
25
 
26
  ### Variables
27
- $base_name = plugin_basename('ban/ban-options.php');
28
  $base_page = 'admin.php?page='.$base_name;
29
  $admin_login = trim($current_user->user_login);
30
  $mode = trim($_GET['mode']);
31
- $ban_settings = array('banned_ips', 'banned_hosts', 'banned_stats', 'banned_message', 'banned_referers', 'banned_exclude_ips', 'banned_ips_range');
32
 
33
 
34
- ### Form Processing
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  if(!empty($_POST['do'])) {
36
  // Decide What To Do
37
  switch($_POST['do']) {
@@ -51,88 +147,6 @@ if(!empty($_POST['do'])) {
51
  $text = '<font color="green">'.__('Selected IP Ban Stats Reseted', 'wp-ban').'</font>';
52
  }
53
  break;
54
- case __('Update Options', 'wp-ban'):
55
- $text = '';
56
- $update_ban_queries = array();
57
- $update_ban_text = array();
58
- $banned_ips_post = explode("\n", trim($_POST['banned_ips']));
59
- $banned_ips_range_post = explode("\n", trim($_POST['banned_ips_range']));
60
- $banned_hosts_post = explode("\n", trim($_POST['banned_hosts']));
61
- $banned_referers_post = explode("\n", trim($_POST['banned_referers']));
62
- $banned_exclude_ips_post = explode("\n", trim($_POST['banned_exclude_ips']));
63
- $banned_message = trim($_POST['banned_template_message']);
64
- if(!empty($banned_ips_post)) {
65
- $banned_ips = array();
66
- foreach($banned_ips_post as $banned_ip) {
67
- if($admin_login == 'admin' && ($banned_ip == get_IP() || is_admin_ip($banned_ip))) {
68
- $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 />';
69
- } else {
70
- $banned_ips[] = trim($banned_ip);
71
- }
72
- }
73
- }
74
- if(!empty($banned_ips_range_post)) {
75
- $banned_ips_range = array();
76
- foreach($banned_ips_range_post as $banned_ip_range) {
77
- $range = explode('-', $banned_ip_range);
78
- $range_start = trim($range[0]);
79
- $range_end = trim($range[1]);
80
- if($admin_login == 'admin' && (check_ip_within_range(get_IP(), $range_start, $range_end))) {
81
- $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'), get_IP(), $range_start, $range_end).'</font><br />';
82
- } else {
83
- $banned_ips_range[] = trim($banned_ip_range);
84
- }
85
- }
86
- }
87
- if(!empty($banned_hosts_post)) {
88
- $banned_hosts = array();
89
- foreach($banned_hosts_post as $banned_host) {
90
- if($admin_login == 'admin' && ($banned_host == @gethostbyaddr(get_IP()) || is_admin_hostname($banned_host))) {
91
- $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 />';
92
- } else {
93
- $banned_hosts[] = trim($banned_host);
94
- }
95
- }
96
- }
97
- if(!empty($banned_referers_post)) {
98
- $banned_referers = array();
99
- foreach($banned_referers_post as $banned_referer) {
100
- if(is_admin_referer($banned_referer)) {
101
- $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 />';
102
- } else {
103
- $banned_referers[] = trim($banned_referer);
104
- }
105
- }
106
- }
107
- if(!empty($banned_exclude_ips_post)) {
108
- $banned_exclude_ips = array();
109
- foreach($banned_exclude_ips_post as $banned_exclude_ip) {
110
- $banned_exclude_ips[] = trim($banned_exclude_ip);
111
- }
112
- }
113
- $update_ban_queries[] = update_option('banned_ips', $banned_ips);
114
- $update_ban_queries[] = update_option('banned_ips_range', $banned_ips_range);
115
- $update_ban_queries[] = update_option('banned_hosts', $banned_hosts);
116
- $update_ban_queries[] = update_option('banned_referers', $banned_referers);
117
- $update_ban_queries[] = update_option('banned_exclude_ips', $banned_exclude_ips);
118
- $update_ban_queries[] = update_option('banned_message', $banned_message);
119
- $update_ban_text[] = __('Banned IPs', 'wp-ban');
120
- $update_ban_text[] = __('Banned IP Range', 'wp-ban');
121
- $update_ban_text[] = __('Banned Host Names', 'wp-ban');
122
- $update_ban_text[] = __('Banned Referers', 'wp-ban');
123
- $update_ban_text[] = __('Banned Excluded IPs', 'wp-ban');
124
- $update_ban_text[] = __('Banned Message', 'wp-ban');
125
- $i=0;
126
- foreach($update_ban_queries as $update_ban_query) {
127
- if($update_ban_query) {
128
- $text .= '<font color="green">'.$update_ban_text[$i].' '.__('Updated', 'wp-ban').'</font><br />';
129
- }
130
- $i++;
131
- }
132
- if(empty($text)) {
133
- $text = '<font color="red">'.__('No Ban Option Updated', 'wp-ban').'</font>';
134
- }
135
- break;
136
  // Uninstall WP-Ban
137
  case __('UNINSTALL WP-Ban', 'wp-ban') :
138
  if(trim($_POST['uninstall_ban_yes']) == 'yes') {
@@ -163,9 +177,9 @@ if(!empty($_POST['do'])) {
163
  switch($mode) {
164
  // Deactivating WP-Ban
165
  case 'end-UNINSTALL':
166
- $deactivate_url = 'plugins.php?action=deactivate&amp;plugin=ban/ban.php';
167
  if(function_exists('wp_nonce_url')) {
168
- $deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_ban/ban.php');
169
  }
170
  echo '<div class="wrap">';
171
  echo '<h2>'.__('Uninstall WP-Ban', 'wp-ban').'</h2>';
@@ -178,6 +192,7 @@ switch($mode) {
178
  $banned_ips_range = get_option('banned_ips_range');
179
  $banned_hosts = get_option('banned_hosts');
180
  $banned_referers = get_option('banned_referers');
 
181
  $banned_exclude_ips = get_option('banned_exclude_ips');
182
  $banned_ips_display = '';
183
  $banned_ips_range_display = '';
@@ -204,6 +219,11 @@ switch($mode) {
204
  $banned_referers_display .= $banned_referer."\n";
205
  }
206
  }
 
 
 
 
 
207
  if(!empty($banned_exclude_ips)) {
208
  foreach($banned_exclude_ips as $banned_exclude_ip) {
209
  $banned_exclude_ips_display .= $banned_exclude_ip."\n";
@@ -213,6 +233,7 @@ switch($mode) {
213
  $banned_ips_range_display = trim($banned_ips_range_display);
214
  $banned_hosts_display = trim($banned_hosts_display);
215
  $banned_referers_display = trim($banned_referers_display);
 
216
  $banned_exclude_ips_display = trim($banned_exclude_ips_display);
217
  $banned_stats = get_option('banned_stats');
218
  ?>
@@ -244,7 +265,7 @@ switch($mode) {
244
  }
245
  }
246
  function preview_bannedmessage() {
247
- window.open('<?php echo get_option('siteurl').'/wp-content/plugins/ban/ban-preview.php'; ?>');
248
  }
249
  /* ]]> */
250
  </script>
@@ -253,7 +274,7 @@ switch($mode) {
253
  <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
254
  <div class="wrap">
255
  <h2><?php _e('Ban Options', 'wp-ban'); ?></h2>
256
- <table width="100%" cellspacing="3" cellpadding="3" border="0">
257
  <tr>
258
  <td valign="top" colspan="2" align="center">
259
  <?php printf(__('Your IP is: <strong>%s</strong><br />Your Host Name is: <strong>%s</strong><br />Your Site URL is: <strong>%s</strong>', 'wp-ban'), get_IP(), @gethostbyaddr(get_IP()), get_option('siteurl')); ?><br />
@@ -315,6 +336,22 @@ switch($mode) {
315
  <textarea cols="40" rows="10" name="banned_referers"><?php echo $banned_referers_display; ?></textarea>
316
  </td>
317
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
318
  <tr>
319
  <td valign="top">
320
  <strong><?php _e('Banned Exclude IPs', 'wp-ban'); ?>:</strong><br />
@@ -346,36 +383,41 @@ switch($mode) {
346
  <textarea cols="60" rows="20" id="banned_template_message" name="banned_template_message"><?php echo stripslashes(get_option('banned_message')); ?></textarea>
347
  </td>
348
  </tr>
349
- <tr>
350
- <td width="100%" colspan="2" align="center"><input type="submit" name="do" class="button" value="<?php _e('Update Options', 'wp-ban'); ?>" />&nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel', 'wp-ban'); ?>" class="button" onclick="javascript:history.go(-1)" /></td>
351
- </tr>
352
  </table>
 
 
 
353
  </div>
354
  </form>
 
355
 
356
  <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
357
  <div class="wrap">
358
  <h2><?php _e('Ban Stats', 'wp-ban'); ?></h2>
359
- <table width="100%" cellspacing="3" cellpadding="3" border="0">
360
- <tr class="thead">
361
- <th width="40%"><?php _e('IPs', 'wp-ban'); ?></th>
362
- <th width="30%"><?php _e('Attempts', 'wp-ban'); ?></th>
363
- <th width="30%"><input type="checkbox" name="toogle_checkbox" value="1" onclick="toggle_checkbox();" />&nbsp; <?php _e('Action', 'wp-ban'); ?></th>
364
- </tr>
 
 
 
365
  <?php
366
  // Credits To Joe (Ttech) - http://blog.fileville.net/
367
  if(!empty($banned_stats['users'])) {
368
  $i = 0;
 
369
  foreach($banned_stats['users'] as $key => $value) {
370
  if($i%2 == 0) {
371
- $style = 'style=\'background-color: #eee\'';
372
  } else {
373
- $style = 'style=\'background-color: none\'';
374
  }
375
- echo "<tr $style>\n";
376
  echo "<td style=\"text-align: center;\">$key</td>\n";
377
- echo "<td style=\"text-align: center;\">$value</td>\n";
378
- echo "<td><input type=\"checkbox\" name=\"delete_ips[]\" value=\"$key\" />&nbsp;Reset this IP ban stat?</td>\n";
379
  echo '</tr>'."\n";
380
  $i++;
381
  }
@@ -387,13 +429,14 @@ switch($mode) {
387
  ?>
388
  <tr class="thead">
389
  <td style="text-align: center;"><strong><?php _e('Total Attempts:', 'wp-ban'); ?></strong></td>
390
- <td style="text-align: center;"><strong><?php echo intval($banned_stats['count']); ?></strong></td>
391
- <td><input type="checkbox" name="reset_ban_stats" value="yes" /> &nbsp;<?php _e('Reset all IP ban stats and total ban stat?', 'wp-ban'); ?>&nbsp;</td>
392
  </tr>
393
  </table>
394
  <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>
395
  </div>
396
  </form>
 
397
 
398
  <!-- Uninstall WP-Ban -->
399
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
@@ -409,12 +452,14 @@ switch($mode) {
409
  <p style="text-align: left; color: red">
410
  <strong><?php _e('The following WordPress Options will be DELETED:', 'wp-ban'); ?></strong><br />
411
  </p>
412
- <table width="70%" border="0" cellspacing="3" cellpadding="3">
413
- <tr class="thead">
414
- <td align="center"><strong><?php _e('WordPress Options', 'wp-ban'); ?></strong></td>
415
- </tr>
 
 
416
  <tr>
417
- <td valign="top" style="background-color: #eee;">
418
  <ol>
419
  <?php
420
  foreach($ban_settings as $settings) {
2
  /*
3
  +----------------------------------------------------------------+
4
  | |
5
+ | WordPress 2.5 Plugin: WP-Ban 1.30 |
6
+ | Copyright (c) 2008 Lester "GaMerZ" Chan |
7
  | |
8
  | File Written By: |
9
  | - Lester "GaMerZ" Chan |
11
  | |
12
  | File Information: |
13
  | - WP-Ban Options |
14
+ | - wp-content/plugins/wp-ban/ban-options.php |
15
  | |
16
  +----------------------------------------------------------------+
17
  */
24
 
25
 
26
  ### Variables
27
+ $base_name = plugin_basename('wp-ban/ban-options.php');
28
  $base_page = 'admin.php?page='.$base_name;
29
  $admin_login = trim($current_user->user_login);
30
  $mode = trim($_GET['mode']);
31
+ $ban_settings = array('banned_ips', 'banned_hosts', 'banned_stats', 'banned_message', 'banned_referers', 'banned_exclude_ips', 'banned_ips_range', 'banned_user_agents');
32
 
33
 
34
+ ### Form Processing
35
+ // Update Options
36
+ if(!empty($_POST['Submit'])) {
37
+ $text = '';
38
+ $update_ban_queries = array();
39
+ $update_ban_text = array();
40
+ $banned_ips_post = explode("\n", trim($_POST['banned_ips']));
41
+ $banned_ips_range_post = explode("\n", trim($_POST['banned_ips_range']));
42
+ $banned_hosts_post = explode("\n", trim($_POST['banned_hosts']));
43
+ $banned_referers_post = explode("\n", trim($_POST['banned_referers']));
44
+ $banned_user_agents_post = explode("\n", trim($_POST['banned_user_agents']));
45
+ $banned_exclude_ips_post = explode("\n", trim($_POST['banned_exclude_ips']));
46
+ $banned_message = trim($_POST['banned_template_message']);
47
+ if(!empty($banned_ips_post)) {
48
+ $banned_ips = array();
49
+ foreach($banned_ips_post as $banned_ip) {
50
+ if($admin_login == 'admin' && ($banned_ip == get_IP() || is_admin_ip($banned_ip))) {
51
+ $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 />';
52
+ } else {
53
+ $banned_ips[] = trim($banned_ip);
54
+ }
55
+ }
56
+ }
57
+ if(!empty($banned_ips_range_post)) {
58
+ $banned_ips_range = array();
59
+ foreach($banned_ips_range_post as $banned_ip_range) {
60
+ $range = explode('-', $banned_ip_range);
61
+ $range_start = trim($range[0]);
62
+ $range_end = trim($range[1]);
63
+ if($admin_login == 'admin' && (check_ip_within_range(get_IP(), $range_start, $range_end))) {
64
+ $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'), get_IP(), $range_start, $range_end).'</font><br />';
65
+ } else {
66
+ $banned_ips_range[] = trim($banned_ip_range);
67
+ }
68
+ }
69
+ }
70
+ if(!empty($banned_hosts_post)) {
71
+ $banned_hosts = array();
72
+ foreach($banned_hosts_post as $banned_host) {
73
+ if($admin_login == 'admin' && ($banned_host == @gethostbyaddr(get_IP()) || is_admin_hostname($banned_host))) {
74
+ $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 />';
75
+ } else {
76
+ $banned_hosts[] = trim($banned_host);
77
+ }
78
+ }
79
+ }
80
+ if(!empty($banned_referers_post)) {
81
+ $banned_referers = array();
82
+ foreach($banned_referers_post as $banned_referer) {
83
+ if(is_admin_referer($banned_referer)) {
84
+ $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 />';
85
+ } else {
86
+ $banned_referers[] = trim($banned_referer);
87
+ }
88
+ }
89
+ }
90
+ if(!empty($banned_user_agents_post)) {
91
+ $banned_user_agents = array();
92
+ foreach($banned_user_agents_post as $banned_user_agent) {
93
+ if(is_admin_user_agent($banned_user_agent)) {
94
+ $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 />';
95
+ } else {
96
+ $banned_user_agents[] = trim($banned_user_agent);
97
+ }
98
+ }
99
+ }
100
+ if(!empty($banned_exclude_ips_post)) {
101
+ $banned_exclude_ips = array();
102
+ foreach($banned_exclude_ips_post as $banned_exclude_ip) {
103
+ $banned_exclude_ips[] = trim($banned_exclude_ip);
104
+ }
105
+ }
106
+ $update_ban_queries[] = update_option('banned_ips', $banned_ips);
107
+ $update_ban_queries[] = update_option('banned_ips_range', $banned_ips_range);
108
+ $update_ban_queries[] = update_option('banned_hosts', $banned_hosts);
109
+ $update_ban_queries[] = update_option('banned_referers', $banned_referers);
110
+ $update_ban_queries[] = update_option('banned_user_agents', $banned_user_agents);
111
+ $update_ban_queries[] = update_option('banned_exclude_ips', $banned_exclude_ips);
112
+ $update_ban_queries[] = update_option('banned_message', $banned_message);
113
+ $update_ban_text[] = __('Banned IPs', 'wp-ban');
114
+ $update_ban_text[] = __('Banned IP Range', 'wp-ban');
115
+ $update_ban_text[] = __('Banned Host Names', 'wp-ban');
116
+ $update_ban_text[] = __('Banned Referers', 'wp-ban');
117
+ $update_ban_text[] = __('Banned User Agents', 'wp-ban');
118
+ $update_ban_text[] = __('Banned Excluded IPs', 'wp-ban');
119
+ $update_ban_text[] = __('Banned Message', 'wp-ban');
120
+ $i=0;
121
+ foreach($update_ban_queries as $update_ban_query) {
122
+ if($update_ban_query) {
123
+ $text .= '<font color="green">'.$update_ban_text[$i].' '.__('Updated', 'wp-ban').'</font><br />';
124
+ }
125
+ $i++;
126
+ }
127
+ if(empty($text)) {
128
+ $text = '<font color="red">'.__('No Ban Option Updated', 'wp-ban').'</font>';
129
+ }
130
+ }
131
  if(!empty($_POST['do'])) {
132
  // Decide What To Do
133
  switch($_POST['do']) {
147
  $text = '<font color="green">'.__('Selected IP Ban Stats Reseted', 'wp-ban').'</font>';
148
  }
149
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  // Uninstall WP-Ban
151
  case __('UNINSTALL WP-Ban', 'wp-ban') :
152
  if(trim($_POST['uninstall_ban_yes']) == 'yes') {
177
  switch($mode) {
178
  // Deactivating WP-Ban
179
  case 'end-UNINSTALL':
180
+ $deactivate_url = 'plugins.php?action=deactivate&amp;plugin=wp-ban/wp-ban.php';
181
  if(function_exists('wp_nonce_url')) {
182
+ $deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_wp-ban/wp-ban.php');
183
  }
184
  echo '<div class="wrap">';
185
  echo '<h2>'.__('Uninstall WP-Ban', 'wp-ban').'</h2>';
192
  $banned_ips_range = get_option('banned_ips_range');
193
  $banned_hosts = get_option('banned_hosts');
194
  $banned_referers = get_option('banned_referers');
195
+ $banned_user_agents = get_option('banned_user_agents');
196
  $banned_exclude_ips = get_option('banned_exclude_ips');
197
  $banned_ips_display = '';
198
  $banned_ips_range_display = '';
219
  $banned_referers_display .= $banned_referer."\n";
220
  }
221
  }
222
+ if(!empty($banned_user_agents)) {
223
+ foreach($banned_user_agents as $banned_user_agent) {
224
+ $banned_user_agents_display .= $banned_user_agent."\n";
225
+ }
226
+ }
227
  if(!empty($banned_exclude_ips)) {
228
  foreach($banned_exclude_ips as $banned_exclude_ip) {
229
  $banned_exclude_ips_display .= $banned_exclude_ip."\n";
233
  $banned_ips_range_display = trim($banned_ips_range_display);
234
  $banned_hosts_display = trim($banned_hosts_display);
235
  $banned_referers_display = trim($banned_referers_display);
236
+ $banned_user_agents_display = trim($banned_user_agents_display);
237
  $banned_exclude_ips_display = trim($banned_exclude_ips_display);
238
  $banned_stats = get_option('banned_stats');
239
  ?>
265
  }
266
  }
267
  function preview_bannedmessage() {
268
+ window.open('<?php echo get_option('siteurl').'/wp-content/plugins/wp-ban/ban-preview.php'; ?>');
269
  }
270
  /* ]]> */
271
  </script>
274
  <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
275
  <div class="wrap">
276
  <h2><?php _e('Ban Options', 'wp-ban'); ?></h2>
277
+ <table class="form-table">
278
  <tr>
279
  <td valign="top" colspan="2" align="center">
280
  <?php printf(__('Your IP is: <strong>%s</strong><br />Your Host Name is: <strong>%s</strong><br />Your Site URL is: <strong>%s</strong>', 'wp-ban'), get_IP(), @gethostbyaddr(get_IP()), get_option('siteurl')); ?><br />
336
  <textarea cols="40" rows="10" name="banned_referers"><?php echo $banned_referers_display; ?></textarea>
337
  </td>
338
  </tr>
339
+ <tr>
340
+ <td valign="top">
341
+ <strong><?php _e('Banned User Agents', 'wp-ban'); ?>:</strong><br />
342
+ <?php _e('Use <strong>*</strong> for wildcards', 'wp-ban'); ?>.<br />
343
+ <?php _e('Start each entry on a new line.', 'wp-ban'); ?><br /><br />
344
+ <?php _e('Examples:', 'wp-ban'); ?><br />
345
+ <strong>&raquo;</strong> EmailSiphon*<br />
346
+ <strong>&raquo;</strong> LMQueueBot*<br />
347
+ <strong>&raquo;</strong> ContactBot*<br /><br />
348
+ <?php _e('Suggestions:', 'wp-ban'); ?><br />
349
+ <strong>&raquo;</strong> <?php _e('See <a href="http://www.user-agents.org/">http://www.user-agents.org/</a>', 'wp-ban'); ?>
350
+ </td>
351
+ <td>
352
+ <textarea cols="40" rows="10" name="banned_user_agents"><?php echo $banned_user_agents_display; ?></textarea>
353
+ </td>
354
+ </tr>
355
  <tr>
356
  <td valign="top">
357
  <strong><?php _e('Banned Exclude IPs', 'wp-ban'); ?>:</strong><br />
383
  <textarea cols="60" rows="20" id="banned_template_message" name="banned_template_message"><?php echo stripslashes(get_option('banned_message')); ?></textarea>
384
  </td>
385
  </tr>
 
 
 
386
  </table>
387
+ <p class="submit">
388
+ <input type="submit" name="Submit" class="button" value="<?php _e('Save Changes', 'wp-ban'); ?>" />
389
+ </p>
390
  </div>
391
  </form>
392
+ <p>&nbsp;</p>
393
 
394
  <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
395
  <div class="wrap">
396
  <h2><?php _e('Ban Stats', 'wp-ban'); ?></h2>
397
+ <br style="clear" />
398
+ <table class="widefat">
399
+ <thead>
400
+ <tr>
401
+ <th width="40%"><?php _e('IPs', 'wp-ban'); ?></th>
402
+ <th width="30%"><?php _e('Attempts', 'wp-ban'); ?></th>
403
+ <th width="30%"><input type="checkbox" id="toogle_checkbox" name="toogle_checkbox" value="1" onclick="toggle_checkbox();" />&nbsp;<label for="toogle_checkbox"><?php _e('Action', 'wp-ban'); ?></label></th>
404
+ </tr>
405
+ </thead>
406
  <?php
407
  // Credits To Joe (Ttech) - http://blog.fileville.net/
408
  if(!empty($banned_stats['users'])) {
409
  $i = 0;
410
+ ksort($banned_stats['users']);
411
  foreach($banned_stats['users'] as $key => $value) {
412
  if($i%2 == 0) {
413
+ $style = '';
414
  } else {
415
+ $style = ' class="alternate"';
416
  }
417
+ echo "<tr$style>\n";
418
  echo "<td style=\"text-align: center;\">$key</td>\n";
419
+ echo "<td style=\"text-align: center;\">".number_format_i18n(intval($value))."</td>\n";
420
+ echo "<td><input type=\"checkbox\" id=\"ban-$i\" name=\"delete_ips[]\" value=\"$key\" />&nbsp;<label for=\"ban-$i\">Reset this IP ban stat?</label></td>\n";
421
  echo '</tr>'."\n";
422
  $i++;
423
  }
429
  ?>
430
  <tr class="thead">
431
  <td style="text-align: center;"><strong><?php _e('Total Attempts:', 'wp-ban'); ?></strong></td>
432
+ <td style="text-align: center;"><strong><?php echo number_format_i18n(intval($banned_stats['count'])); ?></strong></td>
433
+ <td><input type="checkbox" id="reset_ban_stats" name="reset_ban_stats" value="yes" />&nbsp;<label for="reset_ban_stats"><?php _e('Reset all IP ban stats and total ban stat?', 'wp-ban'); ?></label></td>
434
  </tr>
435
  </table>
436
  <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>
437
  </div>
438
  </form>
439
+ <p>&nbsp;</p>
440
 
441
  <!-- Uninstall WP-Ban -->
442
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
452
  <p style="text-align: left; color: red">
453
  <strong><?php _e('The following WordPress Options will be DELETED:', 'wp-ban'); ?></strong><br />
454
  </p>
455
+ <table class="widefat">
456
+ <thead>
457
+ <tr>
458
+ <th><?php _e('WordPress Options', 'wp-ban'); ?></th>
459
+ </tr>
460
+ </thead>
461
  <tr>
462
+ <td valign="top">
463
  <ol>
464
  <?php
465
  foreach($ban_settings as $settings) {
ban/ban-preview.php → ban-preview.php RENAMED
@@ -2,8 +2,8 @@
2
  /*
3
  +----------------------------------------------------------------+
4
  | |
5
- | WordPress 2.1 Plugin: WP-Ban 1.20 |
6
- | Copyright (c) 2007 Lester "GaMerZ" Chan |
7
  | |
8
  | File Written By: |
9
  | - Lester "GaMerZ" Chan |
@@ -11,7 +11,7 @@
11
  | |
12
  | File Information: |
13
  | - Banned Message Preview |
14
- | - wp-content/plugins/ban/ban-preview.php |
15
  | |
16
  +----------------------------------------------------------------+
17
  */
@@ -23,8 +23,8 @@ require('../../../wp-config.php');
23
 
24
  ### Display Banned Message
25
  $banned_stats = get_option('banned_stats');
26
- $banned_stats['count'] = (intval($banned_stats['count']));
27
- $banned_stats['users'][get_IP()] = intval($banned_stats['users'][get_IP()]);
28
  $banned_message = stripslashes(get_option('banned_message'));
29
  $banned_message = str_replace("%SITE_NAME%", get_option('blogname'), $banned_message);
30
  $banned_message = str_replace("%SITE_URL%", get_option('siteurl'), $banned_message);
2
  /*
3
  +----------------------------------------------------------------+
4
  | |
5
+ | WordPress 2.5 Plugin: WP-Ban 1.30 |
6
+ | Copyright (c) 2008 Lester "GaMerZ" Chan |
7
  | |
8
  | File Written By: |
9
  | - Lester "GaMerZ" Chan |
11
  | |
12
  | File Information: |
13
  | - Banned Message Preview |
14
+ | - wp-content/plugins/wp-ban/ban-preview.php |
15
  | |
16
  +----------------------------------------------------------------+
17
  */
23
 
24
  ### Display Banned Message
25
  $banned_stats = get_option('banned_stats');
26
+ $banned_stats['count'] = number_format_i18n(intval($banned_stats['count']));
27
+ $banned_stats['users'][get_IP()] = number_format_i18n(intval($banned_stats['users'][get_IP()]));
28
  $banned_message = stripslashes(get_option('banned_message'));
29
  $banned_message = str_replace("%SITE_NAME%", get_option('blogname'), $banned_message);
30
  $banned_message = str_replace("%SITE_URL%", get_option('siteurl'), $banned_message);
ban/wp-ban.mo DELETED
Binary file
readme.html CHANGED
@@ -2,7 +2,7 @@
2
  <html>
3
  <head>
4
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5
- <title>WP-Ban 1.20 Readme</title>
6
  <style type="text/css" media="screen">
7
  /* Default Style */
8
  BODY {
@@ -203,7 +203,7 @@
203
  <body>
204
  <div id="Container">
205
  <!-- Title -->
206
- <div id="Title">WP-Ban 1.20&nbsp;&nbsp;&nbsp;<span style="color: #aaaaaa;">Readme</span></div>
207
 
208
  <!-- Tabs -->
209
  <ul id="Tabs">
@@ -224,15 +224,6 @@
224
  <strong>Author:</strong><br />
225
  <strong>&raquo;</strong> Lester 'GaMerZ' Chan
226
  </p>
227
- <p>
228
- <strong>EMail:</strong><br />
229
- <strong>&raquo;</strong>
230
- <script type="text/javascript">
231
- /* <![CDATA[*/
232
- document.write(' <a href="mailto:gamerz84@hotmail.com?Subject=WP-Ban%201.20%20Support" title="EMail To gamerz84@hotmail.com">gamerz84@hotmail.com</a>');
233
- /* ]]> */
234
- </script>
235
- </p>
236
  <p>
237
  <strong>Website:</strong><br />
238
  <strong>&raquo;</strong> <a href="http://lesterchan.net/" title="http://lesterchan.net/">http://lesterchan.net/</a>
@@ -243,8 +234,8 @@
243
  </p>
244
  <p>
245
  <strong>Download:</strong><br />
246
- <strong>&raquo;</strong> <a href="http://lesterchan.net/others/downloads.php?id=26" title="http://lesterchan.net/others/downloads.php?id=26">WP-Ban 1.20 For WordPress 2.1.x And Above</a><br />
247
- <strong>&raquo;</strong> <a href="http://lesterchan.net/others/downloads/wp-ban100.zip" title="http://lesterchan.net/others/downloads/wp-ban100.zip">WP-Ban 1.00 For WordPress 2.0.x</a><br />
248
  </p>
249
  <p>
250
  <strong>Screenshots:</strong><br />
@@ -266,25 +257,16 @@
266
  <strong>Support Forums:</strong><br />
267
  <strong>&raquo;</strong> <a href="http://forums.lesterchan.net/index.php?board=10.0" title="http://forums.lesterchan.net/index.php?board=10.0">http://forums.lesterchan.net/index.php?board=10.0</a>
268
  </p>
269
- <p>
270
- <strong>Credits:</strong><br />
271
- <strong>&raquo;</strong> Ban Stats By <a href="http://blog.fileville.net/">Joe (Ttech)</a>
272
- </p>
273
- <p>
274
- <strong>Updated:</strong><br />
275
- <strong>&raquo;</strong> 1st October 2007
276
- </p>
277
  <p>
278
  <strong>Note:</strong><br />
279
  <strong>&raquo;</strong> The <strong>Changelog</strong>, <strong>Installation</strong>, <strong>Upgrade</strong>, <strong>Usage</strong> Tab at the top of the page.<br />
280
- <strong>&raquo;</strong> The ban tab has been moved to '<strong>WP-Admin -> Manage -> Ban</strong>'
281
  </p>
282
  <p>
283
  <strong>Donations:</strong><br />
284
  <strong>&raquo;</strong> 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 as my school allowance, I will really appericiate it. If not feel free to use it without any obligations. Thank You. My Paypal account is
285
  <script type="text/javascript">
286
  /* <![CDATA[*/
287
- document.write(' <strong>gamerz84@hotmail.com</strong>.');
288
  /* ]]> */
289
  </script>
290
  </p>
@@ -294,6 +276,17 @@
294
  <div id="Changelog" style="display: none;">
295
  <div class="SubTitle">&raquo; Changelog</div>
296
  <ul>
 
 
 
 
 
 
 
 
 
 
 
297
  <li>
298
  <strong>Version 1.20 (01-10-2007)</strong>
299
  <ul>
@@ -340,7 +333,7 @@
340
  </li>
341
  <li>
342
  Put:
343
- <blockquote>Folder: ban</blockquote>
344
  </li>
345
  <li>
346
  <strong>Activate</strong> WP-Ban Plugin
@@ -354,7 +347,7 @@
354
  <!-- Upgrade Instructions -->
355
  <div id="Upgrade" style="display: none;">
356
  <div class="SubTitle">&raquo; Upgrade Instructions</div>
357
- <div class="SubSubTitle">From v1.0x To v1.20</div>
358
  <ol>
359
  <li>
360
  <strong>Deactivate</strong> WP-Ban Plugin
@@ -364,11 +357,13 @@
364
  </li>
365
  <li>
366
  Put/Overwrite:
367
- <blockquote>Folder: ban</blockquote>
368
  </li>
369
  <li>
370
- Delete:
371
- <blockquote>File: ban.php</blockquote>
 
 
372
  </li>
373
  <li>
374
  <strong>Activate</strong> WP-Ban Plugin
@@ -394,6 +389,6 @@
394
  </div>
395
  </div>
396
  </div>
397
- <p id="Copyright">WP-Ban 1.20<br />Copyright &copy; 2007 Lester 'GaMerZ' Chan. All Rights Reserved.</p>
398
  </body>
399
  </html>
2
  <html>
3
  <head>
4
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5
+ <title>WP-Ban 1.30 Readme</title>
6
  <style type="text/css" media="screen">
7
  /* Default Style */
8
  BODY {
203
  <body>
204
  <div id="Container">
205
  <!-- Title -->
206
+ <div id="Title">WP-Ban 1.30&nbsp;&nbsp;&nbsp;<span style="color: #aaaaaa;">Readme</span></div>
207
 
208
  <!-- Tabs -->
209
  <ul id="Tabs">
224
  <strong>Author:</strong><br />
225
  <strong>&raquo;</strong> Lester 'GaMerZ' Chan
226
  </p>
 
 
 
 
 
 
 
 
 
227
  <p>
228
  <strong>Website:</strong><br />
229
  <strong>&raquo;</strong> <a href="http://lesterchan.net/" title="http://lesterchan.net/">http://lesterchan.net/</a>
234
  </p>
235
  <p>
236
  <strong>Download:</strong><br />
237
+ <strong>&raquo;</strong> <a href="http://downloads.wordpress.org/plugin/wp-ban.1.30.zip" title="http://downloads.wordpress.org/plugin/wp-ban.1.30.zip">WP-Ban 1.30 For WordPress 2.1.x And Above</a><br />
238
+ <strong>&raquo;</strong> <a href="http://downloads.wordpress.org/plugin/wp-ban.1.00.zip" title="http://downloads.wordpress.org/plugin/wp-ban.1.00.zip">WP-Ban 1.00 For WordPress 2.0.x</a><br />
239
  </p>
240
  <p>
241
  <strong>Screenshots:</strong><br />
257
  <strong>Support Forums:</strong><br />
258
  <strong>&raquo;</strong> <a href="http://forums.lesterchan.net/index.php?board=10.0" title="http://forums.lesterchan.net/index.php?board=10.0">http://forums.lesterchan.net/index.php?board=10.0</a>
259
  </p>
 
 
 
 
 
 
 
 
260
  <p>
261
  <strong>Note:</strong><br />
262
  <strong>&raquo;</strong> The <strong>Changelog</strong>, <strong>Installation</strong>, <strong>Upgrade</strong>, <strong>Usage</strong> Tab at the top of the page.<br />
 
263
  </p>
264
  <p>
265
  <strong>Donations:</strong><br />
266
  <strong>&raquo;</strong> 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 as my school allowance, I will really appericiate it. If not feel free to use it without any obligations. Thank You. My Paypal account is
267
  <script type="text/javascript">
268
  /* <![CDATA[*/
269
+ document.write(' <strong>lesterchan@gmail.com</strong>.');
270
  /* ]]> */
271
  </script>
272
  </p>
276
  <div id="Changelog" style="display: none;">
277
  <div class="SubTitle">&raquo; Changelog</div>
278
  <ul>
279
+ <li>
280
+ <strong>Version 1.30 (01-06-2008)</strong>
281
+ <ul>
282
+ <li>NEW: Uses /wp-ban/ Folder Instead Of /ban/</li>
283
+ <li>NEW: Uses wp-ban.php Instead Of ban.php</li>
284
+ <li>NEW: Uses number_format_i18n()</li>
285
+ <li>NEW: IPs Listed In Ban Stats Is Now Sorted Numerically</li>
286
+ <li>NEW: Banned By User Agents (By: <a href="http://www.linkedin.com/in/jgbustos">Jorge Garcia de Bustos</a>)</li>
287
+ <li>FIXED: "unknown" IPs (By: <a href="http://www.linkedin.com/in/jgbustos">Jorge Garcia de Bustos</a>)</li>
288
+ </ul>
289
+ </li>
290
  <li>
291
  <strong>Version 1.20 (01-10-2007)</strong>
292
  <ul>
333
  </li>
334
  <li>
335
  Put:
336
+ <blockquote>Folder: wp-ban</blockquote>
337
  </li>
338
  <li>
339
  <strong>Activate</strong> WP-Ban Plugin
347
  <!-- Upgrade Instructions -->
348
  <div id="Upgrade" style="display: none;">
349
  <div class="SubTitle">&raquo; Upgrade Instructions</div>
350
+ <div class="SubSubTitle">From v1.0x To v1.30</div>
351
  <ol>
352
  <li>
353
  <strong>Deactivate</strong> WP-Ban Plugin
357
  </li>
358
  <li>
359
  Put/Overwrite:
360
+ <blockquote>Folder: wp-ban</blockquote>
361
  </li>
362
  <li>
363
+ Delete this folder if exists:
364
+ <blockquote>
365
+ Folder: ban
366
+ </blockquote>
367
  </li>
368
  <li>
369
  <strong>Activate</strong> WP-Ban Plugin
389
  </div>
390
  </div>
391
  </div>
392
+ <p id="Copyright">WP-Ban 1.30<br />Copyright &copy; 2008 Lester 'GaMerZ' Chan. All Rights Reserved.</p>
393
  </body>
394
  </html>
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: GamerZ
3
  Donate link: http://lesterchan.net/wordpress
4
  Tags: banned, ban, deny, denied, permission, ip, hostname, host, spam, bots, bot, exclude, referer, url, referral, range
5
- Requires at least: 2.1.0
6
- Stable tag: 1.20
7
 
8
  Ban users by IP, IP Range, host name and referer url from visiting your WordPress's blog.
9
 
2
  Contributors: GamerZ
3
  Donate link: http://lesterchan.net/wordpress
4
  Tags: banned, ban, deny, denied, permission, ip, hostname, host, spam, bots, bot, exclude, referer, url, referral, range
5
+ Requires at least: 2.5.0
6
+ Stable tag: 1.30
7
 
8
  Ban users by IP, IP Range, host name and referer url from visiting your WordPress's blog.
9
 
wp-ban.mo ADDED
Binary file
ban/ban.php → wp-ban.php RENAMED
@@ -1,16 +1,16 @@
1
  <?php
2
  /*
3
  Plugin Name: WP-Ban
4
- Plugin URI: http://lesterchan.net/portfolio/programming.php
5
- Description: Ban users by IP, IP Range, host name and referer url from visiting your WordPress's blog. It will display a custom ban message when the banned IP, IP range, host name or referer url trys 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.20
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  */
10
 
11
 
12
  /*
13
- Copyright 2007 Lester Chan (email : gamerz84@hotmail.com)
14
 
15
  This program is free software; you can redistribute it and/or modify
16
  it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@ Author URI: http://lesterchan.net
31
  ### Create Text Domain For Translation
32
  add_action('init', 'ban_textdomain');
33
  function ban_textdomain() {
34
- load_plugin_textdomain('wp-ban', 'wp-content/plugins/ban');
35
  }
36
 
37
 
@@ -39,7 +39,7 @@ function ban_textdomain() {
39
  add_action('admin_menu', 'ban_menu');
40
  function ban_menu() {
41
  if (function_exists('add_management_page')) {
42
- add_management_page(__('Ban', 'wp-ban'), __('Ban', 'wp-ban'), 'manage_options', 'ban/ban-options.php');
43
  }
44
  }
45
 
@@ -47,10 +47,14 @@ function ban_menu() {
47
  ### Function: Get IP Address
48
  if(!function_exists('get_IP')) {
49
  function get_IP() {
50
- if(empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
51
- $ip_address = $_SERVER["REMOTE_ADDR"];
 
 
 
 
52
  } else {
53
- $ip_address = $_SERVER["HTTP_X_FORWARDED_FOR"];
54
  }
55
  if(strpos($ip_address, ',') !== false) {
56
  $ip_address = explode(',', $ip_address);
@@ -65,16 +69,16 @@ if(!function_exists('get_IP')) {
65
  function print_banned_message() {
66
  // Credits To Joe (Ttech) - http://blog.fileville.net/
67
  $banned_stats = get_option('banned_stats');
68
- $banned_stats['count'] = (intval($banned_stats['count'])+1);
69
- $banned_stats['users'][get_IP()] = intval($banned_stats['users'][get_IP()]+1);
70
  update_option('banned_stats', $banned_stats);
71
  $banned_message = stripslashes(get_option('banned_message'));
72
  $banned_message = str_replace("%SITE_NAME%", get_option('blogname'), $banned_message);
73
  $banned_message = str_replace("%SITE_URL%", get_option('siteurl'), $banned_message);
74
- $banned_message = str_replace("%USER_ATTEMPTS_COUNT%", $banned_stats['users'][get_IP()], $banned_message);
75
  $banned_message = str_replace("%USER_IP%", get_IP(), $banned_message);
76
  $banned_message = str_replace("%USER_HOSTNAME%", @gethostbyaddr(get_IP()), $banned_message);
77
- $banned_message = str_replace("%TOTAL_ATTEMPTS_COUNT%", $banned_stats['count'], $banned_message);
78
  echo $banned_message;
79
  exit();
80
  }
@@ -118,6 +122,7 @@ function banned() {
118
  $banned_ips_range = get_option('banned_ips_range');
119
  $banned_hosts = get_option('banned_hosts');
120
  $banned_referers = get_option('banned_referers');
 
121
  $banned_exclude_ips = get_option('banned_exclude_ips');
122
  $is_excluded = false;
123
  if(!empty($banned_exclude_ips)) {
@@ -133,6 +138,7 @@ function banned() {
133
  process_ban_ip_range($banned_ips_range);
134
  process_ban($banned_hosts, @gethostbyaddr(get_IP()));
135
  process_ban($banned_referers, $_SERVER['HTTP_REFERER']);
 
136
  }
137
  }
138
 
@@ -154,7 +160,7 @@ function check_ip_within_range($ip, $range_start, $range_end) {
154
  $range_start = ip2long($range_start);
155
  $range_end = ip2long($range_end);
156
  $ip = ip2long($ip);
157
- if($ip >= $range_start && $ip <= $range_end) {
158
  return true;
159
  }
160
  return false;
@@ -187,8 +193,16 @@ function is_admin_referer($check) {
187
  }
188
 
189
 
 
 
 
 
 
 
 
 
190
  ### Function: Create Ban Options
191
- add_action('activate_ban/ban.php', 'ban_init');
192
  function ban_init() {
193
  global $wpdb;
194
  $banned_ips = array();
@@ -214,5 +228,7 @@ function ban_init() {
214
  add_option('banned_referers', $banned_referers, 'Banned Referers');
215
  add_option('banned_exclude_ips', $banned_exclude_ips, 'Banned Exclude IP');
216
  add_option('banned_ips_range', $banned_ips_range, 'Banned IP Range');
 
 
217
  }
218
  ?>
1
  <?php
2
  /*
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.30
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  */
10
 
11
 
12
  /*
13
+ Copyright 2008 Lester Chan (email : lesterchan@gmail.com)
14
 
15
  This program is free software; you can redistribute it and/or modify
16
  it under the terms of the GNU General Public License as published by
31
  ### Create Text Domain For Translation
32
  add_action('init', 'ban_textdomain');
33
  function ban_textdomain() {
34
+ load_plugin_textdomain('wp-ban', 'wp-content/plugins/wp-ban');
35
  }
36
 
37
 
39
  add_action('admin_menu', 'ban_menu');
40
  function ban_menu() {
41
  if (function_exists('add_management_page')) {
42
+ add_management_page(__('Ban', 'wp-ban'), __('Ban', 'wp-ban'), 'manage_options', 'wp-ban/ban-options.php');
43
  }
44
  }
45
 
47
  ### Function: Get IP Address
48
  if(!function_exists('get_IP')) {
49
  function get_IP() {
50
+ if(!empty($_SERVER['HTTP_CLIENT_IP'])) {
51
+ $ip_address = $_SERVER['HTTP_CLIENT_IP'];
52
+ } else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
53
+ $ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
54
+ } else if(!empty($_SERVER['REMOTE_ADDR'])) {
55
+ $ip_address = $_SERVER['REMOTE_ADDR'];
56
  } else {
57
+ $ip_address = '';
58
  }
59
  if(strpos($ip_address, ',') !== false) {
60
  $ip_address = explode(',', $ip_address);
69
  function print_banned_message() {
70
  // Credits To Joe (Ttech) - http://blog.fileville.net/
71
  $banned_stats = get_option('banned_stats');
72
+ $banned_stats['count'] = intval($banned_stats['count']) + 1;
73
+ $banned_stats['users'][get_IP()] = intval($banned_stats['users'][get_IP()]) + 1;
74
  update_option('banned_stats', $banned_stats);
75
  $banned_message = stripslashes(get_option('banned_message'));
76
  $banned_message = str_replace("%SITE_NAME%", get_option('blogname'), $banned_message);
77
  $banned_message = str_replace("%SITE_URL%", get_option('siteurl'), $banned_message);
78
+ $banned_message = str_replace("%USER_ATTEMPTS_COUNT%", number_format_i18n($banned_stats['users'][get_IP()]), $banned_message);
79
  $banned_message = str_replace("%USER_IP%", get_IP(), $banned_message);
80
  $banned_message = str_replace("%USER_HOSTNAME%", @gethostbyaddr(get_IP()), $banned_message);
81
+ $banned_message = str_replace("%TOTAL_ATTEMPTS_COUNT%", number_format_i18n($banned_stats['count']), $banned_message);
82
  echo $banned_message;
83
  exit();
84
  }
122
  $banned_ips_range = get_option('banned_ips_range');
123
  $banned_hosts = get_option('banned_hosts');
124
  $banned_referers = get_option('banned_referers');
125
+ $banned_user_agents = get_option('banned_user_agents');
126
  $banned_exclude_ips = get_option('banned_exclude_ips');
127
  $is_excluded = false;
128
  if(!empty($banned_exclude_ips)) {
138
  process_ban_ip_range($banned_ips_range);
139
  process_ban($banned_hosts, @gethostbyaddr(get_IP()));
140
  process_ban($banned_referers, $_SERVER['HTTP_REFERER']);
141
+ process_ban($banned_user_agents, $_SERVER['HTTP_USER_AGENT']);
142
  }
143
  }
144
 
160
  $range_start = ip2long($range_start);
161
  $range_end = ip2long($range_end);
162
  $ip = ip2long($ip);
163
+ if($ip !== false && $ip >= $range_start && $ip <= $range_end) {
164
  return true;
165
  }
166
  return false;
193
  }
194
 
195
 
196
+ ### Function: Check Whether Or Not The User Agent Is Used by Admin
197
+ function is_admin_user_agent($check) {
198
+ $regexp = str_replace ('.', '\\.', $check);
199
+ $regexp = str_replace ('*', '.+', $regexp);
200
+ return ereg("^$regexp$", $_SERVER['HTTP_USER_AGENT']);
201
+ }
202
+
203
+
204
  ### Function: Create Ban Options
205
+ add_action('activate_wp-ban/wp-ban.php', 'ban_init');
206
  function ban_init() {
207
  global $wpdb;
208
  $banned_ips = array();
228
  add_option('banned_referers', $banned_referers, 'Banned Referers');
229
  add_option('banned_exclude_ips', $banned_exclude_ips, 'Banned Exclude IP');
230
  add_option('banned_ips_range', $banned_ips_range, 'Banned IP Range');
231
+ // Database Upgrade For WP-Ban 1.30
232
+ add_option('banned_user_agents', $banned_user_agents, 'Banned User Agents');
233
  }
234
  ?>
ban/wp-ban.pot → wp-ban.pot RENAMED
@@ -1,12 +1,13 @@
1
  msgid ""
2
  msgstr ""
3
- "Project-Id-Version: WP-Ban 1.20\n"
4
- "POT-Creation-Date: \n"
5
- "PO-Revision-Date: 2007-09-30 16:04+0800\n"
6
- "Last-Translator: Lester 'GaMerZ' Chan <gamerz84@hotmail.com>\n"
 
7
  "Language-Team: Lester Chan <gamerz84@hotmail.com>\n"
8
  "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
  "X-Poedit-Language: English\n"
12
  "X-Poedit-Country: SINGAPORE\n"
@@ -14,249 +15,265 @@ msgstr ""
14
  "X-Poedit-Basepath: .\n"
15
  "X-Poedit-SearchPath-0: .\n"
16
 
17
- #: ban-options.php:39
18
- #: ban-options.php:394
19
- msgid "Reset Ban Stats"
20
- msgstr ""
21
-
22
- #: ban-options.php:43
23
- msgid "All IP Ban Stats And Total Ban Stat Reseted"
24
- msgstr ""
25
-
26
  #: ban-options.php:51
27
- msgid "Selected IP Ban Stats Reseted"
28
- msgstr ""
29
-
30
- #: ban-options.php:54
31
- #: ban-options.php:350
32
- msgid "Update Options"
33
- msgstr ""
34
-
35
- #: ban-options.php:68
36
  #, php-format
37
  msgid "This IP '%s' Belongs To The Admin And Will Not Be Added To Ban List"
38
  msgstr ""
39
 
40
- #: ban-options.php:81
41
  #, php-format
42
  msgid "The Admin's IP '%s' Fall Within This Range (%s - %s) And Will Not Be Added To Ban List"
43
  msgstr ""
44
 
45
- #: ban-options.php:91
46
  #, php-format
47
  msgid "This Hostname '%s' Belongs To The Admin And Will Not Be Added To Ban List"
48
  msgstr ""
49
 
50
- #: ban-options.php:101
51
  #, php-format
52
  msgid "This Referer '%s' Belongs To This Site And Will Not Be Added To Ban List"
53
  msgstr ""
54
 
55
- #: ban-options.php:119
56
- #: ban-options.php:265
 
 
 
 
 
57
  msgid "Banned IPs"
58
  msgstr ""
59
 
60
- #: ban-options.php:120
61
- #: ban-options.php:279
62
  msgid "Banned IP Range"
63
  msgstr ""
64
 
65
- #: ban-options.php:121
66
- #: ban-options.php:292
67
  msgid "Banned Host Names"
68
  msgstr ""
69
 
70
- #: ban-options.php:122
71
- #: ban-options.php:306
72
  msgid "Banned Referers"
73
  msgstr ""
74
 
75
- #: ban-options.php:123
 
 
 
 
 
76
  msgid "Banned Excluded IPs"
77
  msgstr ""
78
 
79
- #: ban-options.php:124
80
- #: ban-options.php:334
81
  msgid "Banned Message"
82
  msgstr ""
83
 
84
- #: ban-options.php:128
85
  msgid "Updated"
86
  msgstr ""
87
 
88
- #: ban-options.php:133
89
  msgid "No Ban Option Updated"
90
  msgstr ""
91
 
92
- #: ban-options.php:137
93
- #: ban-options.php:431
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  msgid "UNINSTALL WP-Ban"
95
  msgstr ""
96
 
97
- #: ban-options.php:145
98
  #, php-format
99
  msgid "Setting Key '%s' has been deleted."
100
  msgstr ""
101
 
102
- #: ban-options.php:149
103
  #, php-format
104
  msgid "Error deleting Setting Key '%s'."
105
  msgstr ""
106
 
107
- #: ban-options.php:171
108
- #: ban-options.php:401
109
  msgid "Uninstall WP-Ban"
110
  msgstr ""
111
 
112
- #: ban-options.php:172
113
  #, php-format
114
  msgid "<a href=\"%s\">Click Here</a> To Finish The Uninstallation And WP-Ban Will Be Deactivated Automatically."
115
  msgstr ""
116
 
117
- #: ban-options.php:226
118
- #: ban.php:210
119
  msgid "You Are Banned."
120
  msgstr ""
121
 
122
- #: ban-options.php:255
123
  msgid "Ban Options"
124
  msgstr ""
125
 
126
- #: ban-options.php:259
127
  #, php-format
128
  msgid "Your IP is: <strong>%s</strong><br />Your Host Name is: <strong>%s</strong><br />Your Site URL is: <strong>%s</strong>"
129
  msgstr ""
130
 
131
- #: ban-options.php:260
132
  msgid "Please <strong>DO NOT</strong> ban yourself."
133
  msgstr ""
134
 
135
- #: ban-options.php:266
136
  msgid "Use <strong>*</strong> for wildcards."
137
  msgstr ""
138
 
139
- #: ban-options.php:267
140
- #: ban-options.php:280
141
- #: ban-options.php:294
142
- #: ban-options.php:308
143
- #: ban-options.php:321
 
144
  msgid "Start each entry on a new line."
145
  msgstr ""
146
 
147
- #: ban-options.php:268
148
- #: ban-options.php:281
149
- #: ban-options.php:295
150
- #: ban-options.php:309
151
- #: ban-options.php:322
 
152
  msgid "Examples:"
153
  msgstr ""
154
 
155
- #: ban-options.php:283
156
- #: ban-options.php:311
157
- #: ban-options.php:324
158
  msgid "Notes:"
159
  msgstr ""
160
 
161
- #: ban-options.php:284
162
- #: ban-options.php:325
163
  msgid "No Wildcards Allowed."
164
  msgstr ""
165
 
166
- #: ban-options.php:293
167
- #: ban-options.php:307
 
168
  msgid "Use <strong>*</strong> for wildcards"
169
  msgstr ""
170
 
171
- #: ban-options.php:312
172
  msgid "There are ways to bypass this method of banning."
173
  msgstr ""
174
 
175
- #: ban-options.php:320
 
 
 
 
 
 
 
 
176
  msgid "Banned Exclude IPs"
177
  msgstr ""
178
 
179
- #: ban-options.php:326
180
  msgid "These Users Will Not Get Banned."
181
  msgstr ""
182
 
183
- #: ban-options.php:335
184
  msgid "Allowed Variables:"
185
  msgstr ""
186
 
187
- #: ban-options.php:342
188
  msgid "Restore Default Template"
189
  msgstr ""
190
 
191
- #: ban-options.php:343
192
  msgid "Preview Banned Message"
193
  msgstr ""
194
 
195
- #: ban-options.php:350
196
- msgid "Cancel"
197
  msgstr ""
198
 
199
- #: ban-options.php:358
200
  msgid "Ban Stats"
201
  msgstr ""
202
 
203
- #: ban-options.php:361
204
  msgid "IPs"
205
  msgstr ""
206
 
207
- #: ban-options.php:362
208
  msgid "Attempts"
209
  msgstr ""
210
 
211
- #: ban-options.php:363
212
  msgid "Action"
213
  msgstr ""
214
 
215
- #: ban-options.php:384
216
  msgid "No Attempts"
217
  msgstr ""
218
 
219
- #: ban-options.php:389
220
  msgid "Total Attempts:"
221
  msgstr ""
222
 
223
- #: ban-options.php:391
224
  msgid "Reset all IP ban stats and total ban stat?"
225
  msgstr ""
226
 
227
- #: ban-options.php:394
228
  msgid "You Are About To Reset Ban Stats."
229
  msgstr ""
230
 
231
- #: ban-options.php:394
232
  msgid "This Action Is Not Reversible. Are you sure?"
233
  msgstr ""
234
 
235
- #: ban-options.php:403
236
  msgid "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."
237
  msgstr ""
238
 
239
- #: ban-options.php:406
240
  msgid "WARNING:"
241
  msgstr ""
242
 
243
- #: ban-options.php:407
244
  msgid "Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to back up all the data first."
245
  msgstr ""
246
 
247
- #: ban-options.php:410
248
  msgid "The following WordPress Options will be DELETED:"
249
  msgstr ""
250
 
251
- #: ban-options.php:414
252
  msgid "WordPress Options"
253
  msgstr ""
254
 
255
- #: ban-options.php:430
256
  msgid "Yes"
257
  msgstr ""
258
 
259
- #: ban-options.php:431
260
  msgid ""
261
  "You Are About To Uninstall WP-Ban From WordPress.\\n"
262
  "This Action Is Not Reversible.\\n"
@@ -264,7 +281,7 @@ msgid ""
264
  " Choose [Cancel] To Stop, [OK] To Uninstall."
265
  msgstr ""
266
 
267
- #: ban.php:42
268
  msgid "Ban"
269
  msgstr ""
270
 
1
  msgid ""
2
  msgstr ""
3
+ "Project-Id-Version: WP-Ban 1.30\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2008-05-30 02:01+0800\n"
6
+ "PO-Revision-Date: 2008-05-30 02:01+0800\n"
7
+ "Last-Translator: Lester Chan <lesterchan@gmail.com>\n"
8
  "Language-Team: Lester Chan <gamerz84@hotmail.com>\n"
9
  "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
  "X-Poedit-Language: English\n"
13
  "X-Poedit-Country: SINGAPORE\n"
15
  "X-Poedit-Basepath: .\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
 
 
 
 
 
 
 
 
 
18
  #: ban-options.php:51
 
 
 
 
 
 
 
 
 
19
  #, php-format
20
  msgid "This IP '%s' Belongs To The Admin And Will Not Be Added To Ban List"
21
  msgstr ""
22
 
23
+ #: ban-options.php:64
24
  #, php-format
25
  msgid "The Admin's IP '%s' Fall Within This Range (%s - %s) And Will Not Be Added To Ban List"
26
  msgstr ""
27
 
28
+ #: ban-options.php:74
29
  #, php-format
30
  msgid "This Hostname '%s' Belongs To The Admin And Will Not Be Added To Ban List"
31
  msgstr ""
32
 
33
+ #: ban-options.php:84
34
  #, php-format
35
  msgid "This Referer '%s' Belongs To This Site And Will Not Be Added To Ban List"
36
  msgstr ""
37
 
38
+ #: ban-options.php:94
39
+ #, php-format
40
+ msgid "This User Agent '%s' Is Used By The Current Admin And Will Not Be Added To Ban List"
41
+ msgstr ""
42
+
43
+ #: ban-options.php:113
44
+ #: ban-options.php:286
45
  msgid "Banned IPs"
46
  msgstr ""
47
 
48
+ #: ban-options.php:114
49
+ #: ban-options.php:300
50
  msgid "Banned IP Range"
51
  msgstr ""
52
 
53
+ #: ban-options.php:115
54
+ #: ban-options.php:313
55
  msgid "Banned Host Names"
56
  msgstr ""
57
 
58
+ #: ban-options.php:116
59
+ #: ban-options.php:327
60
  msgid "Banned Referers"
61
  msgstr ""
62
 
63
+ #: ban-options.php:117
64
+ #: ban-options.php:341
65
+ msgid "Banned User Agents"
66
+ msgstr ""
67
+
68
+ #: ban-options.php:118
69
  msgid "Banned Excluded IPs"
70
  msgstr ""
71
 
72
+ #: ban-options.php:119
73
+ #: ban-options.php:371
74
  msgid "Banned Message"
75
  msgstr ""
76
 
77
+ #: ban-options.php:123
78
  msgid "Updated"
79
  msgstr ""
80
 
81
+ #: ban-options.php:128
82
  msgid "No Ban Option Updated"
83
  msgstr ""
84
 
85
+ #: ban-options.php:135
86
+ #: ban-options.php:436
87
+ msgid "Reset Ban Stats"
88
+ msgstr ""
89
+
90
+ #: ban-options.php:139
91
+ msgid "All IP Ban Stats And Total Ban Stat Reseted"
92
+ msgstr ""
93
+
94
+ #: ban-options.php:147
95
+ msgid "Selected IP Ban Stats Reseted"
96
+ msgstr ""
97
+
98
+ #: ban-options.php:151
99
+ #: ban-options.php:476
100
  msgid "UNINSTALL WP-Ban"
101
  msgstr ""
102
 
103
+ #: ban-options.php:159
104
  #, php-format
105
  msgid "Setting Key '%s' has been deleted."
106
  msgstr ""
107
 
108
+ #: ban-options.php:163
109
  #, php-format
110
  msgid "Error deleting Setting Key '%s'."
111
  msgstr ""
112
 
113
+ #: ban-options.php:185
114
+ #: ban-options.php:444
115
  msgid "Uninstall WP-Ban"
116
  msgstr ""
117
 
118
+ #: ban-options.php:186
119
  #, php-format
120
  msgid "<a href=\"%s\">Click Here</a> To Finish The Uninstallation And WP-Ban Will Be Deactivated Automatically."
121
  msgstr ""
122
 
123
+ #: ban-options.php:247
124
+ #: wp-ban.php:224
125
  msgid "You Are Banned."
126
  msgstr ""
127
 
128
+ #: ban-options.php:276
129
  msgid "Ban Options"
130
  msgstr ""
131
 
132
+ #: ban-options.php:280
133
  #, php-format
134
  msgid "Your IP is: <strong>%s</strong><br />Your Host Name is: <strong>%s</strong><br />Your Site URL is: <strong>%s</strong>"
135
  msgstr ""
136
 
137
+ #: ban-options.php:281
138
  msgid "Please <strong>DO NOT</strong> ban yourself."
139
  msgstr ""
140
 
141
+ #: ban-options.php:287
142
  msgid "Use <strong>*</strong> for wildcards."
143
  msgstr ""
144
 
145
+ #: ban-options.php:288
146
+ #: ban-options.php:301
147
+ #: ban-options.php:315
148
+ #: ban-options.php:329
149
+ #: ban-options.php:343
150
+ #: ban-options.php:358
151
  msgid "Start each entry on a new line."
152
  msgstr ""
153
 
154
+ #: ban-options.php:289
155
+ #: ban-options.php:302
156
+ #: ban-options.php:316
157
+ #: ban-options.php:330
158
+ #: ban-options.php:344
159
+ #: ban-options.php:359
160
  msgid "Examples:"
161
  msgstr ""
162
 
163
+ #: ban-options.php:304
164
+ #: ban-options.php:332
165
+ #: ban-options.php:361
166
  msgid "Notes:"
167
  msgstr ""
168
 
169
+ #: ban-options.php:305
170
+ #: ban-options.php:362
171
  msgid "No Wildcards Allowed."
172
  msgstr ""
173
 
174
+ #: ban-options.php:314
175
+ #: ban-options.php:328
176
+ #: ban-options.php:342
177
  msgid "Use <strong>*</strong> for wildcards"
178
  msgstr ""
179
 
180
+ #: ban-options.php:333
181
  msgid "There are ways to bypass this method of banning."
182
  msgstr ""
183
 
184
+ #: ban-options.php:348
185
+ msgid "Suggestions:"
186
+ msgstr ""
187
+
188
+ #: ban-options.php:349
189
+ msgid "See <a href=\"http://www.user-agents.org/\">http://www.user-agents.org/</a>"
190
+ msgstr ""
191
+
192
+ #: ban-options.php:357
193
  msgid "Banned Exclude IPs"
194
  msgstr ""
195
 
196
+ #: ban-options.php:363
197
  msgid "These Users Will Not Get Banned."
198
  msgstr ""
199
 
200
+ #: ban-options.php:372
201
  msgid "Allowed Variables:"
202
  msgstr ""
203
 
204
+ #: ban-options.php:379
205
  msgid "Restore Default Template"
206
  msgstr ""
207
 
208
+ #: ban-options.php:380
209
  msgid "Preview Banned Message"
210
  msgstr ""
211
 
212
+ #: ban-options.php:388
213
+ msgid "Save Changes"
214
  msgstr ""
215
 
216
+ #: ban-options.php:396
217
  msgid "Ban Stats"
218
  msgstr ""
219
 
220
+ #: ban-options.php:401
221
  msgid "IPs"
222
  msgstr ""
223
 
224
+ #: ban-options.php:402
225
  msgid "Attempts"
226
  msgstr ""
227
 
228
+ #: ban-options.php:403
229
  msgid "Action"
230
  msgstr ""
231
 
232
+ #: ban-options.php:426
233
  msgid "No Attempts"
234
  msgstr ""
235
 
236
+ #: ban-options.php:431
237
  msgid "Total Attempts:"
238
  msgstr ""
239
 
240
+ #: ban-options.php:433
241
  msgid "Reset all IP ban stats and total ban stat?"
242
  msgstr ""
243
 
244
+ #: ban-options.php:436
245
  msgid "You Are About To Reset Ban Stats."
246
  msgstr ""
247
 
248
+ #: ban-options.php:436
249
  msgid "This Action Is Not Reversible. Are you sure?"
250
  msgstr ""
251
 
252
+ #: ban-options.php:446
253
  msgid "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."
254
  msgstr ""
255
 
256
+ #: ban-options.php:449
257
  msgid "WARNING:"
258
  msgstr ""
259
 
260
+ #: ban-options.php:450
261
  msgid "Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to back up all the data first."
262
  msgstr ""
263
 
264
+ #: ban-options.php:453
265
  msgid "The following WordPress Options will be DELETED:"
266
  msgstr ""
267
 
268
+ #: ban-options.php:458
269
  msgid "WordPress Options"
270
  msgstr ""
271
 
272
+ #: ban-options.php:475
273
  msgid "Yes"
274
  msgstr ""
275
 
276
+ #: ban-options.php:476
277
  msgid ""
278
  "You Are About To Uninstall WP-Ban From WordPress.\\n"
279
  "This Action Is Not Reversible.\\n"
281
  " Choose [Cancel] To Stop, [OK] To Uninstall."
282
  msgstr ""
283
 
284
+ #: wp-ban.php:42
285
  msgid "Ban"
286
  msgstr ""
287