Bad Behavior - Version 2.0.17

Version Description

Download this release

Release Info

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

Code changes from version 2.0.16 to 2.0.17

README.txt CHANGED
@@ -4,7 +4,7 @@ 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.16
8
 
9
  Welcome to a whole new way of keeping your blog, forum, guestbook, wiki or
10
  content management system free of link spam. Bad Behavior is a PHP-based
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.17
8
 
9
  Welcome to a whole new way of keeping your blog, forum, guestbook, wiki or
10
  content management system free of link spam. Bad Behavior is a PHP-based
bad-behavior-lifetype.php CHANGED
@@ -1,150 +1,163 @@
1
  <?php
2
- /*
3
- http://blog.markplace.net
4
-
5
- Bad Behavior - LifeType Plugin
6
- Copyright (C) 2006 Mark Wu http://blog.markplace.net
7
-
8
- This program is free software; you can redistribute it and/or modify
9
- it under the terms of the GNU General Public License as published by
10
- the Free Software Foundation; either version 2 of the License, or
11
- (at your option) any later version.
12
-
13
- This program is distributed in the hope that it will be useful,
14
- but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- GNU General Public License for more details.
17
-
18
- You should have received a copy of the GNU General Public License
19
- along with this program; if not, write to the Free Software
20
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
- */
22
-
23
- // This file is the entry point for Bad Behavior in LifeType.
24
-
25
- if (!defined('PLOG_CLASS_PATH')) die('No cheating!');
26
-
27
- define('BB2_CWD', PLOG_CLASS_PATH );
28
- define('BB2_EMERGENCY_EMAIL', "admin@yourblog.com" );
29
-
30
- // Bad Behavior callback functions.
31
-
32
- // Return current time in the format preferred by your database.
33
- function bb2_db_date() {
34
- return gmdate('Y-m-d H:i:s');
35
- }
36
-
37
- // Return affected rows from most recent query.
38
- function bb2_db_affected_rows() {
39
- include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
40
- $db =& Db::getDb();
41
 
42
- return $db->Affected_Rows();
43
- }
44
-
45
- // Escape a string for database usage
46
- function bb2_db_escape($string) {
47
- include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
- return Db::qstr($string);
50
- }
 
 
 
51
 
52
- // Return the number of rows in a particular query.
53
- function bb2_db_num_rows($result) {
54
- return $result->RecordCount();
55
- }
56
 
57
- // Run a query and return the results, if any.
58
- // Should return FALSE if an error occurred.
59
- function bb2_db_query($query) {
60
- include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
61
- $db =& Db::getDb();
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
- $result = $db->Execute( $query );
 
 
 
 
 
 
64
 
65
- if (!$result)
66
- return false;
 
 
 
67
 
68
- return $result;
69
- }
 
 
70
 
71
- // Return all rows in a particular query.
72
- // Should contain an array of all rows generated by calling mysql_fetch_assoc()
73
- // or equivalent and appending the result of each call to an array.
74
- function bb2_db_rows($result) {
75
- $rows = array();
76
- while( $row = $result->FetchRow()) {
77
- $rows[] = $row;
78
  }
79
 
80
- return $rows;
81
- }
 
 
 
 
 
 
82
 
83
- // Return emergency contact email address.
84
- function bb2_email() {
85
- return BB2_EMERGENCY_EMAIL;
86
- }
87
-
88
- // retrieve settings from lifetype config
89
- function bb2_read_settings() {
90
- include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
91
- include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
92
- $config =& Config::getConfig();
93
- $prefix = Db::getPrefix();
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
-
106
- // write settings to lifetype config
107
- function bb2_write_settings($settings) {
108
- include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
109
- $config =& Config::getConfig();
110
 
111
- $config->setValue( 'bb2_display_stats', $settings['display_stats'] );
112
- $config->setValue( 'bb2_verbose', $settings['verbose'] );
113
- $config->setValue( 'bb2_installed', $settings['is_installed'] );
114
- $config->save();
115
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
 
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;
124
- bb2_write_settings( $settings );
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  }
126
- }
127
-
128
- // Return the top-level relative path of wherever we are (for cookies)
129
- function bb2_relative_path() {
130
- include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
131
- $config =& Config::getConfig();
132
 
133
- $url = parse_url( $config->getValue( 'base_url' ) );
134
- if( empty($url['path']) )
135
- return '/';
136
- else {
137
- if( substr( $url['path'], -1, 1 ) == '/' )
138
- return $url['path'];
139
- else
140
- return $url['path'] . '/';
 
 
 
 
 
 
141
  }
142
- }
 
 
 
 
 
143
 
144
- // Start Bad Behavior investigation
145
- require_once(BB2_CWD . "/bad-behavior/version.inc.php");
146
- require_once(BB2_CWD . "/bad-behavior/core.inc.php");
147
- bb2_install();
148
- $settings = bb2_read_settings();
149
- bb2_start($settings);
150
- ?>
1
  <?php
