You are not logged in.

#1 2008-06-08 1:13 am

Stryker777
Member
Registered: 2008-06-07
Posts: 43
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

// 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 CHECK

Then 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-08 1:14 am)

Offline

#2 2008-06-25 1:39 am

tcrob
Member
Registered: 2008-06-25
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

// 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 CHECK

Last edited by tcrob (2008-06-25 1:41 am)

Offline

#3 2008-06-25 3:21 am

Stryker777
Member
Registered: 2008-06-07
Posts: 43
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 11:46 pm

pedigree
uıɐbɐ ʎɐqǝ ɯoɹɟ pɹɐoqʎǝʞ ɐ buıʎnq ɹǝʌǝu ɯ,ı
From: New Zealand
Registered: 2008-04-16
Posts: 7,104

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 7:37 am)

Offline

#5 2008-08-19 2:13 am

Ax Slinger
Member
From: The North Coast
Registered: 2008-04-10
Posts: 184
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. rofl3.gif


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

Offline

#6 2008-11-16 11:07 pm

Bluewolf
Member
Registered: 2008-11-16
Posts: 4

Re: SMF

Fingers crossed, I added this code to our SMF forum. Thanks for sharing.

Offline

#7 2008-11-17 6:06 am

Bluewolf
Member
Registered: 2008-11-16
Posts: 4

Re: SMF

I do seem to have a bit of an issue. I tried to test registering an account, and received an error. The line is within the block of code text I pasted into the file.  In the pic, it shows the code, with the error on the bottom.

smf.gif

http://johnpalmeri.com/gallery/albums/u … 01/smf.gif

Offline

#8 2008-11-17 2:44 pm

pedigree
uıɐbɐ ʎɐqǝ ɯoɹɟ pɹɐoqʎǝʞ ɐ buıʎnq ɹǝʌǝu ɯ,ı
From: New Zealand
Registered: 2008-04-16
Posts: 7,104

Re: SMF

SimpleXMLElement is a PHP5 function and Im guessing youre using PHP4 (which is dead, end of life, unsupported and you should upgrade).  I got caught with vbStopForumSpam when people complained it wouldnt run on old old old versions of PHP.  The problem here is that many shared hosts simply wont upgrade as it will break every website running on the machines.

Offline

#9 2008-11-19 1:00 am

MysteryFCM
Member
From: Tyneside, UK
Registered: 2008-01-16
Posts: 606
Website

Re: SMF

I ran into this for one of the boards I look after, however, you can work around this for those using PHP 4, by changing;

$xml_string = file_get_contents('http://www.stopforumspam.com/api?email='.$_POST['email']);
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes')

To;

$fspamcheck = file_get_contents('http://www.stopforumspam.com/api?email='.$_POST['email');
if (strpos($fspamcheck, 'yes') !==False) {

Regards
Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Offline

#10 2008-11-19 11:51 am

ITA003
Member
Registered: 2008-11-19
Posts: 4

Re: SMF

I'm writing and release a mod to enable check with stopforumspam, so you can install the mod from admin panel.

The check is on the Email and IP address, if is a spam the registration doesn't complete and log a message.

I think to relase a first version soon...

Offline

#11 2008-11-23 1:54 am

Bluewolf
Member
Registered: 2008-11-16
Posts: 4

Re: SMF

Much thanks, I shall give it a try.

Offline

#12 2008-11-27 9:20 pm

RichardA
Member
From: East Sussex, UK
Registered: 2008-11-23
Posts: 1
Website

Re: SMF

Many thanks for the mod, and also to MysteryFCM for the fix (although my host is using PHP5, I still had the problem with SimpleXMLElement!)

Offline

#13 2008-11-27 10:32 pm

MysteryFCM
Member
From: Tyneside, UK
Registered: 2008-01-16
Posts: 606
Website

Re: SMF

My pleasure smile


Regards
Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Offline

#14 2008-11-28 1:08 pm

MysteryFCM
Member
From: Tyneside, UK
Registered: 2008-01-16
Posts: 606
Website

Re: SMF


Regards
Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Offline

#15 2008-12-13 8:20 am

fibrochick
Member
Registered: 2008-12-13
Posts: 1

Re: SMF

hi I belong to smf, I would  like to add this, I am not great with mods and putting the codes in ,,,and sometimes can't get the techs to...anyway saw the mod there but see it as a tar.gz package I have no clue as to how to  put something like that in, and i seem to screw up on manual install sometimes  any suggestions??? greatly appreciated

thanks,
amy jill
fibrochicks.com

Offline

#16 2008-12-13 6:46 pm

MysteryFCM
Member
From: Tyneside, UK
Registered: 2008-01-16
Posts: 606
Website

Re: SMF

The mod mentioned here, doesn't come in a .tar.gz, it just requires a small addition to register.php wink (see the temerc.com thread referenced above).


Regards
Steven Burn
I.T. Mate / hpHosts
it-mate.co.uk / hosts-file.net

Offline

#17 2008-12-27 1:49 am

aldo
Member
Registered: 2008-12-27
Posts: 2

Re: SMF

Cool. But if you are running SMF 1.1.x you can apply this modification: http://custom.simplemachines.org/mods/i … p?mod=1519

I have submitted one for SMF 2.0 Beta 4 which does a bit more then that one... but not yet approved wink

Offline

Board footer

Powered by FluxBB

Close
Close