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


PHP Akismet::log方法代码示例

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


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

示例1: get_jetpack_user

 private static function get_jetpack_user()
 {
     if (!class_exists('Jetpack')) {
         return false;
     }
     Jetpack::load_xml_rpc_client();
     $xml = new Jetpack_IXR_ClientMulticall(array('user_id' => get_current_user_id()));
     $xml->addCall('wpcom.getUserID');
     $xml->addCall('akismet.getAPIKey');
     $xml->query();
     Akismet::log(compact('xml'));
     if (!$xml->isError()) {
         $responses = $xml->getResponse();
         if (count($responses) > 1) {
             $api_key = array_shift($responses[0]);
             $user_id = (int) array_shift($responses[1]);
             return compact('api_key', 'user_id');
         }
     }
     return false;
 }
开发者ID:valiror,项目名称:sharingdais_demo1,代码行数:21,代码来源:class.akismet-admin.php

示例2: http_post

 /**
  * Make a POST request to the Akismet API.
  *
  * @param string $request The body of the request.
  * @param string $path The path for the request.
  * @param string $ip The specific IP address to hit.
  * @return array A two-member array consisting of the headers and the response body, both empty in the case of a failure.
  */
 public static function http_post($request, $path, $ip = null)
 {
     $akismet_ua = sprintf('WordPress/%s | Akismet/%s', $GLOBALS['wp_version'], constant('AKISMET_VERSION'));
     $akismet_ua = apply_filters('akismet_ua', $akismet_ua);
     $content_length = strlen($request);
     $api_key = self::get_api_key();
     $host = self::API_HOST;
     if (!empty($api_key)) {
         $host = $api_key . '.' . $host;
     }
     $http_host = $host;
     // use a specific IP if provided
     // needed by Akismet_Admin::check_server_connectivity()
     if ($ip && long2ip(ip2long($ip))) {
         $http_host = $ip;
     }
     $http_args = array('body' => $request, 'headers' => array('Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'), 'Host' => $host, 'User-Agent' => $akismet_ua), 'httpversion' => '1.0', 'timeout' => 15);
     $akismet_url = "http://{$http_host}/1.1/{$path}";
     $response = wp_remote_post($akismet_url, $http_args);
     Akismet::log(compact('akismet_url', 'http_args', 'response'));
     if (is_wp_error($response)) {
         return array('', '');
     }
     return array($response['headers'], $response['body']);
 }
开发者ID:uwitec,项目名称:findgreatmaster,代码行数:33,代码来源:class.akismet.php

示例3: http_post

 /**
  * Make a POST request to the Akismet API.
  *
  * @param string $request The body of the request.
  * @param string $path The path for the request.
  * @param string $ip The specific IP address to hit.
  * @return array A two-member array consisting of the headers and the response body, both empty in the case of a failure.
  */
 public static function http_post($request, $path, $ip = null)
 {
     $akismet_ua = sprintf('WordPress/%s | Akismet/%s', $GLOBALS['wp_version'], constant('AKISMET_VERSION'));
     $akismet_ua = apply_filters('akismet_ua', $akismet_ua);
     $content_length = strlen($request);
     $api_key = self::get_api_key();
     $host = self::API_HOST;
     if (!empty($api_key)) {
         $host = $api_key . '.' . $host;
     }
     $http_host = $host;
     // use a specific IP if provided
     // needed by Akismet_Admin::check_server_connectivity()
     if ($ip && long2ip(ip2long($ip))) {
         $http_host = $ip;
     }
     $http_args = array('body' => $request, 'headers' => array('Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'), 'Host' => $host, 'User-Agent' => $akismet_ua), 'httpversion' => '1.0', 'timeout' => 15);
     $akismet_url = $http_akismet_url = "http://{$http_host}/1.1/{$path}";
     /**
      * Try SSL first; if that fails, try without it and don't try it again for a while.
      */
     $ssl = $ssl_failed = false;
     // Check if SSL requests were disabled fewer than X hours ago.
     $ssl_disabled = get_option('akismet_ssl_disabled');
     if ($ssl_disabled && $ssl_disabled < time() - 60 * 60 * 24) {
         // 24 hours
         $ssl_disabled = false;
         delete_option('akismet_ssl_disabled');
     } else {
         if ($ssl_disabled) {
             do_action('akismet_ssl_disabled');
         }
     }
     if (!$ssl_disabled && function_exists('wp_http_supports') && ($ssl = wp_http_supports(array('ssl')))) {
         $akismet_url = set_url_scheme($akismet_url, 'https');
         do_action('akismet_https_request_pre');
     }
     $response = wp_remote_post($akismet_url, $http_args);
     Akismet::log(compact('akismet_url', 'http_args', 'response'));
     if ($ssl && is_wp_error($response)) {
         do_action('akismet_https_request_failure', $response);
         // Intermittent connection problems may cause the first HTTPS
         // request to fail and subsequent HTTP requests to succeed randomly.
         // Retry the HTTPS request once before disabling SSL for a time.
         $response = wp_remote_post($akismet_url, $http_args);
         Akismet::log(compact('akismet_url', 'http_args', 'response'));
         if (is_wp_error($response)) {
             $ssl_failed = true;
             do_action('akismet_https_request_failure', $response);
             do_action('akismet_http_request_pre');
             // Try the request again without SSL.
             $response = wp_remote_post($http_akismet_url, $http_args);
             Akismet::log(compact('http_akismet_url', 'http_args', 'response'));
         }
     }
     if (is_wp_error($response)) {
         do_action('akismet_request_failure', $response);
         return array('', '');
     }
     if ($ssl_failed) {
         // The request failed when using SSL but succeeded without it. Disable SSL for future requests.
         update_option('akismet_ssl_disabled', time());
         do_action('akismet_https_disabled');
     }
     $simplified_response = array($response['headers'], $response['body']);
     self::update_alert($simplified_response);
     return $simplified_response;
 }
