PDA

View Full Version : Rock Solid Anti-Spam JavaScript


FirstGateDreamer
01-25-2007, 05:21 PM
I've tried Akismet. Not for me. I don't even want to bother having to delete hundreds of spam comments per week. I found this which was somehow originated by Brandon Stone (http://www.phasedrift.com/) of Photoblogs.org (http://www.photoblogs.org).

This is the simplest solution I've seen yet. It doesn't change the appearance of your site whatsoever. It's super simple and I haven't received a single spam message yet. Others can testify that they haven't had ANY for 2 years plus!

What this code does is hide the url which your comments are being submitted to via JavaScript. The only drawback is that users need to have JavaScript enabled. To me this is hardly a problem compared to SPAM. I've seen others use a message that shows up if you don't have JavaScript enabled. I just mention it in the comment box.

I've done this using my alteration of the simple template. You might need to modify accordingly. I can't remember how much I modified my form if at all.

All you have to do is replace the underscores in the FORM ACTION with a different charachter (I used the exclamation point) like so...

Replace this:

<form method='post' action='index.php?x=save_comment' name='commentform' accept-charset='UTF-8'>


With this:

<form method='post' action='index.php?x=save!comment' name='commentform' accept-charset='UTF-8'>


Then insert the following code AFTER your comments form.


<script type="text/javascript">
trueAction = "index.php?x=save!comment";
trueAction = trueAction.replace(/!/g, "_");
document.forms.commentform.action = trueAction;
</script>


Notice that the last line needs to correspond with the NAME of your form (mine was "commentform")

And VOILA! Done.
All you have to do is get over your SPAM-Rage with a nice cold beer!


AKISMET users NOTE: This did not seem compatible with Akismet, but don't worry...just forget Akismet and turn it off.

Dennis
01-25-2007, 05:45 PM
Hmm interesting... The token stuff implemented in 1.6 will stop these events to. Human spammers still get through.

Dkozikowski
01-25-2007, 06:37 PM
This is an interesting idea! I have not tested it but by looking at the code it seems like it may work.

For 1.5 users this is a good way to help prevent spam but as dennis pointed out, 1.6 already has a similar implementation using tokens.

blinking8s
01-26-2007, 12:18 AM
it's been posted on the forum before, it works well for wiki's and several other things. some pixelpost users said it didnt work, i dont know if anyone really adopted it and tested it out...

brandon uses a lot of clever tricks, looking at his source code can teach you a lot (well, it taught me a lot)

se.nsuo.us
01-26-2007, 08:22 AM
Hmm interesting... The token stuff implemented in 1.6 will stop these events to. Human spammers still get through.
And interestingly I am seeing more and more of those.... The bottomline is no *single* anti-spam solution is going to work, combinations are working much better.

FirstGateDreamer
01-26-2007, 01:56 PM
I have yet to receive any Human Spam. In that case I can easily set comments to be moderated. And no doubt the humans controlling these damn robots will find a way around this solution. I'll stick with this until the next full de-bugged version of PP is ready. Now if I can only get my email spam filter to work as good. But then where would I find a good Rolex Replica?

groovyf
01-30-2007, 10:22 AM
Implemented this 2 hours ago. Already had 2 spam comments :/

I used a "]" instead of "!"

FirstGateDreamer
01-30-2007, 01:44 PM
Implemented this 2 hours ago. Already had 2 spam comments :/

I used a "]" instead of "!"

Make sure you replace EVERY instance of 'index.php?x=save_comment'. Are you using the Akismet Add-on? If so, they don't seem perfectly compatible, just turn it off. Also make sure your comment FORM is named 'commentform'.

Either you missed something or you're getting 'human-spam' as schonhose mentioned might get through.

Send me your code via PM and I'll take a look if you like.

GeoS
01-31-2007, 09:10 AM
It is good to use much more complicated values to replace then only ! mark. Many bots can have implemented solution for such simple replacement but with nonstandard it should have a real and quite big problem.
I.e. add to string which is replaced some letters then some special marks and some more letters like:
<script type="text/javascript">
trueAction = "index.php?x=saves%p@m!ercomment";
trueAction = trueAction.replace(/s%p@m!er/g, "_");
document.forms.commentform.action = trueAction;
</script>

PS Above example code isnt tested!!

thukai
02-14-2007, 10:35 AM
I've just tried this method, but it doesn't work for me. At the moment I've forgot the i in index in the script that turns the url back to normal. That means that you can't post comments trough the from, but I still get SPAM.

Any tips and tricks?

Dennis
02-14-2007, 10:42 AM
that is because people don't visit your website, they just inject the variables like message and name directly to the script.

thukai
02-14-2007, 11:43 AM
that is because people don't visit your website, they just inject the variables like message and name directly to the script.

Ok, so how do I stop that?

Dennis
02-14-2007, 03:37 PM
Pixelpost 1.6 has some protection for this but for 1.5 users you could look for GeoS no spam template.

thukai
02-14-2007, 07:22 PM
Pixelpost 1.6 has some protection for this but for 1.5 users you could look for GeoS no spam template.

OK, thanks. Just one more thing :) Where do I find the 1.6 version?

Dennis
02-15-2007, 09:52 AM
It isn't out yet. As we speak I'm still adding useful stuff and cleaning up the code. GeoS and myself have it on our blog running live to get the latest bugs before we release it to the general public.

The rest of the development team is working on a nice template to show off the new features.

kippe
02-18-2007, 11:06 AM
wow this worked great for me!..now I donīt have to moderate my comments any more!

terje
02-22-2007, 03:07 PM
Is it possible to get "in" on the 1.6 beta testing?

Both rdp.no and g8.no recieve a lot of spam these days, it's getting to the point where "I don't give a damn" soon. :-\

thukai
02-22-2007, 03:23 PM
Is it possible to get "in" on the 1.6 beta testing?

Both rdp.no and g8.no recieve a lot of spam these days, it's getting to the point where "I don't give a damn" soon. :-\

I understand how you're feeling Terje. I had the same problem on thukai.net, and I tried everything - nothing helped. Then I found this http://forum.pixelpost.org/showthread.php?t=4310

Haven't gotten a single SPAM comment since :)

FirstGateDreamer
03-01-2007, 06:23 PM
Okay. Perhaps its 'Human Spam' but I suddenly started getting a few trickle in (5 in a month, which was still way better than 500+). I tried turning my Akismet back on and there doesn't seem to be anymore conflict for some reason (I can't remember what that conflict was anymore though?) and it's caught a few that :almost: got through the script. Either way, I'm a happy camper again.

FirstGateDreamer
09-14-2007, 02:02 AM
FYI: Still no spam and lovin it!

kippe
09-20-2007, 05:53 PM
Isnīt there an easy way to add a 1+2=3 box to the comment fied? have seen it on other sites..would like to try it on my site..Itīs hard work deliting 20+ spam aday!

Dennis
09-20-2007, 09:21 PM
With 1.6 you can easily develop a addon for this.

Scarabaeus
02-23-2008, 06:36 PM
I currently use a modification by J Roumagnac, see his articles page, and haven't had any spam whatsoever.