Dragonfly CMS v9 ⇒ CPG-BB (forum) ⇒ Trigger email (or other action) on forum post keyword/phrase ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum Index Modules & Blocks CPG-BB (forum)

Trigger email (or other action) on forum post keyword/phrase Reply to topic


Is it feasible to code a small hack which triggers sending admin an email if a specific keyword or phrase is included in a forum post? Spammers occasionally post the same message to all our forums but fortunately it's always for a specific service which includes certain keywords and it would be great to get an early email notification the next time it happens so I can suspend the account asap.

If the above *is* feasible, does anyone fancy creating the code? I'd be happy to pay for your time.

Note: WWW Private Listing - Staff Only

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
linux/Apache 2.4.27/MySQL 10.1.26-MariaDB/PHP 5.2.17/Dragonfly 9.2.1


Not yet, in v10 it would be possible.
However since many spammers use some kind of automated software it's easy to block them by the time they register to your website by activating the flood protection. I wont trust 9.2.1 firewall but later v9 versions are just great.

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


Thanks for the reply, looks like there's no easy solution for us at the moment in that case Sad

Note: WWW Private Listing - Staff Only

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
linux/Apache 2.4.27/MySQL 10.1.26-MariaDB/PHP 5.2.17/Dragonfly 9.2.1


If you haven't updated your website because its heavily modified... just keep modifying it Very Happy

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


NanoCaiordo wrote
If you haven't updated your website because its heavily modified... just keep modifying it Very Happy

Not easy across CVS -> Mecurial boundary.

Flood protection might work against bots (although it sours the user interface IMHO). But it won't stop the paid-to-post spammers.

To OP's question: could the bad-words feature be used/extended?

Rather than just sending an email to admin, would be better if it moderated the post first. Not sure if there is a non-display state in Forums though (as against a moved state, which would mean recording where to move it back to if it was a false positive).

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


layingback wrote
Not easy across CVS -> Mecurial boundary.

Not sure why you keep saying that, we are managing multiple websites using Mercurial and I couldn't be happier.
layingback wrote
Flood protection might work against bots (although it sours the user interface IMHO). But it won't stop the paid-to-post spammers.
Always account new features in v10 such as the DNSBL using spamhaus, tornevall ... block lists.

layingback wrote
To OP's question: could the bad-words feature be used/extended?

An anti-spam-class is partially done (should be in v9 too) but it hasn't grow as yet because new firewall extensions and somehow when I live tested on df.org's forums few users had issues. So for now its sitting there.


layingback wrote
To OP's question: could the bad-words feature be used/extended?

It wont stop any post from be made, it just replace words.
Instead you could try to require admin's approval for new registrations and deny suspicious ones?

I've recently updated a highly modified v8 to a v10, hard work but it's done.
Moving forward with Dragonfly CMS versions is of trivial importance as it will give us more up-to-date feedback.

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


NanoCaiordo wrote
Instead you could try to require admin's approval for new registrations and deny suspicious ones?


This is a good idea but we already do it! We manage to filter out most of the undesirables but inevitably a few always slip through the net (and when that happens just before our automated email goes out to subscribers containing new forum posts the results can be...embarrassing Embarassed )

Note: WWW Private Listing - Staff Only

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
linux/Apache 2.4.27/MySQL 10.1.26-MariaDB/PHP 5.2.17/Dragonfly 9.2.1


Well, I've just made this. I Hope it suits your needs, tested on DF 9.40 but I guess it should work on 9.21.

What it does?

Every time a forum topic is created or replied it searches for some spam keywords (basic detection). If it finds a match on the post's subject or post's message it will disable the user's account (suspend the user), send an email notification with the username and user id of the "suspect" and log him out.

Also, if you don't want an automated user suspension, you can comment some lines of code, you will get an email alerting you that someone tried to post SPAM with their username and user id,. Still, it will log out the user not allowing to post that message.



Open includes/phpBB/functions_post.php

find this function: function submit_post (around line 110):
In that function find:


global $userdata, $userinfo; include("includes/phpBB/functions_search.php"); $current_time = gmtime();

AFTER those lines ADD

