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


PHP akismet_http_post函数代码示例

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


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

示例1: acf_cf_akismet

function acf_cf_akismet($content)
{
    // innocent until proven guilty
    $isSpam = FALSE;
    $content = (array) $content;
    if (function_exists('akismet_init')) {
        $wpcom_api_key = get_option('wordpress_api_key');
        if (!empty($wpcom_api_key)) {
            global $akismet_api_host, $akismet_api_port;
            // set remaining required values for akismet api
            $content['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
            $content['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
            $content['referrer'] = $_SERVER['HTTP_REFERER'];
            $content['blog'] = get_option('home');
            if (empty($content['referrer'])) {
                $content['referrer'] = get_permalink();
            }
            $queryString = '';
            foreach ($content as $key => $data) {
                if (!empty($data)) {
                    $queryString .= $key . '=' . urlencode(stripslashes($data)) . '&';
                }
            }
            $response = akismet_http_post($queryString, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
            if ($response[1] == 'true') {
                update_option('akismet_spam_count', get_option('akismet_spam_count') + 1);
                $isSpam = TRUE;
            }
        }
    }
    return $isSpam;
}
开发者ID:philbraun,项目名称:acf-contact-form,代码行数:32,代码来源:acf-contact-process.php

示例2: mark_akismet_spam

 public static function mark_akismet_spam($esu_post_vars, $is_spam)
 {
     global $akismet_api_host, $akismet_api_port;
     $fields = self::esu_get_akismet_fields($esu_post_vars);
     $as = $is_spam ? "spam" : "ham";
     //Submitting info do Akismet
     akismet_http_post($fields, $akismet_api_host, '/1.1/submit-' . $as, $akismet_api_port);
 }
开发者ID:coreydunkin,项目名称:eh_wordpress,代码行数:8,代码来源:esu-akismet.php

示例3: recheck_config_page

function recheck_config_page()
{
    global $wpdb, $akismet_api_host, $akismet_api_port;
    if (isset($_POST['recheck_update'])) {
        /* do import */
        $comments = $wpdb->get_results("SELECT comment_ID FROM {$wpdb->comments}\tWHERE comment_approved = '1'", ARRAY_A);
        $spam_found = 0;
        $comments_processed = 0;
        foreach ($comments as $c) {
            $i = $c['comment_ID'];
            $comment = $wpdb->get_row("SELECT * FROM {$wpdb->comments} WHERE comment_id = {$i}", ARRAY_A);
            $comment['user_ip'] = $comment['comment_author_IP'];
            $comment['user_agent'] = $comment['comment_agent'];
            $comment['referrer'] = '';
            $comment['blog'] = get_option('home');
            $id = (int) $comment['comment_ID'];
            $query_string = '';
            foreach ($comment 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 ($response[1] == 'true') {
                //echo '<p>comment #' . $comment['comment_ID'] . ' is SPAM!!!</p>';
                $wpdb->query("UPDATE {$wpdb->comments} SET comment_approved = '0' WHERE comment_ID = {$id}");
                $spam_found++;
            }
            $comments_processed++;
        }
        echo '<p>total spam found: ' . $spam_found . '</p>';
        echo '<p>total comments processed: ' . $comments_processed . '</p>';
        ?>
		<div id="message" class="updated fade">
			<p>Victory!</p>
		</div>
	<?php 
    }
    ?>

<div class="wrap">
	<h2>Spam Recheck</h2>
	<form method="post" action="">
		<div style="width:100%; horizontal-align:right">
			<input type="submit" name="recheck_update" value="Check &raquo;"  style="float:right;" />
			<hr style="clear:both; visibility: hidden" />
		</div>
	</form>
</div>
<?php 
}
开发者ID:hwork,项目名称:spam-recheck,代码行数:49,代码来源:spam-recheck.php

示例4: flamingo_akismet_submit

function flamingo_akismet_submit($comment, $as = 'spam')
{
    global $akismet_api_host, $akismet_api_port;
    if (!flamingo_akismet_is_active()) {
        return false;
    }
    if (!in_array($as, array('spam', 'ham'))) {
        return false;
    }
    $query_string = '';
    foreach ((array) $comment as $key => $data) {
        $query_string .= $key . '=' . urlencode(wp_unslash((string) $data)) . '&';
    }
    if (is_callable(array('Akismet', 'http_post'))) {
        // Akismet v3.0+
        $response = Akismet::http_post($query_string, 'submit-' . $as);
    } else {
        $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/submit-' . $as, $akismet_api_port);
    }
    return (bool) $response[1];
}
开发者ID:jgacuca567,项目名称:jamesvanwaza,代码行数:21,代码来源:akismet.php

示例5: clean_contact_akismet

function clean_contact_akismet($body, $subject, $email, $name)
{
    if (!function_exists('akismet_http_post')) {
        return true;
    }
    global $akismet_api_host, $akismet_api_port;
    $comment['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
    $comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
    $comment['referrer'] = $_SERVER['HTTP_REFERER'];
    $comment['blog'] = get_option('home');
    $comment['comment_author_email'] = $email;
    $comment['comment_author'] = clean_contact_scrub($name);
    $comment['comment_content'] = clean_contact_scrub($body);
    $query_string = '';
    foreach ($comment 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]) {
        return true;
    }
}
开发者ID:envickery,项目名称:staging.xylemwatermark.org,代码行数:22,代码来源:clean_contact.php

示例6: sharing_email_check_for_spam_via_akismet

function sharing_email_check_for_spam_via_akismet($data)
{
    if (!function_exists('akismet_http_post') && !method_exists('Akismet', 'http_post')) {
        return $data;
    }
    // Prepare the body_request for akismet
    $body_request = array('blog' => get_option('home'), 'permalink' => get_permalink($data['post']->ID), 'comment_type' => 'share', 'comment_author' => $data['name'], 'comment_author_email' => $data['source'], 'comment_content' => sharing_email_send_post_content($data), 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null);
    if (method_exists('Akismet', 'http_post')) {
        $body_request['user_ip'] = Akismet::get_ip_address();
        $response = Akismet::http_post(build_query($body_request), 'comment-check');
    } else {
        global $akismet_api_host, $akismet_api_port;
        $body_request['user_ip'] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null;
        $response = akismet_http_post(build_query($body_request), $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
    }
    // The Response is spam lets not send the email.
    if (!empty($response) && isset($response[1]) && 'true' == trim($response[1])) {
        // 'true' is spam
        return false;
        // don't send the email
    }
    return $data;
}
开发者ID:JSpier,项目名称:smacamp,代码行数:23,代码来源:sharedaddy.php

示例7: api_check

 public static function api_check($params)
 {
     global $akismet_api_host, $akismet_api_port;
     /* bail if no content to check against akismet */
     if (!isset($params['comment_content'])) {
         return;
     }
     $spam = false;
     $query_string = '';
     foreach ($params as $key => $data) {
         $query_string .= $key . '=' . urlencode(wp_unslash((string) $data)) . '&';
     }
     if (is_callable(array('Akismet', 'http_post'))) {
         // Akismet v3.0+
         $response = Akismet::http_post($query_string, 'comment-check');
     } else {
         $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
     }
     /* returns true if spam else return false */
     if ('true' == $response[1]) {
         return true;
     }
     return false;
 }
开发者ID:devilcranx,项目名称:landing-pages,代码行数:24,代码来源:class.inbound-forms.akismet.php

示例8: akismet

 function akismet($values)
 {
     $content = FrmEntriesHelper::entry_array_to_string($values);
     if (empty($content)) {
         return false;
     }
     $datas = array();
     $datas['blog'] = FrmAppHelper::site_url();
     $datas['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
     $datas['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
     $datas['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : false;
     $datas['comment_type'] = 'formidable';
     if ($permalink = get_permalink()) {
         $datas['permalink'] = $permalink;
     }
     $datas['comment_content'] = $content;
     foreach ($_SERVER as $key => $value) {
         if (!in_array($key, array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW')) && is_string($value)) {
             $datas["{$key}"] = $value;
         } else {
             $datas["{$key}"] = '';
         }
         unset($key, $value);
     }
     $query_string = '';
     foreach ($datas as $key => $data) {
         $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
         unset($key, $data);
     }
     if (is_callable('Akismet::http_post')) {
         $response = Akismet::http_post($query_string, 'comment-check');
     } else {
         global $akismet_api_host, $akismet_api_port;
         $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
     }
     return (is_array($response) and $response[1] == 'true') ? true : false;
 }
开发者ID:amit0773,项目名称:manaslake,代码行数:37,代码来源:FrmEntry.php

示例9: is_spam

 function is_spam($contact)
 {
     if (function_exists('akismet_http_post')) {
         global $akismet_api_host, $akismet_api_port;
         $comment = array('comment_author' => $contact['name'], 'comment_author_email' => $contact['email'], 'comment_author_url' => $contact['email'], 'contact_form_subject' => '', 'comment_content' => $contact['message'], 'user_ip' => preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']), 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'referrer' => $_SERVER['HTTP_REFERER'], 'blog' => get_option('home'));
         foreach ($_SERVER as $key => $value) {
             if ($key != 'HTTP_COOKIE' && is_string($value)) {
                 $comment[$key] = $value;
             }
         }
         $query = '';
         foreach ($comment as $key => $value) {
             $query .= $key . '=' . urlencode($value) . '&';
         }
         $response = akismet_http_post($query, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
         if ('true' == trim($response[1])) {
             return true;
         }
     }
     return false;
 }
开发者ID:ramonvloon,项目名称:Ingrid,代码行数:21,代码来源:index.php

示例10: array

 $ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW');
 foreach ($_SERVER as $key => $value) {
     if (!in_array($key, $ignore) && is_string($value)) {
         $c["{$key}"] = $value;
     } else {
         $c["{$key}"] = '';
     }
 }
 $query_string = '';
 foreach ($c as $key => $data) {
     if (is_string($data)) {
         $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
     }
 }
 //echo "test $akismet_api_host, $akismet_api_port, $query_string"; exit;
 $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
 if ('true' == $response[1]) {
     if ($si_contact_opt['akismet_send_anyway'] == 'false') {
         $this->si_contact_error = 1;
         // Akismet says it is spam.
         $fsc_error_message['message'] = $si_contact_opt['error_input'] != '' ? $si_contact_opt['error_input'] : __('Invalid Input - Spam?', 'si-contact-form');
         if ($user_ID != '' && current_user_can('level_10')) {
             // show administrator a helpful message
             $fsc_error_message['message'] .= '<br />' . __('Akismet determined your message is spam. This can be caused by the message content, your email address, or your IP address being on the Akismet spam system. The administrator can turn off Akismet for the form on the form edit menu.', 'si-contact-form');
         }
     } else {
         // Akismet says it is spam. flag the subject as spam and send anyway.
         $subj = __('Akismet: Spam', 'si-contact-form') . ' - ' . $subj;
         $msg = str_replace(__('Sent from (ip address)', 'si-contact-form'), __('Akismet Spam Check: probably spam', 'si-contact-form') . $php_eol . __('Sent from (ip address)', 'si-contact-form'), $msg);
         $posted_data['akismet'] = __('probably spam', 'si-contact-form');
     }
开发者ID:akimxtreme,项目名称:materialesdimacoy.com.ve,代码行数:31,代码来源:si-contact-form-process.php

示例11: shandora_process_agent_contact

function shandora_process_agent_contact()
{
    if (!isset($_POST) || empty($_POST)) {
        $return_data['value'] = __('Cannot send email to destination. No parameter receive form AJAX call.', 'bon');
        die(json_encode($return_data));
    }
    $name = esc_html($_POST['name']);
    if (empty($name)) {
        $return_data['value'] = __('Please enter your name.', 'bon');
        die(json_encode($return_data));
    }
    $email = sanitize_email($_POST['email']);
    if (empty($email)) {
        $return_data['value'] = __('Please enter a valid email address.', 'bon');
        die(json_encode($return_data));
    }
    $phone = isset($_POST['phone']) ? esc_attr($_POST['phone']) : '';
    $subject = esc_html($_POST['subject']);
    $listing_id = absint($_POST['listing_id']);
    $messages = esc_textarea($_POST['messages']);
    if (empty($messages)) {
        $return_data['value'] = 'Please enter your messages.';
        die(json_encode($return_data));
    }
    if (function_exists('akismet_http_post') && trim(get_option('wordpress_api_key')) != '') {
        global $akismet_api_host, $akismet_api_port;
        $c['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
        $c['blog'] = home_url();
        $c['comment_author'] = $name;
        $c['comment_author_email'] = $email;
        $c['comment_content'] = $messages;
        $query_string = '';
        foreach ($c as $key => $data) {
            if (is_string($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]) {
            // Akismet says it's SPAM
            $return_data['value'] = __('Cheatin Huh?!', 'bon');
            die(json_encode($return_data));
        }
    }
    $receiver = $_POST['receiver'];
    //$body = "You have received a new contact form message via ".get_bloginfo('name')." \n";
    $body = sprintf(__("You have received a new contact form message via %s \n", 'bon'), get_bloginfo('name'));
    /*$body .= 'Name : ' . $name . " \n";
    	$body .= 'Email : ' . $email . " \n";
    	$body .= 'Subject : ' . $subject . " \n";
    	$body .= 'Email Send From: ' . get_permalink( $listing_id ) . " \n";
    	$body .= 'Sender Phone Number :' . $phone . " \n";
    	$body .= 'Message : ' . $messages;
    	*/
    $body .= sprintf(__("Sender Name : %s \n", "bon"), $name);
    $body .= sprintf(__("Sender Email : %s \n", "bon"), $email);
    $body .= sprintf(__("Subject : %s \n", "bon"), $subject);
    $body .= sprintf(__("Sender Phone Number : %s \n", "bon"), $phone);
    $body .= sprintf(__("Email Send From : %s \n", "bon"), get_permalink($listing_id));
    $body .= sprintf(__("Message : %s \n", "bon"), $messages);
    $header = "From: " . $name . " <" . $email . "> \r\n";
    $header .= "Reply-To: " . $email;
    $subject_email = "[" . get_bloginfo('name') . " Contact Form] " . $subject;
    if (wp_mail($receiver, $subject_email, $body, $header)) {
        $return_data['success'] = '1';
        $return_data['value'] = __('Email was sent successfully.', 'bon');
        die(json_encode($return_data));
    } else {
        $return_data['value'] = __('There is an error sending email.', 'bon');
        die(json_encode($return_data));
    }
}
开发者ID:VadimSid,项目名称:thinkgreek,代码行数:72,代码来源:theme-actions.php

示例12: akismet

 function akismet($values)
 {
     global $akismet_api_host, $akismet_api_port, $frm_siteurl;
     $content = '';
     foreach ($values['item_meta'] as $val) {
         if ($content != '') {
             $content .= "\n\n";
         }
         $content .= $val;
     }
     if ($content == '') {
         return false;
     }
     $datas = array();
     $datas['blog'] = $frm_siteurl;
     $datas['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
     $datas['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
     $datas['referrer'] = $_SERVER['HTTP_REFERER'];
     $datas['comment_type'] = 'formidable';
     if ($permalink = get_permalink()) {
         $datas['permalink'] = $permalink;
     }
     $datas['comment_content'] = $content;
     foreach ($_SERVER as $key => $value) {
         if (!in_array($key, array('HTTP_COOKIE', 'argv'))) {
             $datas["{$key}"] = $value;
         }
     }
     $query_string = '';
     foreach ($datas 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);
     return $response[1] == 'true' ? true : false;
 }
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:35,代码来源:FrmEntry.php

示例13: check_akismet

 static function check_akismet()
 {
     $string = '';
     // Check with Akismet, but only if Akismet is installed, activated, and has a KEY. (Recommended for spam control).
     if (self::$form_options['akismet_disable'] == 'false') {
         // per form disable feature
         // check if akismet is activated, version 2.x or 3.x
         if ((is_callable(array('Akismet', 'http_post')) || function_exists('akismet_http_post')) && get_option('wordpress_api_key')) {
             global $akismet_api_host, $akismet_api_port;
             $c['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
             $c['user_agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
             $c['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
             $c['blog'] = get_option('home');
             $c['blog_lang'] = get_locale();
             // default 'en_US'
             $c['blog_charset'] = get_option('blog_charset');
             $c['permalink'] = self::$form_action_url;
             $c['comment_type'] = 'contact-form';
             if (!empty(self::$email_fields['from_name'])) {
                 $c['comment_author'] = self::$email_fields['from_name'];
             }
             //$c['is_test']  = "1";  // uncomment this when testing spam detection
             //$c['comment_author']  = "viagra-test-123";  // uncomment this to test spam detection
             // or  You can just put viagra-test-123 as the name when testing the form (no need to edit this php file to test it)
             if (!empty(self::$email_fields['from_email'])) {
                 $c['comment_author_email'] = self::$email_fields['from_email'];
             }
             $c['comment_content'] = self::$email_msg;
             $ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW');
             foreach ($_SERVER as $key => $value) {
                 if (!in_array($key, $ignore) && is_string($value)) {
                     $c["{$key}"] = $value;
                 } else {
                     $c["{$key}"] = '';
                 }
             }
             $query_string = '';
             foreach ($c as $key => $data) {
                 if (is_string($data)) {
                     $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
                 }
             }
             //echo "test $akismet_api_host, $akismet_api_port, $query_string"; exit;
             if (is_callable(array('Akismet', 'http_post'))) {
                 // Akismet v3.0+
                 $response = Akismet::http_post($query_string, 'comment-check');
             } else {
                 // Akismet v2.xx
                 $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
             }
             if ('true' == $response[1]) {
                 if (self::$form_options['akismet_send_anyway'] == 'false') {
                     self::$form_errors['akismet'] = self::$form_options['error_input'] != '' ? self::$form_options['error_input'] : __('Invalid Input - Spam?', 'si-contact-form');
                     global $user_ID;
                     if ($user_ID != '' && current_user_can('manage_options')) {
                         // this error only shown to WP admins
                         // show administrator a helpful message
                         self::$form_errors['akismet'] .= '<br />' . __('Akismet determined your message is spam. This can be caused by the message content, your email address, or your IP address being on the Akismet spam system. The administrator can turn off Akismet for the form on the form edit menu.', 'si-contact-form');
                     }
                 } else {
                     // Akismet says it is spam. flag the subject as spam and send anyway.
                     // XXX someday make these messages editable in settings
                     self::$akismet_spam_subject = __('Akismet: Spam', 'si-contact-form') . ' - ';
                     $string .= __('Akismet Spam Check: probably spam', 'si-contact-form') . self::$php_eol;
                     self::$email_fields['akismet'] = __('probably spam', 'si-contact-form');
                 }
             } else {
                 $string .= __('Akismet Spam Check: passed', 'si-contact-form') . self::$php_eol;
                 self::$email_fields['akismet'] = __('passed', 'si-contact-form');
             }
         }
     }
     return $string;
 }
开发者ID:GnaritasInc,项目名称:gnlms,代码行数:74,代码来源:class-fscf-process.php

示例14: akismet_check_db_comment

function akismet_check_db_comment($id)
{
    global $wpdb, $akismet_api_host, $akismet_api_port;
    $id = (int) $id;
    $c = $wpdb->get_row("SELECT * FROM {$wpdb->comments} WHERE comment_ID = '{$id}'", ARRAY_A);
    if (!$c) {
        return;
    }
    $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']);
    $id = $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);
    return $response[1];
}
开发者ID:gigikiri,项目名称:bcnAutoWallpaperSite,代码行数:23,代码来源:akismet.php

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