然而,人無完人,插(件)無完插! Akismet也不完美,最近, 我常在被Akismet評判為垃圾的留言中找到“好人”的留言,然而,有時時間長了就自動刪除了,損失珍貴的友情和留言。 程式碼如下: require_once ('classes/Akismet.class.php');
別忘了修改程式碼中的__YOUR_AKISMET_KEY__, __YOUR_WEBSITE_URL__ and __YOUR_NAME__
http://www.script-tutorials.com/akismet-spam-protection/
index.php
複製程式碼
require_once ('classes/Akismet.class.php');
class MySpamProtection {class 🎜>// variables
var $sMyAkismetKey;
var $sWebsiteUrl;
var $sAuthName;
var $sAuthEml;
var $sAUrl; // constructor
public function MySpamProtection() {
// set necessary values for variables
$this->sMyAkismetKey = '__YOUR_AKISMET_KEY__';
$this->Web_ '__YOUR >$this->sAuthName = '__YOUR_NAME__';
$this->sAuthEml = '';
$this->sAuthUrl = '';
// Akismet initialization
$this->oAkismet$->oAkismet$->oAkismet$->oAkismet$->oAkismet$->oAkismet$->oAkismet$->oAkismet$->o = new Akismet($this->sWebsiteUrl ,$this->sMyAkismetKey);
$this->oAkismet->setCommentAuthor($this->sAuthName);
$this->oAkismet->setCommentAuthorEmail($this-d ->sAuthEml);
$this->oAkismet->setCommentAuthorURL($this->sAuthUrl);
}
public function isSpam($s) {
if (! $this-this>oAkismet ) return false;
$this->oAkismet->setCommentContent($s);
return $this->oAkismet->isCommentSpam();
}
}
echo
EOF;
if ($_POST) {
// draw debug information
echo ''; <br>print_r($_POST); <br> echo '
// obtain sent info
$sPostAuthor = $_POST['author'];
$sCommentComment = $_POST['comment'];
//ecksCommentComment = $_POST['comment'];
//ecksCommentComment = $_POST['comment'];
///ecksCommentComment = $_POST['comment'];
//ecksCommentComment for spam
$oMySpamProtection = new MySpamProtection();
$sAuthorCheck = ($oMySpamProtection->isSpam($sPostAuthor)) ? ' "Author" marked as Spam' : '"Author" not'am;
$sCommentCheck = ($oMySpamProtection->isSpam($sCommentComment)) ? ' "Comment" marked as Spam' : '"Comment" not marked as Spam';
echo $sAuthorCheck . '
' . $sCommentCheck;
}
?>
source.zip