Howdy all,
Lately, I've been getting buckets of comment spam on my Coppermine image gallery, and I have no obvious recourse aside from disabling anonymous commenting altogether (which, in my opinion, has a detrimental effect on commenting in general). I did see a captcha plugin for an older version of Coppermine, but haven’t invested any time in seeing if I can adapt it or if an updated version exists. So....
I've started some spare-time work on what I hope to one day become an
Akismet plugin for Coppermine. If you're unfamiliar with Akismet, it's a comment-spam management system that's adaptable to almost any application (often used with content management software like Wordpress). I'm currently using
Bret Kuhns' PHP4 library and, right now, the hack is fairly rough - but basically doesn't allow comments which are suspected as spam by the Akismet screening. The "dis-allowance" is a horridly ungraceful Coppermine "You don't have permission" error, but it works for now.
The only guidance I give the Akismet server at this point is the comment author and text, which is just scratching the surface of spam-evaluating criterion which may be passed. Also, I did not bother to modify the Coppermine database to enable tagging comments as spam, nor did I implement a way to submit false positives (ham) back to Akismet for training (although both are relatively easy to implement using the Akismet PHP4 library include). Since both of these things are essential functionality for "conscientious" Akismet usage, I've still got some work to do.
Eventually, I'd like to make it into a full-fledged Coppermine plugin - but for now it's a complete hack. It's a hack, however, that works - and that works for me until I can make it a bit more robust.
If you're interested, here's the mods to make this work in its current ugly form (modifying only the 'db_input.php' file):
First, get an Akismet API key
here. Next, download the
Akisment PHP4 library and copy it into your Coppermine root folder. Then, include the actual file at the top of your 'db_input.php' file with the following statement:
include 'Akismet.class.php';
Next, replace the following line:
$insert = cpg_db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id, msg_raw_ip, msg_hdr_ip) VALUES ('$pid', '{$CONFIG['comments_anon_pfx']}$msg_author', '$msg_body', NOW(), '{$USER['ID']}', '0', '$raw_ip', '$hdr_ip')");
With this:
$WordPressAPIKey = 'your Akismet API key goes here';
$MyBlogURL = 'http://www.example.com/coppermine_root_dir/';
$name = $msg_author;
$comment = $msg_body;
$akismet = new Akismet($MyBlogURL ,$WordPressAPIKey);
$akismet->setCommentAuthor($name);
$akismet->setCommentAuthorEmail($email);
$akismet->setCommentAuthorURL($url);
$akismet->setCommentContent($comment);
$akismet->setPermalink('http://www.example.com/blog/alex/someurl/');
if($akismet->isCommentSpam())
// store the comment but mark it as spam (in case of a mis-diagnosis)
cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
else
// store the comment normally
$insert = cpg_db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id, msg_raw_ip, msg_hdr_ip) VALUES ('$pid', '{$CONFIG['comments_anon_pfx']}$msg_author', '$msg_body', NOW(), '{$USER['ID']}', '0', '$raw_ip', '$hdr_ip')");
Well, that's it then. If you like this and could benefit from me cleaning it up, reply here and give me some encouraging words... I'd love to see full Akismet/Coppermine integration via a simple plugin... maybe I can make my own dreams come true.
Take care, enjoy.