本文整理匯總了PHP中Akismet::check_spam方法的典型用法代碼示例。如果您正苦於以下問題:PHP Akismet::check_spam方法的具體用法?PHP Akismet::check_spam怎麽用?PHP Akismet::check_spam使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Akismet
的用法示例。
在下文中一共展示了Akismet::check_spam方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Akismet
function akismet_check()
{
global $base_url, $akismet_key;
if (!@$akismet_key) {
return;
}
$ak = new Akismet($akismet_key);
$params = array("user_ip" => $this->ip_addr, "user_agent" => $this->user_agent, "referrer" => $this->referrer, "permalink" => "{$base_url}/content.php?cid=" . $this->content_id, "comment_type" => "comment", "comment_author" => $this->name, "comment_author_email" => $this->email, "comment_author_url" => $this->homepage, "comment_content" => $this->comment);
if ($this->user_id > 0) {
$user = new User();
$user->load((int) $this->user_id);
$params['comment_author'] = $user->get_name();
$params['comment_author_email'] = $user->email;
$params['comment_author_url'] = "{$base_url}/user.php?uid={$this->user_id}";
}
$akismet_decision = $ak->check_spam($base_url, $params);
switch ($akismet_decision) {
case 'true':
$this->akismet_spam = 1;
break;
case 'false':
$this->akismet_spam = 0;
break;
default:
// akismet couldn't make up its mind - probably we didn't give it enough data.
return;
}
$sql = "";
if ($this->akismet_spam) {
$this->spam_state = SPAM_STATE_AKISMET;
$this->is_active = 0;
$sql .= ", spam_state={$this->spam_state}, is_active={$this->is_active}";
}
Dal::query("UPDATE comments SET akismet_spam=? {$sql} WHERE comment_id=?", array($this->akismet_spam, $this->comment_id));
}