当前位置: 首页>>代码示例>>PHP>>正文


PHP akismet_update_comment_history函数代码示例

本文整理汇总了PHP中akismet_update_comment_history函数的典型用法代码示例。如果您正苦于以下问题:PHP akismet_update_comment_history函数的具体用法?PHP akismet_update_comment_history怎么用?PHP akismet_update_comment_history使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了akismet_update_comment_history函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: akismet_recheck_queue

function akismet_recheck_queue()
{
    global $wpdb, $akismet_api_host, $akismet_api_port;
    if (!(isset($_GET['recheckqueue']) || isset($_REQUEST['action']) && 'akismet_recheck_queue' == $_REQUEST['action'])) {
        return;
    }
    $moderation = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE comment_approved = '0'", 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_option('home');
        $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']);
        }
        $id = (int) $c['comment_ID'];
        $query_string = '';
        foreach ($c as $key => $data) {
            $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
        }
        $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
        if ('true' == $response[1]) {
            wp_set_comment_status($c['comment_ID'], 'spam');
            update_comment_meta($c['comment_ID'], 'akismet_result', 'true');
            akismet_update_comment_history($c['comment_ID'], __('Akismet re-checked and caught this comment as spam'), 'check-spam');
        } elseif ('false' == $response[1]) {
            update_comment_meta($c['comment_ID'], 'akismet_result', 'false');
            akismet_update_comment_history($c['comment_ID'], __('Akismet re-checked and cleared this comment'), '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)'), $response[1]), 'check-error');
        }
    }
    wp_redirect($_SERVER['HTTP_REFERER']);
    exit;
}
开发者ID:hoonio,项目名称:wordpress,代码行数:41,代码来源:admin.php

示例2: akismet_cron_recheck

