Anti-spam idea: anonymous link rejector

PieterDC - June 6, 2007 - 20:29

I'v been searching for a Drupal module that is the equivalent of Links Rejector for phpBB and No Spam by Guests for Simple Machines Forum... but I haven't found it (yet).
I've used both of the modules, mentioned above, and have (had) very positive experiences with it.

The concept is that it blocks any anonymous post containing hyperlinks, telling the user that (s)he should register first if (s)he wants to submit a link.
The main thing spammers want to do is leave as many links on your website as possible... so.. it's not that silly to try to stop those.

Does anyone know where I can find such a Drupal module?
If not, how would you (conceptionally) write such a module?
I'm willing to write it myself and I read the Pro Drupal Development book, but I'm not sure what's the best way to handle this specific situation...

form validation

pwolanin - June 6, 2007 - 22:24

What you want is a check at the validation stage - for comments I guess?

Which Drupal version?

see: http://api.drupal.org/api/5/function/hook_comment

drupal 4.7 compatible test version

PieterDC - June 11, 2007 - 12:05

Yes, indeed. I just made a first version of my blockanonymouslinks module and uploaded it to a website that suffers from 'people'-spam.

<?php

/**
* Implementation of hook_comment
*/
function blockanonymouslinks_comment($a1, $op) {
  global
$user;

  switch (
$op) {
      case
"validate":
       
//check if anonymous user
     
if (!$user->uid) {
         
//the first check is derived from drupal 5 filter_url method
          //the second one, from the SMF NoSpamByGuests mod
       
if (preg_match("@(http://|https://|ftp://|mailto:|smb://|afp://|file://|gopher://|news://|ssl://|sslv2://|sslv3://|tls://|tcp://|udp://)+@se", $a1["comment"]) || strpos($a1["comment"], "www.") !== false) {
         
form_set_error("comment", t("Je moet ingelogd zijn om links te kunnen posten. Dit is een anti-spam maatregel."));
        }
      }
        break;
  }
}
?>

If it seems to work, I might port it to drupal 5 and submit both versions to the drupal.org module repository..
(ps: the error message is in dutch)

Feedback of any kind is welcome!

A nice option

eli - September 11, 2007 - 14:30

A nice option would be to allow the user to select whether to block all urls (i.e. anything like http://....) or just hyperlinked urls (i.e. <A HREF="...">)

(And for anyone else reading, I posted some code for blocking anon links over here http://groups.drupal.org/node/6082 )

It depends

PieterDC - September 13, 2007 - 15:40

That option would then depend on the filter being used for comments, I think. Because you can enable a filter rule which automatically converts http://... into a <a href="">...</a> ...

I already noticed that spam-bots not only post a-href's but also the plain text and bb-code version of the urls to raise the changes for their submitted urls to be displayed as meant to be.

Anyhow, if you still want that feature, you can submit it in the feature request queue at the blockanonymouslinks module page.

 
 

Drupal is a registered trademark of Dries Buytaert.