コード例 #1
0
 public static function submit_nonspam_comment($comment_id)
 {
     global $wpdb, $current_user, $current_site;
     $comment_id = (int) $comment_id;
     $comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $comment_id));
     if (!$comment) {
         // it was deleted
         return;
     }
     // use the original version stored in comment_meta if available
     $as_submitted = get_comment_meta($comment_id, 'akismet_as_submitted', true);
     if ($as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content'])) {
         $comment = (object) array_merge((array) $comment, $as_submitted);
     }
     $comment->blog = get_bloginfo('url');
     $comment->blog_lang = get_locale();
     $comment->blog_charset = get_option('blog_charset');
     $comment->permalink = get_permalink($comment->comment_post_ID);
     $comment->user_role = '';
     if (is_object($current_user)) {
         $comment->reporter = $current_user->user_login;
     }
     if (is_object($current_site)) {
         $comment->site_domain = $current_site->domain;
     }
     if (isset($comment->user_ID)) {
         $comment->user_role = Akismet::get_user_roles($comment->user_ID);
     }
     if (Akismet::is_test_mode()) {
         $comment->is_test = 'true';
     }
     $post = get_post($comment->comment_post_ID);
     $comment->comment_post_modified_gmt = $post->post_modified_gmt;
     $response = Akismet::http_post(http_build_query($comment), 'submit-ham');
     if ($comment->reporter) {
         Akismet::update_comment_history($comment_id, sprintf(__('%s reported this comment as not spam', 'akismet'), $comment->reporter), 'report-ham');
         update_comment_meta($comment_id, 'akismet_user_result', 'false');
         update_comment_meta($comment_id, 'akismet_user', $comment->reporter);
     }
     do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]);
 }
コード例 #2
0
 public static function recheck_queue()
 {
     global $wpdb;
     Akismet::fix_scheduled_recheck();
     if (!(isset($_GET['recheckqueue']) || isset($_REQUEST['action']) && 'akismet_recheck_queue' == $_REQUEST['action'])) {
         return;
     }
     $paginate = '';
     if (isset($_POST['limit']) && isset($_POST['offset'])) {
         $paginate = $wpdb->prepare(" LIMIT %d OFFSET %d", array($_POST['limit'], $_POST['offset']));
     }
     $moderation = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE comment_approved = '0'{$paginate}", ARRAY_A);
     foreach ((array) $moderation as $c) {
         $c['user_ip'] = $c['comment_author_IP'];
         $c['user_agent'] = $c['comment_agent'];
         $c['referrer'] = '';
         $c['blog'] = get_bloginfo('url');
         $c['blog_lang'] = get_locale();
         $c['blog_charset'] = get_option('blog_charset');
         $c['permalink'] = get_permalink($c['comment_post_ID']);
         $c['user_role'] = '';
         if (isset($c['user_ID'])) {
             $c['user_role'] = Akismet::get_user_roles($c['user_ID']);
         }
         if (Akismet::is_test_mode()) {
             $c['is_test'] = 'true';
         }
         add_comment_meta($c['comment_ID'], 'akismet_rechecking', true);
         $response = Akismet::http_post(Akismet::build_query($c), 'comment-check');
         if ('true' == $response[1]) {
             wp_set_comment_status($c['comment_ID'], 'spam');
             update_comment_meta($c['comment_ID'], 'akismet_result', 'true');
             delete_comment_meta($c['comment_ID'], 'akismet_error');
             delete_comment_meta($c['comment_ID'], 'akismet_delayed_moderation_email');
             Akismet::update_comment_history($c['comment_ID'], __('Akismet re-checked and caught this comment as spam', 'akismet'), 'check-spam');
         } elseif ('false' == $response[1]) {
             update_comment_meta($c['comment_ID'], 'akismet_result', 'false');
             delete_comment_meta($c['comment_ID'], 'akismet_error');
             delete_comment_meta($c['comment_ID'], 'akismet_delayed_moderation_email');
             Akismet::update_comment_history($c['comment_ID'], __('Akismet re-checked and cleared this comment', 'akismet'), 'check-ham');
             // abnormal result: error
         } else {
             update_comment_meta($c['comment_ID'], 'akismet_result', 'error');
             Akismet::update_comment_history($c['comment_ID'], sprintf(__('Akismet was unable to re-check this comment (response: %s)', 'akismet'), substr($response[1], 0, 50)), 'check-error');
         }
         delete_comment_meta($c['comment_ID'], 'akismet_rechecking');
     }
     if (defined('DOING_AJAX') && DOING_AJAX) {
         wp_send_json(array('processed' => count((array) $moderation)));
     } else {
         $redirect_to = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : admin_url('edit-comments.php');
         wp_safe_redirect($redirect_to);
         exit;
     }
 }
コード例 #3
0
function akismet_update_comment_history($comment_id, $message, $event = null)
{
    return Akismet::update_comment_history($comment_id, $message, $event);
}
コード例 #4
0
ファイル: wrapper.php プロジェクト: Didox/beminfinito
function akismet_update_comment_history($comment_id, $message, $event = null)
{
    _deprecated_function(__FUNCTION__, '3.0', 'Akismet::update_comment_history()');
    return Akismet::update_comment_history($comment_id, $message, $event);
}
コード例 #5
0
 public static function recheck_comment($id, $recheck_reason = 'recheck_queue')
 {
     add_comment_meta($id, 'akismet_rechecking', true);
     $api_response = self::check_db_comment($id, $recheck_reason);
     delete_comment_meta($id, 'akismet_rechecking');
     if (is_wp_error($api_response)) {
         // Invalid comment ID.
     } else {
         if ('true' === $api_response) {
             wp_set_comment_status($id, 'spam');
             update_comment_meta($id, 'akismet_result', 'true');
             delete_comment_meta($id, 'akismet_error');
             delete_comment_meta($id, 'akismet_delayed_moderation_email');
             Akismet::update_comment_history($id, '', 'recheck-spam');
         } elseif ('false' === $api_response) {
             update_comment_meta($id, 'akismet_result', 'false');
             delete_comment_meta($id, 'akismet_error');
             delete_comment_meta($id, 'akismet_delayed_moderation_email');
             Akismet::update_comment_history($id, '', 'recheck-ham');
         } else {
             // abnormal result: error
             update_comment_meta($id, 'akismet_result', 'error');
             Akismet::update_comment_history($id, '', 'recheck-error', array('response' => substr($api_response, 0, 50)));
         }
     }
     return $api_response;
 }