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


PHP Akismet::build_query方法代码示例

本文整理汇总了PHP中Akismet::build_query方法的典型用法代码示例。如果您正苦于以下问题:PHP Akismet::build_query方法的具体用法?PHP Akismet::build_query怎么用?PHP Akismet::build_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Akismet的用法示例。


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

示例1: submit_nonspam_comment

 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 = self::sanitize_comment_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 = self::http_post(Akismet::build_query($comment), 'submit-ham');
     if ($comment->reporter) {
         self::update_comment_history($comment_id, '', '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]);
 }
开发者ID:onedaylabs,项目名称:onedaylabs.com,代码行数:41,代码来源:class.akismet.php

示例2: spam_check

 /**
  * Check the email for spam
  *
  * @param $email_fields
  * @param $instance
  *
  * @return array
  */
 function spam_check($post_vars, $email_fields, $instance)
 {
     $errors = array();
     $recaptcha_config = $instance['spam']['recaptcha'];
     $use_recaptcha = $recaptcha_config['use_captcha'] && !empty($recaptcha_config['site_key']) && !empty($recaptcha_config['secret_key']);
     if ($use_recaptcha) {
         $result = wp_remote_post('https://www.google.com/recaptcha/api/siteverify', array('body' => array('secret' => $instance['spam']['recaptcha']['secret_key'], 'response' => $post_vars['g-recaptcha-response'], 'remoteip' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null)));
         if (!is_wp_error($result) && !empty($result['body'])) {
             $result = json_decode($result['body'], true);
             if (isset($result['success']) && !$result['success']) {
                 $errors['recaptcha'] = __('Error validating your Captcha response.', 'so-widgets-bundle');
             }
         }
     }
     if ($instance['spam']['akismet']['use_akismet'] && class_exists('Akismet')) {
         $comment = array();
         $message_text = array();
         foreach ($email_fields['message'] as $m) {
             $message_text[] = $m['value'];
         }
         $comment['comment_text'] = $email_fields['subject'] . "\n\n" . implode("\n\n", $message_text);
         $comment['comment_author'] = !empty($email_fields['name']) ? $email_fields['name'] : '';
         $comment['comment_author_email'] = $email_fields['email'];
         $comment['comment_post_ID'] = get_the_ID();
         $comment['comment_type'] = 'contact-form';
         $comment['user_ip'] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null;
         $comment['user_agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
         $comment['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
         $comment['blog'] = get_option('home');
         $comment['blog_lang'] = get_locale();
         $comment['blog_charset'] = get_option('blog_charset');
         // Pretend to check with Akismet
         $response = Akismet::http_post(Akismet::build_query($comment), 'comment-check');
         $is_spam = !empty($response[1]) && $response[1] == 'true';
         if ($is_spam) {
             $errors['akismet'] = __('Unfortunately our system identified your message as spam.', 'so-widgets-bundle');
         }
     }
     return $errors;
 }
开发者ID:GvarimAZA,项目名称:website,代码行数:48,代码来源:contact.php

示例3: verify_wpcom_key

 public static function verify_wpcom_key($api_key, $user_id, $extra = array())
 {
     $akismet_account = Akismet::http_post(Akismet::build_query(array_merge(array('user_id' => $user_id, 'api_key' => $api_key, 'get_account_type' => 'true'), $extra)), 'verify-wpcom-key');
     if (!empty($akismet_account[1])) {
         $akismet_account = json_decode($akismet_account[1]);
     }
     Akismet::log(compact('akismet_account'));
     return $akismet_account;
 }
开发者ID:sb-xs,项目名称:que-pour-elle,代码行数:9,代码来源:class.akismet-admin.php

示例4: is_spam

 public function is_spam($contact)
 {
     if (method_exists('Akismet', 'http_post')) {
         $comment = array('comment_author' => $contact['name'], 'comment_author_email' => $contact['email'], 'comment_content' => $contact['message'], 'comment_type' => $this->tag, 'user_ip' => preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']), 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'referrer' => $_SERVER['HTTP_REFERER'], 'blog' => get_option('home'), 'blog_lang' => get_locale(), 'blog_charset' => get_option('blog_charset'));
         foreach ($_SERVER as $key => $value) {
             if ($key != 'HTTP_COOKIE' && is_string($value)) {
                 $comment[$key] = $value;
             }
         }
         $response = Akismet::http_post(Akismet::build_query($comment), 'comment-check');
         if ('true' == trim($response[1])) {
             return true;
         }
     }
     return false;
 }
开发者ID:kkoscielniak,项目名称:partner,代码行数:16,代码来源:index.php


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