// SPAM trigger global $user_prefix; // this Array has the spam keywords. case insensitive. basic keyword detection $spam_words = array("viagra", "china rolex"); foreach($spam_words as $word) { if(stripos($post_message, $word) !== false || stripos($post_subject, $word) !== false) { /* // uncomment to auto suspend spammer accounts $db->sql_query('UPDATE '.$user_prefix."_users SET user_level=0 WHERE user_id='".$userinfo['user_id']."' "); // The message body $mail_message = $userinfo['username']. ' has posted spam and its account has been suspended. USER ID: '. $userinfo['user_id']; // uncomment this line to send emails each time a user gets suspended by the spam filter send_mail($spamsucks, $mail_message, 0, 'User has been Suspended for spamming', 'youremail@dot.com', 'Your name Here', 'siteemail@yourdomain.com', $from_name='Yoursite name', false); */ // this block just sends an email alerting that SPAM has been found. $mail_message = $userinfo['username']. ' has posted spam. USER ID: '. $userinfo['user_id']; send_mail($spamsucks, $mail_message, 0, 'User has posted spam', 'youremail@dot.com', 'Your name Here', 'siteemail@yourdomain.com', $from_name='Yoursite name', false); // Shows an error page, logouts the user, so it wont be able to post again if its account has been disabled cpg_error('DONT POST SPAM. Your Account has been disabled',_ERROR ,getlink('Your_Account&op=logout', false)); } }

www.greenday2k.net

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


Hi greenday2k, thanks very much indeed for this - I'll give it a go as soon as I can and report back here.

Note: WWW Private Listing - Staff Only

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
linux/Apache 2.4.27/MySQL 10.1.26-MariaDB/PHP 5.2.17/Dragonfly 9.2.1


This is excellent, just what I was looking for - thanks so much! I haven't tested the account disabling feature (yet) and I've made a small change so that the forum post subject line and content are included in the email sent out but basically it's working exactly as hoped for - fantastic, thanks again!

Note: WWW Private Listing - Staff Only

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
linux/Apache 2.4.27/MySQL 10.1.26-MariaDB/PHP 5.2.17/Dragonfly 9.2.1


I'm glad it works fine for you.

Also, i did not include the the message and subject lines into the email messages to avoid triggering the spam filter on the mail box.

www.greenday2k.net

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


greenday2k wrote
Also, i did not include the the message and subject lines into the email messages to avoid triggering the spam filter on the mail box.


That's a very good point - I'll keep an eye out for that. Thanks again Smile

Note: WWW Private Listing - Staff Only

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
linux/Apache 2.4.27/MySQL 10.1.26-MariaDB/PHP 5.2.17/Dragonfly 9.2.1


Below I have an improved filter to use in v9 and v10 and most outdated PHP 5.x
Sure it will change soon but I just want to be as compatible as possible.

Using default values call as - in v9 you would also need to require_once(the file):
Antispam::POST($text);
and it will send an email from noreply@yourhost to your MAIN_CFG global adminmail.

If you want to change settings:
<?php $myoptions = array('details'=>true, 'matchLimit' =>5); Antispam::init($myoptions); Antispam::POST($text);

In both cases it will automatically check if run the filters for the user or not, send email and/or suspend. Users registered "userMinAge" days ago will always be checked, when the timeout in days expires it will still keep running the filters for users who has less then "userMinPosts" forums posts.
If the user has more then "userMinAge" AND more then "userMinPosts" will NOT be filtered.

With "details=>true" will add the searched $text as email body etc etc... multibyte safe.
Attachment: antispam.zip
Description v0.1
Filename antispam.zip
Filesize 2.24 KiB
Downloaded 6 Time(s)
You are not allowed to view/download this attachment
Attachment: antispam.zip
Description v0.2
Filename antispam.zip
Filesize 2.23 KiB
Downloaded 2 Time(s)
You are not allowed to view/download this attachment

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS

Last edited by NanoCaiordo on Tue Feb 18, 2014 10:02 am; edited 1 time in total


Neat work Nano.

My minimal suggestion is to not include "HOT" by default, it could trigger false positives, I know there is a lot of spam with "Hot Deals", "Meet Hot Russians&locals" etc.
But it's a common adjective.

The actions: warnEmail, suspendUser are available only for DF 10?

If i'm not wrong, ALL the classes will be auto loaded on DF 10?

www.greenday2k.net

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


That's right, "hot" can be removed. However all keywords will be moved to db, so user manageable ... and multilanguage will always be an issue.

Only "log" is reserved to v10 since it logs errors to file.

Yes in v10 we have an autoloader, where in v9s you need to require_once() the file. In v10 file name, class name and file location might differ from current one.

Uploaded v0.2 because some code needed to be commented out inside the POST method ...

One more thing, passing subject and text to the method would need to be done as follow:
Antispam::POST($subject.' '.$text);

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS

All times are UTC


Jump to: