Using Akismet to prevent Spam comments Akismet is an excellent plug-in that prevents Spam messages. most wordpress blogger is using it. with akismet, there is basically no need to worry about Spam messages. 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.
Do not forget to modify _ YOUR_AKISMET_KEY __, _ YOUR_WEBSITE_URL _ and _ YOUR_NAME _ in the code __
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 <<
form p {margin:10px;}form label {width:90px;float:left;display:block;}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;}?>