I've ported the module to use Bad Behavior 2. It works great on my site.

To use it, download Bad Behavior 2(I'm using 2.05), extract the zip file, then place the folder Bad-Behavior/bad-behavior inside the folder badbehavior(where badbehavior.module is), you don't need bad-behavior-generic.php, bad-behavior-wordpress, etc.

The patch is against the 4.7 version of the module.

Comments

luperry’s picture

Status: Active » Needs review
luperry’s picture

StatusFileSize
new12.13 KB

fixed up a minor typo.

luperry’s picture

StatusFileSize
new12.8 KB

more tweaks

luperry’s picture

StatusFileSize
new13.06 KB

optimization on database structure installation

pobster’s picture

I was just thinking about updating this module myself! Nice work! :o)

One thing though it doesn't seem to degrade gracefully... I have the previous module installed and when I patch it - the logs vanish although saying that, the module doesn't appear to write to the logs anyway?

Pobster

pobster’s picture

Ah my mistake - YES the logs get written to, but the page displaying them is always blank...

Pobster

pobster’s picture

Ah okay - it *does* work after all ;o) But when you tick the verbose logging it doesn't change anything (as the query is hard coded to ignore entries with a key of '00000000'). Why not use;

if (variable_get('badbehavior_verbose_logging_enable',0)) {
$sql = "SELECT w.* FROM {bad_behavior_log} w " . tablesort_sql($header);
}
else {
$sql = "SELECT w.* FROM {bad_behavior_log} w WHERE w.key != '00000000' " . tablesort_sql($header);
}

Pobster

luperry’s picture

StatusFileSize
new13.16 KB

Ah. you are right.

this should fix it.

dkruglyak’s picture

Could you commit to CVS or at least post a patched module file?

I also wonder if anyone tested BB2 with IE 7: http://drupal.org/node/82567

luperry’s picture

StatusFileSize
new7.95 KB

I'm not the maintainer of this module, so I can't commit it to the cvs.

here is the patched module.

moggy’s picture

Title: BB2 port » error checking logs

when checking the bad behavior logs (verbose disabled) I've getting an empty table with the following error being recorded in the logs

Unknown column 'w.key' in 'where clause' query: SELECT w.* FROM bad_behavior_log w WHERE w.key != '00000000' ORDER BY w.date DESC LIMIT 0, 50 in /var/www/Drupal-47/includes/database.mysql.inc on line 120.

luperry’s picture

Title: error checking logs » BB2 port

the database structure is different in BB2, drop your old bad_behavior_log table and let it re-create a new one.

crozilla’s picture

Category: feature » support

> drop your old bad_behavior_log table and let it re-create a new one.

Okay, I did the first part, but the second part didn't happen. How do I create 'bad_behavior_log' manually?

Thanks in advance.

luperry’s picture

you don't create it manually, it'll automatically create it for you.

luperry’s picture

Category: support » feature
tkgafs’s picture

Thanks for doing this port it works well on my 4.7.4 system using bad-behavior files 2.0.6

please note however the installation instructions at the top are not that clear

when I first tried this I was getting lots of errors in the logs saying

The third-party bad-behavior files are not installed. Please consult badbehavior/README.txt for details

what I had done wrongly was to put the folder structure Bad-Behavior/bad-behavior inside my badbehavior module [which is what I thought was meant at the start]

so the 3rd party files where placed at modules/badbehavior/Bad-Behavior/bad-behavior where the system could not find them

this was wrong I should have extracted the folder bad-behavior from the Bad-Behavior folder and placed it in

modules/badbehavior/bad-behavior

the other problem I had was that once I had dropped the bad-behavior-log table the system would not recreate it

what I ended up doing was installing the devel module and using that to re-install the badbehavior module

tkgafs

luperry’s picture

I'm not the official maintainer of this module, this is provided for your convenience only.

it would be up to the official maintainer to fix up the documetations and do a proper port.

but I thought the database part is pretty obvious.

tkgafs’s picture

Hopefully somebody can point out what my problem is here

I have installed this bb2 port of bad-behavior into my drupal 4.7.4 install and its working perfectly

My system is running on MySQL v 3.23.56

I have dumped my database using mysqldump -user user --password=password dbname > dbname.sql

but if I try and reload the database from the sql dump it fails on the CREATE TABLE bad_behavior_log

