3
Ok here's the code that I used to fix comment spam in the "Contact us" XOOPS module. Works a treat!
I put the Akisment.class.php file in the Class folder (yep, made sense to me too).
I modified the modules/contact/index.php file. I inserted your code between these two lines in that file -- this is where the file gets set to send the email;
$xoopsMailer->setBody($adminMessage);
$xoopsMailer->send();
I took your code, stuck in my info (site, Wordpress key, etc) and ran up the code looking for variables that would work. The first time I tried it, I wound up with a blank screen, so i commented it out and then uncommented each line. As I came across errors (leading to a blank screen) I'd fix 'em. Completely nifty.
Quote:
// start Akismet hack --
include_once XOOPS_ROOT_PATH . '/class/Akismet.class.php';
$WordPressAPIKey = 'PutYourKeyHere';
$MyBlogURL = 'http://www.YourName.Tld/modules/AMS';
$name = $usersName;
$comment = $usersComments;
$akismet = new Akismet($MyBlogURL ,$WordPressAPIKey);
$akismet->setCommentAuthor($usersName);
$akismet->setCommentAuthorEmail($usersEmail);
$akismet->setCommentAuthorURL($usersSite);
$akismet->setCommentContent($usersComments);
$akismet->setPermalink('http://www.YourName.Tld/modules/contact');
if($akismet->isCommentSpam()){
// Here, the routine you want to perform when spam is caught
redirect_header( 'index.php', 2, 'Your submission looks like spam to us');
exit();
}
// end Akismet, store the submission normally
Perfecto! I pasted a little spam into the comment field and the module came back with that "your comment looks like spam to us". Put in a real message and it came through fine.
I'm completely fired up. AMS hack is next.