开发者ID:onedaylabs,项目名称:onedaylabs.com,代码行数:76,代码来源:class.akismet.php

示例4: ap_check_spam

/**
 * Check post for spam, if spam then hold it for moderation.
 * @param  integer $post_id Post id.
 */
function ap_check_spam($post_id)
{
    // Return if akisment is not enabled.
    if (!class_exists('Akismet') || is_super_admin()) {
        return;
    }
    $post = get_post($post_id);
    // Set default arguments to pass.
    $defaults = array('blog' => home_url('/'), 'user_ip' => get_post_meta($post->ID, 'create_ip', true), 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'referrer' => $_SERVER['HTTP_REFERER'], 'permalink' => get_permalink($post->ID), 'comment_type' => 'forum-post', 'comment_author' => get_the_author_meta('nicename', $post->post_author), 'comment_author_email' => get_the_author_meta('user_email', $post->post_author), 'comment_author_url' => get_the_author_meta('url', $post->post_author), 'comment_content' => $post->post_content);
    $akismet_ua = sprintf('WordPress/%s | Akismet/%s', $GLOBALS['wp_version'], constant('AKISMET_VERSION'));
    $akismet_ua = apply_filters('akismet_ua', $akismet_ua);
    $content_length = strlen($request);
    $api_key = Akismet::get_api_key();
    $host = Akismet::API_HOST;
    if (!empty($api_key)) {
        $host = $api_key . '.' . $host;
    }
    $http_host = $host;
    // Use a specific IP if provided.
    // Needed by Akismet_Admin::check_server_connectivity().
    if ($ip && long2ip(ip2long($ip))) {
        $http_host = $ip;
    }
    $http_args = array('body' => $defaults, 'headers' => array('Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'), 'Host' => $host, 'User-Agent' => $akismet_ua), 'httpversion' => '1.0', 'timeout' => 15);
    $akismet_url = $http_akismet_url = "http://{$http_host}/1.1/comment-check";
    /**
     * Try SSL first; if that fails, try without it and don't try it again for a while.
     */
    $ssl = $ssl_failed = false;
    // Check if SSL requests were disabled fewer than X hours ago.
    $ssl_disabled = get_option('akismet_ssl_disabled');
    if ($ssl_disabled && $ssl_disabled < time() - 60 * 60 * 24) {
        // 24 hours
        $ssl_disabled = false;
        delete_option('akismet_ssl_disabled');
    } else {
        if ($ssl_disabled) {
            do_action('akismet_ssl_disabled');
        }
    }
    if (!$ssl_disabled && function_exists('wp_http_supports') && ($ssl = wp_http_supports(array('ssl')))) {
        $akismet_url = set_url_scheme($akismet_url, 'https');
    }
    $response = wp_remote_post($akismet_url, $http_args);
    Akismet::log(compact('akismet_url', 'http_args', 'response'));
    if ($ssl && is_wp_error($response)) {
        // Intermittent connection problems may cause the first HTTPS
        // request to fail and subsequent HTTP requests to succeed randomly.
        // Retry the HTTPS request once before disabling SSL for a time.
        $response = wp_remote_post($akismet_url, $http_args);
        Akismet::log(compact('akismet_url', 'http_args', 'response'));
        if (is_wp_error($response)) {
            $ssl_failed = true;
            // Try the request again without SSL.
            $response = wp_remote_post($http_akismet_url, $http_args);
            Akismet::log(compact('http_akismet_url', 'http_args', 'response'));
        }
    }
    if (is_wp_error($response)) {
        return array('', '');
    }
    if ($ssl_failed) {
        // The request failed when using SSL but succeeded without it. Disable SSL for future requests.
        update_option('akismet_ssl_disabled', time());
        do_action('akismet_https_disabled');
    }
    if ($response['body']) {
        wp_update_post(array('ID' => $post_id, 'post_status' => 'moderate'));
    }
}
开发者ID:erashu212,项目名称:anspress,代码行数:74,代码来源:akismet.php


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