Logo

Stop Forum Spam

Forum



#1 2008-06-07 9:13 pm

Stryker777
Member
Registered: 2008-06-06
Posts: 35
Website

SMF

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 smile

In Sources/Register.php after

Code:

// Set the options needed for registration.

add this:

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']="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 CHECK

Then in Sources/ManageBans.php
Find:

Code:

        if (!empty($_POST['add_new_trigger']) || !empty($_POST['edit_trigger']))
        {
               checkSession();

And replace with:

Code:

        if (!empty($_POST['add_new_trigger']) || !empty($_POST['edit_trigger']))
        {
                if(!isset($_POST['HBan']) || $_POST['HBan']!=="YourCustomKeyHERE")checkSession();

Then find:

Code:

$context['sub_template'] = 'ban_edit';

Replace with:

Code:

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

 

#2 2008-06-24 9:39 pm

tcrob
Member
Registered: 2008-06-24
Posts: 1

Re: SMF

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

Code:

// Set the options needed for registration.

New code:

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 CHECK

Last edited by tcrob (2008-06-24 9:41 pm)

Offline

 

#3 2008-06-24 11:21 pm

Stryker777
Member
Registered: 2008-06-06
Posts: 35
Website

Re: SMF

Nice job tcrob smile  I am sure there are several with different needs in that respect.  Good to see another option.

Offline

 

#4 2008-06-30 7:46 pm

pedigree
Member
Registered: 2008-04-16
Posts: 14

Re: SMF

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

 

#5 2008-08-18 10:13 pm

Ax Slinger
Member
From: The North Coast
Registered: 2008-04-09
Posts: 39
Website

Re: SMF

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. http://i71.photobucket.com/albums/i160/axelslingerland/smilies/rofl3.gif


I only like Spam if it is Deep Fried and served with Cheese.
But only once every six months or so.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson



Donate Valid XHTML 1.0 Transitional RSS 2.0 Feed