Bad Behavior - Version 2.0.15

Version Description

Download this release

Release Info

Developer error
Plugin Icon wp plugin Bad Behavior
Version 2.0.15
Comparing to
See all releases

Code changes from version 2.0.14 to 2.0.15

README.txt CHANGED
@@ -3,8 +3,8 @@ Tags: comment,trackback,referrer,spam,robot,antispam
3
  Contributors: error, MarkJaquith, Firas, skeltoac
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=error%40ioerror%2eus&item_name=Bad%20Behavior%20%28From%20WordPress%20Page%29&no_shipping=1&cn=Comments%20about%20Bad%20Behavior&tax=0&currency_code=USD&bn=PP%2dDonationsBF&charset=UTF%2d8
5
  Requires at least: 1.2
6
- Tested up to: 2.5
7
- Stable tag: 2.0.14
8
 
9
  Bad Behavior is a set of PHP scripts which prevents spambots and other
10
  malicious accesses to your PHP-based Web site. It prevents comment spam,
3
  Contributors: error, MarkJaquith, Firas, skeltoac
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=error%40ioerror%2eus&item_name=Bad%20Behavior%20%28From%20WordPress%20Page%29&no_shipping=1&cn=Comments%20about%20Bad%20Behavior&tax=0&currency_code=USD&bn=PP%2dDonationsBF&charset=UTF%2d8
5
  Requires at least: 1.2
6
+ Tested up to: 2.6
7
+ Stable tag: 2.0.15
8
 
9
  Bad Behavior is a set of PHP scripts which prevents spambots and other
10
  malicious accesses to your PHP-based Web site. It prevents comment spam,
bad-behavior-generic.php CHANGED
@@ -36,7 +36,8 @@ $bb2_settings_defaults = array(
36
  'log_table' => 'bad_behavior',
37
  'display_stats' => true,
38
  'strict' => false,
39
- 'verbose' => false
 
40
  );
41
 
42
  // Bad Behavior callback functions.
36
  'log_table' => 'bad_behavior',
37
  'display_stats' => true,
38
  'strict' => false,
39
+ 'verbose' => false,
40
+ 'logging' => true
41
  );
42
 
43
  // Bad Behavior callback functions.
bad-behavior-lifetype.php CHANGED
@@ -94,10 +94,12 @@ function bb2_read_settings() {
94
  $displayStats = $config->getValue( 'bb2_display_stats', true );
95
  $verbose = $config->getValue( 'bb2_verbose', false );
96
  $isInstalled = $config->getValue( 'bb2_installed', false );
 
97
 
98
  return array('log_table' => $prefix . 'bad_behavior',
99
  'display_stats' => $displayStats,
100
  'verbose' => $verbose,
 
101
  'is_installed' => $isInstalled );
102
  }
103
 
