don't know where to do this, made this recently, first time i've posted it
Spam blacklist made simple
Purpose: Block blacklisted spam IPs from registering. With a minimalist approach.
The IPs are checked right before the new user is added to the DB, and after all the input is checked and OK.
Spam bots will see an almost blank page with: "spam, email me"
Black lists: (aimed at comment spam instead of email spam)
http://www.stopforumspam.com
http://projecthoneypot.org
Goto file:
Find:
Code: Select all
// Register user...
$user_id = user_add($user_row, $cp_data);
ABOVE the code found, ADD this:
Code: Select all
include($phpbb_root_path . 'projecthoneypot_asdf.php');
include($phpbb_root_path . 'stopforumspam_asdf.php');
So you should end up with
Code: Select all
include($phpbb_root_path . 'projecthoneypot_asdf.php');
include($phpbb_root_path . 'stopforumspam_asdf.php');
// Register user...
$user_id = user_add($user_row, $cp_data);
Goto file: projecthoneypot_asdf.php (created a few steps down this page)
Register/Find/replace key (Project Honey Pot)
Replace MyAccessKeyHere with your key.
Get key from here:
http://projecthoneypot.org/httpbl_configure.php
Code: Select all
$h= new http_bl('MyAccessKeyHere'); // put your access key here
No key for stopforumspam
(nothing to do)
CREATE, filename: projecthoneypot_asdf.php (same folder as index.php/config.php)
Code: Select all
<?php
/*
* Posts modified this:
* Project Honey Pot Http BlackList
* http://www.projecthoneypot.org/httpbl_configure.php
* version 0.1
* - 2008-01-18 version 0.1 by Francois Dechery, www.440net.net
* This php class is distribured under the GNU Public License ("GPL") version 2.
* http://www.gnu.org/licenses/gpl.txt
*/
if (!defined('IN_PHPBB'))
{
exit;
}
//make sure vars don't collide by wrapping in func
blahblahblahasdfasdf();
function blahblahblahasdfasdf()
{
$h= new http_bl('MyAccessKeyHere'); // put your access key here
$ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : '';
//$ip = "234"; // test
$r = $h->query($ip);
//echo htmlspecialchars($ip).": ";
//if($r==2) {
// echo "Found a " . $h->type_txt ." (".$h->type_num .") with a score of ". $h->score . ", last seen since ". $h->days . " days";
//} elseif($r==1) {
// echo "Found a Search engine (". $h->engine_num . ")";
//} else {
// echo "Not Found";
//}
if($r == 2 && $h->type_num >= 1 && $h->days <= 20) {
die("spam, email me");
}
}
//**************************************************************
//**************************************************************
class http_bl{
var $access_key ="";
var $domain ="dnsbl.httpbl.org";
var $answer_codes=array(
0 =>'Search Engine',
1 =>'Suspicious',
2 =>'Harvester',
3 =>'Suspicious & Harvester',
4 =>'Comment Spammer',
5 =>'Suspicious & Comment Spammer',
6 =>'Harvester & Comment Spammer',
7 =>'Suspicious & Harvester & Comment Spammer'
);
//var $engine_codes=array();
var $ip ='';
var $type_txt ='';
var $type_num =0;
var $engine_txt ='';
var $engine_num =0;
var $days =0;
var $score =0;
// ***********************************************
function http_bl($key=''){
$key and $this->access_key=$key;
}
// return 1 (Search engine) or 2 (Generic) if host is found, else return 0
function query($ip){
if(!$ip){return FALSE;}
$this->ip=$ip;
list($a,$b,$c,$d)=explode('.',$ip);
$query=$this->access_key.".$d.$c.$b.$a.".$this->domain;
$host=gethostbyname($query);
list($first,$days,$score,$type)=explode('.',$host);
if($first==127){
//spammer
$this->days =$days;
$this->score=$score;
$this->type_num =$type;
$this->type_txt=$this->answer_codes[$type];
// search engine
if($type==0){
$this->days =0;
$this->score =0;
$this->engine_num =$score;
//$this->engine_txt =$this->engine_codes[$score];
return 1;
}
else{
return 2;
}
}
return 0;
}
} //end class
?>
CREATE, filename: stopforumspam_asdf.php (same folder as index.php/config.php)
Code: Select all
<?php
/*
* Posts modified this:
* "Smurf_Minions wrote a spambot detector in PHP using the API.
* The source is included as well."
* http://guildwarsholland.nl/phphulp/testspambot.php
* http://guildwarsholland.nl/
*
* black list site:
* http://www.stopforumspam.com
*/
if (!defined('IN_PHPBB'))
{
exit;
}
//make sure vars don't collide by wrapping in func
yumyumyumyumasdf();
function yumyumyumyumasdf()
{
$ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : '';
//$ip = "123"; // test
$spambot = yumcheckSpambots($ip);
if($spambot == true){
die("spam, email me");
}
}
function yumcheckSpambots($ip){
$spambot = false;
$xml_string = @file_get_contents('http://www.stopforumspam.com/api?ip='.$ip);
if($xml_string === FALSE) {
return $spambot;
}
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes'){
$spambot = true;
}
/*
if(isset($xml->frequency)) {
$freq = (int)$xml->frequency;
if(3 > $freq) {
$spambot = false;
}
}
*/
if(isset($xml->lastseen)) {
$seen = substr($xml->lastseen,0,7);
$test1 = date('Y-m');
$test2 = date('Y-m', strtotime('-2 week'));
if($seen != $test1 && $seen != $test2) {
$spambot = false;
}
}
return $spambot;
}
?>