本文整理汇总了PHP中Akismet::submitSpam方法的典型用法代码示例。如果您正苦于以下问题:PHP Akismet::submitSpam方法的具体用法?PHP Akismet::submitSpam怎么用?PHP Akismet::submitSpam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Akismet
的用法示例。
在下文中一共展示了Akismet::submitSpam方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
$comment_id = (int) waRequest::post('spam');
$comment_model = new blogCommentModel();
$comment = $comment_model->getById($comment_id);
$this->response['status'] = null;
if ($comment) {
$comment_model->updateById($comment_id, array('akismet_spam' => 1, 'status' => blogCommentModel::STATUS_DELETED));
$this->response['status'] = blogCommentModel::STATUS_DELETED;
$blog_plugin = wa()->getPlugin('akismet');
$akismet = new Akismet(wa()->getRouting()->getUrl('blog', array(), true), $blog_plugin->getSettingValue('api_key'));
$akismet->setCommentAuthor($comment['name']);
$akismet->setCommentAuthorEmail($comment['email']);
$akismet->setCommentContent($comment['text']);
if (!waSystemConfig::isDebug() && $blog_plugin->getSettingValue('send_spam')) {
$akismet->submitSpam();
}
}
}
示例2: akismet_showpage
//.........这里部分代码省略.........
if ($view == 'isSpam') {
if ($_GET['action'] == "bulkmod") {
if (isset($_POST['submit'])) {
$spam = array();
foreach ($_POST["spam"] as $k => $v) {
$spam[intval($k)] = $v;
}
foreach ($spam as $key => $value) {
if ($value == "spam") {
if (isset($key)) {
$link_id = sanitize($key, 3);
} else {
$link_id = '';
}
$spam_links = get_misc_data('spam_links');
$spam_links = unserialize(get_misc_data('spam_links'));
$key = array_search($link_id, $spam_links);
unset($spam_links[$key]);
misc_data_update('spam_links', serialize($spam_links));
$link = new Link();
$link->id = $link_id;
$link->read();
$link->status = 'discard';
$link->store();
$user = new User();
$user->id = $link->author;
$user->read();
$akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key'));
$akismet->setCommentAuthor($user->username);
$akismet->setCommentAuthorEmail($user->email);
$akismet->setCommentAuthorURL($link->url);
$akismet->setCommentContent($link->content);
$akismet->setPermalink(getmyurl('story', $link->id));
$akismet->submitSpam();
} elseif ($value == "notspam") {
if (isset($key)) {
$link_id = sanitize($key, 3);
} else {
$link_id = '';
}
$spam_links = get_misc_data('spam_links');
$spam_links = unserialize(get_misc_data('spam_links'));
$key = array_search($link_id, $spam_links);
unset($spam_links[$key]);
misc_data_update('spam_links', serialize($spam_links));
$link = new Link();
$link->id = $link_id;
$link->read(FALSE);
$link->status = 'queued';
$link->store();
$user = new User();
$user->id = $link->author;
$user->read();
$akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key'));
$akismet->setCommentAuthor($user->username);
$akismet->setCommentAuthorEmail($user->email);
$akismet->setCommentAuthorURL($link->url);
$akismet->setCommentContent($link->content);
$akismet->setPermalink(getmyurl('story', $link->id));
$akismet->submitHam();
}
}
}
}
header('Location: ' . URL_akismet . '&view=manageSpam');
}
示例3: appconf
<?php
$ak = appconf('akismet_key');
if (!$ak) {
header('Location: ' . $_SERVER['HTTP_REFERER']);
exit;
}
loader_import('siteblog.Filters');
$c = db_single('select * from siteblog_comment where id = ?', $parameters['id']);
db_execute('delete from siteblog_comment where id = ?', $parameters['id']);
$title = db_shift('select subject from siteblog_post where id = ?', $vals['post']);
$comment = array('author' => $c->name, 'email' => $c->email, 'website' => $c->url, 'body' => $c->body, 'permalink' => site_url() . '/index/siteblog-post-action/id.' . $c->post_id . '/title.' . siteblog_filter_link_title($title), 'user_ip' => $c->ip, 'user_agent' => '');
loader_import('siteblog.Akismet');
$akismet = new Akismet(site_url(), $ak, $comment);
if (!$akismet->errorsExist()) {
// no errors
$akismet->submitSpam();
}
header('Location: ' . $_SERVER['HTTP_REFERER']);
exit;
示例4: akismet_showpage
//.........这里部分代码省略.........
if ($_GET['action'] == "bulkmod") {
if (isset($_POST['submit'])) {
$spam = array();
foreach ($_POST["spam"] as $k => $v) {
$spam[intval($k)] = $v;
}
foreach ($spam as $key => $value) {
if (isset($key)) {
$link_id = sanitize($key, 3);
} else {
continue;
}
$link = new Link();
$link->id = $link_id;
$link->read();
$user = new User();
$user->id = $link->author;
$user->read();
if (phpnum() < 5) {
$comment = array('author' => $user->username, 'email' => $user->email, 'website' => $link->url, 'body' => $link->content, 'permalink' => my_base_url . getmyurl('story', $link->id));
$akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key'), $comment);
} else {
$akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key'));
$akismet->setCommentAuthor($user->username);
$akismet->setCommentAuthorEmail($user->email);
$akismet->setCommentAuthorURL($link->url);
$akismet->setCommentContent($link->content);
$akismet->setPermalink(my_base_url . getmyurl('story', $link->id));
}
if ($value == "spam") {
$link->status = 'spam';
$link->store();
killspam($user->id);
$akismet->submitSpam();
} elseif ($value == "notspam") {
$link->status = 'new';
$link->store();
$akismet->submitHam();
}
$db->query("DELETE FROM " . table_prefix . "spam_links WHERE linkid={$link_id}");
}
}
}
header('Location: ' . URL_akismet . '&view=manageSpam');
die;
}
if ($view == 'isSpamcomment') {
if ($_GET['action'] == "bulkmod") {
if (isset($_POST['submit'])) {
$spamcomment = array();
foreach ($_POST["spamcomment"] as $k => $v) {
$spamcomment[intval($k)] = $v;
}
foreach ($spamcomment as $key => $value) {
if (isset($key)) {
$link_id = sanitize($key, 3);
} else {
continue;
}
$sql_result = "Select * from " . table_prefix . "spam_comments where auto_id=" . $link_id;
$result = $db->get_row($sql_result);
#print_r($result);
$link = new Link();
$link->id = $result->linkid;
$link->read();
$user = new User();
示例5: intval
function delete_comment()
{
if (!isset($this->get['c'])) {
return $this->message('Delete Comment', 'No comment was specified for editing.');
}
$c = intval($this->get['c']);
$comment = $this->db->quick_query('SELECT c.*, u.* FROM %pblogcomments c
LEFT JOIN %pusers u ON u.user_id=c.comment_user
WHERE comment_id=%d', $c);
if (!$comment) {
return $this->message('Delete Comment', 'No such comment was found for deletion.');
}
if (!isset($this->get['confirm'])) {
$xtpl = new XTemplate('./skins/' . $this->skin . '/AdminCP/post_comment_edit.xtpl');
$xtpl->assign('token', $this->generate_token());
$xtpl->assign('author', htmlspecialchars($comment['user_name']));
$params = POST_BBCODE | POST_EMOTICONS;
$xtpl->assign('text', $this->format($comment['comment_message'], $params));
$xtpl->assign('date', date($this->settings['blog_dateformat'], $comment['comment_date']));
$link = 'admin.php?a=posts&s=del_comment&c=' . $c;
$sp = null;
if (isset($this->get['t']) && $this->get['t'] == 'spam') {
$link .= '&t=spam';
$sp = '<br />This comment will be reported as spam.';
}
$xtpl->assign('action_link', $link);
$xtpl->assign('sp', $sp);
$xtpl->parse('Comment.Delete');
return $xtpl->text('Comment.Delete');
}
if (!$this->is_valid_token()) {
return $this->error('Invalid or expired security token. Please go back, reload the form, and try again.');
}
$out = null;
if (isset($this->get['t']) && $this->get['t'] == 'spam') {
// Time to report the spammer before we delete the comment. Hopefully this is enough info to strike back with.
require_once 'lib/akismet.php';
$akismet = new Akismet($this->settings['site_address'], $this->settings['wordpress_api_key']);
$akismet->setCommentAuthor($comment['user_name']);
$akismet->setCommentAuthorURL($comment['user_url']);
$akismet->setCommentContent($comment['comment_message']);
$akismet->setUserIP($comment['comment_ip']);
$akismet->setReferrer($comment['comment_referrer']);
$akismet->setCommentUserAgent($comment['comment_agent']);
$akismet->setCommentType('comment');
$akismet->submitSpam();
$this->settings['spam_count']++;
$this->settings['spam_uncaught']++;
$this->save_settings();
$out .= 'Comment tagged as spam and reported.<br />';
}
$this->db->dbquery('DELETE FROM %pblogcomments WHERE comment_id=%d', $c);
if ($comment['comment_type'] == COMMENT_BLOG) {
$this->db->dbquery('UPDATE %pblogposts SET post_comment_count=post_comment_count-1 WHERE post_id=%d', $comment['comment_post']);
} elseif ($comment['comment_type'] == COMMENT_GALLERY) {
$this->db->dbquery('UPDATE %pphotogallery SET photo_comment_count=photo_comment_count-1 WHERE photo_id=%d', $comment['comment_post']);
} elseif ($comment['comment_type'] == COMMENT_FILE) {
$this->db->dbquery('UPDATE %pfilelist SET file_comment_count=file_comment_count-1 WHERE file_id=%d', $comment['comment_post']);
}
$out .= 'Comment has been deleted.';
return $this->message('Delete Comment', $out, 'Continue', "admin.php?a=posts&s=edit&p={$comment['comment_post']}");
}
示例6: reportSpam
static function reportSpam($comments)
{
$config = Config::current();
foreach ($comments as $comment) {
$akismet = new Akismet($config->url, $config->akismet_api_key);
$akismet->setCommentAuthor($comment->author);
$akismet->setCommentAuthorEmail($comment->author_email);
$akismet->setCommentAuthorURL($comment->author_url);
$akismet->setCommentContent($comment->body);
$akismet->setPermalink($comment->post_id);
$akismet->setReferrer($comment->author_agent);
$akismet->setUserIP($comment->author_ip);
$akismet->submitSpam();
}
}
示例7: submitSpam
/**
* Submit spam, his call is for submitting comments that weren't marked as spam but should have been.
*
* @return bool If everything went fine true will be returned, otherwise an exception will be triggered.
* @param string $userIp IP address of the comment submitter.
* @param string $userAgent User agent information.
* @param string[optional] $content The content that was submitted.
* @param string[optional] $author Submitted name with the comment.
* @param string[optional] $email Submitted email address.
* @param string[optional] $url Commenter URL.
* @param string[optional] $permalink The permanent location of the entry the comment was submitted to.
* @param string[optional] $type May be blank, comment, trackback, pingback, or a made up value like "registration".
* @param string[optional] $referrer The content of the HTTP_REFERER header should be sent here.
* @param array[optional] $others Other data (the variables from $_SERVER).
*/
public static function submitSpam($userIp, $userAgent, $content, $author = null, $email = null, $url = null, $permalink = null, $type = null, $referrer = null, $others = null)
{
// get some settings
$akismetKey = self::getModuleSetting('core', 'akismet_key');
// invalid key, so we can't detect spam
if ($akismetKey === '') {
return false;
}
// require the class
require_once PATH_LIBRARY . '/external/akismet.php';
// create new instance
$akismet = new Akismet($akismetKey, SITE_URL);
// set properties
$akismet->setTimeOut(10);
$akismet->setUserAgent('Fork CMS/2.1');
// try it to decide it the item is spam
try {
// check with Akismet if the item is spam
return $akismet->submitSpam($userIp, $userAgent, $content, $author = null, $email = null, $url = null, $permalink = null, $type = null, $referrer = null, $others = null);
} catch (Exception $e) {
// in debug mode we want to see exceptions, otherwise the fallback will be triggered
if (SPOON_DEBUG) {
throw $e;
}
}
// when everything fails
return false;
}
示例8: intval
function delete_comment()
{
// Lock this shit down!!!
if ($this->user['user_level'] < USER_PRIVILEGED) {
return $this->module->error('Access Denied: You do not have permission to perform that action.');
}
if (!isset($this->module->get['c'])) {
return $this->module->message('Delete Comment', 'No comment was specified for editing.');
}
$c = intval($this->module->get['c']);
$comment = $this->db->quick_query('SELECT c.*, u.* FROM %pblogcomments c
LEFT JOIN %pusers u ON u.user_id=c.comment_user WHERE comment_id=%d', $c);
if (!$comment) {
return $this->module->message('Delete Comment', 'No such comment was found for deletion.');
}
if ($this->user['user_id'] != $comment['comment_user'] && $this->user['user_level'] < USER_CONTRIBUTOR) {
return $this->module->error('Access Denied: You do not own the comment you are attempting to delete.');
}
// After 3 hours, you're stuck with it if you're a regular member.
if ($this->user['user_level'] == USER_PRIVILEGED && $this->module->time - $comment['comment_date'] > 10800) {
return $this->module->error('Access Denied: You cannot delete your comments after 3 hours have gone by.');
}
$user = null;
if ($comment['comment_type'] == COMMENT_BLOG) {
$user = $this->db->quick_query('SELECT post_user FROM %pblogposts WHERE post_id=%d', $comment['comment_post']);
} elseif ($comment['comment_type'] == COMMENT_GALLERY) {
$user = $this->db->quick_query('SELECT photo_user FROM %pphotogallery WHERE photo_id=%d', $comment['comment_post']);
} elseif ($comment['comment_type'] == COMMENT_FILE) {
$user = $this->db->quick_query('SELECT file_user FROM %pfilelist WHERE file_id=%d', $comment['comment_post']);
}
if (!$user) {
return $this->module->error('Access Denied: You do not own the entry you are trying to edit.');
}
if ($this->user['user_level'] == USER_CONTRIBUTOR) {
switch ($comment['comment_type']) {
case COMMENT_BLOG:
if ($this->user['user_id'] != $user['post_user'] && $this->user['user_id'] != $comment['comment_user']) {
return $this->module->error('Access Denied: You do not own the blog entry you are trying to edit.');
}
break;
case COMMENT_GALLERY:
if ($this->user['user_id'] != $user['photo_user'] && $this->user['user_id'] != $comment['comment_user']) {
return $this->module->error('Access Denied: You do not own the image entry you are trying to edit.');
}
break;
case COMMENT_FILE:
if ($this->user['user_id'] != $user['file_user'] && $this->user['user_id'] != $comment['comment_user']) {
return $this->module->error('Access Denied: You do not own the download entry you are trying to edit.');
}
break;
default:
return $this->module->error('Unknown comment type selected for editing.');
}
}
if (isset($this->module->get['t']) && $this->module->get['t'] == 'spam') {
if ($this->user['user_level'] < USER_CONTRIBUTOR) {
return $this->module->error('Access Denied: You are not authorized to report spam.');
}
}
$page = '';
if ($comment['comment_type'] == COMMENT_BLOG) {
$page = 'blog';
} elseif ($comment['comment_type'] == COMMENT_GALLERY) {
$page = 'gallery';
} elseif ($comment['comment_type'] == COMMENT_FILE) {
$page = 'downloads';
}
if (!isset($this->module->get['confirm'])) {
$author = htmlspecialchars($comment['user_name']);
$params = POST_BBCODE | POST_EMOTICONS;
$text = $this->module->format($comment['comment_message'], $params);
$date = date($this->settings['blog_dateformat'], $comment['comment_date']);
$msg = "<div class=\"title\">Comment by {$author} Posted on: {$date}</div><div class=\"article\">{$text}</div>";
$link = "index.php?a={$page}&s=del_comment&c={$c}&confirm=1";
$sp = null;
if (isset($this->module->get['t']) && $this->module->get['t'] == 'spam') {
$link .= '&t=spam';
$sp = '<br />This comment will be reported as spam.';
}
$msg .= "<div class=\"title\" style=\"text-align:center\">Are you sure you want to delete this comment?{$sp}</div>";
return $this->module->message('DELETE COMMENT', $msg, 'Delete', $link, 0);
}
$out = null;
if (isset($this->module->get['t']) && $this->module->get['t'] == 'spam') {
// Time to report the spammer before we delete the comment. Hopefully this is enough info to strike back with.
require_once 'lib/akismet.php';
$akismet = new Akismet($this->settings['site_address'], $this->settings['wordpress_api_key'], $this->module->version);
$akismet->setCommentAuthor($comment['user_name']);
$akismet->setCommentAuthorURL($comment['user_url']);
$akismet->setCommentContent($comment['comment_message']);
$akismet->setUserIP($comment['comment_ip']);
$akismet->setReferrer($comment['comment_referrer']);
$akismet->setCommentUserAgent($comment['comment_agent']);
$akismet->setCommentType('comment');
$akismet->submitSpam();
$this->settings['spam_count']++;
$this->settings['spam_uncaught']++;
$this->module->save_settings();
$out .= 'Comment tagged as spam and reported.<br />';
}
//.........这里部分代码省略.........
示例9: markspamAction
public function markspamAction()
{
$id = $this->intVal(3);
if ($id == 0) {
header("location:/homeadmin/comments/");
}
$newsModel = new NewsModel();
$newsModel->markSpam($id, 1);
$akismet = new Akismet();
$akismet->key = "5a3c4dc9f909";
$akismet->blog = "http://tiny4cocoa.org/home/";
if (!$akismet->verifyKey()) {
die("akismet verify error");
}
$comment = $newsModel->commentById($id);
if (!$comment) {
die("can not find comment");
}
$data = array('blog' => 'http://tiny4cocoa.org/home/', 'user_ip' => $comment["ip"], 'user_agent' => $comment["useragent"], 'referrer' => $comment["referrer"], 'permalink' => "http://tiny4cocoa.org/home/s/{$comment['newsid']}", 'comment_type' => 'comment', 'comment_author' => $comment["poster"], 'comment_author_email' => '', 'comment_author_url' => '', 'comment_content' => $comment["content"]);
$ret = $akismet->submitSpam($data);
header("location:/homeadmin/comments/");
}
示例10: action_admin_moderate_comments
public function action_admin_moderate_comments($action, $comments, $handler)
{
$false_negatives = 0;
$false_positives = 0;
$provider = Options::get('habariakismet__provider');
$endpoint = $provider == 'Akismet' ? self::SERVER_AKISMET : self::SERVER_TYPEPAD;
$a = new Akismet(Site::get_url('habari'), Options::get('habariakismet__api_key'));
$a->setAkismetServer($endpoint);
foreach ($comments as $comment) {
switch ($action) {
case 'spam':
if ($comment->status == Comment::STATUS_APPROVED || $comment->status == Comment::STATUS_UNAPPROVED) {
$a->setCommentAuthor($comment->name);
$a->setCommentAuthorEmail($comment->email);
$a->setCommentAuthorURL($comment->url);
$a->setCommentContent($comment->content);
$a->submitSpam();
$false_negatives++;
}
break;
case 'approved':
if ($comment->status == Comment::STATUS_SPAM) {
$a->setCommentAuthor($comment->name);
$a->setCommentAuthorEmail($comment->email);
$a->setCommentAuthorURL($comment->url);
$a->setCommentContent($comment->content);
$a->submitHam();
$false_positives++;
}
break;
}
}
if ($false_negatives) {
Session::notice(_t('Reported %d false negatives to %s.', array($false_negatives, $provider)));
}
if ($false_positives) {
Session::notice(_t('Reported %d false positives to %s.', array($false_positives, $provider)));
}
}
示例11: delete_comments
public function delete_comments($marks, $deleteallspam = false) {
if ($this->manage !== true) return false;
if (is_array($marks)) {
foreach ($marks as $k => $mark) {
if (!is_numeric($mark)) { // id must be a number
unset($marks[$k]);
continue;
}
if ($where) $where .= ' OR ';
$where .= "id=$mark";
}
}
elseif ($deleteallspam) $where = 'spam=1';
if (!$where) return;
if ($_POST['unspam'] || $_POST['spam']) {
$action = 'UPDATE ';
$action_result = $_POST['unspam'] ? 'unmarked as spam' : 'marked as spam';
$set = ' SET spam=' . (int)(bool)$_POST['spam'] . ' ';
if ($_POST['spam'] && $GLOBALS['mark_as_spam_and_delete']) {
$action = 'DELETE FROM ';
$action_result = 'marked for Akismet as spam and then deleted';
$set = '';
}
if (!empty($this->akismet_file) && !empty($this->wpAPIkey) && @include_once($this->akismet_file)) { // submit false positive or missed spam to Akismet
$res = mysqli_query($this->link, "SELECT * FROM commentator_comments WHERE $where AND page=\"{$this->page}\"");
$error = mysqli_error($this->link);
if (!$res) {
if ($_POST['unspam']) $not = ' not';
$error = $error ? "Mysql error: $error" : "Selection is already$not spam";
$this->alert("No comments affected. $error");
return;
}
while ($row = mysqli_fetch_array($res, MYSQL_ASSOC)) {
$akismet = new Akismet($this->domain, $this->wpAPIkey);
$akismet->setCommentAuthor($row['name']);
$akismet->setCommentAuthorEmail($row['email']);
$akismet->setCommentAuthorURL($row['website']);
$akismet->setCommentContent($row['comment']);
$akismet->setPermalink('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
if ($_POST['unspam']) $akismet->submitHam();
else $akismet->submitSpam();
}
}
}
else {
$action = 'DELETE FROM ';
$action_result = 'deleted';
}
$res = mysqli_query($this->link, $action . "commentator_comments {$set}WHERE $where AND page=\"{$this->page}\"");
$affected = mysqli_affected_rows($this->link);
if ($affected !== 1) $s = 's';
$this->alert($affected . " comment$s $action_result");
}