WP-Ban - Version 1.62

Version Description

N/A

Download this release

Release Info

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

Code changes from version 1.50 to 1.62

Files changed (11) hide show
  1. ban-options.php +42 -14
  2. ban-preview.php +0 -42
  3. readme.html +0 -425
  4. readme.txt +113 -31
  5. screenshot-1.png +0 -0
  6. screenshot-2.png +0 -0
  7. screenshot-3.png +0 -0
  8. screenshot-4.png +0 -0
  9. wp-ban.mo +0 -0
  10. wp-ban.php +75 -33
  11. wp-ban.pot +29 -15
ban-options.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
3
  +----------------------------------------------------------------+
4
  | |
5
- | WordPress 2.6 Plugin: WP-Ban 1.50 |
6
- | Copyright (c) 2008 Lester "GaMerZ" Chan |
7
  | |
8
  | File Written By: |
9
  | - Lester "GaMerZ" Chan |
@@ -34,6 +34,7 @@ $ban_settings = array('banned_ips', 'banned_hosts', 'banned_stats', 'banned_mess
34
  ### Form Processing
35
  // Update Options
36
  if(!empty($_POST['Submit'])) {
 
37
  $text = '';
38
  $update_ban_queries = array();
39
  $update_ban_text = array();
@@ -133,6 +134,7 @@ if(!empty($_POST['do'])) {
133
  switch($_POST['do']) {
134
  // Credits To Joe (Ttech) - http://blog.fileville.net/
135
  case __('Reset Ban Stats', 'wp-ban'):
 
136
  if($_POST['reset_ban_stats'] == 'yes') {
137
  $banned_stats = array('users' => array(), 'count' => 0);
138
  update_option('banned_stats', $banned_stats);
@@ -149,6 +151,7 @@ if(!empty($_POST['do'])) {
149
  break;
150
  // Uninstall WP-Ban
151
  case __('UNINSTALL WP-Ban', 'wp-ban') :
 
152
  if(trim($_POST['uninstall_ban_yes']) == 'yes') {
153
  echo '<div id="message" class="updated fade">';
154
  echo '<p>';
@@ -244,7 +247,7 @@ switch($mode) {
244
  var default_template;
245
  switch(template) {
246
  case "message":
247
- default_template = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" <?php echo str_replace('"', '\"', get_language_attributes()); ?>>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=<?php echo get_option('blog_charset'); ?>\" />\n<title>%SITE_NAME% - %SITE_URL%</title>\n</head>\n<body>\n<p style=\"text-align: center; font-weight: bold;\"><?php _e('You Are Banned.', 'wp-ban'); ?></p>\n</body>\n</html>";
248
  break;
249
  }
250
  jQuery("#banned_template_" + template).val(default_template);
@@ -263,14 +266,35 @@ switch($mode) {
263
  checked = 0;
264
  }
265
  }
266
- function preview_bannedmessage() {
267
- window.open('<?php echo WP_PLUGIN_URL.'/wp-ban/ban-preview.php'; ?>');
268
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  /* ]]> */
270
  </script>
271
  <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
272
  <!-- Ban Options -->
273
- <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=<?php echo plugin_basename(__FILE__); ?>">
 
274
  <div class="wrap">
275
  <?php screen_icon(); ?>
276
  <h2><?php _e('Ban Options', 'wp-ban'); ?></h2>
@@ -397,25 +421,28 @@ switch($mode) {
397
  <p style="margin: 2px 0">- %SITE_NAME%</p>
398
  <p style="margin: 2px 0">- %SITE_URL%</p>
399
  <p style="margin: 2px 0">- %USER_ATTEMPTS_COUNT%</p>
400
- <p style="margin: 2px 0">- %USER_IP%<br />
401
- <p style="margin: 2px 0">- %USER_HOSTNAME%<br />
402
  <p style="margin: 2px 0">- %TOTAL_ATTEMPTS_COUNT%</p><br />
 
403
  <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-ban'); ?>" onclick="banned_default_templates('message');" class="button" /><br /><br />
404
- <input type="button" name="RestoreDefault" value="<?php _e('Preview Banned Message', 'wp-ban'); ?>" onclick="preview_bannedmessage();" class="button" /><br />
405
  </td>
406
  <td>
407
- <textarea cols="60" rows="20" id="banned_template_message" name="banned_template_message"><?php echo stripslashes(get_option('banned_message')); ?></textarea>
 
408
  </td>
409
  </tr>
410
  </table>
411
- <p class="submit">
412
  <input type="submit" name="Submit" class="button" value="<?php _e('Save Changes', 'wp-ban'); ?>" />
413
  </p>
414
  </div>
415
  </form>
416
  <p>&nbsp;</p>
417
 
418
- <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=<?php echo plugin_basename(__FILE__); ?>">
 
419
  <div class="wrap">
420
  <h3><?php _e('Ban Stats', 'wp-ban'); ?></h3>
421
  <br style="clear" />
@@ -463,7 +490,8 @@ switch($mode) {
463
  <p>&nbsp;</p>
464
 
465
  <!-- Uninstall WP-Ban -->
466
- <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=<?php echo plugin_basename(__FILE__); ?>">
 
467
  <div class="wrap">
468
  <h3><?php _e('Uninstall WP-Ban', 'wp-ban'); ?></h3>
469
  <p>
2
  /*
3
  +----------------------------------------------------------------+
4
  | |
5
+ | WordPress Plugin: WP-Ban |
6
+ | Copyright (c) 2012 Lester "GaMerZ" Chan |
7
  | |
8
  | File Written By: |
9
  | - Lester "GaMerZ" Chan |
34
  ### Form Processing
35
  // Update Options
36
  if(!empty($_POST['Submit'])) {
37
+ check_admin_referer('wp-ban_templates');
38
  $text = '';
39
  $update_ban_queries = array();
40
  $update_ban_text = array();
134
  switch($_POST['do']) {
135
  // Credits To Joe (Ttech) - http://blog.fileville.net/
136
  case __('Reset Ban Stats', 'wp-ban'):
137
+ check_admin_referer('wp-ban_stats');
138
  if($_POST['reset_ban_stats'] == 'yes') {
139
  $banned_stats = array('users' => array(), 'count' => 0);
140
  update_option('banned_stats', $banned_stats);
151
  break;
152
  // Uninstall WP-Ban
153
  case __('UNINSTALL WP-Ban', 'wp-ban') :
154
+ check_admin_referer('wp-ban_uninstall');
155
  if(trim($_POST['uninstall_ban_yes']) == 'yes') {
156
  echo '<div id="message" class="updated fade">';
157
  echo '<p>';
247
  var default_template;
248
  switch(template) {
249
  case "message":
250
+ default_template = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" <?php echo str_replace('"', '\"', get_language_attributes()); ?>>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=<?php echo get_option('blog_charset'); ?>\" />\n<title>%SITE_NAME% - %SITE_URL%</title>\n</head>\n<body>\n<div id=\"wp-ban-container\">\n<p style=\"text-align: center; font-weight: bold;\"><?php _e('You Are Banned.', 'wp-ban'); ?></p>\n</div>\n</body>\n</html>";
251
  break;
252
  }
253
  jQuery("#banned_template_" + template).val(default_template);
266
  checked = 0;
267
  }
268
  }
269
+ jQuery(document).ready(function() {
270
+ jQuery('#show_button').click(function(event)
271
+ {
272
+ event.preventDefault();
273
+ var banned_template_message_el = jQuery('#banned_template_message');
274
+ if(jQuery(banned_template_message_el).is(':hidden'))
275
+ {
276
+ jQuery(this).val('<?php _e('Show Current Banned Message', 'wp-ban'); ?>');
277
+ jQuery('#banned_preview_message').empty();
278
+ jQuery(banned_template_message_el).fadeIn('fast');
279
+ }
280
+ else
281
+ {
282
+ jQuery(this).val('<?php _e('Show Banned Message Template', 'wp-ban'); ?>');
283
+ jQuery.ajax({type: 'GET', url: '<?php echo admin_url('admin-ajax.php', (is_ssl() ? 'https' : 'http')); ?>', data: 'action=ban-admin', cache: false, success: function(data) {
284
+ var html_message = data;
285
+ jQuery(banned_template_message_el).fadeOut('fast', function() {
286
+ jQuery(html_message).filter('#wp-ban-container').appendTo('#banned_preview_message');
287
+ });
288
+ }});
289
+ }
290
+ });
291
+ });
292
  /* ]]> */
293
  </script>
294
  <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
295
  <!-- Ban Options -->
296
+ <form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
297
+ <?php wp_nonce_field('wp-ban_templates'); ?>
298
  <div class="wrap">
299
  <?php screen_icon(); ?>
300
  <h2><?php _e('Ban Options', 'wp-ban'); ?></h2>
421
  <p style="margin: 2px 0">- %SITE_NAME%</p>
422
  <p style="margin: 2px 0">- %SITE_URL%</p>
423
  <p style="margin: 2px 0">- %USER_ATTEMPTS_COUNT%</p>
424
+ <p style="margin: 2px 0">- %USER_IP%</p>
425
+ <p style="margin: 2px 0">- %USER_HOSTNAME%</p>
426
  <p style="margin: 2px 0">- %TOTAL_ATTEMPTS_COUNT%</p><br />
427
+ <p><?php printf(__('Note: Your message must be within %s', 'wp-ban'), htmlspecialchars('<div id="wp-ban-container"></div>')); ?></p><br />
428
  <input type="button" name="RestoreDefault" value="<?php _e('Restore Default Template', 'wp-ban'); ?>" onclick="banned_default_templates('message');" class="button" /><br /><br />
429
+ <input type="button" id="show_button" value="<?php _e('Show Current Banned Message', 'wp-ban'); ?>" class="button" /><br />
430
  </td>
431
  <td>
432
+ <textarea cols="100" style="width: 100%;" rows="20" id="banned_template_message" name="banned_template_message"><?php echo stripslashes(get_option('banned_message')); ?></textarea>
433
+ <div id="banned_preview_message"></div>
434
  </td>
435
  </tr>
436
  </table>
437
+ <p style="text-align: center;">
438
  <input type="submit" name="Submit" class="button" value="<?php _e('Save Changes', 'wp-ban'); ?>" />
439
  </p>
440
  </div>
441
  </form>
442
  <p>&nbsp;</p>
443
 
444
+ <form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
445
+ <?php wp_nonce_field('wp-ban_stats'); ?>
446
  <div class="wrap">
447
  <h3><?php _e('Ban Stats', 'wp-ban'); ?></h3>
448
  <br style="clear" />
490
  <p>&nbsp;</p>
491
 
492
  <!-- Uninstall WP-Ban -->
493
+ <form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
494
+ <?php wp_nonce_field('wp-ban_uninstall'); ?>
495
  <div class="wrap">
496
  <h3><?php _e('Uninstall WP-Ban', 'wp-ban'); ?></h3>
497
  <p>
ban-preview.php DELETED
@@ -1,42 +0,0 @@
1
- <?php
2
- /*
3
- +----------------------------------------------------------------+
4
- | |
5
- | WordPress 2.6 Plugin: WP-Ban 1.50 |
6
- | Copyright (c) 2008 Lester "GaMerZ" Chan |
7
- | |
8
- | File Written By: |
9
- | - Lester "GaMerZ" Chan |
10
- | - http://lesterchan.net |
11
- | |
12
- | File Information: |
13
- | - Banned Message Preview |
14
- | - wp-content/plugins/wp-ban/ban-preview.php |
15
- | |
16
- +----------------------------------------------------------------+
17
- */
18
-
19
-
20
- ### Require wp-config.php
21
- $wp_root = '../../..';
22
- if (file_exists($wp_root.'/wp-load.php')) {
23
- require_once($wp_root.'/wp-load.php');
24
- } else {
25
- require_once($wp_root.'/wp-config.php');
26
- }
27
-
28
-
29
- ### Display Banned Message
30
- $banned_stats = get_option('banned_stats');
31
- $banned_stats['count'] = number_format_i18n(intval($banned_stats['count']));
32
- $banned_stats['users'][get_IP()] = number_format_i18n(intval($banned_stats['users'][get_IP()]));
33
- $banned_message = stripslashes(get_option('banned_message'));
34
- $banned_message = str_replace("%SITE_NAME%", get_option('blogname'), $banned_message);
35
- $banned_message = str_replace("%SITE_URL%", get_option('siteurl'), $banned_message);
36
- $banned_message = str_replace("%USER_ATTEMPTS_COUNT%", $banned_stats['users'][get_IP()], $banned_message);
37
- $banned_message = str_replace("%USER_IP%", get_IP(), $banned_message);
38
- $banned_message = str_replace("%USER_HOSTNAME%", @gethostbyaddr(get_IP()), $banned_message);
39
- $banned_message = str_replace("%TOTAL_ATTEMPTS_COUNT%", $banned_stats['count'], $banned_message);
40
- echo $banned_message;
41
- exit();
42
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.html DELETED
@@ -1,425 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
- <head>
4
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5
- <title>WP-Ban 1.50 Readme</title>
6
- <style type="text/css" media="screen">
7
- /* Default Style */
8
- BODY {
9
- font-family: Verdana, Arial;
10
- font-size: 12px;
11
- color: #000000;
12
- background: #FFFFFF;
13
- }
14
- P {
15
- padding-left: 10px;
16
- }
17
- BLOCKQUOTE {
18
- margin: 10px 20px 0px 20px;
19
- padding: 10px;
20
- border: 1px solid #8d8d8d;
21
- background-color: #f5f5f5;
22
- }
23
- LI {
24
- margin-top: 20px;
25
- }
26
- UL LI UL LI {
27
- margin-top: 10px;
28
- }
29
- A, A:active, A:link, A:visited {
30
- color: #2d3a4c;
31
- text-decoration: none;
32
- }
33
- A:hover {
34
- color: #5577a5;
35
- text-decoration: underline;
36
- }
37
- /* Place Holder Style */
38
- #Container {
39
- width: 780px;
40
- margin-left: auto;
41
- margin-right: auto;
42
- }
43
- #Content {
44
- background-color: #fafafa;
45
- border: 1px solid #a2b6cb;
46
- padding: 10px;
47
- margin-top: -13px;
48
- }
49
- /* Title Style */
50
- #Title {
51
- font-family: Verdana, Arial;
52
- font-size: 22px;
53
- font-weight: bold;
54
- color: #389aff;
55
- border-bottom: 1px solid #389aff;
56
- margin-bottom: 10px;
57
- }
58
- .SubTitle {
59
- font-family: Verdana, Arial;
60
- font-size: 18px;
61
- font-weight: bold;
62
- color: #5b87b4;
63
- }
64
- .SubSubTitle {
65
- font-family: Verdana, Arial;
66
- font-size: 14px;
67
- font-weight: bold;
68
- color: #73a4d6;
69
- }
70
- /* Tabs */
71
- UL#Tabs {
72
- font-family: Verdana, Arial;
73
- font-size: 12px;
74
- font-weight: bold;
75
- list-style-type: none;
76
- padding-bottom: 28px;
77
- border-bottom: 1px solid #a2b6cb;
78
- margin-bottom: 12px;
79
- z-index: 1;
80
- }
81
- #Tabs LI.Tab {
82
- float: right;
83
- height: 25px;
84
- background-color: #deedfb;
85
- margin: 2px 0px 0px 5px;
86
- border: 1px solid #a2b6cb;
87
- }
88
- #Tabs LI.Tab A {
89
- float: left;
90
- display: block;
91
- color: #666666;
92
- text-decoration: none;
93
- padding: 5px;
94
- }
95
- #Tabs LI.Tab A:hover {
96
- background-color: #bfe0fe;
97
- border-bottom: 1px solid #bfe0fe;
98
- }
99
- /* Selected Tab */
100
- #Tabs LI.SelectedTab {
101
- float: right;
102
- height: 25px;
103
- background-color: #fafafa;
104
- margin: 2px 0px 0px 5px;
105
- border-top: 1px solid #a2b6cb;
106
- border-right: 1px solid #a2b6cb;
107
- border-bottom: 1px solid #fafafa;
108
- border-left: 1px solid #a2b6cb;
109
- }
110
- #Tabs LI.SelectedTab A {
111
- float: left;
112
- display: block;
113
- color: #666666;
114
- text-decoration: none;
115
- padding: 5px;
116
- cursor: default;
117
- }
118
- /* Copyright */
119
- #Copyright {
120
- text-align: center;
121
- }
122
- </style>
123
- <script type="text/javascript">
124
- /* <![CDATA[*/
125
- // Index Page
126
- function index() {
127
- // Tab
128
- document.getElementById('IndexTab').className = 'SelectedTab';
129
- document.getElementById('ChangelogTab').className = 'Tab';
130
- document.getElementById('InstallTab').className = 'Tab';
131
- document.getElementById('UpgradeTab').className = 'Tab';
132
- document.getElementById('UsageTab').className = 'Tab';
133
- // Page
134
- document.getElementById('Index').style.display= 'block';
135
- document.getElementById('Changelog').style.display = 'none';
136
- document.getElementById('Install').style.display = 'none';
137
- document.getElementById('Upgrade').style.display = 'none';
138
- document.getElementById('Usage').style.display = 'none';
139
- }
140
- // Changelog Page
141
- function changelog() {
142
- // Tab
143
- document.getElementById('IndexTab').className = 'Tab';
144
- document.getElementById('ChangelogTab').className = 'SelectedTab';
145
- document.getElementById('InstallTab').className = 'Tab';
146
- document.getElementById('UpgradeTab').className = 'Tab';
147
- document.getElementById('UsageTab').className = 'Tab';
148
- // Page
149
- document.getElementById('Index').style.display = 'none';
150
- document.getElementById('Changelog').style.display = 'block';
151
- document.getElementById('Install').style.display = 'none';
152
- document.getElementById('Upgrade').style.display = 'none';
153
- document.getElementById('Usage').style.display = 'none';
154
- }
155
- // Installation Page
156
- function install() {
157
- // Tab
158
- document.getElementById('IndexTab').className = 'Tab';
159
- document.getElementById('ChangelogTab').className = 'Tab';
160
- document.getElementById('InstallTab').className = 'SelectedTab';
161
- document.getElementById('UpgradeTab').className = 'Tab';
162
- document.getElementById('UsageTab').className = 'Tab';
163
- // Page
164
- document.getElementById('Index').style.display= 'none';
165
- document.getElementById('Changelog').style.display = 'none';
166
- document.getElementById('Install').style.display = 'block';
167
- document.getElementById('Upgrade').style.display = 'none';
168
- document.getElementById('Usage').style.display = 'none';
169
- }
170
- // Upgrade Page
171
- function upgrade() {
172
- // Tab
173
- document.getElementById('IndexTab').className = 'Tab';
174
- document.getElementById('ChangelogTab').className = 'Tab';
175
- document.getElementById('InstallTab').className = 'Tab';
176
- document.getElementById('UpgradeTab').className = 'SelectedTab';
177
- document.getElementById('UsageTab').className = 'Tab';
178
- // Page
179
- document.getElementById('Index').style.display= 'none';
180
- document.getElementById('Changelog').style.display = 'none';
181
- document.getElementById('Install').style.display = 'none';
182
- document.getElementById('Upgrade').style.display = 'block';
183
- document.getElementById('Usage').style.display = 'none';
184
- }
185
- // Usage Page
186
- function usage() {
187
- // Tab
188
- document.getElementById('IndexTab').className = 'Tab';
189
- document.getElementById('ChangelogTab').className = 'Tab';
190
- document.getElementById('InstallTab').className = 'Tab';
191
- document.getElementById('UpgradeTab').className = 'Tab';
192
- document.getElementById('UsageTab').className = 'SelectedTab';
193
- // Page
194
- document.getElementById('Index').style.display= 'none';
195
- document.getElementById('Changelog').style.display = 'none';
196
- document.getElementById('Install').style.display = 'none';
197
- document.getElementById('Upgrade').style.display = 'none';
198
- document.getElementById('Usage').style.display = 'block';
199
- }
200
- /* ]]> */
201
- </script>
202
- </head>
203
- <body>
204
- <div id="Container">
205
- <!-- Title -->
206
- <div id="Title">WP-Ban 1.50&nbsp;&nbsp;&nbsp;<span style="color: #aaaaaa;">Readme</span></div>
207
-
208
- <!-- Tabs -->
209
- <ul id="Tabs">
210
- <li id="UsageTab" class="Tab"><a href="#Usage" onclick="usage(); return false;" title="Usage Instructions">Usage</a></li>
211
- <li id="UpgradeTab" class="Tab"><a href="#Upgrade" onclick="upgrade(); return false;" title="Upgrade Instructions">Upgrade</a></li>
212
- <li id="InstallTab" class="Tab"><a href="#Installation" onclick="install(); return false;" title="Installation Instructions">Installation</a></li>
213
- <li id="ChangelogTab" class="Tab"><a href="#Changelog" onclick="changelog(); return false;" title="Changelog">Changelog</a></li>
214
- <li id="IndexTab" class="SelectedTab"><a href="#Index" onclick="index(); return false;" title="Index Instructions">Index</a></li>
215
- </ul>
216
-
217
- <!-- Content -->
218
- <div id="Content">
219
- <!-- Index -->
220
- <div id="Index">
221
- <div class="SubTitle">&raquo; Index</div>
222
- <div class="SubSubTitle">Plugin Information</div>
223
- <p>
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>
230
- </p>
231
- <p>
232
- <strong>Features:</strong><br />
233
- <strong>&raquo;</strong> 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.
234
- </p>
235
- <p>
236
- <strong>Download:</strong><br />
237
- <strong>&raquo;</strong> <a href="http://downloads.wordpress.org/plugin/wp-ban.1.50.zip" title="http://downloads.wordpress.org/plugin/wp-ban.1.50.zip">WP-Ban 1.50 For WordPress 2.7.x And 2.8.x</a><br />
238
- <strong>&raquo;</strong> <a href="http://downloads.wordpress.org/plugin/wp-ban.1.31.zip" title="http://downloads.wordpress.org/plugin/wp-ban.1.31.zip">WP-Ban 1.31 For WordPress 2.5.x And 2.6.x</a><br />
239
- <strong>&raquo;</strong> <a href="http://downloads.wordpress.org/plugin/wp-ban.1.20.zip" title="http://downloads.wordpress.org/plugin/wp-ban.1.20.zip">WP-Ban 1.20 For WordPress 2.1.x To 2.3.x</a><br />
240
- <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 />
241
- </p>
242
- <p>
243
- <strong>Screenshots:</strong><br />
244
- <strong>&raquo;</strong> <a href="http://lesterchan.net/wordpress/screenshots/browse/wp-ban/" title="http://lesterchan.net/wordpress/screenshots/browse/wp-ban/">http://lesterchan.net/wordpress/screenshots/browse/wp-ban/</a>
245
- </p>
246
- <p>
247
- <strong>Demo:</strong><br />
248
- <strong>&raquo;</strong> N/A
249
- </p>
250
- <p>
251
- <strong>Development:</strong><br />
252
- <strong>&raquo;</strong> <a href="http://dev.wp-plugins.org/browser/wp-ban/" title="http://dev.wp-plugins.org/browser/wp-ban/">http://dev.wp-plugins.org/browser/wp-ban/</a>
253
- </p>
254
- <p>
255
- <strong>Translations:</strong><br />
256
- <strong>&raquo;</strong> <a href="http://dev.wp-plugins.org/browser/wp-ban/i18n/" title="http://dev.wp-plugins.org/browser/wp-ban/i18n/">http://dev.wp-plugins.org/browser/wp-ban/i18n/</a>
257
- </p>
258
- <p>
259
- <strong>Support Forums:</strong><br />
260
- <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>
261
- </p>
262
- <p>
263
- <strong>Credits:</strong><br />
264
- <strong>&raquo;</strong> Right To Left Language Support by <a href="http://persian-programming.com/" title="http://persian-programming.com/">Kambiz R. Khojasteh</a>.
265
- </p>
266
- <p>
267
- <strong>Note:</strong><br />
268
- <strong>&raquo;</strong> The <strong>Changelog</strong>, <strong>Installation</strong>, <strong>Upgrade</strong>, <strong>Usage</strong> Tab at the top of the page.<br />
269
- </p>
270
- <p>
271
- <strong>Donations:</strong><br />
272
- <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
273
- <script type="text/javascript">
274
- /* <![CDATA[*/
275
- document.write(' <strong>lesterchan@gmail.com</strong>.');
276
- /* ]]> */
277
- </script>
278
- </p>
279
- </div>
280
-
281
- <!-- Changelog -->
282
- <div id="Changelog" style="display: none;">
283
- <div class="SubTitle">&raquo; Changelog</div>
284
- <ul>
285
- <li>
286
- <strong>Version 1.50 (01-06-2009)</strong>
287
- <ul>
288
- <li>NEW: Added "Your User Agent" Details</li>
289
- <li>NEW: Uses jQuery Framework</li>
290
- <li>FIXED: Uses $_SERVER['PHP_SELF'] With plugin_basename(__FILE__) Instead Of Just $_SERVER['REQUEST_URI']</li>
291
- </ul>
292
- </li>
293
- <li>
294
- <strong>Version 1.40 (12-12-2008)</strong>
295
- <ul>
296
- <li>NEW: Works With WordPress 2.7 Only</li>
297
- <li>NEW: Changed Ban Admin Setting Location To 'WP-Admin -> Settings -> Ban'</li>
298
- <li>NEW: Right To Left Language Support by <a href="http://persian-programming.com/" title="http://persian-programming.com/">Kambiz R. Khojasteh</a></li>
299
- <li>NEW: Called ban_textdomain() In ban_init() by <a href="http://persian-programming.com/" title="http://persian-programming.com/">Kambiz R. Khojasteh</a><li>
300
- <li>NEW: Use language_attributes() To Get Attributes Of HTML Tag For Default Template by <a href="http://persian-programming.com/" title="http://persian-programming.com/">Kambiz R. Khojasteh</a></li>
301
- </ul>
302
- </li>
303
- <li>
304
- <strong>Version 1.31 (16-07-2008)</strong>
305
- <ul>
306
- <li>NEW: Works With WordPress 2.6</li>
307
- <li>FIXED: Do Not Ban If IP is "unknown"</li>
308
- </ul>
309
- </li>
310
- <li>
311
- <strong>Version 1.30 (01-06-2008)</strong>
312
- <ul>
313
- <li>NEW: Uses /wp-ban/ Folder Instead Of /ban/</li>
314
- <li>NEW: Uses wp-ban.php Instead Of ban.php</li>
315
- <li>NEW: Uses number_format_i18n()</li>
316
- <li>NEW: IPs Listed In Ban Stats Is Now Sorted Numerically</li>
317
- <li>NEW: Banned By User Agents (By: <a href="http://www.linkedin.com/in/jgbustos">Jorge Garcia de Bustos</a>)</li>
318
- <li>FIXED: "unknown" IPs (By: <a href="http://www.linkedin.com/in/jgbustos">Jorge Garcia de Bustos</a>)</li>
319
- </ul>
320
- </li>
321
- <li>
322
- <strong>Version 1.20 (01-10-2007)</strong>
323
- <ul>
324
- <li>NEW: Ability To Uninstall WP-Ban</li>
325
- <li>NEW: Moved Ban Options From ban.php To ban-options.php</li>
326
- </ul>
327
- </li>
328
- <li>
329
- <strong>Version 1.11 (01-06-2007)</strong>
330
- <ul>
331
- <li>NEW: Banned By Referer URL</li>
332
- <li>NEW: Ability To Exclude Specific IPs From Being Banned</li>
333
- <li>NEW: Added Template Variables For User Attempts Count And Total Attempts Count</li>
334
- <li>FIXED: Suppress gethostbyaddr() Error</li>
335
- </ul>
336
- </li>
337
- <li>
338
- <strong>Version 1.10 (01-02-2007)</strong>
339
- <ul>
340
- <li>NEW: Works For WordPress 2.1 Only</li>
341
- <li>NEW: Move ban.php To ban Folder</li>
342
- <li>NEW: Localize WP-Ban</li>
343
- <li>NEW: Added Ban Attempts Statistics In 'WP-Admin -> Manage -> Ban'</li>
344
- <li>NEW: Move Ban Tab To 'WP-Admin -> Manage'</li>
345
- <li>NEW: Added Toggle All Checkboxes</li>
346
- <li>FIXED: Main Administrator Of The Site Cannot Be Banned</li>
347
- </ul>
348
- </li>
349
- <li>
350
- <strong>Version 1.00 (02-01-2007)</strong>
351
- <ul>
352
- <li>NEW: Initial Release</li>
353
- </ul>
354
- </li>
355
- </ul>
356
- </div>
357
-
358
- <!-- Installation Instructions -->
359
- <div id="Install" style="display: none;">
360
- <div class="SubTitle">&raquo; Installation Instructions</div>
361
- <ol>
362
- <li>
363
- Open <strong>wp-content/plugins</strong> Folder
364
- </li>
365
- <li>
366
- Put:
367
- <blockquote>Folder: wp-ban</blockquote>
368
- </li>
369
- <li>
370
- <strong>Activate</strong> WP-Ban Plugin
371
- </li>
372
- <li>
373
- Refer To <strong>Usage</strong> For Further Instructions
374
- </li>
375
- </ol>
376
- </div>
377
-
378
- <!-- Upgrade Instructions -->
379
- <div id="Upgrade" style="display: none;">
380
- <div class="SubTitle">&raquo; Upgrade Instructions</div>
381
- <div class="SubSubTitle">From v1.0x To v1.50</div>
382
- <ol>
383
- <li>
384
- <strong>Deactivate</strong> WP-Ban Plugin
385
- </li>
386
- <li>
387
- Open <strong>wp-content/plugins</strong> Folder
388
- </li>
389
- <li>
390
- Put/Overwrite:
391
- <blockquote>Folder: wp-ban</blockquote>
392
- </li>
393
- <li>
394
- Delete this folder if exists:
395
- <blockquote>
396
- Folder: ban
397
- </blockquote>
398
- </li>
399
- <li>
400
- <strong>Activate</strong> WP-Ban Plugin
401
- </li>
402
- <li>
403
- Refer To <strong>Usage</strong> For Further Instructions
404
- </li>
405
- </ol>
406
- </div>
407
-
408
- <!-- Usage Instructions -->
409
- <div id="Usage" style="display: none;">
410
- <div class="SubTitle">&raquo; Usage Instructions</div>
411
- <div class="SubSubTitle">General Usage</div>
412
- <ol>
413
- <li>
414
- Go to '<strong>WP-Admin -> Settings -> Ban</strong>'
415
- </li>
416
- <li>
417
- Configure your ban options
418
- </li>
419
- </ol>
420
- </div>
421
- </div>
422
- </div>
423
- <p id="Copyright">WP-Ban 1.50<br />Copyright &copy; 2009 Lester 'GaMerZ' Chan. All Rights Reserved.</p>
424
- </body>
425
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,31 +1,113 @@
1
- === WP-Ban ===
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.8
6
- Stable tag: 1.50
7
-
8
- Ban users by IP, IP Range, host name, user agent and referer url from visiting your WordPress's blog.
9
-
10
- == Description ==
11
-
12
- 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.
13
-
14
- All the information (general, changelog, installation, upgrade, usage) you need about this plugin can be found here: [WP-Ban Readme](http://lesterchan.net/wordpress/readme/wp-ban.html "WP-Ban Readme").
15
- It is the exact same readme.html is included in the zip package.
16
-
17
- == Development Blog ==
18
-
19
- [GaMerZ WordPress Plugins Development Blog](http://lesterchan.net/wordpress/ "GaMerZ WordPress Plugins Development Blog")
20
-
21
- == Installation ==
22
-
23
- [WP-Ban Readme](http://lesterchan.net/wordpress/readme/wp-ban.html "WP-Ban Readme") (Installation Tab)
24
-
25
- == Screenshots ==
26
-
27
- [WP-Ban Screenshots](http://lesterchan.net/wordpress/screenshots/browse/wp-ban/ "WP-Ban Screenshots")
28
-
29
- == Frequently Asked Questions ==
30
-
31
- [WP-Ban Support Forums](http://forums.lesterchan.net/index.php?board=10.0 "WP-Ban Support Forums")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === WP-Ban ===
2
+ 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: 3.9
7
+ Stable tag: trunk
8
+
9
+ Ban users by IP, IP Range, host name, user agent and referrer url from visiting your WordPress's blog.
10
+
11
+ == Description ==
12
+
13
+ It will display a custom ban message when the banned IP, IP range, host name or referrer url that tries to visit you blog. You can also exclude certain IPs from being banned. There will be statistics recorded on how many times they attempt to visit your blog. It allows wildcard matching too.
14
+
15
+ = Development =
16
+ * [https://github.com/lesterchan/wp-ban](https://github.com/lesterchan/wp-ban "https://github.com/lesterchan/wp-ban")
17
+
18
+ = Translations =
19
+ * [http://dev.wp-plugins.org/browser/wp-ban/i18n/](http://dev.wp-plugins.org/browser/wp-ban/i18n/ "http://dev.wp-plugins.org/browser/wp-ban/i18n/")
20
+
21
+ = Credits =
22
+ * Right To Left Language Support by [Kambiz R. Khojasteh](http://persian-programming.com/ "Kambiz R. Khojasteh")
23
+
24
+ = Donations =
25
+ * 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.
26
+
27
+ == Changelog ==
28
+
29
+ = Version 1.62 (12-03-2013) =
30
+ * FIXED: Use a different modifier for preg_match() and use preg_quote() to escape regex
31
+
32
+ = Version 1.61 (11-03-2013) =
33
+ * FIXED: Replace ereg() with preg_match()
34
+
35
+ = Version 1.60 (23-05-2012) =
36
+ * NEW: AJAX Preview Of Current Banned Message
37
+ * NEW: Added nonce To Form
38
+ * FIXED: Don't Process Ban If Any Of The Conditions Are Empty
39
+
40
+ = Version 1.50 (01-06-2009) =
41
+ * NEW: Added "Your User Agent" Details
42
+ * NEW: Uses jQuery Framework
43
+ * FIXED: Uses $_SERVER['PHP_SELF'] With plugin_basename(__FILE__) Instead Of Just $_SERVER['REQUEST_URI']
44
+
45
+ = Version 1.40 (12-12-2008) =
46
+ * NEW: Works With WordPress 2.7 Only
47
+ * NEW: Changed Ban Admin Setting Location To 'WP-Admin -> Settings -> Ban'
48
+ * NEW: Right To Left Language Support by Kambiz R. Khojasteh
49
+ * NEW: Called ban_textdomain() In ban_init() by Kambiz R. Khojasteh
50
+ * NEW: Use language_attributes() To Get Attributes Of HTML Tag For Default Template by Kambiz R. Khojasteh
51
+
52
+ = Version 1.31 (16-07-2008) =
53
+ * NEW: Works With WordPress 2.6
54
+ * FIXED: Do Not Ban If IP is "unknown"
55
+
56
+ = Version 1.30 (01-06-2008) =
57
+ * NEW: Uses /wp-ban/ Folder Instead Of /ban/
58
+ * NEW: Uses wp-ban.php Instead Of ban.php
59
+ * NEW: Uses number_format_i18n()
60
+ * NEW: IPs Listed In Ban Stats Is Now Sorted Numerically
61
+ * NEW: Banned By User Agents (By: Jorge Garcia de Bustos)
62
+ * FIXED: "unknown" IPs (By: Jorge Garcia de Bustos)
63
+
64
+ = Version 1.20 (01-10-2007) =
65
+ * NEW: Ability To Uninstall WP-Ban
66
+ * NEW: Moved Ban Options From ban.php To ban-options.php
67
+
68
+ = Version 1.11 (01-06-2007 =
69
+ * NEW: Banned By Referer URL
70
+ * NEW: Ability To Exclude Specific IPs From Being Banned
71
+ * NEW: Added Template Variables For User Attempts Count And Total Attempts Count
72
+ * FIXED: Suppress gethostbyaddr() Error
73
+
74
+ = Version 1.10 (01-02-2007) =
75
+ * NEW: Works For WordPress 2.1 Only
76
+ * NEW: Move ban.php To ban Folder
77
+ * NEW: Localize WP-Ban
78
+ * NEW: Added Ban Attempts Statistics In 'WP-Admin -> Manage -> Ban'
79
+ * NEW: Move Ban Tab To 'WP-Admin -> Manage'
80
+ * NEW: Added Toggle All Checkboxes
81
+ * FIXED: Main Administrator Of The Site Cannot Be Banned
82
+
83
+ = Version 1.00 (02-01-2007) =
84
+ * NEW: Initial Release
85
+
86
+ == Installation ==
87
+
88
+ 1. Open `wp-content/plugins` Folder
89
+ 2. Put: `Folder: wp-ban`
90
+ 3. Activate `WP-Ban` Plugin
91
+ 4. Go to `WP-Admin -> Settings -> Ban` to configure the plugin
92
+
93
+ == Upgrading ==
94
+
95
+ 1. Deactivate `WP-Ban` Plugin
96
+ 2. Open `wp-content/plugins` Folder
97
+ 3. Put/Overwrite: `Folder: wp-ban`
98
+ 4. Activate `WP-Ban` Plugin
99
+
100
+ == Upgrade Notice ==
101
+
102
+ N/A
103
+
104
+ == Screenshots ==
105
+
106
+ 1. Admin - Ban
107
+ 2. Admin - Ban
108
+ 3. Admin - Ban
109
+ 4. Ban - Message
110
+
111
+ == Frequently Asked Questions ==
112
+
113
+ N/A
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
screenshot-4.png ADDED
Binary file
wp-ban.mo DELETED
Binary file
wp-ban.php CHANGED
@@ -3,14 +3,15 @@
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.50
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
 
9
  */
10
 
11
 
12
- /*
13
- Copyright 2009 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
@@ -65,6 +66,23 @@ if(!function_exists('get_IP')) {
65
  }
66
 
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  ### Function: Print Out Banned Message
69
  function print_banned_message() {
70
  // Credits To Joe (Ttech) - http://blog.fileville.net/
@@ -78,9 +96,9 @@ function print_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
  }
85
 
86
 
@@ -88,9 +106,7 @@ function print_banned_message() {
88
  function process_ban($banarray, $against) {
89
  if(!empty($banarray) && !empty($against)) {
90
  foreach($banarray as $cban) {
91
- $regexp = str_replace ('.', '\\.', $cban);
92
- $regexp = str_replace ('*', '.+', $regexp);
93
- if(ereg("^$regexp$", $against)) {
94
  print_banned_message();
95
  }
96
  }
@@ -123,11 +139,29 @@ function banned() {
123
  return;
124
  }
125
  $banned_ips = get_option('banned_ips');
 
 
 
126
  $banned_ips_range = get_option('banned_ips_range');
 
 
 
127
  $banned_hosts = get_option('banned_hosts');
 
 
 
128
  $banned_referers = get_option('banned_referers');
 
 
 
129
  $banned_user_agents = get_option('banned_user_agents');
 
 
 
130
  $banned_exclude_ips = get_option('banned_exclude_ips');
 
 
 
131
  $is_excluded = false;
132
  if(!empty($banned_exclude_ips)) {
133
  foreach($banned_exclude_ips as $banned_exclude_ip) {
@@ -137,25 +171,25 @@ function banned() {
137
  }
138
  }
139
  }
 
140
  if(!$is_excluded) {
141
- process_ban($banned_ips, $ip);
142
- process_ban_ip_range($banned_ips_range);
143
- process_ban($banned_hosts, @gethostbyaddr($ip));
144
- process_ban($banned_referers, $_SERVER['HTTP_REFERER']);
145
- process_ban($banned_user_agents, $_SERVER['HTTP_USER_AGENT']);
 
 
 
 
 
146
  }
147
  }
148
 
149
 
150
  ### Function: Check Whether Or Not The IP Address Belongs To Admin
151
  function is_admin_ip($check) {
152
- $admin_ip = get_IP();
153
- $regexp = str_replace ('.', '\\.', $check);
154
- $regexp = str_replace ('*', '.+', $regexp);
155
- if(ereg("^$regexp$", $admin_ip)) {
156
- return true;
157
- }
158
- return false;
159
  }
160
 
161
 
@@ -173,23 +207,15 @@ function check_ip_within_range($ip, $range_start, $range_end) {
173
 
174
  ### Function: Check Whether Or Not The Hostname Belongs To Admin
175
  function is_admin_hostname($check) {
176
- $admin_hostname = @gethostbyaddr(get_IP());
177
- $regexp = str_replace ('.', '\\.', $check);
178
- $regexp = str_replace ('*', '.+', $regexp);
179
- if(ereg("^$regexp$", $admin_hostname)) {
180
- return true;
181
- }
182
- return false;
183
  }
184
 
185
 
186
  ### Function: Check Whether Or Not The Referer Belongs To This Site
187
  function is_admin_referer($check) {
188
- $regexp = str_replace ('.', '\\.', $check);
189
- $regexp = str_replace ('*', '.+', $regexp);
190
  $url_patterns = array(get_option('siteurl'), get_option('home'), get_option('siteurl').'/', get_option('home').'/', get_option('siteurl').'/ ', get_option('home').'/ ', $_SERVER['HTTP_REFERER']);
191
  foreach($url_patterns as $url) {
192
- if(ereg("^$regexp$", $url)) {
193
  return true;
194
  }
195
  }
@@ -199,11 +225,10 @@ function is_admin_referer($check) {
199
 
200
  ### Function: Check Whether Or Not The User Agent Is Used by Admin
201
  function is_admin_user_agent($check) {
202
- $regexp = str_replace ('.', '\\.', $check);
203
- $regexp = str_replace ('*', '.+', $regexp);
204
- return ereg("^$regexp$", $_SERVER['HTTP_USER_AGENT']);
205
  }
206
 
 
207
  ### Function: Returns page's language attributes depends on WordPress language
208
  function get_language_attributes($doctype = 'html') {
209
  ob_start();
@@ -214,6 +239,21 @@ function get_language_attributes($doctype = 'html') {
214
  }
215
 
216
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  ### Function: Create Ban Options
218
  add_action('activate_wp-ban/wp-ban.php', 'ban_init');
219
  function ban_init() {
@@ -235,7 +275,9 @@ function ban_init() {
235
  '<title>%SITE_NAME% - %SITE_URL%</title>'."\n".
236
  '</head>'."\n".
237
  '<body>'."\n".
 
238
  '<p style="text-align: center; font-weight: bold;">'.__('You Are Banned.', 'wp-ban').'</p>'."\n".
 
239
  '</body>'."\n".
240
  '</html>', 'Banned Message');
241
  // Database Upgrade For WP-Ban 1.11
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.62
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
+ Text Domain: wp-ban
10
  */
11
 
12
 
13
+ /*
14
+ Copyright 2013 Lester Chan (email : lesterchan@gmail.com)
15
 
16
  This program is free software; you can redistribute it and/or modify
17
  it under the terms of the GNU General Public License as published by
66
  }
67
 
68
 
69
+ ### Function: Preview Banned Message
70
+ add_action('wp_ajax_ban-admin', 'preview_banned_message');
71
+ function preview_banned_message()
72
+ {
73
+ $banned_stats = get_option('banned_stats');
74
+ $banned_message = stripslashes(get_option('banned_message'));
75
+ $banned_message = str_replace("%SITE_NAME%", get_option('blogname'), $banned_message);
76
+ $banned_message = str_replace("%SITE_URL%", get_option('siteurl'), $banned_message);
77
+ $banned_message = str_replace("%USER_ATTEMPTS_COUNT%", number_format_i18n($banned_stats['users'][get_IP()]), $banned_message);
78
+ $banned_message = str_replace("%USER_IP%", get_IP(), $banned_message);
79
+ $banned_message = str_replace("%USER_HOSTNAME%", @gethostbyaddr(get_IP()), $banned_message);
80
+ $banned_message = str_replace("%TOTAL_ATTEMPTS_COUNT%", number_format_i18n($banned_stats['count']), $banned_message);
81
+ echo $banned_message;
82
+ exit();
83
+ }
84
+
85
+
86
  ### Function: Print Out Banned Message
87
  function print_banned_message() {
88
  // Credits To Joe (Ttech) - http://blog.fileville.net/
96
  $banned_message = str_replace("%USER_ATTEMPTS_COUNT%", number_format_i18n($banned_stats['users'][get_IP()]), $banned_message);
97
  $banned_message = str_replace("%USER_IP%", get_IP(), $banned_message);
98
  $banned_message = str_replace("%USER_HOSTNAME%", @gethostbyaddr(get_IP()), $banned_message);
99
+ $banned_message = str_replace("%TOTAL_ATTEMPTS_COUNT%", number_format_i18n($banned_stats['count']), $banned_message);
100
  echo $banned_message;
101
+ exit();
102
  }
103
 
104
 
106
  function process_ban($banarray, $against) {
107
  if(!empty($banarray) && !empty($against)) {
108
  foreach($banarray as $cban) {
109
+ if(preg_match_wildcard($cban, $against)) {
 
 
110
  print_banned_message();
111
  }
112
  }
139
  return;
140
  }
141
  $banned_ips = get_option('banned_ips');
142
+ if(is_array($banned_ips))
143
+ $banned_ips = array_filter($banned_ips);
144
+
145
  $banned_ips_range = get_option('banned_ips_range');
146
+ if(is_array($banned_ips_range))
147
+ $banned_ips_range = array_filter($banned_ips_range);
148
+
149
  $banned_hosts = get_option('banned_hosts');
150
+ if(is_array($banned_hosts))
151
+ $banned_hosts = array_filter($banned_hosts);
152
+
153
  $banned_referers = get_option('banned_referers');
154
+ if(is_array($banned_referers))
155
+ $banned_referers = array_filter($banned_referers);
156
+
157
  $banned_user_agents = get_option('banned_user_agents');
158
+ if(is_array($banned_user_agents))
159
+ $banned_user_agents = array_filter($banned_user_agents);
160
+
161
  $banned_exclude_ips = get_option('banned_exclude_ips');
162
+ if(is_array($banned_exclude_ips))
163
+ $banned_exclude_ips = array_filter($banned_exclude_ips);
164
+
165
  $is_excluded = false;
166
  if(!empty($banned_exclude_ips)) {
167
  foreach($banned_exclude_ips as $banned_exclude_ip) {
171
  }
172
  }
173
  }
174
+
175
  if(!$is_excluded) {
176
+ if(!empty($banned_ips))
177
+ process_ban($banned_ips, $ip);
178
+ if(!empty($banned_ips_range))
179
+ process_ban_ip_range($banned_ips_range);
180
+ if(!empty($banned_hosts))
181
+ process_ban($banned_hosts, @gethostbyaddr($ip));
182
+ if(!empty($banned_referers))
183
+ process_ban($banned_referers, $_SERVER['HTTP_REFERER']);
184
+ if(!empty($banned_user_agents))
185
+ process_ban($banned_user_agents, $_SERVER['HTTP_USER_AGENT']);
186
  }
187
  }
188
 
189
 
190
  ### Function: Check Whether Or Not The IP Address Belongs To Admin
191
  function is_admin_ip($check) {
192
+ return preg_match_wildcard($check, get_IP());
 
 
 
 
 
 
193
  }
194
 
195
 
207
 
208
  ### Function: Check Whether Or Not The Hostname Belongs To Admin
209
  function is_admin_hostname($check) {
210
+ return preg_match_wildcard($check, @gethostbyaddr(get_IP()));
 
 
 
 
 
 
211
  }
212
 
213
 
214
  ### Function: Check Whether Or Not The Referer Belongs To This Site
215
  function is_admin_referer($check) {
 
 
216
  $url_patterns = array(get_option('siteurl'), get_option('home'), get_option('siteurl').'/', get_option('home').'/', get_option('siteurl').'/ ', get_option('home').'/ ', $_SERVER['HTTP_REFERER']);
217
  foreach($url_patterns as $url) {
218
+ if(preg_match_wildcard($check, $url)) {
219
  return true;
220
  }
221
  }
225
 
226
  ### Function: Check Whether Or Not The User Agent Is Used by Admin
227
  function is_admin_user_agent($check) {
228
+ return preg_match_wildcard($check, $_SERVER['HTTP_USER_AGENT']);
 
 
229
  }
230
 
231
+
232
  ### Function: Returns page's language attributes depends on WordPress language
233
  function get_language_attributes($doctype = 'html') {
234
  ob_start();
239
  }
240
 
241
 
242
+ ### Function: Wildcard Check
243
+ function preg_match_wildcard($regex, $subject) {
244
+ $regex = preg_quote($regex, '#');
245
+ $regex = str_replace('\*', '.*', $regex);
246
+ if(preg_match("#^$regex$#", $subject))
247
+ {
248
+ return true;
249
+ }
250
+ else
251
+ {
252
+ return false;
253
+ }
254
+ }
255
+
256
+
257
  ### Function: Create Ban Options
258
  add_action('activate_wp-ban/wp-ban.php', 'ban_init');
259
  function ban_init() {
275
  '<title>%SITE_NAME% - %SITE_URL%</title>'."\n".
276
  '</head>'."\n".
277
  '<body>'."\n".
278
+ '<div id="wp-ban-container">'."\n".
279
  '<p style="text-align: center; font-weight: bold;">'.__('You Are Banned.', 'wp-ban').'</p>'."\n".
280
+ '</div>'."\n".
281
  '</body>'."\n".
282
  '</html>', 'Banned Message');
283
  // Database Upgrade For WP-Ban 1.11
wp-ban.pot CHANGED
@@ -1,43 +1,40 @@
 
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP-Ban 1.50\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2009-06-08 18:34+0800\n"
6
- "PO-Revision-Date: 2009-06-08 18:34+0800\n"
7
- "Last-Translator: Lester Chan <lesterchan@gmail.com>\n"
8
- "Language-Team: Lester Chan <lesterchan@gmail.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"
14
- "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;__ngettext_noop:1,2\n"
15
  "X-Poedit-Basepath: .\n"
16
- "Plural-Forms: nplurals=2; plural=n != 1;\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
  #: ban-options.php:51
20
- #, php-format
21
  msgid "This IP '%s' Belongs To The Admin And Will Not Be Added To Ban List"
22
  msgstr ""
23
 
24
  #: ban-options.php:64
25
- #, php-format
26
  msgid "The Admin's IP '%s' Fall Within This Range (%s - %s) And Will Not Be Added To Ban List"
27
  msgstr ""
28
 
29
  #: ban-options.php:74
30
- #, php-format
31
  msgid "This Hostname '%s' Belongs To The Admin And Will Not Be Added To Ban List"
32
  msgstr ""
33
 
34
  #: ban-options.php:84
35
- #, php-format
36
  msgid "This Referer '%s' Belongs To This Site And Will Not Be Added To Ban List"
37
  msgstr ""
38
 
39
  #: ban-options.php:94
40
- #, php-format
41
  msgid "This User Agent '%s' Is Used By The Current Admin And Will Not Be Added To Ban List"
42
  msgstr ""
43
 
@@ -102,12 +99,10 @@ msgid "UNINSTALL WP-Ban"
102
  msgstr ""
103
 
104
  #: ban-options.php:159
105
- #, php-format
106
  msgid "Setting Key '%s' has been deleted."
107
  msgstr ""
108
 
109
  #: ban-options.php:163
110
- #, php-format
111
  msgid "Error deleting Setting Key '%s'."
112
  msgstr ""
113
 
@@ -117,7 +112,6 @@ msgid "Uninstall WP-Ban"
117
  msgstr ""
118
 
119
  #: ban-options.php:186
120
- #, php-format
121
  msgid "<a href=\"%s\">Click Here</a> To Finish The Uninstallation And WP-Ban Will Be Deactivated Automatically."
122
  msgstr ""
123
 
@@ -309,3 +303,23 @@ msgstr ""
309
  msgid "Ban"
310
  msgstr ""
311
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2010 WP-Ban
2
+ # This file is distributed under the same license as the WP-Ban package.
3
  msgid ""
4
  msgstr ""
5
  "Project-Id-Version: WP-Ban 1.50\n"
6
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/wp-ban\n"
7
+ "POT-Creation-Date: 2011-02-23 15:01:05+00:00\n"
 
 
 
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2011-02-23 23:04+0800\n"
12
+ "Last-Translator: Lester Chan <lesterchan@gmail.com>\n"
13
+ "Language-Team: Lester Chan <lesterchan@gmail.com>\n"
14
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
15
  "X-Poedit-Language: English\n"
16
  "X-Poedit-Country: SINGAPORE\n"
17
+ "X-Poedit-KeywordsList: __\n"
18
  "X-Poedit-Basepath: .\n"
 
19
  "X-Poedit-SearchPath-0: .\n"
20
 
21
  #: ban-options.php:51
 
22
  msgid "This IP '%s' Belongs To The Admin And Will Not Be Added To Ban List"
23
  msgstr ""
24
 
25
  #: ban-options.php:64
 
26
  msgid "The Admin's IP '%s' Fall Within This Range (%s - %s) And Will Not Be Added To Ban List"
27
  msgstr ""
28
 
29
  #: ban-options.php:74
 
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
  msgid "This Referer '%s' Belongs To This Site And Will Not Be Added To Ban List"
35
  msgstr ""
36
 
37
  #: ban-options.php:94
 
38
  msgid "This User Agent '%s' Is Used By The Current Admin And Will Not Be Added To Ban List"
39
  msgstr ""
40
 
99
  msgstr ""
100
 
101
  #: ban-options.php:159
 
102
  msgid "Setting Key '%s' has been deleted."
103
  msgstr ""
104
 
105
  #: ban-options.php:163
 
106
  msgid "Error deleting Setting Key '%s'."
107
  msgstr ""
108
 
112
  msgstr ""
113
 
114
  #: ban-options.php:186
 
115
  msgid "<a href=\"%s\">Click Here</a> To Finish The Uninstallation And WP-Ban Will Be Deactivated Automatically."
116
  msgstr ""
117
 
303
  msgid "Ban"
304
  msgstr ""
305
 
306
+ #. Plugin Name of the plugin/theme
307
+ msgid "WP-Ban"
308
+ msgstr ""
309
+
310
+ #. Plugin URI of the plugin/theme
311
+ msgid "http://lesterchan.net/portfolio/programming/php/"
312
+ msgstr ""
313
+
314
+ #. Description of the plugin/theme
315
+ msgid "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."
316
+ msgstr ""
317
+
318
+ #. Author of the plugin/theme
319
+ msgid "Lester 'GaMerZ' Chan"
320
+ msgstr ""
321
+
322
+ #. Author URI of the plugin/theme
323
+ msgid "http://lesterchan.net"
324
+ msgstr ""
325
+