首页 > 作文

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

更新时间:2023-04-06 11:36:45 阅读: 评论:0

然而,人无完人,流行妆容插(件)无完插!akismet也并非完美,最近, 我常在被akismet评判为垃圾的留言中找到“好人”的留言,然而,有时时间长了就自动删除了,损失珍贵的友情和留言。

别忘了修改代码中的 __your_akismet_key__, __your_website_url__ and __your_name__

/d/file/titlepic/br />
index.php


复制代码 代码如下:

<?

require_once (‘class/akismet.class.php’);

class myspamprotection {

// variables

var $smyakismetkey;

var $swebsiteurl;

var $sauthname;

var $sautheml;

var $sauthurl;

var $oakismet;

// constructor

public function myspamprotection() {

// t necessary values for variables

$this-&g乡下的美景t;smyakismetkey = ‘__your_akismet_key__’;

$this->swebsiteurl = ‘__your_website_url__’;

$this->sa每日分享uthname = ‘__your_name__’;

$this->sautheml = ”;

$this->sauthurl = ”;

// akismet initialization

$this->oakismet = new akismet($this->swebsiteurl ,$this->smyakismetkey);

$this->oakismet->tcommentauthor($this->sauthname);

$this->oakismet->tcommentauthoremail($this->sautheml);

$this->oakismet->tcommentauthorurl($this->sauthurl);

}

public function isspam($s) {

if (! $this->oakismet) return fal;

$this->oakismet->tcommentcontent($s);

return $this->oakismet->iscommentspam();

}

}

echo <<<eof

<style type=”text/css”>

form div {

margin:10px;

}

form label {

width:90px;

float:left;

display:block;

}

</style>

<form action=”” method=”post”>

<div><label for=”author”>author</label><input id=”author” name=”author” type=”text” value=”” /></div>

<div><label for=”comment”>c逛街作文omment</label><textarea id=”comment” name=”comment” cols=”20″ rows=”4″></textarea></div>

<div><input name=”submit” type=”submit” value=”nd” /></div>

</form>

eof;

if ($_post) {

// draw debug information

echo ‘<pre>’;

print_r($_post);

echo ‘</pre>’;

// obtain nt info

$spostauthor = $_post[‘author’];

$scommentcomment = $_post[‘comment’];

// check for spam

$omyspamprotection = new myspamprotection();

$sauthorcheck = ($omyspamprotection->isspam($spostauthor)) ? ‘ “author” marked as spam’ : ‘̶验收报告模板1;author” not marked as spam’;

$scommentcheck = ($omyspamprotection->isspam($scommentcomment)) ? ‘ “comment” marked as spam’ : ‘”comment” not marked as spam’;

echo $sauthorcheck . ‘<br />’ . $scommentcheck;

}

?>

source.zip

本文发布于:2023-04-06 11:36:41,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/ba306feb60721844a2aac641e57a0366.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:php中使用Akismet防止垃圾评论的代码.doc

本文 PDF 下载地址:php中使用Akismet防止垃圾评论的代码.pdf

标签:留言   代码   人无完人   别忘了
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图