[wp-hackers] wp-denyhost

Sabin Iacob iacobs at m0n5t3r.info
Fri Apr 18 10:33:55 GMT 2008


Per Søderlind wrote:
> Alexander Beutl
>   
>> Cool. Very cool indeed!
>>
>> But maybe you could add an option to write this blocking to htaccess
>> after it was detected to be a "need to block" IP) - this would stop
>> spammers from even bothering to start the php parser and to load the
>> stuff wordpress loads before the init actions - when they knock on the
>> door apache would just throw an errorcode after them and hopefully hit
>> their head ;-)
>>
>>     
>
> This might work (not tested :)
>
> In .htaccess:
> php_value auto_prepend_file suspect.php
>
> suspect.php:
> <?php
> define('WP_USE_THEMES', false);
> require('./wp-blog-header.php');
>
> $suspect = $_SERVER["REMOTE_ADDR"];
> $count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments  WHERE comment_approved = 'spam' AND comment_author_IP LIKE ('%$suspect%')");
>
> if ($count >= 1) {		
> 	header("HTTP/1.1 403 Forbidden");
> 	die();
> }
> ?>
>   

I think Alexander was trying to say that you could, for example, append 
the offending IP to a rewrite map file and have .htaccess block 
addresses that match (requires access to server config); or just insert 
"deny from" entries into the htaccess file (there is a function 
somewhere in the Wordpress core that does the insert between markers 
thing, but I forgot how it's called :o))


More information about the wp-hackers mailing list