However, no one is perfect, and no plug-in is complete! Akismet is not perfect either. Recently, I often find a "good guy" message in the comment that akismet judges as spam. However, it is deleted automatically after a long time, loss of valuable friendship and messages.
Don't forget to modify Code _ Your_akismet_key __, _ your_website_url _ and _ your_name __
Http://www.script-tutorials.com/akismet-spam-protection/
Index. php
Copy code The Code is 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 = "20" rows = "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