Another fix

IAmNos - October 23, 2008 - 16:12
Project:http:BL
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:duplicate
Description

This patch includes my previous patch.

Basically, the module wasn't working before, but seems to be now. The checks for isset($result) were causing the actual BL check to be skipped. I changed it to is_int() and it seems to work. Also, the constant HTTPBL_BLACKLIST was being used instead of HTTPBL_LIST_BLACK which made every IP get blocked.

--- orig/httpbl/httpbl.module 2008-07-30 06:05:51.000000000 -0600
+++ /home/www/thekerrs.ca/html/sites/all/modules/httpbl/httpbl.module 2008-10-23 10:07:37.000000000 -0600
@@ -78,10 +78,9 @@
*/
function hook_boot() {
// Only continue when checks are enabled
- if (variable_get('httpbl_check', HTTPBL_CHECK_NONE) == HTTPBL_CHECK_ALL) {
+ if (variable_get('httpbl_check', HTTPBL_CHECK_NONE) == HTTPBL_CHECK_NONE) {
return;
}
-
if (httpbl_check() == HTTPBL_LIST_BLACK) {
$message = 'Sorry, %ip has been blacklisted by http:BL.%honeypot';

@@ -111,7 +110,7 @@
*/
function httpbl_init() {
// Only continue when checks are enabled
- if (variable_get('httpbl_check', HTTPBL_CHECK_NONE) == 2) {
+ if (variable_get('httpbl_check', HTTPBL_CHECK_NONE) == HTTPBL_CHECK_NONE) {
return;
}

@@ -176,7 +175,7 @@
function httpbl_check() {
static $result;
// Result was already calculated -- return.
- if (!isset($result)) {
+ if (is_int($result)) {
return $result;
}

@@ -191,7 +190,8 @@
$result = _httpbl_cache_get($ip);
}

- if ($result === NULL) {
+
+ if (!is_int($result)) {
// Do a DNS lookup, and continue if lookup was succesful
if ($response = httpbl_dnslookup($ip)) {
$stats = variable_get('httpbl_stats', TRUE);
@@ -683,10 +683,12 @@
*/
function _httpbl_cache_set($ip, $status, $offset = 0) {
db_query("DELETE FROM {httpbl} WHERE hostname = '%s'", $ip);
+
db_query("INSERT INTO {httpbl} (hostname, status, expire) VALUES ('%s', %d, %d)", $ip, $status, time() + $offset);

- if ($status == HTTPBL_BLACKLIST && variable_get('httpbl_cache', HTTPBL_CACHE_DBDRUPAL)) {
+ if ($status == HTTPBL_LIST_BLACK && variable_get('httpbl_cache', HTTPBL_CACHE_DBDRUPAL)) {
db_query("INSERT INTO {access} (mask, type, status) VALUES ('%s', '%s', %d)", $ip, 'host', 0);
+ watchdog('httpbl', 'Banned %ip for %status', array('%ip' => $ip, '%status' => $status), WATCHDOG_INFO);
}
}

#1

Dane Powell - September 5, 2009 - 15:25
Status:active» duplicate

I don't know how we ended up with two issues on this, but I've rolled most of this into a patchfile over in #322221: Drupal 6 port needs work. If anything still not working, please fix it in that issue.

 
 

Drupal is a registered trademark of Dries Buytaert.