Revision [10778]
This is an old revision of BadBehavior made by UserFolderol on 2005-08-19 15:15:21.
Bad Behavior
See also
Bad Behavior is a set of PHP scripts which prevents spambots from accessing your site by analyzing their actual HTTP requests and comparing them to profiles from known spambots. It goes far beyond User-Agent and Referer, however. Bad Behavior is available for several PHP-based software packages, and also can be integrated in seconds into any PHP script. (quote from the homepage).
Integration in wikka
these instructions are for version 1.2-RC3. For upgrading see the notes at the end.
- download it
- unzip the file, go into the folder and make the following changes:
- add bad-behavior-wikkawiki.php to the folder, with the following content:
- ?php
- /*
- http://www.ioerror.us/software/bad-behavior/
- Bad Behavior - detects and blocks unwanted Web accesses
- Copyright (C) 2005 Michael Hampton
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
- /**
- * Entry point for using bad behavior with wikkawiki.
- *
- * @author: {@link http://www.ioerror.us/software/bad-behavior/ Michael Hampton} (generic entry file)
- * @author: {@link http://wikka.jsnx.com/NilsLindenberg Nils Lindenberg} (rewritten for wikka)
- * @author: {Stefan Lindenberg} (simplification of the code)
- *
- * @version: 1.2
- */
- //***Configuration***
- // The database table name to use.
- // Log failed requests to the database.
- if ($wakka->config['bad-behavior-logging'] == 1) $wp_bb_logging = TRUE;
- else $wp_bb_logging = TRUE;
- // Log all requests to the database, not just failed requests.
- if ($wakka->config['bad-behavior-logging'] == 2) $wp_bb_verbose_logging = TRUE;
- else $wp_bb_verbose_logging = FALSE;
- // How long to keep the logs around (in days).
- $wp_bb_logging_duration = 7;
- // Email address to contact you in case of problems
- // This will be shown to users on the error page, which means it will
- // be exposed to spammers! Bad Behavior will munge it automatically; you
- // should NOT munge it here!
- $wp_bb_email = $wakka->config['admin_email'];
- //***Callbacks***
- // return a UTC date in the format preferred by your database
- function wp_bb_date() {
- }
- // run a SQL query and return # of rows affected, or FALSE if query failed
- function wp_bb_db_query($query) {
- global $wakka;
- $result = $wakka->Query($query);
- if ($result === TRUE || $result === FALSE) $returnValue = $result;
- else {
- switch ($mysql_statement) {
- case "insert":
- case "delete":
- case "update":
- break;
- case "select":
- break;
- default:
- if($data === FALSE) $returnValue = 0;
- else $returnValue = 1;
- }
- }
- return $returnValue;
- }
- // Load core functions and do initial checks
- require_once(WP_BB_CWD . "/bad-behavior-core.php");
- ?>
upload the whole folder to 3rdparty/plugins/bad-behavior/
Calling Bad-behavior
add the following line to wikka.php
//load 'bad-behavior'
if ($wakka->config['bad-behavior'] == 1) require_once("3rdparty/plugins/bad-behavior/bad-behavior-wikkawiki.php");
if ($wakka->config['bad-behavior'] == 1) require_once("3rdparty/plugins/bad-behavior/bad-behavior-wikkawiki.php");
=> right before the
// go !
Configuration
add
'bad-behavior' => '1',
'bad-behavior-logging' => '1',
'bad-behavior-logging' => '1',
to your wikka.config.php
bad-behavior:
- 0: don't run bad-behavior
- 1: run bad-behavior
bad-behavior-logging
- 0: don't log anything
- 1: log failed request
- 2: log all requests
Upgrading
The table upgrade in 1.2.rc3 has an error so you have to swap the following:
- // Upgrades from 1.1
- $query = "DESCRIBE `" . WP_BB_LOG . "` `denied_reason`;";
- if (wp_bb_db_query($query) == 0) {
- $query = "ALTER TABLE `" . WP_BB_LOG . "` ADD `denied_reason` TEXT AFTER `request_entity`;";
- if (wp_bb_db_query($query) === FALSE) {
- $wp_bb_db_failure = TRUE;
- }
- }
- // Upgrades from 1.0
- $query = "DESCRIBE `" . WP_BB_LOG . "` `request_entity`;";
- if (wp_bb_db_query($query) == 0) {
- $query = "ALTER TABLE `" . WP_BB_LOG . "` ADD `request_entity` TEXT AFTER `http_headers`;";
- if (wp_bb_db_query($query) === FALSE) {
- $wp_bb_db_failure = TRUE;
- }
- // Upgrades from 1.0
- $query = "DESCRIBE `" . WP_BB_LOG . "` `request_entity`;";
- if (wp_bb_db_query($query) == 0) {
- $query = "ALTER TABLE `" . WP_BB_LOG . "` ADD `request_entity` TEXT AFTER `http_headers`;";
- if (wp_bb_db_query($query) === FALSE) {
- $wp_bb_db_failure = TRUE;
- }
- }
- // Upgrades from 1.1
- $query = "DESCRIBE `" . WP_BB_LOG . "` `denied_reason`;";
- if (wp_bb_db_query($query) == 0) {
- $query = "ALTER TABLE `" . WP_BB_LOG . "` ADD `denied_reason` TEXT AFTER `request_entity`;";
- if (wp_bb_db_query($query) === FALSE) {
- $wp_bb_db_failure = TRUE;
- }
CategoryDevelopment3rdParty CategoryDevelopmentAntiSpam