您好,欢迎访问一九零五行业门户网

kismet php中使用Akismet防止垃圾评论的代码

然而,人无完人,插(件)无完插!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');
class myspamprotection {
// variables
var $smyakismetkey;
var $swebsiteurl;
var $sauthname;
var $sautheml;
var $sauthurl;
var $oakismet;
// constructor
public function myspamprotection() {
// set necessary values for variables
$this->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
author
comment
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;
}
?>
source.zip 以上就介绍了kismet php中使用akismet防止垃圾评论的代码,包括了kismet方面的内容,希望对php教程有兴趣的朋友有所帮助。
其它类似信息

推荐信息