function akismet_cron_recheck( $data ) {
	global $wpdb;

	delete_option('akismet_available_servers');

	$comment_errors = $wpdb->get_col( "
		SELECT comment_id
		FROM {$wpdb->prefix}commentmeta
		WHERE meta_key = 'akismet_error'
	" );

	foreach ( (array) $comment_errors as $comment_id ) {
		add_comment_meta( $comment_id, 'akismet_rechecking', true );
		$status = akismet_check_db_comment( $comment_id, 'retry' );

		$msg = '';
		if ( $status == 'true' ) {
			$msg = __( 'Akismet caught this comment as spam during an automatic retry.' );
		} elseif ( $status == 'false' ) {
			$msg = __( 'Akismet cleared this comment during an automatic retry.' );
		}
		
		// If we got back a legit response then update the comment history
		// other wise just bail now and try again later.  No point in
		// re-trying all the comments once we hit one failure.
		if ( !empty( $msg ) ) {
			delete_comment_meta( $comment_id, 'akismet_error' );
			akismet_update_comment_history( $comment_id, $msg, 'cron-retry' );
			update_comment_meta( $comment_id, 'akismet_result', $status );
			// make sure the comment status is still pending.  if it isn't, that means the user has already moved it elsewhere.
			$comment = get_comment( $comment_id );
			if ( $comment && 'unapproved' == wp_get_comment_status( $comment_id ) ) {
				if ( $status == 'true' ) {
					wp_spam_comment( $comment_id );
				} elseif ( $status == 'false' ) {
					// comment is good, but it's still in the pending queue.  depending on the moderation settings
					// we may need to change it to approved.
					if ( check_comment($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent, $comment->comment_type) )
						wp_set_comment_status( $comment_id, 1 );
				}
			}
		} else {
			delete_comment_meta( $comment_id, 'akismet_rechecking' );
			wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
			return;
		}
	}
}
开发者ID:realfluid,项目名称:umbaugh,代码行数:48,代码来源:akismet.php

示例3: akismet_cron_recheck

function akismet_cron_recheck()
{
    global $wpdb;
    $status = akismet_verify_key(akismet_get_key());
    if (get_option('akismet_alert_code') || $status == 'invalid') {
        // since there is currently a problem with the key, reschedule a check for 6 hours hence
        wp_schedule_single_event(time() + 21600, 'akismet_schedule_cron_recheck');
        return false;
    }
    delete_option('akismet_available_servers');
    $comment_errors = $wpdb->get_col("\n\t\tSELECT comment_id\n\t\tFROM {$wpdb->prefix}commentmeta\n\t\tWHERE meta_key = 'akismet_error'\n\t\tLIMIT 100\n\t");
    foreach ((array) $comment_errors as $comment_id) {
        // if the comment no longer exists, or is too old, remove the meta entry from the queue to avoid getting stuck
        $comment = get_comment($comment_id);
        if (!$comment || strtotime($comment->comment_date_gmt) < strtotime("-15 days")) {
            delete_comment_meta($comment_id, 'akismet_error');
            continue;
        }
        add_comment_meta($comment_id, 'akismet_rechecking', true);
        $status = akismet_check_db_comment($comment_id, 'retry');
        $msg = '';
        if ($status == 'true') {
            $msg = __('Akismet caught this comment as spam during an automatic retry.');
        } elseif ($status == 'false') {
            $msg = __('Akismet cleared this comment during an automatic retry.');
        }
        // If we got back a legit response then update the comment history
        // other wise just bail now and try again later.  No point in
        // re-trying all the comments once we hit one failure.
        if (!empty($msg)) {
            delete_comment_meta($comment_id, 'akismet_error');
            akismet_update_comment_history($comment_id, $msg, 'cron-retry');
            update_comment_meta($comment_id, 'akismet_result', $status);
            // make sure the comment status is still pending.  if it isn't, that means the user has already moved it elsewhere.
            $comment = get_comment($comment_id);
            if ($comment && 'unapproved' == wp_get_comment_status($comment_id)) {
                if ($status == 'true') {
                    wp_spam_comment($comment_id);
                } elseif ($status == 'false') {
                    // comment is good, but it's still in the pending queue.  depending on the moderation settings
                    // we may need to change it to approved.
                    if (check_comment($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent, $comment->comment_type)) {
                        wp_set_comment_status($comment_id, 1);
                    }
                }
            }
        } else {
            delete_comment_meta($comment_id, 'akismet_rechecking');
            wp_schedule_single_event(time() + 1200, 'akismet_schedule_cron_recheck');
            return;
        }
        delete_comment_meta($comment_id, 'akismet_rechecking');
    }
    $remaining = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'");
    if ($remaining && !wp_next_scheduled('akismet_schedule_cron_recheck')) {
        wp_schedule_single_event(time() + 1200, 'akismet_schedule_cron_recheck');
    }
}
开发者ID:GarryVeles,项目名称:Artibaltika,代码行数:58,代码来源:akismet.php

示例4: akismet_recheck_queue

function akismet_recheck_queue()
{
    global $wpdb, $akismet_api_host, $akismet_api_port;
    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_test_mode()) {
            $c['is_test'] = 'true';
        }
        $id = (int) $c['comment_ID'];
        $query_string = '';
        foreach ($c as $key => $data) {
            $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
        }
        add_comment_meta($c['comment_ID'], 'akismet_rechecking', true);
        $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
        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');
            akismet_update_comment_history($c['comment_ID'], __('Akismet re-checked and caught this comment as spam'), 'check-spam');
        } elseif ('false' == $response[1]) {
            update_comment_meta($c['comment_ID'], 'akismet_result', 'false');
            delete_comment_meta($c['comment_ID'], 'akismet_error');
            akismet_update_comment_history($c['comment_ID'], __('Akismet re-checked and cleared this comment'), '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)'), 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;
    }
}
开发者ID:AgnaldoJaws,项目名称:belavista-wordpress,代码行数:58,代码来源:admin.php


注:本文中的akismet_update_comment_history函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。