@@ -115,7 +117,7 @@ function bb2_write_settings($settings) {
115
  // installation
116
  function bb2_install() {
117
  $settings = bb2_read_settings();
118
- if( $settings['is_installed'] == false )
119
  {
120
  bb2_db_query(bb2_table_structure($settings['log_table']));
121
  $settings['is_installed'] = true;
94
  $displayStats = $config->getValue( 'bb2_display_stats', true );
95
  $verbose = $config->getValue( 'bb2_verbose', false );
96
  $isInstalled = $config->getValue( 'bb2_installed', false );
97
+ $logging = $config->getValue( 'bb2_logging', false );
98
 
99
  return array('log_table' => $prefix . 'bad_behavior',
100
  'display_stats' => $displayStats,
101
  'verbose' => $verbose,
102
+ 'logging' => $logging,
103
  'is_installed' => $isInstalled );
104
  }
105
 
117
  // installation
118
  function bb2_install() {
119
  $settings = bb2_read_settings();
120
+ if( $settings['is_installed'] == false && $settings['logging'] )
121
  {
122
  bb2_db_query(bb2_table_structure($settings['log_table']));
123
  $settings['is_installed'] = true;
bad-behavior-mediawiki.php CHANGED
@@ -29,7 +29,8 @@ $bb2_settings_defaults = array(
29
  'log_table' => $wgDBprefix . 'bad_behavior',
30
  'display_stats' => true,
31
  'strict' => false,
32
- 'verbose' => false
 
33
  );
34
 
35
  define('BB2_CWD', dirname(__FILE__));
@@ -105,6 +106,7 @@ function bb2_write_settings($settings) {
105
  function bb2_install() {
106
  $settings = bb2_read_settings();
107
  if (defined('BB2_NO_CREATE')) return;
 
108
  bb2_db_query(bb2_table_structure($settings['log_table']));
109
  }
110
 
29
  'log_table' => $wgDBprefix . 'bad_behavior',
30
  'display_stats' => true,
31
  'strict' => false,
32
+ 'verbose' => false,
33
+ 'logging' => true
34
  );
35
 
36
  define('BB2_CWD', dirname(__FILE__));
106
  function bb2_install() {
107
  $settings = bb2_read_settings();
108
  if (defined('BB2_NO_CREATE')) return;
109
+ if (!$settings['logging']) return;
110
  bb2_db_query(bb2_table_structure($settings['log_table']));
111
  }
112
 
bad-behavior-wordpress.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Bad Behavior
4
- Version: 2.0.14
5
  Description: Deny automated spambots access to your PHP-based Web site.
6
  Plugin URI: http://www.bad-behavior.ioerror.us/
7
  Author: Michael Hampton
@@ -106,7 +106,7 @@ function bb2_read_settings() {
106
  // Add in default settings when they aren't yet present in WP
107
  $settings = get_settings('bad_behavior_settings');
108
  if (!$settings) $settings = array();
109
- return array_merge(array('log_table' => $wpdb->prefix . 'bad_behavior', 'display_stats' => true, 'strict' => false, 'verbose' => false), $settings);
110
  }
111
 
112
  // write settings to database
@@ -117,6 +117,7 @@ function bb2_write_settings($settings) {
117
  // installation
118
  function bb2_install() {
119
  $settings = bb2_read_settings();
 
120
  bb2_db_query(bb2_table_structure($settings['log_table']));
121
  }
122
 
1
  <?php
2
  /*
3
  Plugin Name: Bad Behavior
4
+ Version: 2.0.15
5
  Description: Deny automated spambots access to your PHP-based Web site.
6
  Plugin URI: http://www.bad-behavior.ioerror.us/
7
  Author: Michael Hampton
106
  // Add in default settings when they aren't yet present in WP
107
  $settings = get_settings('bad_behavior_settings');
108
  if (!$settings) $settings = array();
109
+ return array_merge(array('log_table' => $wpdb->prefix . 'bad_behavior', 'display_stats' => true, 'strict' => false, 'verbose' => false, 'logging' => true), $settings);
110
  }
111
 
112
  // write settings to database
117
  // installation
118
  function bb2_install() {
119
  $settings = bb2_read_settings();
120
+ if (!$settings['logging']) return;
121
  bb2_db_query(bb2_table_structure($settings['log_table']));
122
  }
123
 
bad-behavior/admin.inc.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php if (!defined('BB2_CORE')) die('I said no cheating!');
 
2
 
3
  function bb2_admin_pages() {
4
  if (function_exists('current_user_can')) {
@@ -39,6 +40,18 @@ function bb2_options()
39
  } else {
40
  $settings['verbose'] = false;
41
  }
 
 
 
 
 
 
 
 
 
 
 
 
42
  bb2_write_settings($settings);
43
  ?>
44
  <div id="message" class="updated fade"><p><strong><?php _e('Options saved.') ?></strong></p></div>
@@ -59,7 +72,12 @@ function bb2_options()
59
 
60
  <fieldset class="options">
61
  <legend><?php _e('Logging'); ?></legend>
62
- <p><label><input type="checkbox" name="verbose" value="true" <?php if ($settings['verbose']) { ?>checked="checked" <?php } ?>/> <?php _e('Verbose HTTP request logging'); ?></label></p>
 
 
 
 
 
63
  <legend><?php _e('Strict Mode'); ?></legend>
64
  <p><label><input type="checkbox" name="strict" value="true" <?php if ($settings['strict']) { ?>checked="checked" <?php } ?>/> <?php _e('Strict checking (blocks more spam but may block some people)'); ?></label></p>
65
  </fieldset>
1
  <?php if (!defined('BB2_CORE')) die('I said no cheating!');
2
+ /* This techncially belongs a level up, with the WordPress code. It'll be moved soon. */
3
 
4
  function bb2_admin_pages() {
5
  if (function_exists('current_user_can')) {
40
  } else {
41
  $settings['verbose'] = false;
42
  }
43
+ if ($_POST['logging']) {
44
+ if ($_POST['logging'] == 'verbose') {
45
+ $settings['verbose'] = true;
46
+ $settings['logging'] = true;
47
+ } else {
48
+ $settings['verbose'] = false;
49
+ $settings['logging'] = true;
50
+ }
51
+ } else {
52
+ $settings['verbose'] = false;
53
+ $settings['logging'] = false;
54
+ }
55
  bb2_write_settings($settings);
56
  ?>
57
  <div id="message" class="updated fade"><p><strong><?php _e('Options saved.') ?></strong></p></div>
72
 
73
  <fieldset class="options">
74
  <legend><?php _e('Logging'); ?></legend>
75
+ <p><label><input type="radio" name="logging" value="verbose" <?php if ($settings['verbose'] && $settings['logging']) { ?>checked="checked" <?php } ?>/> <?php _e('Verbose HTTP request logging'); ?></label></p>
76
+ <p><label><input type="radio" name="logging" value="normal" <?php if ($settings['logging'] && !$settings['verbose']) { ?>checked="checked" <?php } ?>/> <?php _e('Normal HTTP request logging (recommended)'); ?></label></p>
77
+ <p><label><input type="radio" name="logging" value="false" <?php if (!$settings['logging']) { ?>checked="checked" <?php } ?>/> <?php _e('Do not log HTTP requests (not recommended)'); ?></label></p>
78
+ </fieldset>
79
+
80
+ <fieldset class="options">
81
  <legend><?php _e('Strict Mode'); ?></legend>
82
  <p><label><input type="checkbox" name="strict" value="true" <?php if ($settings['strict']) { ?>checked="checked" <?php } ?>/> <?php _e('Strict checking (blocks more spam but may block some people)'); ?></label></p>
83
  </fieldset>
bad-behavior/banned.inc.php CHANGED
@@ -42,6 +42,7 @@ function bb2_display_denial($settings, $key, $previous_key = false)
42
 
43
  function bb2_log_denial($settings, $package, $key, $previous_key=false)
44
  {
 
45
  bb2_db_query(bb2_insert($settings, $package, $key));
46
  }
47
 
42
 
43
  function bb2_log_denial($settings, $package, $key, $previous_key=false)
44
  {
45
+ if (!$settings['logging']) return;
46
  bb2_db_query(bb2_insert($settings, $package, $key));
47
  }
48
 
bad-behavior/core.inc.php CHANGED
@@ -80,7 +80,7 @@ function bb2_approved($settings, $package)
80
  }
81
 
82
  // Decide what to log on approved requests.
83
- if ($settings['verbose'] || empty($package['user_agent'])) {
84
  bb2_db_query(bb2_insert($settings, $package, "00000000"));
85
  }
86
  }
80
  }
81
 
82
  // Decide what to log on approved requests.
83
+ if (($settings['verbose'] && $settings['logging']) || empty($package['user_agent'])) {
84
  bb2_db_query(bb2_insert($settings, $package, "00000000"));
85
  }
86
  }
bad-behavior/version.inc.php CHANGED
@@ -1,3 +1,3 @@
1
  <?php if (!defined('BB2_CWD')) die("I said no cheating!");
2
- define('BB2_VERSION', "2.0.14");
3
  ?>
1
  <?php if (!defined('BB2_CWD')) die("I said no cheating!");
2
+ define('BB2_VERSION', "2.0.15");
3
  ?>