You are not logged in.
Here is my mod for SMF. I do not check usernames because some are valid ones that others would use also. This is working well for me at this moment. Just remember to change the couple variables to fit your needs. I also have a registration mod to auto add spammers to sfs but have not test enough to post here yet. Till then, SMF users, enjoy ![]()
In Sources/Register.php after
// Set the options needed for registration.
add this:
//SPAM CHECK
function doBanAdd(){
include_once('Sources/ManageBans.php');
$_REQUEST['bg'] = 10; //Set this to whatever ban you want to use.
$_POST['add_new_trigger']='Add';
$_POST['HBan']="YourCustomKeyHERE";
BanEdit();
}
isBannedEmail($_POST['email'], 'cannot_register', 'Sorry, you are not allowed to register on this forum.');
if(isset($_SERVER['HTTP_X_FORWARD_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARD_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$xml_string = file_get_contents('http://www.stopforumspam.com/api?email='.$_POST['email']);
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes')
{
$_POST['bantype'] = 'email_ban';
doBanAdd();
}
else
{
$xml_string = file_get_contents('http://www.stopforumspam.com/api?ip='.$ip);
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes')
{
$_POST['bantype'] = 'ip_ban';
$_POST['ip']=$ip;
doBanAdd();
}
}
//END SPAM CHECKThen in Sources/ManageBans.php
Find:
if (!empty($_POST['add_new_trigger']) || !empty($_POST['edit_trigger']))
{
checkSession();And replace with:
if (!empty($_POST['add_new_trigger']) || !empty($_POST['edit_trigger']))
{
if(!isset($_POST['HBan']) || $_POST['HBan']!=="YourCustomKeyHERE")checkSession();Then find:
$context['sub_template'] = 'ban_edit';
Replace with:
if(!isset($_POST['HBan']) || $_POST['HBan']!=="YourCustomKeyHERE")$context['sub_template'] = 'ban_edit';
This will add the ip or email address to your ban list with the bg of 10. If you do not have bg=10 in the url of any of your bans, replace the 10 with whatever number you want it to go to.
Also, remember to replace "YourCustomKeyHERE" with a secret key.
Last edited by Stryker777 (2008-06-07 9:14 pm)
Offline
I have a website hosted with Dreamhost. They have somehow disabled use of file_get_contents. So... I solved this by using CURL instead:
In Sources/Register.php after
// Set the options needed for registration.
New code:
//SPAM CHECK
function doBanAdd(){
include_once('Sources/ManageBans.php');
$_REQUEST['bg'] = 10; //Set this to whatever ban you want to use.
$_POST['add_new_trigger']='Add';
$_POST['HBan']="0123456789DEADBEEF";
BanEdit();
}
isBannedEmail($_POST['email'], 'cannot_register', 'Sorry, you are not allowed to register on this forum.');
if(isset($_SERVER['HTTP_X_FORWARD_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARD_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'http://www.stopforumspam.com/api?email='.$_POST['email']);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,true);
$xml_string = curl_exec($curl_handle);
curl_close($curl_handle);
// $xml_string = file_get_contents('http://www.stopforumspam.com/api?email='.$_POST['email']);
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes')
{
$_POST['bantype'] = 'email_ban';
doBanAdd();
}
else
{
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'http://www.stopforumspam.com/api?ip='.$ip);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,true);
$xml_string = curl_exec($curl_handle);
curl_close($curl_handle);
// $xml_string = file_get_contents('http://www.stopforumspam.com/api?ip='.$ip);
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes')
{
$_POST['bantype'] = 'ip_ban';
$_POST['ip']=$ip;
doBanAdd();
}
}
//END SPAM CHECKLast edited by tcrob (2008-06-24 9:41 pm)
Offline
Nice job tcrob
I am sure there are several with different needs in that respect. Good to see another option.
Offline
If I remember correctly, SimpleXMLElement, is a PHP5 class. If youre running 4 (and you shouldnt be unless your gay hosting company is crap), this wont work for you :-(
Last edited by pedigree (2008-07-01 3:37 am)
Offline
You know, pedigree, that there are some very good programs out there that do not support PHP5. That is why I ask any potential webhost I look into doing business with whether they offer PHP4 servers, and if they don't then I pass on doing business with them. And I don't care if they are gay or not. That has no bearing on whether they are a good host or not in my opinion. 
Offline