首頁 >後端開發 >php教程 >kismet php中使用Akismet來防止垃圾評論的程式碼

kismet php中使用Akismet來防止垃圾評論的程式碼

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-07-29 08:45:371182瀏覽

然而,人無完人,插(件)無完插! Akismet也不完美,最近, 我常在被Akismet評判為垃圾的留言中找到“好人”的留言,然而,有時時間長了就自動刪除了,損失珍貴的友情和留言。
別忘了修改程式碼中的__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');

require_once ('classes/Akismet.class.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

以上就介紹了kismet php中使用Akismet防止垃圾評論的程式碼,包括了kismet方面的內容,希望對PHP教學有興趣的朋友有所幫助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn