UBB.Dev
This Template Hack is no longer supported, instead please see the Stop Forum spam Integration (Modification) thread.

Author: Gizmo (James of VNC Web Design)

Requirements:
  • Valid UBB.Threads 7.0 install and license
  • PHP5+, PHP4 is not supported.
  • To REPORT users you will need an API Key from Stop Forum Spam.


About:
This modification will allow you to check your users (via the "Edit User" function in the Control Panel) and new signups (via the "Registration Queue") against the Stop Forum Spam databases.

When a spammer is identified a Red/Bold ! will display next to the field, clicking this ! will allow you to view the associated data on Stop Forum Spam.

Demo:
See the screen captures attached to this thread for a demo.

The Modification
In templates/default/admin/membermanage.tmpl
Find:
Code
for($i=0;$i<sizeof($que);$i++) { //UBBTREMARK

Add Under:
Code
	$xml_string = file_get_contents("http://www.stopforumspam.com/api?email=". $que[$i]['email']);
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes'){
$spammer_real_email = " <a href=\"http://stopforumspam.com/search/?q=". $que[$i]['email'] ."\" target=\"_blank\" style=\"color: #FF0000; font-weight: bold;\">!</a>";
} else {
$spammer_real_email = "";
}

$xml_string = file_get_contents("http://www.stopforumspam.com/api?ip=". $que[$i]['ip']);
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes'){
$spammer_reg_ip = " <a href=\"http://stopforumspam.com/ipcheck/". $que[$i]['ip'] ."\" target=\"_blank\" style=\"color: #FF0000; font-weight: bold;\">!</a>";
} else {
$spammer_reg_ip = "";
}


Find:
Code
<br />{$que[$i]['uname']}<br />{$que[$i]['email']}<br />{$que[$i]['ip']}

Replace With:
Code
<br />{$que[$i]['uname']}<br />{$que[$i]['email']}{$spammer_real_email}<br />{$que[$i]['ip']}{$spammer_reg_ip}


In templates/default/admin/showuser.tmpl
Find:
Code
$forum_link = make_ubb_url("", "", false);


Add Under:
Code
	$xml_string = file_get_contents("http://www.stopforumspam.com/api?email=". $email);
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes'){
$spammer_real_email = " <a href=\"http://stopforumspam.com/search/?q=". $email ."\" target=\"_blank\" style=\"color: #FF0000; font-weight: bold;\">!</a>";
} else {
$spammer_real_email = "";
}

$xml_string = file_get_contents("http://www.stopforumspam.com/api?ip=". $regip);
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes'){
$spammer_reg_ip = " <a href=\"http://stopforumspam.com/ipcheck/". $regip ."\" target=\"_blank\" style=\"color: #FF0000; font-weight: bold;\">!</a>";
} else {
$spammer_reg_ip = "";
}

if($lastpostip != "") {
$xml_string = file_get_contents("http://www.stopforumspam.com/api?ip=". $lastpostip);
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes'){
$spammer_last_ip = " <a href=\"http://stopforumspam.com/ipcheck/". $lastpostip ."\" target=\"_blank\" style=\"color: #FF0000; font-weight: bold;\">!</a>";
} else {
$spammer_last_ip = "";
}
} else {
$spammer_last_ip = "";
}

Find:
Code
<input type="text" name="email" value="$email" id="email" />

Replace With:
Code
<input type="text" name="email" value="$email" id="email" />$spammer_real_email

Find:
Code
$regdate - $regip

Replace With:
Code
$regdate - $regip$spammer_reg_ip

Find:
Code
$lastpost - $lastpostip

Replace With:
Code
$lastpost - $lastpostip$spammer_last_ip


To be able to report users
In templates/default/admin/showuser.tmpl
Find:
Code
$forum_link = make_ubb_url("", "", false);


Add Under (be sure to add your API Key to the API-Key section below):
Code
	if($lastpostip != "") {
$report_spammer = "http://www.stopforumspam.com/add.php?username=". $lname ."&ip_addr=". $lastpostip ."&email=". $email ."&api_key=API-KEY";
} else {
$report_spammer = "http://www.stopforumspam.com/add.php?username=". $lname ."&ip_addr=". $regip ."&email=". $email ."&api_key=API-KEY";
}

Find:
Code
$lname

Replace With:
Code
$lname (<a href="$report_spammer" target="_blank" style="color: #FF0000;">Report Spammer</a>)



To detect and deny detected spammers when they register (via IP):
In templates/default/newuser_signup.tpl
Find:
Code
{* Script Version 7.5.6 *}

Add Under:
Code
{php}
$xml_string = file_get_contents("http://www.stopforumspam.com/api?ip=". $_SERVER["REMOTE_ADDR"]);
$xml = new SimpleXMLElement($xml_string);