with the following error

ERROR 1064 at line 11916: You have an error in your SQL syntax near 'NOT NULL,
PRIMARY KEY (id),
KEY ip (ip(15)),
KEY user_agent (user_agent(1' at line 11

the create table [which is line 11916] in the dump file is as follows

CREATE TABLE bad_behavior_log (
id int(11) NOT NULL auto_increment,
ip text NOT NULL,
date datetime NOT NULL default '0000-00-00 00:00:00',
request_method text NOT NULL,
request_uri text NOT NULL,
server_protocol text NOT NULL,
http_headers text NOT NULL,
user_agent text NOT NULL,
request_entity text NOT NULL,
key text NOT NULL,
PRIMARY KEY (id),
KEY ip (ip(15)),
KEY user_agent (user_agent(10))
) TYPE=MyISAM;

the create table command in the bb2 code in core.inc.php is

return "CREATE TABLE IF NOT EXISTS `$name_escaped` (
`id` INT(11) NOT NULL auto_increment,
`ip` TEXT NOT NULL,
`date` DATETIME NOT NULL default '0000-00-00 00:00:00',
`request_method` TEXT NOT NULL,
`request_uri` TEXT NOT NULL,
`server_protocol` TEXT NOT NULL,
`http_headers` TEXT NOT NULL,
`user_agent` TEXT NOT NULL,
`request_entity` TEXT NOT NULL,
`key` TEXT NOT NULL,
INDEX (`ip`(15)),
INDEX (`user_agent`(10)),
PRIMARY KEY (`id`) );"; // TODO: INDEX might need tuning
}

I dont know mysql very well but I'm stumped as to what the error could be as 1064 usually an error in the syntax
but this is a dump and reload on the same system, surely mysqldump would get the syntax correct !!

I have also tried adding the --opt option to the mysqldump command but it makes no difference

If I remove the badbehavior_log table from the backup the rest of the dump reloads quite happily

any advice gratefully received

Tkgafs

tkgafs’s picture

after a bit of research it would appear the line key text NOT NULL, is the problem

I am puzzled if this is a problem why I didnt see any errors when the module was first installed

tkgafs

eaton’s picture

StatusFileSize
new14.92 KB

The attached patch file will update BadBehavior for use with Drupal 5 and Bad-Behavior 2.0.x.

Enjoy...

scroogie’s picture

Oh great Eaton, gonna try that out hopefully tomorrow. Did anyone else already test that patch? I completely trust Eatons magnificient Skills, its just that im wondering why it didnt get commited yet.

eaton’s picture

Well, I haven't had too much time to test it; I was still getting spammed pretty hard and ended up porting Akismet shortly after. But to the best of my knowledge it does work. ;-)

juerg’s picture

Title: BB2 port » Install table does not respect table prefixes (4.7.4 version)

I just wanted to mention that the patched module for Drupal 4.7.4 (http://drupal.org/files/issues/badbehavior_0.module) does not respect table prefixes when creating the table.

Assuming the table prefixes are set to "pre1-" then the module creates table bad_bevavior_log instead of pre1-bad_bevahior_log (probably missing {} around the table name). If you create the table manually, then it seems to work OK, however.

Juerg

mcurry’s picture

Title: Install table does not respect table prefixes (4.7.4 version) » BB2 port

Restoring original issue title.

pjb’s picture

I've tested the BB2 + Drupal 5 patch submitted in #20 and it seems to work fine. Couple of things:

1) The menu hook on line 28 should probably be changed to admin/settings/badbehavior vs. admin/content/badbehavior

2) I think there are README.txt updates necessary; the original version states that the module file should be placed into the bad-behavior directory that is created when you unzip the file from ioerror.us but now we do the opposite and put that directory into the Drupal module directory per luperry's directions from the original patch.

Thanks for the patch Eaton, that's some great work and much appreciated! :)

p_palmer’s picture

Status: Needs review » Active

Hi Eaton,

Can you confirm which of these to go with as the dates are the same, but the code different (I guess you were enjoyin festive times)...

1) Comment #20 above pointing to http://drupal.org/files/issues/badbehavior-2_5.patch

or your comment (The attached patch updates the Bad Behavior module to the happy world of Drupal 5) here

2) http://drupal.org/node/105065 to patch http://drupal.org/files/issues/badbehavior_5.patch

