sMyAkismetKey = '4814a2738859'; $this->sWebsiteUrl = 'http://www.script-tutorials.com/'; $this->sAuthName = 'Andrew'; $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 << Akismet - spam protection demo
EOF; if ($_POST) { // draw debug information echo '
';
    print_r($_POST);
    echo '
'; // 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 . '
' . $sCommentCheck; } ?>

back to original article page