Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: 1 2 3 4 [5] 6   Go Down

Author Topic: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting  (Read 213647 times)

0 Members and 1 Guest are viewing this topic.

DJTG

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #80 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.

Logged

fcollingwood

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #81 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
Logged

jesusarmy

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 34
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #82 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.
« Last Edit: February 28, 2008, 01:15:50 pm by jesusarmy »
Logged

Scott O

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #83 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.
Logged

dannypritchett01

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #84 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.
Logged

dannypritchett01

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #85 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')");
« Last Edit: July 28, 2008, 09:26:25 pm by Nibbler »
Logged

Nibbler

  • Guest
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #86 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.
Logged

dannypritchett01

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #87 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.
Logged

Scott O

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #88 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.
Logged

totalcollection

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Female
  • Posts: 44
  • ::.CopperMind Addicted.::
    • Total Wallpaper Collection
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #89 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
Logged
Total Wallpaper Collection
We collect everything for your desktop look and feel!
http://www.totalcollection.info

totalcollection

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Female
  • Posts: 44
  • ::.CopperMind Addicted.::
    • Total Wallpaper Collection
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #90 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/’);
Logged
Total Wallpaper Collection
We collect everything for your desktop look and feel!
http://www.totalcollection.info

totalcollection

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Female
  • Posts: 44
  • ::.CopperMind Addicted.::
    • Total Wallpaper Collection
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #91 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?
Logged
Total Wallpaper Collection
We collect everything for your desktop look and feel!
http://www.totalcollection.info

totalcollection

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Female
  • Posts: 44
  • ::.CopperMind Addicted.::
    • Total Wallpaper Collection
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #92 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
Logged
Total Wallpaper Collection
We collect everything for your desktop look and feel!
http://www.totalcollection.info

uglycars

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 45
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #93 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?
Logged

archiski123

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #94 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??
Logged

Nibbler

  • Guest
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #95 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.
Logged

archiski123

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #96 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. 
Logged

dwo

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 143
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #97 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
Logged

JoniW

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #98 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
Logged

hlabout

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 118
    • Harald Labout Fotografie
Re: Mod/Hack: Adding Akismet spam-checking to Coppermine commenting
« Reply #99 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
Logged
Pages: 1 2 3 4 [5] 6   Go Up
 

Page created in 0.028 seconds with 20 queries.