2
+ /*
3
+ http://blog.markplace.net
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
+ Bad Behavior - LifeType Plugin
6
+ Copyright (C) 2006 Mark Wu http://blog.markplace.net
7
+
8
+ This program is free software; you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation; either version 2 of the License, or
11
+ (at your option) any later version.
12
+
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program; if not, write to the Free Software
20
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
+ */
22
+
23
+ // This file is the entry point for Bad Behavior in LifeType.
24
 
25
+ if (!defined('PLOG_CLASS_PATH')) die('No cheating!');
26
+
27
+ // Timer start
28
+ $bb2_mtime = explode(" ", microtime());
29
+ $bb2_timer_start = $bb2_mtime[1] + $bb2_mtime[0];
30
 
31
+ define('BB2_CWD', PLOG_CLASS_PATH . "plugins/badbehavior/" );
32
+ define('BB2_EMERGENCY_EMAIL', "admin@yourblog.com" );
33
+ define('BB2_DEFAULT_LOG_TABLE', "bad_behavior" );
 
34
 
35
+ // Bad Behavior callback functions.
36
+
37
+ // Return current time in the format preferred by your database.
38
+ function bb2_db_date() {
39
+ return gmdate('Y-m-d H:i:s');
40
+ }
41
+
42
+ // Return affected rows from most recent query.
43
+ function bb2_db_affected_rows() {
44
+ lt_include( PLOG_CLASS_PATH."class/database/db.class.php" );
45
+ $db =& Db::getDb();
46
+
47
+ return $db->Affected_Rows();
48
+ }
49
+
50
+ // Escape a string for database usage
51
+ function bb2_db_escape($string) {
52
+ lt_include( PLOG_CLASS_PATH."class/database/db.class.php" );
53
 
54
+ return Db::qstr($string);
55
+ }
56
+
57
+ // Return the number of rows in a particular query.
58
+ function bb2_db_num_rows($result) {
59
+ return $result->RecordCount();
60
+ }
61
 
62
+ // Run a query and return the results, if any.
63
+ // Should return FALSE if an error occurred.
64
+ function bb2_db_query($query) {
65
+ lt_include( PLOG_CLASS_PATH."class/database/db.class.php" );
66
+ $db =& Db::getDb();
67
 
68
+ $result = $db->Execute( $query );
69
+
70
+ if (!$result)
71
+ return FALSE;
72
 
73
+ return $result;
 
 
 
 
 
 
74
  }
75
 
