However, no one is perfect, plug in (pieces) without finishing! Akismet is not perfect, recently, I often in the Akismet judge for rubbish message to find "good people" message, however, sometimes a long time automatically deleted, loss of precious friendship and messages.
Don't forget to modify the __your_akismet_key__ in the code, __your_website_url__ and __your_name__
http://www.script-tutorials.com/akismet-spam-protection/
index.php
Copy Code code as follows:
?
Require_once (' classes/akismet.class.php ');
Class Myspamprotection {
Variables
var $sMyAkismetKey;
var $sWebsiteUrl;
var $sAuthName;
var $sAuthEml;
var $sAuthUrl;
var $oAkismet;
Constructor
Public Function myspamprotection () {
Set necessary values for variables
$this->smyakismetkey = ' __your_akismet_key__ ';
$this->swebsiteurl = ' __your_website_url__ ';
$this->sauthname = ' __your_name__ ';
$this->sautheml = ';
$this->sauthurl = ';
Akismet initialization
$this->oakismet = new Akismet ($this->swebsiteurl, $this->smyakismetkey);
$this->oakismet->setcommentauthor ($this->sauthname);
$this->oakismet->setcommentauthoremail ($this->sautheml);
$this->oakismet->setcommentauthorurl ($this->sauthurl);
}
Public function Isspam ($s) {
if (! $this->oakismet) return false;
$this->oakismet->setcommentcontent ($s);
return $this->oakismet->iscommentspam ();
}
}
Echo <<<eof
<style type= "Text/css" >
Form Div {
margin:10px;
}
Form Label {
width:90px;
Float:left;
Display:block;
}
</style>
<form action= "" method= "POST" >
<div><label for= "Author" >author</label><input id= "author" name= "author" "Type=" text "value=" " ></div>
<div><label for= "comment" >comment</label><textarea id= "comment" name= "comment" cols= " "4" ></textarea></div>
<div><input name= "Submit" type= "Submit" value= "Send"/></div>
</form>
EOF;
if ($_post) {
Draw Debug Information
Echo ' <pre> ';
Print_r ($_post);
Echo ' </pre> ';
Obtain sent Info
$sPostAuthor = $_post[' author '];
$sCommentComment = $_post[' comment '];
Check for spam
$oMySpamProtection = new Myspamprotection ();
$sAuthorCheck = ($oMySpamProtection->isspam ($sPostAuthor))? ' Author ' marked as Spam ': ' Author ' not marked as Spam ';
$sCommentCheck = ($oMySpamProtection->isspam ($sCommentComment))? ' Comment ' marked as Spam ': ' Comment ' not marked as Spam ';
Echo $sAuthorCheck. ' <br/> '. $sCommentCheck;
}
?>
Source.zip