forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Comments => Topic started by: pharaohweb on July 13, 2006, 07:09:05 am

Title: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: pharaohweb on July 13, 2006, 07:09:05 am
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 (http://akismet.com) 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 (http://akismet.com/development) 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 (http://wordpress.com/api-keys/).  Next, download the Akisment PHP4 library (http://akismet.com/development) 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:

Code: [Select]
include 'Akismet.class.php';
Next, replace the following line:

Code: [Select]
$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:

Code: [Select]
        $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.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Tranz on July 13, 2006, 04:58:32 pm
This is a great idea! I have been using Akismet in my Wordpress blog for a few months and it has stopped thousands of spam comments. I use captcha to curtail spamming for my Coppermine comments and it has worked well. The limitation is that it only works for people who can see the captcha test. I like how Akismet works in the backend and doesn't change anything for the user.

So yes, please keep up the development of this.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Tarique Sani on July 16, 2006, 04:56:24 am
Good work I was hoping that someone would do this - thanks
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Prisoner_24601 on July 17, 2006, 08:08:49 pm
Works nice, especially as I can't seem to get the catchpa plugin to work for me.

BTB, I have PHP5.  I'm usening the PHP5 class from http://www.achingbrain.net/stuff/akismet/
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: schalicto on July 22, 2006, 12:47:23 am
I have absolutley no idea what I'm doing, but I did your hack and it seems to be doing the trick.  Thanks a lot!
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: jpsloshua on July 25, 2006, 08:43:37 pm
Hey guys, after recieving alot of spam on our coppermine gallery from bots, I installed this hack. But after 5 minutes of releasing the comments for guests, those sneaky bastards still were able to post the spam. How can I verify that the hack is working properly? It makes no sense having the gallery without comments but the spammers are winning the war.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Nibbler on July 25, 2006, 10:24:59 pm
Make sure you replaced the correct line. There are 2 that are similar. Posting a link might be useful.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: jpsloshua on July 25, 2006, 10:43:14 pm
sorry very stupid of me. The gallery location is http://www.bangkokrecorder.com/fotos (http://www.bangkokrecorder.com/fotos)
I am pretty sure I replaced the correct line but will double check.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: tmitche2 on August 07, 2006, 04:29:42 pm

First, get an Akismet API key here (http://wordpress.com/api-keys/).  Next, download the Akisment PHP4 library (http://akismet.com/development) 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:


Is there anyway of getting the API Key without having a wordpress account?
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Peter Palm on August 16, 2006, 12:23:34 pm
$akismet->setPermalink('http://www.example.com/blog/alex/someurl/');

Hi there, should I change above address too or leave it as is ?
Thanks a lot for this, they're spamming like hell :-(
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Joachim Müller on August 16, 2006, 01:27:33 pm
Is there anyway of getting the API Key without having a wordpress account?
No. What's wrong with signing up there, it's free?
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Fotomaf on August 16, 2006, 11:32:09 pm
thank you for the hack, i was crazy, i went 10 days to hollidays and in the returns... 500 spams! ;)
thanks!
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: soro on August 25, 2006, 11:48:11 pm
Also from here, many thanks for the hack. I'm not getting much spam yet, but I want to close the door before it starts. And my users are unlikely to understand the Captcha thing, so I'd very much prefer to filter behind the scenes. So I'd be very grateful if you would pursue it further.

Anyone has a spam message that's supposed that should get filtered, for testing purposes? The spam I'm mostly getting seems to pass the filter, or at least I can repost it as a comment after having applied the hack. So I'm not quite sure I actually did it right.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Joachim Müller on August 26, 2006, 07:27:47 am
Spam samples taken from the Akismet spam section of my wordpress page:
In fact, 99% of comment spam is being submit to advertize pharmaceutical products.
You can try to check if the Akismet spam-checker is also blocking a false positive by adding a comment like this "The guy on the photo is looking like he was on viagra. Looks like the bloke on http://foobar.tld/"
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: soro on August 29, 2006, 12:24:47 am
Thanks, GauGau, your spam samples seem to be doing the job here. Once I submit one of them, I don't seem to be able to post any more legit comments from the same IP, though. Do you get blacklisted for one single test spam? Temporarily, I would hope.

Hi there, should I change above address too or leave it as is ?
Thanks a lot for this, they're spamming like hell :-(

There're more knowledgable people out there, of course, but it seems to me it started working for me only after I'd changed that permalink thing as well. Mine is now on www.mysite.com/pathtocpg/displayimage.php?album=lastcom&cat=0&pos=0.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: pharaohweb on August 30, 2006, 06:57:17 am
Folks, quick update on my progress here (it's been slow going). 

I've finished the mods needed to the Coppermine database to ID comments as spam.  Now, instead of Coppermine simply barfing when a spam comment is submitted, the comment is instead "poisoned" as spam (i.e. marked in the database) and not shown.  This way, users are given the ability to review comments Akismet determined to be spam, and to reclaim them as non-spam if the ID was false.  This false-positive process also successfully subits the mis-ID'd comment back to the Akismet server as "ham" to help the system get better.

For this review process, I've created a special "review spam comments" page which is similar to the current "review comments" page except it shows only comments ID'd as spam.  On this page is where you can correct Akismet if a comment was mis-ID'd, thus helping the system learn.

I've also added a "Delete selected comments as spam" button to the bottom of the regular "review comments" page.  Clicking this submits a spam comment missed by Akismet to the server and also flips its spam status to positive (i.e. "poisoning" the comment in the database and not displaying it on the picture), again helping the system learn.  Not implemented, but on the to-do list is a regular "flush" of comments ID'd as spam every ~14 days or so.

Unfortunately, I've not been working on plugin-izing all this as of yet.  Right now I'm working right in the source files and database and haven't put everything together into a neat installable/uninstallable plugin.  That's next. 

Within the next few days, I plan to start looking to how to pluing-ize the whole thing.  Before then though, I may post some raw code snippets for those not interested in waiting and more keen on modding their own installation.  I want to do a little more testing of the spam/ham functionality before I rush to get it up though.

Thanks for the support, take care.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: fixedeyes on August 31, 2006, 10:34:47 am
Hi, I'm very excited about getting this to work, but I'm having some troubles. . .
Maybe someone can help me see where I went wrong.
What happens now is there is when anyone posts any comment, nothing happens after that.  You just get a white screen.  http://www.fixedeyes.com/photos/displayimage.php?album=38&pos=2 (http://www.fixedeyes.com/photos/displayimage.php?album=38&pos=2).   
Wondering what I did? Well....
The instructions said to include this code in the 'db_input.php' file:
Quote
include 'Akismet.class.php';
This is what it looked like when I was done:
Quote
define('DB_INPUT_PHP', true);

require('include/Akismet.class.php');
require('include/init.inc.php');
require('include/picmgmt.inc.php');
I know it said to drop the 'Askimet.class.php' file in coppermine root folder, and I think I tried that correctly first, and when that wasn't working, I shifted it to the include folder... still no luck. 

The next piece of instruction was to replace the following line:
Quote
$insert = cpg_db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg...etc...
with that other chunk of code. 
But, I think that line was in that file twice. It seemed to be the exact same, should I have replaced both occurrances?
Any suggestions would be greatly appreciated.
Thanks all!
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Fotomaf on August 31, 2006, 11:40:32 pm
I have exactly the same problem with 1.4.9 version at http://www.fotomaf.com/index.php
  when somebody try to put a comment a White Screen apears and in the bar you can read http://www.fotomaf.com/db_input.php ...

I repeat the process for three time with exactly the same result
What we are doing bad?

Thanks in advance
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: ckroell on September 01, 2006, 11:51:57 am
Hi,

I do have also the 'blan screen issue'. 1.4.8 and 1.4.9 shows this as soon as a non registered person enters a comment (I replaced only line 1, not the second one for the registered users).

But anyway - it does not work because the screen wents blank and the comment is not saved...

Why?

Thank you and best regards,
Christian
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: jasa on September 02, 2006, 12:08:45 am
same for me - I get only blank screen...

Something is wrong here:  :(
Code: [Select]
$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
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: soro on September 02, 2006, 08:21:40 pm
same for me - I get only blank screen...

I also had the blank screen, until I realized I hadn't correctly entered my Akismet API key. :) Also, on my local sandbox install, it doesn't work. So I assume it's about the hack not interpreting the error Akismet probably returns if you're not authorized to use the service?

In any case, make sure you've dropped in your Akismet key, and your URL where it belongs. I believe also the Permalink URL some lines below. Finally, if your server is on PHP 5.+, from Prisoner_24601 above:

BTB, I have PHP5.  I'm usening the PHP5 class from http://www.achingbrain.net/stuff/akismet/

Hope that solves the issue. Plus, I have the serious impression that this hack seriously rrrrrrrocks. At least, I haven't seen any spam for a week or so. Eager to see the next version with the possibility to have a look into what's being filtered. :)
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: jasa on September 03, 2006, 05:12:49 pm
It is definitely not the API key...
When I use wrog key than I get
Quote
Invalid API key. Please obtain one from http://wordpress.com/api-keys/
.

I also realized that I can add comment when I put out part of code after
Code: [Select]
$akismet = new Akismet($MyBlogURL, $WordPressAPIKey);or comment the rest after
Code: [Select]
/* $akismet->setCommentAuthor($name);
$akismet->setCommentAuthorEmail($email);
$akismet->setCommentAuthorURL($url);
$akismet->setCommentContent($comment);
$akismet->setPermalink('http://www.kjd-zagreb.hr/galerija');

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 */

I tried everything but I don't know how to debug this and what is wrong in this part...
When I put only one line more for example:
Quote
$akismet->setCommentAuthor($name);
I get again only blank screen...

When I use PHP5, it doesnt work from begining (include)...

SPAMers are killing me, and captcha also doesnt seem to work...

Any help?

Greetz
J.


Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: soro on September 05, 2006, 04:12:41 am
Hmm, different idea: May it be the include 'Akismet.class.php' statement has to come after you set the IN_COPPERMINE thingy to true? I remember I also played with the order of these statements between when I got a blank screen and when it started to pull. Just an idea, perhaps complete nonsense, for which case I do apologize.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: soro on September 07, 2006, 05:54:11 pm
My Akismet hack stopped filtering. :-( Only thing I did in the meantime was to upgrade my CPG installation form 1.4.8 to 1.4.9. I redeployed the hack afterward, of course.

Anyone with a similar experience? Or is it just my site? Is there a way to monitor the communication between my installation and Akismet? I don't have access to server logs.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: ernst34 on September 10, 2006, 10:29:20 pm
I move this ost to this thjread as per suggestion of one of the Administrators:

Gau Gau
Thanks for your answer. Sorry to react late to it.
I was following your advise, got an API key and followed the procedures described in post
http://forum.coppermine-gallery.net/index.php?topic=33827.0 of Pharaoweb.

I must have done something wrong, when I did this:
------------------------------------------
<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2006 Coppermine Dev Team
  v1.1 originally written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  ********************************************
  Coppermine version: 1.4.4
  $Source: /cvsroot/coppermine/stable/db_input.php,v $
  $Revision: 1.18 $
  $Author: gaugau $
  $Date: 2006/02/24 13:30:07 $
**********************************************/

include 'Akismet.class.php';
define('IN_COPPERMINE', true);
define('DB_INPUT_PHP', true);[/size][/size]
---------------------------------------------------

I tested my new configuration in the gallery, and when I posted a test comment as a guest I only got an empty page, the route was http://www.ecolyma/galeria/db_input.php, and the page froze

I am confused now as to what the correct procedures would be.

Again, help from the forum will be much appreciated
Regards
Ernst
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: vody on September 16, 2006, 08:45:47 pm
Dear,

I think I have the solution for the "blank page" problem. I'm a newbie in programming and bad in English, so I will try to explain the little modifications I made...

The matter comes that the functions called in "db_input.php" haven't the same name in the "Akismet.class.php" document. You have to change the code that you input in "db_input.php" :

Code: [Select]
        $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->setAuthor($name);
$akismet->setAuthorEmail($email);
$akismet->setAuthorURL($url);
$akismet->setContent($comment);
$akismet->setPermalink('http://www.example.com/blog/alex/someurl/');

if($akismet->isSpam())
    // 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')");

As you can see, the functions are no more called "setCommentAuthor(); setCommentAuthorEmail(); setCommentAuthorURL(); setCommentContent() and isCommentSpam()". I give them the same name as in the "Akismet.class.php" I found.

Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: freesouljah on September 18, 2006, 07:19:07 am
your english is fine and your fix worked great...thanks a bunch for figuring this out...

peace
 ;D


Dear,

I think I have the solution for the "blank page" problem. I'm a newbie in programming and bad in English, so I will try to explain the little modifications I made...

The matter comes that the functions called in "db_input.php" haven't the same name in the "Akismet.class.php" document. You have to change the code that you input in "db_input.php" :

Code: [Select]
        $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->setAuthor($name);
$akismet->setAuthorEmail($email);
$akismet->setAuthorURL($url);
$akismet->setContent($comment);
$akismet->setPermalink('http://www.example.com/blog/alex/someurl/');

if($akismet->isSpam())
    // 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')");

As you can see, the functions are no more called "setCommentAuthor(); setCommentAuthorEmail(); setCommentAuthorURL(); setCommentContent() and isCommentSpam()". I give them the same name as in the "Akismet.class.php" I found.


Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: ckroell on September 25, 2006, 03:48:15 pm
5000 times thank you very much - your description solved my blank page issue and comments are now stored again caoorectly - waiting for the spamers now :-)
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: jasa on September 28, 2006, 12:54:06 am
finally...  ;D work for me also fine! No blank screen any more...
TNX vody!
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: ckroell on September 29, 2006, 06:02:00 pm
Hi,

I have successfully implemented this SPAM thing but do still suffer from these kind of entries:

http://tennotr.ifrance.com http://novieludi.blogspot.com/ (...) http://voyagithochu.blogspot.com/ (...) http://blditedor.blogspot.com/


I have just received more than 200 comments in a row with these links.

I do not want to force my guests to register so guests are allowed to enter comments.

Is there a chance to avoid these http comments? Maybe using this SPAM thing?

Thank you in advance.

Christian
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: ckroell on September 29, 2006, 09:33:59 pm
Please disregard my last comment - I found the solution - I hope - in a different threat and I will go on implementing the captcha thing.

Thank you,

Christian
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Thorsten on October 23, 2006, 12:07:22 am
Hello

to the first post: there are 2 identical lines that match the one to replace! Which one is to replace? I replaced the first one.
It seems to work, no errors but I don't know if spammers still can spam.
what to enter in $MyBlogURL and $akismet->setPermalink ? I entered the url to the cpg root in the first and my domain in the second field. correct? the whole rest has been untouched by me.

my gallery: http://bilder.dampftraktion.de
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Thorsten on October 23, 2006, 11:14:00 pm
adding Askimet to the gallery brought me this error:
Parse error: parse error, unexpected T_IF, expecting T_CASE or T_DEFAULT or '}' in /[...]/coppermine/db_input.php on line 40
so, commenting is not possible at the moment.....
I only edited what waswritten above.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Joachim Müller on October 24, 2006, 07:37:00 am
See my reply to your identical posting on the German support board: http://forum.coppermine-gallery.net/index.php?topic=37632.msg177659#msg177659
Please don't double-post your issues on several threads - decide for one, then stick to it.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: osh on November 10, 2006, 11:08:47 pm
Vody - thank you!!!   Your changes fix it correctly, and yes.  Your English is excellent, I was able to follow along what was going on.

This hack works great, so far.  I tested it as being logged in, not logged in with a legit anonymous comment, and with a proven spam comment (user "viagra-test-123" will always provide a true spam, based on akismet web site http://akismet.com/development/api/ (http://akismet.com/development/api/))

Now I wait patiently for pharaohweb's updates.  Being able to submit spam and ham back will allow us to help keep that database up to date and keep those evil bastard spammers at bay!!!
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Sosha on November 21, 2006, 05:21:48 pm
There seems to be a server error causing the captcha plugin/mod to not work on my host so I tried this instead and, after using the fix, it works great

hopefully the gallery will still be spam free in a few days

thanks
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: osh on November 27, 2006, 08:07:07 pm
I have currently turned off anonymous comments, there were still spam comments getting through.  I believe this is the better method, it requires less overhead from the end user to worry about.  Having to try and decipher text in an image box is not something I enjoy, so don't want to inflict that on my visitors.

I eagerly await the additional changes to get the spam/ham submissions working...
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Sosha on November 28, 2006, 01:54:31 pm
ditto, the mod seems to work well but akismet aren't stopping the type of spam that goes through.
I honestly think that if i could just block any messages that contained urls or (...) then it would be spam free
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: bllamasy@gmail.com on December 10, 2006, 10:27:40 pm
I am sorry I am new at this! I have installed akismet and done all modifications, how do I know that it is working???
Thanks in advance
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Nibbler on December 10, 2006, 11:36:49 pm
Already discussed, please read the thread before replying to it.

http://forum.coppermine-gallery.net/index.php?topic=33827.msg166277#msg166277
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: csa on December 13, 2006, 12:45:57 pm
Within the next few days, I plan to start looking to how to pluing-ize the whole thing.  Before then though, I may post some raw code snippets for those not interested in waiting and more keen on modding their own installation.  I want to do a little more testing of the spam/ham functionality before I rush to get it up though.

Thanks for the support, take care.

Sounds great pharaohweb. Any chance you might be posting fresh code snippets any time soon?
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: moli on January 16, 2007, 12:33:29 am
I´m doing anything or all bad, I 'm getting blank page.

Quote
$WordPressAPIKey =  'my api  key code (including this marks ' ')';
   $MyBlogURL = 'http://usuarios.lycos.es/moliterni/web/';
   $name = $msg_author;
   $comment = $msg_body;

   $akismet = new Akismet($MyBlogURL ,$WordPressAPIKey);
   $akismet->setAuthor($name);
   $akismet->setAuthorEmail($email);
   $akismet->setAuthorURL($url);
   $akismet->setContent($comment);
   $akismet->setPermalink('http://www.example.com/blog/alex/someurl/');

could somebody help me?

thanks in advance.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: moli on January 16, 2007, 08:57:36 pm
no ones help me?
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: osh on January 17, 2007, 10:51:52 pm
Make sure that the Akismet.class.php file contains the same function names that you are calling from your db_input.php.  (that they contain  setAuthor, setAuthorEmail, etc....)

One of the issues solved earlier was the Akismet.class changed and the function names changed.  If you are using an older Akismet.class.php file, it could be that the functions are still the older names.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: cindyr on January 23, 2007, 06:22:55 am
Hello. This looks like the perfect solution to my spam problem (thanks!), but I'm obviously doing something basic wrong. I don't get any errors, it just lets spam through, even the "viagra-test-123". http://www.sandycove.org/community/gallery

I obtained the WP API key and the Akismet.class.php. I followed your include and put it in the root folder. I found the only line that directly matched your line to replace (using search and replace) and pasted your code into it. Then correctly put in my API key and my URL. (I'm using PHP4 and using Vody's hacks to avoid the blank screen for anonymous users which by the way doesn't show up for registered users...)  Uploaded it to replace the existing db_input.php file in the root directory. Nothing. Nada. It doesn't even attempt to block spam, but doesn't create any errors or blank screens (now, thanks to Vody).

Possible causes:
1. I'm still uncertain about the permalink line. What should this be? I tried a couple of different things, but I don't know what this line is for, so I haven't a clue what it should be.

2. Um, well, I don't have any other ideas. Help?

cindyr
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: osh on January 25, 2007, 07:54:42 pm
Make sure the "patch" is applied at the correct location.  There are some similar places that is can be applied.  The original $insert=cpg_db_query... was on line 147.  As far as permalink, I didn't change anything from the sample, and it (for the most part) works.

There is still spam making it through, but the bulk of my issues were resolved with this fix.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: soro on January 25, 2007, 10:20:31 pm
The permalink thing is for if you apply it to a single blog which has one exact address, I guess. So that Akismet can know for which blog it is filtering. Now, with coppermine, you have of course a different address for each of your images. I remember I got the impression that there was an issue with the permalink when I first installed it, and I settled on the address of a random image from my gallery. Works since then.

The entire system works like a charm for me. Every once in a while, I get a few spam messages, and I'm always waiting for the dams to break. Particularly since we don't have a way to submit the coppermine specific spam that might be out there. But it seems that until now, Akismet has always learned of the new spam arriving at my gallery within a day or two.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: osh on January 26, 2007, 09:36:12 pm
Hmmm, that could be why I kept getting spam, even though akismet blocked the bulk of it.  I'll try setting the permalink to one of the images.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: MstrMitch on January 27, 2007, 09:49:33 am
I cannot get this to work and I have upgraded to the latest version

in the vody hack it says to change the hack to whatever askimet is using as its parameters. I am using the php4 version

askimet says to use these:

$format = array(
            'type' => 'comment_type',
            'author' => 'comment_author',
            'email' => 'comment_author_email',
            'website' => 'comment_author_url',
            'body' => 'comment_content'
         );

but the hack says to use these...

$akismet->setAuthor($name);
$akismet->setAuthorEmail($email);
$akismet->setAuthorURL($url);
$akismet->setContent($comment);

am I reading this wrong because I would think it should be SetAuthor($author) not ($name)

sometimes when I do this I get an array error. it shows the info for my settings but most variations give me a blank page EVEN with vody's hack changes.

Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: jasa on January 28, 2007, 07:44:18 pm
Im using PHP4 Askimet class with coppermine 1.4.8
Till now everything worked fine - I installed askimet and it reduced spam to few spam comments in a week. But now the spamers are back again and I didn't changed anything by my coppermine gallery or Askimet.

Today I even tried to simulate the spam writing someting like viagra etc. but everything goes through. Did they changed something at askimet or I don't know what happened?

I use folowing piece of code in db_input.php
Code: [Select]
$WordPressAPIKey='my_key';
$MyBlogURL = 'http://www.xxx.com/dir/';
$name = $msg_author;
$comment = $msg_body;

$akismet = new Akismet($MyBlogURL, $WordPressAPIKey);
$akismet->setAuthor($name);
$akismet->setAuthorEmail($email);
$akismet->setAuthorURL($url);
$akismet->setContent($comment);
$akismet->setPermalink('http://www.xxx.com/dir/');

if($akismet->isSpam())
    // 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')");

What for is this setPremalink command anyway?

Thanks!

Greetz
J.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: soro on February 03, 2007, 03:09:00 am
That setPermalink sets some information that the Akismet system wants to collect/verify. It should normally point back to your blog. But since we're here not talking about a blog, but about a whole lot of different pictures, it's not quite obvious what to correctly fill in here... It may, at some point in time, prevent Akismet from catching all the spam if it doesn't point back to the exact URL for which the system is put to work, but I don't think that's the case now.

Akismet reads every message posted to your gallery against a database of spam messages that have been submitted and identified as spam by users. There may be some spam messages which are clearly spam, but haven't been identified as such by any Akismet user (yet). Those spam messages will get through. Don't expect Akismet to catch everything! If you want to implement and never look back, consider Captchas instead.

If you want to check whether your Akismet implementation works, you have to send a comment to your gallery which is clearly in the Akismet database. There're a few sample spam messages a few pages up in this thread, which have done the trick for me a few months back.

You may also look into your server logs or, better, webstats if you compile them for instance with Awstats. If your hits on db_input.php are considerably more frequent than ham AND spam arriving at your gallery, it's my understanding that Akismet is filtering something. Also, I've found that the spambots posting to my site hit directly on db_input.php, without doing some camouflage moves through the gallery before. Which means my Awstats counts them as Entry/Exit to the site. Normal legit users shouldn't enter the site at the comment input script, I would believe. So you can count those Entry/Exit hits, or hosts which don't leave any trace other than hits con db_input.php, as spambots, and see whether the number of those hits is considerably higher than the Spam arriving at your gallery. If it is --> take it as evidence that Akismet is performing.

Also a trace of the spammers in your webstats: Hosts which make as many hits as pageviews. I don't think there's any page which is worth just one hit in most of our sites, so you can assume that those one-hit-per-pageview visits are spambots. Again, to have an idea how much exposure to spambots you have, and to weigh it against the spam that's actually arriving.

The shame is that we don't have the full plugin promised by Pharaoweb so far. With that, we could submit our own spam samples to Akismet, and we could also see what's identified as spam by Akismet. We could be full Akismet users, in other words. But I'm not complaining! :-)
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: jasa on February 10, 2007, 11:29:10 pm

Thank you for your long reply soro.

However some things connected to Askimet are still unknown for me.
I just noticed that Askimet efficiency dropped to nearly zero in my case in last 2 months. At the beginning when I installed Askimet I had few comments in a week or day. Now I’ve again 30-100 or more per day! Why is Askimet filtering so badly or SPAMers are now much better?

However I did some simple tests – when I put for the name of commenter for example “Viagra”, and for comment ”visit Viagra site” – Askimet will block the comment. When I change the name of commenter to for example Marco, and use same comment text (visit Viagra site) comment will go trough. Both examples are simplest case of spam. Why Askimet let the second one to go through?

I implemented Askimet also on cutenews and some other scripts… It is the same problem and spamers are now back again. :(
I wanted to try with captcha but it didn’t work with my gallery.

Awstats says for January that db_imput.php was 2022 accessed, from which was 728x entry, and 1257 exit. However as you say I don’t know how much Askimet blocked because I delete every week all spam in my gallery – and it was lot, more than 500 for sure…

It seems that I’ve to move to other solutions for spamers such as captcha is…

TNX…
Greetz
Jasa
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: soro on February 11, 2007, 12:10:54 am
At my gallery, they arrive in bouts. But after two days or three, it's always been over so far. Why Akismet blocks some things and not others, that's certainly something they would have to tell. It's not a perfect defense, and the spammers can probably also interfere with the filtering and mark their own shit as ham. So on the long run, it depends on everyone cooperating in telling spam from ham. We can't do that for the moment. But having a more elaborate Akismet module would probably mean some serious mods to the database... Which is something I certainly cannot do on my own.

I guess somebody thinks there may be legit reasons for people to exchange about erectile dysfunction and cures for it.

On a different system, I've made pretty positive experiences with Bad Behavior. That also looks like something that could be implemented rather easily. Or perhaps, it's just back to the captcha and other challenges once it gets too bad.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: morktron on February 14, 2007, 01:15:23 am
Hello everyone, well done developing this thing.

I can't get it to work though, I'm getting a blank screen despite using the fix.

in my akismet.class.php i have:

'type' => 'setType',
'author' => 'setAuthor',
'email' => 'setAuthorEmail',
'website' => 'setAuthorUrl',
'body' => 'setContent'

in my db_input.php i have:

   $akismet = new Akismet($MyBlogURL ,$WordPressAPIKey);
   $akismet->setAuthor($name);
   $akismet->setAuthorEmail($email);
   $akismet->setAuthorURL($url);
   $akismet->setContent($comment);
   $akismet->setPermalink('http://www.yellowyak.tv/');

should it be working?
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: fcollingwood on February 16, 2007, 12:32:06 pm
Hi

Using 1.4.10 and the latest version of akismet.class.php. I also had the blank screen problem, and on looking at the changes made in the current (as of todays date) class, this is how you get it to work (Replace the bold sections with your own relevant information):

Quote
        $WordPressAPIKey =  'put your API key here';
        $MyBlogURL = 'put your gallery URL here';
        $name = $msg_author;
        $comment = $msg_body;

        $check_comment = array(
                'author'         => $name,
                'email'           => 'no-one@nowhere.com',
                'website'        => 'http://www.example.com/',
                'body'           => $comment,
                'permalink'     => 'put a link to one of your images here',
        );

        $akismet = new Akismet($MyBlogURL ,$WordPressAPIKey,$check_comment);

        if($akismet->isSpam())
                // 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')");
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: fcollingwood on February 16, 2007, 12:35:15 pm
Update to above - Akismet PHP4 class version is 0.3.3
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: fcollingwood on February 16, 2007, 01:00:07 pm
Final update to the above......

Find the following lines in db_input.php:


Above each of these lines, add the following (do not replace them!!!!):

Quote
        $WordPressAPIKey =  '853b85ad0ab0';
        $MyBlogURL = 'http://www.collingwood.me.uk/gallery/';
        $name = $msg_author;
        $comment = $msg_body;

        $check_comment = array(
                'author'        => $name,
                'email'         => $email,
                'website'       => 'http://www.example.com/',
                'body'          => $comment,
                'permalink'     => 'http://http://www.collingwood.me.uk/gallery/displayimage.php?album=6&pos=4/',
        );

        $akismet = new Akismet($MyBlogURL ,$WordPressAPIKey,$check_comment);

        if($akismet->isSpam())
                // 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

This does not allow spam comments from anonymous or registered users, and also prevents editing of an existing, innocuous, comment to add spam. All done, your gallery is no longer open to abuse by the b'stards!
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Anrulz on February 21, 2007, 02:04:05 pm
I did all what said above but I dont have anythin changed
www.hababam.biz/galeri
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Anrulz on February 21, 2007, 02:49:22 pm
Do I need to add bad words on my own or what ? :( anyways guys the problem why all you get blank page is pharoah is telling you the way with php5 library but you are downloading php4 keep this in mind ...
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Vee on February 27, 2007, 03:19:10 am
if you're using 1.4.10. do fcollingwood's solution. it works great!
thank you so much!  ;D
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: fcollingwood on February 27, 2007, 04:04:16 am
Revisited over the weekend, and have hacked Coppermine to death. Unfortunately, I haven't pluginised the hacks, but if you understand PHP, and are able to alter MySQL tables, you should be able to install it.

Hack Features:
Spam comments are added into the comment DB table, but are not displayed.
You can report false negatives to Akismet
You can report false positives to Akismet
You can submit abuse reports and delete the spam at the click of a button.

Can be found here (http://www.collingwood.me.uk/downloads/coppermine.rar)
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: fcollingwood on February 28, 2007, 10:47:54 pm
And now here's an even easier way to block spam......

Just add this directly after the include/require (Or function, if you have them) declarations in db_input.php:

Code: [Select]
if(preg_match(/"db_input.php"/,$_SERVER['HTTP_REFERER'])) cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);

As the spammers generally just call db_input.php with the POST variables set, the referer is usualy <gallery url>/db_input.php (if the gallery is used as it should be, the referer will be displayimage.php)

This is a much easier to implement hack, downside is, there is no reporting; with my previous hack, I've been annoying a prolific spammer over the last few days, as every abuse report has been ending up in their email inbox over the last few days, as the reports are emailed to the domain registrant. They've now blocked mail from my mailserver  ;D. It's also caused >20 of their sites to be taken down, and also 6 compromised spambots have been fixed
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Joachim Müller on March 01, 2007, 08:58:50 am
Downside: legitimate users (non-spammers) who run a privacy app like Norton Internet Security will not have the referer var populated and therefor will fail to be able to post comments without an error message.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: fcollingwood on March 01, 2007, 09:55:29 am
Should be ok - it tests for the presence of "db_input.php" in the referer var, and blocks if it finds it. If the variable is empty, everything will proceed as normal.

It does work, I'm running NIS, and I can post on my gallery.........
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Joachim Müller on March 01, 2007, 10:20:59 am
Spammers will adopt to this technique pretty fast and not send a referer then.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: fcollingwood on March 01, 2007, 11:42:08 am
Ah well - there's the rest of the hack then (Moved all of the spam related functions to a single include today)......either way, I've gone from lots of spam to nothing, while still getting legitimate comments.
Title: Uploading dead after akismet
Post by: Anrulz on March 22, 2007, 10:20:53 pm
Hi guys I think after installing akismet I am not able to upload any pictures.
Test user: Boramir:12345678

I live in germany so the site is also in german I want to make it english but I cant after setting up to english it becomes german again my english better than german how can I use it always english ?
Title: Re: Uploading dead after akismet
Post by: Anrulz on March 22, 2007, 10:21:48 pm
I cant see edit ...

www.hababam.biz/galeri is my gallery
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Anrulz on March 22, 2007, 10:22:35 pm
Hi guys I think after installing akismet I am not able to upload any pictures.
Test user: Boramir:12345678
www.hababam.biz/galeri

I live in germany so the site is also in german I want to make it english but I cant after setting up to english it becomes german again my english better than german how can I use it always english ?

Thanks a lot appreciated.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Anrulz on March 23, 2007, 11:26:55 am
GauGau sorry for cross posting , it is an upload problem actually so I wanted to open a thread there as well , did you understand the problem ?
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Anrulz on March 27, 2007, 10:38:53 pm
Can somebody please tell me how do I delete this akismet thing and return my gallery back to old values because it is non sense anymore because spam bots are spamming like hell...So that at least I can upload pictures again ...
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Joachim Müller on March 29, 2007, 08:13:01 am
Just undo the modifications you applied.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: michiel on May 12, 2007, 01:01:26 pm
Hi,
After attempts to include Captcha in my album (http://lorelei.dwaalgasten.nl/frummel/index.php (http://lorelei.dwaalgasten.nl/frummel/index.php) the conclusion appeared to be, unfortunately, that my hosting firm does not support it. Now I have turned to Askimet. However, I just get the white page, and the db_input.php page. At the forum several sollutions are suggested; this is what I have done sofar:
- I use Coppermine 1.4.8 and PHP4
- I have today downloaded the latest askimet.class.php file, and included in the root folder
- I have included Vody's (reply 25) suggestion; result is the white page
- I have included fcollingwood' suggestions (reply 54 and next 56): still the white page
Any other suggestions, please?
Thanks!
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Joachim Müller on May 12, 2007, 01:24:37 pm
- I use Coppermine 1.4.8
May or may not be related, but upgrading to the most recent stable release (currently cpg1.4.10) is absolutely mandatory no matter what.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: JLB on June 04, 2007, 09:36:28 pm
First, thanks very much to everyone involved in creating and refining this hack. I'm using fcollingwood's file with Coppermine 1.4.10 and installation was (or seemed to be) a snap.

I have some issues that I hope are minor, but I'd like to try to solve them myself before posting for help.  What I want to know is what logfiles would be associated with the actions taken by the hack code?  I'd like to see if I can find that I've made a simple error just by reading those logs.

(It seems to detect spam properly -- my "new comments" email indeed appends the fact that the comment has been marked as spam.  However, the comments are still visible to users.  Also, "Report and Delete" seems to hang, with no effect that I can tell.)

Thanks,
Joe
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: JLB on June 06, 2007, 03:00:47 pm
^^OK, I've solved my problem, and this may help others as well.

I was only looking at the "Last Comments" page as an anonymous user to determine whether it was working properly.  What I eventually figured out was that it WAS blocking spam comments from being shown with individual pictures, but not on the "Last Comments" page.

Since this is the page my wife tends to view most often, it was important to me to get this fixed.

****************************
DISCLAIMER:
I'm NOT a PHP or SQL Expert. 
I'm NOT EVEN a PHP noob.
The only testing that was done was that this fixed MY problem on MY Coppermine 1.4.10 install.
****************************

It appears that the comments shown on the "Last Comments" page are queried from the section of code that begins on Line 963 of functions.inc.php (in /include)

I made very minor changes to two queries in this section, and it seems to have fixed the problem.

The first is on Line 979

The ORIGINAL, UMODIFIED QUERY:
Code: [Select]
$query = "SELECT COUNT(*) from {$CONFIG['TABLE_COMMENTS']}, {$CONFIG['TABLE_PICTURES']}  WHERE approved = 'YES' AND {$CONFIG['TABLE_COMMENTS']}.pid = {$CONFIG['TABLE_PICTURES']}.pid $TMP_SET $keyword)";
All I did was ad an "AND" to check that is_spam=0.  If you don't change this query, your spam comments will still be masked, but it will count ALL the records, and show you empty pages where the spam comments would be.

Modify the above query to match this:
Code: [Select]
$query = "SELECT COUNT(*) from {$CONFIG['TABLE_COMMENTS']}, {$CONFIG['TABLE_PICTURES']}  WHERE approved = 'YES' AND {$CONFIG['TABLE_COMMENTS']}.is_spam = 0 AND {$CONFIG['TABLE_COMMENTS']}.pid = {$CONFIG['TABLE_PICTURES']}.pid $TMP_SET $keyword)";

One more query to do.  It's on line 993.  This is the one that actually loads the comments (vs counting the comments it intends to load).

This is the ORIGINAL, UNMODIFIED QUERY:
Code: [Select]
$query = "SELECT $select_columns FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE approved = 'YES' AND c.pid = p.pid $TMP_SET $keyword) ORDER by msg_id DESC $limit";
Again, I just added an AND.  Modify it to match this:
Code: [Select]
$query = "SELECT $select_columns FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE approved = 'YES' AND c.pid = p.pid AND c.is_spam = 0 $TMP_SET $keyword) ORDER by msg_id DESC $limit";
I don't know enough to know whether it will be in exactly the same place on every install, nor whether functions.inc.php is the same on every 1.4.10 install, so that's why I thought it would be better to just post exactly what I did.  It does, however, work.

Joe
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: JLB on June 06, 2007, 07:07:06 pm
^^ And just one more note.  If it wasn't clear from my post, the changes I posted are to be done in addition to application of fcollingwood's hack, which is linked at the top of page 4 of this thread.  I intend to keep a copy of his files, so if he removes hosting at some point, PM me and I will provide his files + my changes.

Joe
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: fcollingwood on June 07, 2007, 01:56:26 pm
Thanks for tidying up the loose ends there Joe - Glad the hack helped.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: fcollingwood on June 30, 2007, 03:27:02 am
Here is a source of comment spam:

http://www.netgainhosting.net/

As you can see, they make mention of rover-host.com, a spammer friendly hosting outfit. I've had quite a few attempts at spamming originate from their hosts, which are 64.22.110.34 and 64.22.110.35.

I spoke nicely to the abuse department of my hosting company, they went and had a look, and have now configured their firewalls to drop incoming traffic from these two hosts. You may want to do the same.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: deandre81 on July 07, 2007, 09:47:53 pm
is any of this up to date cause i got the akismet but it only comes as a 28kb file named "akismet.php" along with a gif image file "akismet.gif"
version 2.0
or have i downloaded the wrong thing....
because i get a blank screen in firefox but get this error in explorer
Fatal error: Call to undefined function: add_action() in /home/content/d/e/a/deandre81/html/coppermine/akismet.php on line 25
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: DJTG on July 12, 2007, 01:05:42 pm
Is akismet still alive? I tried all methods posted in this Thread but can't get it to work. It seems it doenst filter any spam comments i try (also the examples by gau-gau). At the moment i am using the hack from fcollingwood and got the same prob.

Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: fcollingwood on July 16, 2007, 08:39:46 am
The methods have probably changed again. You'll need to have a look at the Akismet plugin, and modify the hack accordingly
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: jesusarmy on February 28, 2008, 12:52:37 pm
is any of this up to date cause i got the akismet but it only comes as a 28kb file named "akismet.php" along with a gif image file "akismet.gif"
version 2.0
or have i downloaded the wrong thing....
because i get a blank screen in firefox but get this error in explorer
Fatal error: Call to undefined function: add_action() in /home/content/d/e/a/deandre81/html/coppermine/akismet.php on line 25


You downloaded the wrong file: the correct one is PHP5 Class or PHP4 Class (depending on your version of PHP) on http://akismet.com/development/

For the sake of completeness, this is what the relevant sections of my PHP4 mod look like now, updated to reflect the new PHP4 Class version of akismet.class.php:
Code: [Select]
        $WordPressAPIKey =  'xxxxxxxxxxx'; // Put your API key here
        $MyBlogURL = 'http://www.jesus.org.uk/gallery/displayimage.php?album=lastcom&cat=0&pos=0';

        // load array with comment data
        $comment = array(
            'author'       => $msg_author,
            //'email'        => $email,
            //'website'      => $url,
            'body'         => $msg_body,
            'permalink'    => $MyBlogURL,
        );
        // instantiate an instance of the class
        $akismet = new Akismet($MyBlogURL,$WordPressAPIKey,$comment);

        // Check for spam
        if ($akismet->isSpam()) { // returns true if Akismet thinks the comment is spam
            // do something with the spam comment
            // store the comment but mark it as spam (in case of a mis-diagnosis)
            if (!isset($lang_errors['spam_found'])) $lang_errors['spam_found'] = 'Spam?' . $lang_errors['perm_denied'];
            cpg_die(ERROR, $lang_errors['spam_found'], __FILE__, __LINE__);
        } else {
            // do something with the non-spam comment
            // 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')");
        }

/*
        $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', '" . addslashes(USER_NAME) . "', '$msg_body', NOW(), '', '" . USER_ID . "', '$raw_ip', '$hdr_ip')");
*/

However, the process is interminably slow, and I'm not sure if I will be using it.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Scott O on May 10, 2008, 09:42:13 am
Okay, I just read over the entire thread, but I'm not a developer or PHP expert, so I'm really confused.

Since the original instructions appeared, it looks like there have been a lot of modifications, etc.  I'm not sure which ones to add and which ones are obsolete.  I'm wondering if someone could update the instructions with all the updates, etc, to something really simple for an idiot like me.

I'm using PHP5 which I guess makes a big difference.

Thanks.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: dannypritchett01 on July 28, 2008, 08:18:52 pm
I did what it said on page 1, as well as what is mentioned below.

^^OK, I've solved my problem, and this may help others as well.

I was only looking at the "Last Comments" page as an anonymous user to determine whether it was working properly.  What I eventually figured out was that it WAS blocking spam comments from being shown with individual pictures, but not on the "Last Comments" page.

Since this is the page my wife tends to view most often, it was important to me to get this fixed.

****************************
DISCLAIMER:
I'm NOT a PHP or SQL Expert. 
I'm NOT EVEN a PHP noob.
The only testing that was done was that this fixed MY problem on MY Coppermine 1.4.10 install.
****************************

It appears that the comments shown on the "Last Comments" page are queried from the section of code that begins on Line 963 of functions.inc.php (in /include)

I made very minor changes to two queries in this section, and it seems to have fixed the problem.

The first is on Line 979

The ORIGINAL, UMODIFIED QUERY:
Code: [Select]
$query = "SELECT COUNT(*) from {$CONFIG['TABLE_COMMENTS']}, {$CONFIG['TABLE_PICTURES']}  WHERE approved = 'YES' AND {$CONFIG['TABLE_COMMENTS']}.pid = {$CONFIG['TABLE_PICTURES']}.pid $TMP_SET $keyword)";
All I did was ad an "AND" to check that is_spam=0.  If you don't change this query, your spam comments will still be masked, but it will count ALL the records, and show you empty pages where the spam comments would be.

Modify the above query to match this:
Code: [Select]
$query = "SELECT COUNT(*) from {$CONFIG['TABLE_COMMENTS']}, {$CONFIG['TABLE_PICTURES']}  WHERE approved = 'YES' AND {$CONFIG['TABLE_COMMENTS']}.is_spam = 0 AND {$CONFIG['TABLE_COMMENTS']}.pid = {$CONFIG['TABLE_PICTURES']}.pid $TMP_SET $keyword)";

One more query to do.  It's on line 993.  This is the one that actually loads the comments (vs counting the comments it intends to load).

This is the ORIGINAL, UNMODIFIED QUERY:
Code: [Select]
$query = "SELECT $select_columns FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE approved = 'YES' AND c.pid = p.pid $TMP_SET $keyword) ORDER by msg_id DESC $limit";
Again, I just added an AND.  Modify it to match this:
Code: [Select]
$query = "SELECT $select_columns FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE approved = 'YES' AND c.pid = p.pid AND c.is_spam = 0 $TMP_SET $keyword) ORDER by msg_id DESC $limit";
I don't know enough to know whether it will be in exactly the same place on every install, nor whether functions.inc.php is the same on every 1.4.10 install, so that's why I thought it would be better to just post exactly what I did.  It does, however, work.

Joe

akismet.class.php version 0.3.4
Code: [Select]
var $blogUrl = "http://www.dannysgamefowlfarm.com/cpg/";
var $apiKey  = "MY KEY REMOVED";
var $comment = array();
.....................skip a lot of code.....
function _formatCommentArray() {
$format = array(
'type' => 'comment_type',
'author' => 'comment_author',
'email' => 'comment_author_email',
'website' => 'comment_author_url',
'body' => 'comment_content'
);

db_input.php

Code: [Select]
include 'akismet.class.php';
define('IN_COPPERMINE', true);
define('DB_INPUT_PHP', true);

require('include/init.inc.php');
require('include/picmgmt.inc.php');
require('include/mailer.inc.php');
require('include/smilies.inc.php');

... skip a lot of lines...

$WordPressAPIKey =  '....my key removed....';
$MyBlogURL = 'http://www.dannysgamefowlfarm.com/cpg/';
$name = $msg_author;
$comment = $msg_body;

$akismet = new Akismet($MyBlogURL ,$WordPressAPIKey);
$akismet->setAuthor($name);
$akismet->setAuthorEmail($email);
$akismet->setAuthorURL($url);
$akismet->setContent($comment);
$akismet->setPermalink('http://www.dannysgamefowlfarm.com/cpg/displayimage.php?album=lastcom&cat=0&pos=18');

if($akismet->isSpam())
    // 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')");


and of course my funcions.inc.php was modified as stated above. When I post a spam message such as buy levitra online | http://buy-levitra-online.mabulle.com/ it posts it as if the hack was never made. Yet when I click "last comments" i get this error...

There was an error while processing a database query

Use this if you wish to test...

User: test
Pass: testpass

I have to work tonight so I will be home around 10-11pm. Hopefully we can figure it out. Ive been getting users in my gallery posting the same spam message on every photo. Its annoying.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: dannypritchett01 on July 28, 2008, 08:47:56 pm
Where is the edit on this message board? I tried to edit my last post...

I changed my db_input.php as mentioned in the akismet class usate code below to the code at the end of the post but still nothing working and spam still gets entered...

 * <code>
 *    $comment = array(
 *           'author'    => 'viagra-test-123',
 *           'email'     => 'test@example.com',
 *           'website'   => 'http://www.example.com/',
 *           'body'      => 'This is a test comment',
 *           'permalink' => 'http://yourdomain.com/yourblogpost.url',
 *        );
 *
 *    $akismet = new Akismet('http://www.yourdomain.com/', 'YOUR_WORDPRESS_API_KEY', $comment);
 *
 *    if($akismet->errorsExist()) {
 *        echo"Couldn't connected to Akismet server!";
 *    } else {
 *        if($akismet->isSpam()) {
 *            echo"Spam detected";
 *        } else {
 *            echo"yay, no spam!";
 *        }
 *    }
 * </code>

updated code in db_input.php

Code: [Select]
   $WordPressAPIKey =  'xxx';
$MyBlogURL = 'http://www.dannysgamefowlfarm.com/cpg/';
$name = $msg_author;
$comment = $msg_body;

$akismet = new Akismet($MyBlogURL ,$WordPressAPIKey);
$akismet->setauthor($name);
$akismet->setemail($email);
$akismet->setwebsite($url);
$akismet->setbody($comment);
$akismet->setpermalink('http://www.dannysgamefowlfarm.com/cpg/displayimage.php?album=lastcom&cat=0&pos=18');

if($akismet->isSpam())
    // 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')");
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Nibbler on July 28, 2008, 08:57:23 pm
You post code that applies this mod to anonymous users but yet you test with a registered user. The code change does not affect that.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: dannypritchett01 on July 28, 2008, 09:05:18 pm
oh ok. Would you please edit the post and remove the api key, I accidently posted it with my last post and I can not find a edit or modify button as the help section says.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Scott O on July 29, 2008, 08:06:40 pm
After reading through this entire board (again), I'm still confused on implementing this.

Since the original post there have been several modifications, etc.  My questions:

-Should I still follow the instructions in the original post (i.e. have they been updated)?  If not, has anyone combined all the updates, fixes, etc, into a new set of instructions?

-Does this work with PHP 5?  I can't discern whether or not it does merely by reading this thread.

-There was talk of making this into a plug-in for Coppermine.  Did anyone ever do that?  (I would, but I don't have the skillz!)

Thanks in advance for any info you can share.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: totalcollection on October 23, 2008, 05:44:03 pm
Which one to download then?

Code: [Select]
Libraries

    * David Lynch's Python library
    * Voidspace Python module
    * PHP 5 class by Alex
    * PHP 4 class by Bret Kuhns
    * Micro-Akismet PHP class by Gaby Vanhegan
    * CFAkismet for Coldfusion
    * Net::Akismet Perl module on CPAN
    * David Czarnecki's Java API
    * David Czarnecki's Ruby API
    * Ruby on Rails plugin
    * Lasso API
    * Akismet .Net 2.0 API Library
    * Akismet .Net 1.1 API Library
    * Code Igniter (PHP) Library
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: totalcollection on October 23, 2008, 05:49:12 pm
Edit: Well found it: http://www.achingbrain.net/stuff/php/akismet
But what to enter here:

#
$akismet->setPermalink(‘http://www.example.com/blog/alex/someurl/’);
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: totalcollection on October 23, 2008, 06:08:32 pm
strange when I tried to enter some comments, it returned: include 'Akismet.class.php';

Any solution, please?
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: totalcollection on October 23, 2008, 06:19:02 pm
Edit: Seems to work fine now. Anyway, I attempted to do some spam by entering many links, and it returns this:

You don't have permission to perform this operation. 

Is this the correct behavior from my setup of Akismet? If so, I am now free from SPAM!!!
BRAVO
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: uglycars on November 19, 2008, 03:25:41 am
I get this error after doing the mod:
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /homepages/40/d237348395/htdocs/uglycars/photo/gallery/Akismet.class.php on line 66

I also put the db_input.php mod here:
require('Akismet.class.php');
require('include/init.inc.php');
require('include/picmgmt.inc.php');
require('include/mailer.inc.php');
require('include/smilies.inc.php');

is that correct?
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: archiski123 on August 18, 2009, 10:05:43 pm
 ???

I tried implementing this.  Unfortunatley I now very little about PHP.  I have tried with both PHP4 and PHP5. 
I do believe that I have read the entire thread (about 3 times). 

My problem I believe is more basic. when I try to add a comment, I get :

Fatal error: require() [function.require]: Failed opening required 'include/akismet.class.php' (include_path='.:/usr/local/php5/lib/php') in /home/skildum/www/www/darcarphoto/db_input.php on line 27

I assume there is something someplace that sets the include_path, but I do not know how or where. 

You can see my site in the error message. 

Any Ideas??
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Nibbler on August 18, 2009, 10:53:33 pm
What do you have on line 27? The instructions say to put

Code: [Select]
include 'Akismet.class.php';

The error message says you put something different.

Post a link to your gallery so we can see if you uploaded Akismet.class.php to the correct location.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: archiski123 on August 18, 2009, 11:15:11 pm
I did get it figured it out.  The problem in following the entire thread, that some indicated a
Requires('include......).  I thought that was how some people had made it work. 

I did go back to the plain old include, and now it works. 

Thank you for getting back to me. 
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: dwo on March 13, 2010, 08:23:54 pm
Works wonderful. Thank you.

It is important that you dont use your existing blog aksimet key, but get a new one at the website of akismet.

That was my problem with getting the white screen..


regards
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: JoniW on August 10, 2010, 08:21:04 am
I have no idea how to mess with any of this stuff. Is is just wise then, to makes sure you approve of all comments so that you can week them out via email and approve the ligit ones?

If I knew any of this hack business, I'd try it but for me I'd say I am Artist Jim not a damn Hacker!  :D
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: hlabout on August 16, 2010, 10:21:08 am
Running cpg 1.4.26 on PHP version 4.4.7 on my gallery www.haraldlabout.nl
Downloaded PHP 4 class library from askimet.com
Installed mod and applied modifications by fcollingwood's.
Working fine so far, no waiting and see if the spam comments disappear.

Harald
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Joachim Müller on August 16, 2010, 01:19:06 pm
Existing spam records won't go away using this mod afaik. Only new comments posted after applying the mod will be processed by Akismet. There are instructions available how to test for yourself:
Quote from: http://akismet.com/development/api/
If you are having trouble triggering you can send "viagra-test-123" as the author and it will trigger a true response, always.
Alternatively, simply create a new posting with the text of 'akismet-test-123'. Any comment with this name or content will be marked as spam by the Akismet service. If this comment is also detected as spam, then everything is working perfectly. Possible values are "viagra-test-123" and "akismet-test-123" that will help you test if things are working as expected.
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: hlabout on August 16, 2010, 06:05:10 pm
Joachim,

Disappear was a wrong word choice of mine.
I know it only prevents new spam in the comment field.

Half a year ago I removed the possibility of adding comments due to the frequent spam messages even with captcha installed.
I hope the Akismet mod will prevent this so I activated the comment option again.

Tested the mod as described by you, found working fine, both mentioned options where blocked..

Next step will be disabling links in the comment filed, any tips?
Thanks again for the feedback.

Harald
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: Joachim Müller on August 19, 2010, 07:46:16 am
Next step will be disabling links in the comment filed, any tips?
Not related to this thread. No thread drift!
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: fcollingwood on December 07, 2010, 03:33:22 am
Right, some more hacking of the gallery to take advantage of some more stupidity on the part of the spam bots.......


Both methods tested, humans can still post, bots can't
Title: Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
Post by: galacmardan on February 26, 2011, 11:05:08 am
Thank you for this.