Revision [9978]

This is an old revision of BadBehavior made by NilsLindenberg on 2005-07-15 09:57:07.

 

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.1.4

  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. <?php
  3. /*
  4. http://www.ioerror.us/software/bad-behavior/
  5.    
  6. Bad Behavior - detects and blocks unwanted Web accesses
  7. Copyright (C) 2005 Michael Hampton
  8.    
  9. This program is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation; either version 2 of the License, or
  12. (at your option) any later version.
  13.    
  14. This program is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. GNU General Public License for more details.
  18.    
  19. You should have received a copy of the GNU General Public License
  20. along with this program; if not, write to the Free Software
  21. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. */
  23.  
  24. /**
  25.  * Entry point for using bad behavior with wikkawiki.
  26.  *
  27.  * @author: {@link http://www.ioerror.us/software/bad-behavior/ Michael Hampton} (generic entry file)
  28.  * @author: {@link http://wikka.jsnx.com/NilsLindenberg Nils Lindenberg} (rewritten for wikka)
  29.  *
  30.  * @version: 1.0
  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. var_dump($wakka->config['bad-behavior-logging']);
  42.  
  43. // Log failed requests to the database.
  44. if ($wakka->config['bad-behavior-logging'] == 1) $wp_bb_logging = TRUE;
  45. else $wp_bb_logging = FALSE;
  46.  
  47. // Log all requests to the database, not just failed requests.
  48. if ($wakka->config['bad-behavior-logging'] == 2) $wp_bb_verbose_logging = TRUE;
  49. else $wp_bb_verbose_logging = FALSE;
  50.  
  51. // How long to keep the logs around (in days).
  52. $wp_bb_logging_duration = 7;
  53.  
  54. // Email address to contact you in case of problems
  55. // This will be shown to users on the error page, which means it will
  56. // be exposed to spammers! Bad Behavior will munge it automatically; you
  57. // should NOT munge it here!
  58. $wp_bb_email = $wakka->config['admin_email'];
  59.  
  60.  
  61. //***Callbacks***
  62.  
  63. // return a UTC date in the format preferred by your database
  64. function wp_bb_date() {
  65.     return gmdate('Y-m-d H:i:s');
  66. }
  67.  
  68. // run a SQL query and return # of rows affected, or FALSE if query failed
  69. function wp_bb_db_query($query) {
  70.     global $wakka;
  71.  
  72.     // run the query
  73.     $result = $wakka->Query($query);
  74.  
  75.     if ($result === TRUE) return 1;
  76.    
  77.     $data = mysql_fetch_row($result);
  78.     mysql_free_result($result);
  79.  
  80.     //get the number of affected rows
  81.       $query_parts = explode(" ",$query);
  82.     $query_statement = strtolower($query_parts[0]);
  83.       switch ($query_statement) {
  84.         case "describe":
  85.             if ($data === FALSE) return 0;
  86.             else return 1;
  87.         case "insert":
  88.         case "delete":
  89.         case "update":
  90.             $rows_affected = mysql_num_rows($result);
  91.             break;
  92.         case "select":
  93.             $rows_affected = mysql_rows_affected($result);
  94.             break;
  95.       }
  96.     return $rows_affected;
  97. }
  98.  
  99. // Load core functions and do initial checks
  100. require_once(WP_BB_CWD . "/bad-behavior-core.php");
  101. ?>


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



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