76
+ // Return all rows in a particular query.
77
+ // Should contain an array of all rows generated by calling mysql_fetch_assoc()
78
+ // or equivalent and appending the result of each call to an array.
79
+ function bb2_db_rows($result) {
80
+ $rows = array();
81
+ while( $row = $result->FetchRow()) {
82
+ $rows[] = $row;
83
+ }
84
 
85
+ return $rows;
86
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
+ // Return emergency contact email address.
89
+ function bb2_email() {
90
+ return BB2_EMERGENCY_EMAIL;
91
+ }
 
 
 
 
 
 
 
92
 
93
+ // retrieve settings from lifetype config
94
+ function bb2_read_settings() {
95
+ lt_include( PLOG_CLASS_PATH."class/database/db.class.php" );
96
+ lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
97
+ $config =& Config::getConfig();
98
+ $prefix = Db::getPrefix();
99
+ $logTable = $config->getValue( 'bb2_log_table', BB2_DEFAULT_LOG_TABLE );
100
+ $displayStats = $config->getValue( 'bb2_display_stats', true );
101
+ $strict = $config->getValue( 'bb2_strict', false );
102
+ $verbose = $config->getValue( 'bb2_verbose', false );
103
+ $isInstalled = $config->getValue( 'bb2_installed', false );
104
+ $logging = $config->getValue( 'bb2_logging', true );
105
+
106
+ return array('log_table' => $prefix . $logTable,
107
+ 'display_stats' => $displayStats,
108
+ 'strict' => $strict,
109
+ 'verbose' => $verbose,
110
+ 'logging' => $logging,
111
+ 'is_installed' => $isInstalled );
112
+ }
113
 
114
+ // write settings to lifetype config
115
+ function bb2_write_settings($settings) {
116
+ lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
117
+ $config =& Config::getConfig();
118
+ $config->setValue( 'bb2_log_table', BB2_DEFAULT_LOG_TABLE );
119
+ $config->setValue( 'bb2_display_stats', $settings['display_stats'] );
120
+ $config->setValue( 'bb2_strict', $settings['strict'] );
121
+ $config->setValue( 'bb2_verbose', $settings['verbose'] );
122
+ $config->setValue( 'bb2_installed', $settings['is_installed'] );
123
+ $config->save();
124
+ }
125
+
126
+ // installation
127
+ function bb2_install() {
128
+ $settings = bb2_read_settings();
129
+ if( $settings['is_installed'] == false && $settings['logging'] )
130
+ {
131
+ bb2_db_query(bb2_table_structure($settings['log_table']));
132
+ $settings['is_installed'] = true;
133
+ bb2_write_settings( $settings );
134
+ }
135
  }
 
 
 
 
 
 
136
 
137
+ // Return the top-level relative path of wherever we are (for cookies)
138
+ function bb2_relative_path() {
139
+ lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
140
+ $config =& Config::getConfig();
141
+
142
+ $url = parse_url( $config->getValue( 'base_url' ) );
143
+ if( empty($url['path']) )
144
+ return '/';
145
+ else {
146
+ if( substr( $url['path'], -1, 1 ) == '/' )
147
+ return $url['path'];
148
+ else
149
+ return $url['path'] . '/';
150
+ }
151
  }
152
+
153
+ // Load Bad Behavior Core
154
+ lt_include(BB2_CWD . "bad-behavior/core.inc.php");
155
+ bb2_install();
156
+ $settings = bb2_read_settings();
157
+ bb2_start($settings);
158
 
159
+ // Time Stop
160
+ $bb2_mtime = explode(" ", microtime());
161
+ $bb2_timer_stop = $bb2_mtime[1] + $bb2_mtime[0];
162
+ $bb2_timer_total = $bb2_timer_stop - $bb2_timer_start;
163
+ ?>
 
 
bad-behavior/admin.inc.php → bad-behavior-wordpress-admin.php RENAMED
@@ -1,5 +1,4 @@
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')) {
1
  <?php if (!defined('BB2_CORE')) die('I said no cheating!');
 
2
 
3
  function bb2_admin_pages() {
4
  if (function_exists('current_user_can')) {
bad-behavior-wordpress.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Bad Behavior
4
- Version: 2.0.16
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
@@ -160,7 +160,7 @@ require_once(BB2_CWD . "/bad-behavior/core.inc.php");
160
  bb2_install(); // FIXME: see above
161
 
162
  if (is_admin() || strstr($_SERVER['PHP_SELF'], 'wp-admin/')) { // 1.5 kludge
163
- require_once(BB2_CWD . "/bad-behavior/admin.inc.php");
164
  }
165
 
166
  bb2_start(bb2_read_settings());
1
  <?php
2
  /*
3
  Plugin Name: Bad Behavior
4
+ Version: 2.0.17
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
160
  bb2_install(); // FIXME: see above
161
 
162
  if (is_admin() || strstr($_SERVER['PHP_SELF'], 'wp-admin/')) { // 1.5 kludge
163
+ require_once(BB2_CWD . "/bad-behavior-wordpress-admin.php");
164
  }
165
 
166
  bb2_start(bb2_read_settings());
bad-behavior/common_tests.inc.php CHANGED
@@ -96,6 +96,7 @@ function bb2_misc_headers($settings, $package)
96
  if (array_key_exists('X-Aaaaaaaaaaaa', $package['headers_mixed']) || array_key_exists('X-Aaaaaaaaaa', $package['headers_mixed'])) {
97
  return "b9cc1d86";
98
  }
 
99
  if (array_key_exists('Proxy-Connection', $package['headers_mixed'])) {
100
  return "b7830251";
101
  }
96
  if (array_key_exists('X-Aaaaaaaaaaaa', $package['headers_mixed']) || array_key_exists('X-Aaaaaaaaaa', $package['headers_mixed'])) {
97
  return "b9cc1d86";
98
  }
99
+ // Proxy-Connection does not exist and should never be seen in the wild
100
  if (array_key_exists('Proxy-Connection', $package['headers_mixed'])) {
101
  return "b7830251";
102
  }
bad-behavior/post.inc.php CHANGED
@@ -32,9 +32,13 @@ function bb2_post($settings, $package)
32
  // Screen by cookie/JavaScript form add
33
  if (isset($_COOKIE[BB2_COOKIE])) {
34
  $screener1 = explode(" ", $_COOKIE[BB2_COOKIE]);
 
 
35
  }
36
  if (isset($_POST[BB2_COOKIE])) {
37
  $screener2 = explode(" ", $_POST[BB2_COOKIE]);
 
 
38
  }
39
  $screener = max($screener1[0], $screener2[0]);
40
 
32
  // Screen by cookie/JavaScript form add
33
  if (isset($_COOKIE[BB2_COOKIE])) {
34
  $screener1 = explode(" ", $_COOKIE[BB2_COOKIE]);
35
+ } else {
36
+ $screener1 = array(0);
37
  }
38
  if (isset($_POST[BB2_COOKIE])) {
39
  $screener2 = explode(" ", $_POST[BB2_COOKIE]);
40
+ } else {
41
+ $screener2 = array(0);
42
  }
43
  $screener = max($screener1[0], $screener2[0]);
44
 
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.16");
3
  ?>
1
  <?php if (!defined('BB2_CWD')) die("I said no cheating!");
2
+ define('BB2_VERSION', "2.0.17");
3
  ?>