!JoomlaComment is one of the leading free commenting components for Joomla!. I've been using the component since the beginning of my website.
As I said before, !JoomlaComment isn't perfect (yet). It's still missing some features that make others (Like JomComment) more attractive, like the support for trackback. On the other hand, !JoomlaComment does allow threaded / nested comments which is a big positive point.

We're now going to disable the CAPTCHA and enable Akismet support in !JoomlaComment. How? By "hacking" in the !JoomlaComment core.
So let's edit the PHP code from !JoomlaComment and add Akismet support! This tutorial is written for the latest release of !JoomlaComment at this moment: 3.26.
Before you start, I strongly suggest that you backup your files before changing. In case something goes wrong, you can just put everything back as it should be.
Resources
First things first, you'll need to have the following before we can start:- PHP5 class for Akismet by Aching Brain. There also is a PHP4 class, but this tutorial is written for PHP5.
- A WordPress API Key needed to get Akismet working.
- A PHP editor (Notepad++, Dreamweaver, Eclipse etc.)
- Good pair of brains.
The setup
UnZIP the archive that contains the PHP5 class for Akismet that you downloaded in the previous step. Grab the class file (Akismet.class.php
) and upload it to the following folder on your FTP:/components/com_comment/joscomment/
While you're still there, grab the class file from !JoomlaComment to change (
comment.class.php
). Open that file with your PHP editor.Dig in te code
First, we'll need to make a reference to the Akismet class. From line 25 till 28, you'll see a couple of PHP includes. Add another one on line 29:require_once($mosConfig_absolute_path.'/components/ com_comment/joscomment/Akismet.class.php');Now search for the function that inserts new comments to the database (
function insertNewPost
around line 995). Inside that function, there is will be a query prepared to write to the database ($database->SetQuery
arund line 1022). Now add the following code before that query.// START Marcofolio.net Akismet $WordPressAPIKey = 'XXXXXX'; // Insert WordPress API Key $MyBlogURL = 'http://www.XXX.com'; // Insert your own blog URL (Don't end with '/') $akismet = new Akismet($MyBlogURL ,$WordPressAPIKey); $akismet->setCommentAuthor($this->_tname); $akismet->setCommentAuthorEmail($this->_temail); $akismet->setCommentAuthorURL($this->_twebsite); $akismet->setCommentContent($this->_tcomment); // For Joomla! 1.0.x $akismet->setPermalink($MyBlogURL.'/index.php?option=com_content& task=view&id='.$this->_content_id); // For Joomla! 1.5.x $akismet->setPermalink($MyBlogURL.'/index.php?option=com_content& view=article&id='.$this->_content_id); if($akismet->isCommentSpam()) { // store the comment but mark it as spam (in case of a mis-diagnosis) $published = 0; } // END Marcofolio.net AkismetMake sure you change the
$WordPressAPIKey
into the API Key that you found in your WordPress registration mail. Also, change the $MyBlogURL
value to the place where you have your blog. Don't end with a slash ("www.marcofolio.net" is a good value, "www.marcofolio.net/" is not).Akismet needs the permalink where the comment has been submitted. In Joomla!, the way of viewing articles is different from Joomla! 1.0.x and 1.5.x . Check which version of Joomla! you're running and remove that line that doesn't belong to your version. Also, make sure that the variable is on one line (had to do it on multiple lines here because of fitting on the page).
That's it! Save the file and upload it back to the server.
Testing
Everything should be working fine now. First, disable CAPTCHA from the component settings in the admin panel. Now go to your blog and try to make a comment like you would normally do. Everything should be working fine now.To test if it actually worked, use the following username: viagra-test-123. When now trying to submit, the comment will be caught as spam by Akismet and will not be directly published. The comment will be stored in the database in case of mis-diagnosis. You can still view and approve comments from the admin panel.
Conclusion and Download
Although also Akismet isn't perfect (it doesn't catch all spam, especially when humans enter a spammy comment instead of an automated script), this is a better solution than CAPTCHA. Also, you'll need to check yourself every time of a comment is caught as spam, but isn't.Another thing is that Akismet would normally learn from spam comments. The Akismet class does provide the functionality to help the system by telling which comments where spam and which were ham, but that would require changing the admin panel. Feel free to do so if you want!
Hope this helped and maybe it gets included in one of the next released of !JoomlaComment.
0 comments:
Post a Comment