Revision [10656]

This is an old revision of BadBehavior made by NilsLindenberg on 2005-08-12 15:44:00.

 

Bad Behavior


 


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

  1. download it
  1. unzip the file, go into the folder and make the following changes:
  1. add bad-behavior-wikkawiki.php to the folder, with the following content:
  1. ?php
  2. /*
  3. http://www.ioerror.us/software/bad-behavior/
  4.  
  5. Bad Behavior - detects and blocks unwanted Web accesses
  6. Copyright (C) 2005 Michael Hampton
  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. /**
  24.  * Entry point for using bad behavior with wikkawiki.
  25.  *
  26.  * @author: {@link http://www.ioerror.us/software/bad-behavior/ Michael Hampton} (generic entry file)
  27.  * @author: {@link http://wikka.jsnx.com/NilsLindenberg Nils Lindenberg} (rewritten for wikka)
  28.  * @author: {Stefan Lindenberg} (simplification of the code)
  29.  *
  30.  * @version: 1.2
  31.  */
  32.  
  33.  
  34. //***Configuration***
  35.  
  36. // The database table name to use.
  37. define('WP_BB_LOG', $wakka->config['table_prefix'].'bad_behavior_log');
  38.  
  39. define('WP_BB_CWD', dirname(__FILE__));
  40.  
  41. // Log failed requests to the database.
  42. if ($wakka->config['bad-behavior-logging'] == 1) $wp_bb_logging = TRUE;
  43. else $wp_bb_logging = TRUE;
  44.  
  45. // Log all requests to the database, not just failed requests.
  46. if ($wakka->config['bad-behavior-logging'] == 2) $wp_bb_verbose_logging = TRUE;
  47. else $wp_bb_verbose_logging = FALSE;
  48.  
  49. // How long to keep the logs around (in days).
  50. $wp_bb_logging_duration = 7;
  51.  
  52. // Email address to contact you in case of problems
  53. // This will be shown to users on the error page, which means it will
  54. // be exposed to spammers! Bad Behavior will munge it automatically; you
  55. // should NOT munge it here!
  56. $wp_bb_email = $wakka->config['admin_email'];
  57.  
  58.  
  59. //***Callbacks***
  60.  
  61. // return a UTC date in the format preferred by your database
  62. function wp_bb_date() {
  63.     return gmdate('Y-m-d H:i:s');
  64. }
  65.  
  66. // run a SQL query and return # of rows affected, or FALSE if query failed
  67. function wp_bb_db_query($query) {
  68.     global $wakka;
  69.  
  70.     $result = $wakka->Query($query);
  71.     if ($result === TRUE || $result === FALSE) $returnValue = $result;
  72.          else {
  73.             $data = mysql_fetch_row($result);
  74.         $query_parts = explode(" ",$query);
  75.         $mysql_statement = strtolower($query_parts[0]);
  76.         switch ($mysql_statement) {
  77.                      case "insert":
  78.                      case "delete":
  79.                      case "update":
  80.                              $returnValue = mysql_num_rows($result);
  81.                              break;
  82.                      case "select":
  83.                              $returnValue = mysql_affected_rows();
  84.                              break;
  85.                           default:
  86.                                   if($data === FALSE) $returnValue = 0;
  87.                  else $returnValue = 1;
  88.                  }
  89.                  mysql_free_result($result);
  90.     }
  91.          return $returnValue;
  92. }
  93.  
  94. // Load core functions and do initial checks
  95. require_once(WP_BB_CWD . "/bad-behavior-core.php");
  96.  
  97. ?>


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");


=> right before the
// go !



Configuration


add
    'bad-behavior' => '1',
    'bad-behavior-logging' => '1',


to your wikka.config.php

bad-behavior:

bad-behavior-logging


CategoryDevelopment3rdParty CategoryDevelopmentAntiSpam
There are 13 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki