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

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

高洛峰
高洛峰原創
2016-11-30 10:20:141128瀏覽

然而,人無完人,插(件)無完插! Akismet也不完美,最近, 我常在被Akismet評判為垃圾的留言中找到“好人”的留言,然而,有時時間長了就自動刪除了,損失珍貴的友情和留言。
別忘了修改程式碼中的__YOUR_AKISMET_KEY__, __YOUR_WEBSITE_URL__ and __YOUR_NAME__ 
http://www.script-tutorials.com/akismet-spam-protection/ 
index.php . classes/Akismet.class.php'); 
class MySpamProtection { 
// variables 
var $sMyAkismetKey; 
var $sWebsiteUrl; 
var $sAuthorguthhuthorwow; kismet; 
/ / constructor 
public function MySpamProtection() { 
// set necessary values for variables 
$this->sMyAkismetKey = '__YOUR_AKISMET_KEY__'; Name = '__YOUR_NAME__';
$this->sAuthEml = ''; 
$this->sAuthUrl = ''; 
// Akismet initialization 
$this->oAkismet = new Akismet($this->sWebsiteUrlp. this->oAkismet->setCommentAuthor($this->sAuthName); 
$this->oAkismet->setCommentAuthorEmail($this->sAuthEml); 
$this->oAkismet->setCommentAuthorURL($ } 
public function isSpam($s) { 
if (! $this->oAkismet) return false; 
$this->oAkismet->setCommentContent($s); 
return $this->oAkimets-thissContent;


echo  

 
 
 
 
 
EOF; 
if ($_POST) { 
// draw debug information 
echo '
'; <br>print_r($_POST); <br>echo '
'; 
// obtain sent infoecho ''; 
// obtain v. ']; 
$sCommentComment = $_POST['comment']; 
// check for spam 
$oMySpamProtection = new MySpamProtection(); 
$sAuthorCheck = ($oor MySpamProtection(); 
$sAuthorCheck = ($o MySpam(Phost marked as Spam' : '"Author" not marked as Spam'; 
$sCommentCheck = ($oMySpamProtection->isSpam($sCommentComment)) ? ' "Comment" marked as Spam' : '"Comment" not marked as Spam';
echo $sAuthorCheck . '
' . $sCommentCheck; 

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