if ($xml->appears == 'yes') {
{/php}
{$tbopen}
<tr>
<td class="tdheader" colspan="2">
Spammer Detected
</td>
</tr>
<tr>
<td colspan="2" class="alt-2">
At this time your registration can not be continued. Your IP address has been flagged as that of a known spammer/spambot via the <a href="http://stopforumspam.com/ipcheck/{$smarty.server.REMOTE_ADDR}" target="_blank">Stop Forum Spam</a> database. To proceed you'll need to <a href="http://stopforumspam.com/contact" target="_blank">contact them</a> to clear yourself from their database.
</td>
</tr>
{$tbclose}

{php}
} else {
{/php}


Find:
Code
</form>

Add Under:
Code
{php} } {/php}



NOTE: StopForumSpam.com only allows 5k lookups per day; thus, you should refrain from attempting to implement this code on pages which would quickly hit this limit (such as adding searches for all types of data on the search users page).

Attached picture edituser.jpg
Attached picture regqueue.jpg
Attached picture reportspam.jpg
Attached picture detected.jpg
Thanks Gizmo! It appears to work very well.
Works great, thanks Giz :thumb:
Added ability to report spammers; see the last step and the notice about retrieving an API Key.

Thanks Gizmo. We are gonna try it over the weekend and see what happens. We do have an API. Will report back.

Larry
Thanks Giz, I just signed up there and tested with the API and it submitted perfectly. Good job :thumb:
Yeah, I grossly over-analyzed how to do it; when I thought outside the box with the demo code I had it just sort of clicked how easy it really was...

The "hard" part was where to put the report link yet have it stand out, so I just kind of suggested its current placement.

I also over-thought what to submit, then I figured that the only thing that really matters was their latest ip, so if a "last post ip" didn't exist then just grab the reg ip so no matter what it'd be their "last logged" ip address.

Have a couple little things I want to work in, but I went and reported this mod to them so that they could (hopefully) add it to their listing.

Let me know if you guys run into any oddities and I'll take a look. I'm thinking about building a separate (non UBB) script to do a one-time scan of user data, meant to be run on different days for large forums (to bypass the 5k limit) but I'll have that separate for those who want it.
Thanks Giz, I would def love to see this become stock in v8!!
Originally Posted by gliderdad79
Thanks Giz, I would def love to see this become stock in v8!!
Well, my code is pretty basic, Rick is more than welcome to use it for inspiration for v8; it's torn from the demo's at stopforumspam's api documentation.

In its current phase it's perfect for anyone who wants to use it, it likely won't hit their 5k limit; the problem is the api key needed for submission; but it could just not show unless an api key shows in the config.

It'd be great to integrate with the reg process, but the idea of false positives that users need to contact stopforumspam.com to bypass is kind of a setback... If I do add it (and I probably will) I'd advise against its general use, but it'd be there regardless.
If included in stock I think it would need to be an option like twitter where you need to check the box to enable and enter your twitter name or in this case api key.
Basically, yeah, that's what I was going for
Great minds think.... Who am I kidding I dont have a great mind :roflmao:
Added the ability to do an IP check against the Stop Forum Spam database at signup; if their IP is detected then they're not allowed to sign up (see the screen attached for the error message portion).
Sweet, been added. I see no reason this shouldn't be added to stock, I hope it does!
Awesome

Works a treat smile

Cheers for this.

Regards

Barry
Fixed a bug reported by Gliderdad with the showuser.tmpl portion for last post ip; when a user doesn't have a last post ip (0 posts) the script will throw an error; the fix is to just not do the check in this case. New code (updated on first post) is:

Take this:
Code

$xml_string = file_get_contents("http://www.stopforumspam.com/api?ip=". $lastpostip);
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes'){
$spammer_last_ip = " <a href=\"http://stopforumspam.com/ipcheck/". $lastpostip ."\" target=\"_blank\" style=\"color: #FF0000; font-weight: bold;\">!</a>";
} else {
$spammer_last_ip = "";
}

Change To:
Code

if($lastpostip != "") {
$xml_string = file_get_contents("http://www.stopforumspam.com/api?ip=". $lastpostip);
$xml = new SimpleXMLElement($xml_string);
if($xml->appears == 'yes'){
$spammer_last_ip = " <a href=\"http://stopforumspam.com/ipcheck/". $lastpostip ."\" target=\"_blank\" style=\"color: #FF0000; font-weight: bold;\">!</a>";
} else {
$spammer_last_ip = "";
}
} else {
$spammer_last_ip = "";
}
I've redone this template hack as a full modification available here. I've also added to it by setting it to check emails on registration and report offenders who're signing up with triggered email data to Stop Forum Spam automatically in the v0.3 Modification thread.
© UBB.Developers