I am using dru 5.1

Good work, and thanks in advance :)

jbc’s picture

Component: Code » User interface

I’ve installed badbehaviour v. 2.0.10 and utilised it with the drupal module which has been patched to work with this version (under BB2 Port post)

However, I am getting messages saying that major search engines msnbot and googlebot are being banned, eg:

_______________________________

IP Addr 66.249.72.228
Hostname crawl-66-249-72-228.googlebot.com (whois)
Date 2007-05-18 19:47:16
Request type GET
URI /node/923/print
Protocol HTTP/1.1
User Agent Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
Headers GET /node/923/print HTTP/1.1 Host: www.eternalpurpose.org.uk Connection: Keep-alive Accept: */* From: googlebot(at)googlebot.com User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) Accept-Encoding: gzip
Request Entity
Denied Reason User-Agent claimed to be Googlebot, claim appears to be false.
Explanation An invalid request was received. You claimed to be a major search engine, but you do not appear to actually be a major search engine.
Response 403
_______________________________

Can you advise on this? I’m keen to get bb working again with my drupal instal, having had good results with it a year ago.

singpolyma’s picture

Can someone post the patched module for BB2 and Drupal5

pears447’s picture

I would also very much appreciate a complete zip file for BB2 on Drupal 5. I have a site that I am trying to get live in a few days, and would like to include this module...

Many thanks.

juerg’s picture

I have uploaded a patched module, see here: http://drupal.org/node/172552

Please make sure you follow the installing instructions given in the above node and in the README-Drupal.txt

willfe’s picture

Just an FYI to anyone having trouble getting this thing to create the "new" table structure when upgrading an existing Drupal 4.x site to Drupal 5.x and trying to use the new (patched) BB2 module in their site: you need to *drop* the old bad_behavior_log table entirely (or at least rename it if you want to retain the logs stored in it) before you even *try* to set up the new module.

The module doesn't follow the "Drupal way" of performing an upgrade; it presumes it's a new installation and makes a couple little gaffes when that's not the case. Specifically, the module doesn't use Drupal's database schema upgrade handling -- it just tells Drupal it's using "schema version 0" and never changes that. It also doesn't try to migrate the old table to the new one -- the only place where a "CREATE TABLE bleh bleh..." is attempted is on the settings page for the "Bad behavior" module, and that only happens when you *save* settings. Also, the "CREATE TABLE" blurb is written as "CREATE TABLE IF NOT EXISTS" (which is fine/safe) but also only happens if the module hasn't already stored a configuration variable that says "yes, I've already (tried to) create the table!"

In effect, if you don't remove the old table before your first attempt to install the module, it never again tries to create the new table even if you delete it after installation. First, I intend to snag the module and fix this (it shouldn't be *too* painful -- at worst, it needs to rename the table and create the new one automatically during installation; at best, it can do ALTER TABLE commands and try to migrate the old data -- either way this needs to be done in badbehavior.install, which doesn't exist right now), but second (and more importantly), here's how to fix this problem if you bump into it :) :

These instructions assume you've gotten a 4.x site upgraded to 5.x, and you've tried to install the Bad Behavior module, and it's wedged (can't log stuff and can't show the log) because it thinks it's created the new table but really hasn't. You'll need access to your databases; I show MySQL client commands here, but you can also do this trickery via PHPMyAdmin or similar if you haven't got a client (or aren't comfortable with command-line stuff).

  1. First, drop or rename the old table (Important! Only do one of these):
    • mysql> drop table bad_behavior_log;
        - or -
    • mysql> rename table bad_behavior_log to bad_behavior_log_old;
  2. Next, remove the configuration directive for the Bad Behavior module so it'll create the table later:
    • mysql> delete from variable where name = 'badbehavior_db_installed';
  3. Finally, browse to your site's admin page, click the "Bad behavior" link (in "Content Management," not "Logs"), then click "Save configuration" (even if you don't change anything). This should create the new table properly.

If your site is getting *any* kind of traffic at all, you should immediately begin seeing entries turning up in the log (site admin -> "Bad behavior" (under "Logs" this time)).

wilco’s picture

Version: 7.x-1.x-dev » 5.x-2.0-beta1
Status: Active » Closed (fixed)

Please use and download the D5 latest release.

This issue is now closed.