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


PHP akismet_get_key函数代码示例

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


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

示例1: gwolle_gb_akismet

function gwolle_gb_akismet($entry, $action)
{
    $actions = array('comment-check', 'submit-ham', 'submit-spam');
    if (!in_array($action, $actions)) {
        return false;
    }
    $akismet_active = get_option('gwolle_gb-akismet-active', 'false');
    if ($akismet_active != 'true') {
        // Akismet is not active, so we don't do anything
        return false;
    }
    if (is_callable(array('Akismet', 'get_api_key'))) {
        // Akismet v3.0+
        $api_key = (bool) Akismet::get_api_key();
    } else {
        if (function_exists('akismet_get_key')) {
            $api_key = (bool) akismet_get_key();
        }
    }
    if (!$api_key) {
        // No api key, no glory
        return false;
    }
    if (!is_object($entry)) {
        // No object, no fuss
        return false;
    }
    $comment = array();
    $comment['comment_author'] = $entry->get_author_name();
    $comment['comment_author_email'] = $entry->get_author_email();
    $comment['comment_author_origin'] = $entry->get_author_origin();
    $comment['comment_author_url'] = $entry->get_author_website();
    $comment['comment_content'] = gwolle_gb_bbcode_strip($entry->get_content());
    $comment['blog'] = get_option('home');
    $comment['blog_lang'] = get_locale();
    $comment['blog_charset'] = get_option('blog_charset');
    $comment['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
    $comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
    if (isset($_SERVER['HTTP_REFERER'])) {
        $comment['referrer'] = $_SERVER['HTTP_REFERER'];
    }
    // http://blog.akismet.com/2012/06/19/pro-tip-tell-us-your-comment_type/
    $comment['comment_type'] = 'comment';
    $permalink = get_permalink(get_the_ID());
    if ($permalink) {
        $comment['permalink'] = $permalink;
    }
    $ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW');
    foreach ($_SERVER as $key => $value) {
        if (!in_array($key, (array) $ignore)) {
            $comment["{$key}"] = $value;
        }
    }
    // Send the thing to the Akismet service
    return gwolle_gb_akismet_entry_check($comment, $action);
}
开发者ID:RainGrid,项目名称:site,代码行数:56,代码来源:akismet.php

示例2: is_enable

 /**
  * is_enable
  * @return string APIキー
  */
 private function is_enable()
 {
     if (is_callable(array('Akismet', 'get_api_key'))) {
         return Akismet::get_api_key();
     }
     if (function_exists('akismet_get_key')) {
         return akismet_get_key();
     }
     return false;
 }
开发者ID:sakadon,项目名称:firststepkit_wp,代码行数:14,代码来源:class.akismet.php

示例3: wpcf7_akismet_is_available

function wpcf7_akismet_is_available()
{
    if (is_callable(array('Akismet', 'get_api_key'))) {
        // Akismet v3.0+
        return (bool) Akismet::get_api_key();
    }
    if (function_exists('akismet_get_key')) {
        return (bool) akismet_get_key();
    }
    return false;
}
开发者ID:zoran180,项目名称:natashazindrou,代码行数:11,代码来源:akismet.php

示例4: get_api_key

 public static function get_api_key()
 {
     if (is_callable(array('Akismet', 'get_api_key'))) {
         /* Akismet v3.0+ */
         return (bool) Akismet::get_api_key();
     }
     if (function_exists('akismet_get_key')) {
         return (bool) akismet_get_key();
     }
     return false;
 }
开发者ID:gbaladi,项目名称:landing-pages,代码行数:11,代码来源:class.inbound-forms.akismet.php

示例5: wpcf7_akismet

function wpcf7_akismet($spam)
{
    if ($spam) {
        return $spam;
    }
    if (!function_exists('akismet_get_key') || !akismet_get_key()) {
        return false;
    }
    if (!($params = wpcf7_akismet_submitted_params())) {
        return false;
    }
    $c = array();
    if (!empty($params['author'])) {
        $c['comment_author'] = $params['author'];
    }
    if (!empty($params['author_email'])) {
        $c['comment_author_email'] = $params['author_email'];
    }
    if (!empty($params['author_url'])) {
        $c['comment_author_url'] = $params['author_url'];
    }
    if (!empty($params['content'])) {
        $c['comment_content'] = $params['content'];
    }
    $c['blog'] = get_option('home');
    $c['blog_lang'] = get_locale();
    $c['blog_charset'] = get_option('blog_charset');
    $c['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
    $c['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
    $c['referrer'] = $_SERVER['HTTP_REFERER'];
    // http://blog.akismet.com/2012/06/19/pro-tip-tell-us-your-comment_type/
    $c['comment_type'] = 'contact-form';
    if ($permalink = get_permalink()) {
        $c['permalink'] = $permalink;
    }
    $ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW');
    foreach ($_SERVER as $key => $value) {
        if (!in_array($key, (array) $ignore)) {
            $c["{$key}"] = $value;
        }
    }
    return wpcf7_akismet_comment_check($c);
}
开发者ID:pathumego,项目名称:easykarma,代码行数:43,代码来源:akismet.php

示例6: akismet_check_server_connectivity

function akismet_check_server_connectivity()
{
    global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
    $test_host = 'rest.akismet.com';
    // Some web hosts may disable one or both functions
    if (!is_callable('fsockopen') || !is_callable('gethostbynamel')) {
        return array();
    }
    $ips = gethostbynamel($test_host);
    if (!$ips || !is_array($ips) || !count($ips)) {
        return array();
    }
    $servers = array();
    foreach ($ips as $ip) {
        $response = akismet_verify_key(akismet_get_key(), $ip);
        // even if the key is invalid, at least we know we have connectivity
        if ($response == 'valid' || $response == 'invalid') {
            $servers[$ip] = true;
        } else {
            $servers[$ip] = false;
        }
    }
    return $servers;
}
开发者ID:gigikiri,项目名称:bcnAutoWallpaperSite,代码行数:24,代码来源:akismet.php

示例7: akismet_stats_display

function akismet_stats_display()
{
    global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
    $blog = urlencode(get_option('home'));
    $url = 'http://';
    if (is_ssl()) {
        $url = 'https://';
    }
    $url .= 'akismet.com/web/1.0/user-stats.php';
    $url .= "?blog={$blog}&api_key=" . akismet_get_key();
    ?>
	<div class="wrap">
	<iframe src="<?php 
    echo $url;
    ?>
" width="100%" height="100%" frameborder="0" id="akismet-stats-frame"></iframe>
	</div>
	<?php 
}
开发者ID:hoonio,项目名称:wordpress,代码行数:19,代码来源:admin.php

示例8: 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

示例9: wpcf7_akismet

function wpcf7_akismet($spam)
{
    global $akismet_api_host, $akismet_api_port;
    if (!function_exists('akismet_get_key') || !akismet_get_key()) {
        return false;
    }
    $akismet_ready = false;
    $author = $author_email = $author_url = $content = '';
    $fes = wpcf7_scan_shortcode();
    foreach ($fes as $fe) {
        if (!isset($fe['name']) || !is_array($fe['options'])) {
            continue;
        }
        if (preg_grep('%^akismet:author$%', $fe['options'])) {
            $author .= ' ' . $_POST[$fe['name']];
            $author = trim($author);
            $akismet_ready = true;
        }
        if (preg_grep('%^akismet:author_email$%', $fe['options']) && '' == $author_email) {
            $author_email = trim($_POST[$fe['name']]);
            $akismet_ready = true;
        }
        if (preg_grep('%^akismet:author_url$%', $fe['options']) && '' == $author_url) {
            $author_url = trim($_POST[$fe['name']]);
            $akismet_ready = true;
        }
        if ('' != $content) {
            $content .= "\n\n";
        }
        $content .= $_POST[$fe['name']];
    }
    if (!$akismet_ready) {
        return false;
    }
    $c['blog'] = get_option('home');
    $c['blog_lang'] = get_locale();
    $c['blog_charset'] = get_option('blog_charset');
    $c['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
    $c['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
    $c['referrer'] = $_SERVER['HTTP_REFERER'];
    $c['comment_type'] = 'contactform7';
    if ($permalink = get_permalink()) {
        $c['permalink'] = $permalink;
    }
    if ('' != $author) {
        $c['comment_author'] = $author;
    }
    if ('' != $author_email) {
        $c['comment_author_email'] = $author_email;
    }
    if ('' != $author_url) {
        $c['comment_author_url'] = $author_url;
    }
    if ('' != $content) {
        $c['comment_content'] = $content;
    }
    $ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW');
    foreach ($_SERVER as $key => $value) {
        if (!in_array($key, (array) $ignore)) {
            $c["{$key}"] = $value;
        }
    }
    $query_string = '';
    foreach ($c as $key => $data) {
        $query_string .= $key . '=' . urlencode(stripslashes((string) $data)) . '&';
    }
    $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
    if ('true' == $response[1]) {
        $spam = true;
    }
    return $spam;
}
开发者ID:Telemedellin,项目名称:feriadelasfloresmedellin,代码行数:72,代码来源:akismet.php

示例10: __actionWPAjaxContactForm

 public function __actionWPAjaxContactForm()
 {
     if (!isset($this->features['contact-form'])) {
         exit;
     }
     $contact_form = $this->features['contact-form'];
     $options = $this->theme_options->child(array($contact_form['group'], $contact_form['name']));
     $output = function ($result, $message) use($contact_form) {
         echo json_encode(array($contact_form['result_var'] => $result, $contact_form['message_var'] => $message));
         exit;
     };
     $values = array();
     foreach ($options->value('fields') as $field) {
         $value = isset($_POST[$field]) ? trim(strip_tags($_POST[$field])) : '';
         switch ($field) {
             case 'name':
                 if (empty($value)) {
                     $output(false, __('Please enter your name.', $this->domain));
                 }
                 break;
             case 'email':
                 if (!preg_match('/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)+$/i', $value)) {
                     $output(false, __('Invalid email address.', $this->domain));
                 }
                 break;
             case 'website':
                 if (!empty($value) && !preg_match('|^(https?://)?(www\\.)?([-_a-z0-9]+\\.)+[-_a-z0-9]+$|i', $value)) {
                     $output(false, __('Invalid website address.', $this->domain));
                 }
                 break;
             case 'phone':
                 if (!empty($value) && !preg_match('/^[-_#\\+\\*\\(\\)0-9 ]+$/', $value)) {
                     $output(false, __('Invalid phone number.', $this->domain));
                 }
                 break;
             case 'message':
                 if (strlen($value) < 3) {
                     $output(false, __('Please write your message.', $this->domain));
                 }
                 break;
             case 'captcha':
                 if (function_exists('cptch_check_custom_form') && !cptch_check_custom_form()) {
                     $output(false, __('Please complete the captcha.', $this->domain));
                 }
                 break;
         }
         $values[$field] = $value;
     }
     $to = $options->value('to');
     switch ($options->value('from')) {
         case 'to':
             $from = $to;
             break;
         case 'field':
             $from = $values['email'];
             break;
         default:
             $from = get_option('admin_email');
     }
     $reply_to = $values['email'];
     $author = isset($values['name']) ? $values['name'] : '';
     $subject = $options->value('subject');
     $subject = str_replace(array('%blogname%', '%blogurl%'), array(get_bloginfo('name'), home_url()), $subject);
     $subject = preg_replace_callback('/%([a-z]+)%/i', function ($m) use($values) {
         return isset($values[$m[1]]) ? $values[$m[1]] : '';
     }, $subject);
     $subject = wp_specialchars_decode(trim(str_replace(array("\r", "\n"), ' ', $subject)));
     $message = "{$values['message']}\r\n\r\n---\r\n" . implode("\r\n", array_intersect_key($values, array_flip(array_intersect($options->value('fields'), array('name', 'email', 'website', 'phone')))));
     if ($options->child('settings')->value('akismet') && function_exists('akismet_get_key') && akismet_get_key()) {
         $comment = array('blog' => home_url(), 'blog_lang' => get_locale(), 'blog_charset' => get_option('blog_charset'), 'user_ip' => $_SERVER['REMOTE_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'referrer' => $_SERVER['HTTP_REFERER'], 'comment_type' => 'contactform');
         if (isset($values['name'])) {
             $comment['comment_author'] = $values['name'];
         }
         if (isset($values['email'])) {
             $comment['comment_author_email'] = $values['email'];
         }
         if (isset($values['comment_author_url'])) {
             $comment['comment_author_email'] = $values['website'];
         }
         if (isset($values['message'])) {
             $comment['comment_content'] = $values['message'];
         }
         foreach ($_SERVER as $key => $value) {
             if (!in_array($key, array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW')) && is_string($value)) {
                 $comment[$key] = $value;
             } else {
                 $comment[$key] = '';
             }
         }
         $query_string = Func::arraySerialize(array_map('stripslashes', $comment));
         $response = akismet_http_post($query_string, $GLOBALS['akismet_api_host'], '/1.1/comment-check', $GLOBALS['akismet_api_port']);
         if ($response[1] == 'true') {
             $output(false, __('Your message is recognized as spam.', $this->domain));
         }
     }
     $result = @wp_mail($to, $subject, $message, ($options->child('settings')->value('from_header') ? "From: \"{$author}\" <{$from}>\r\n" : '') . "Reply-to: {$reply_to}\r\n" . "Content-type: text/plain; charset=\"" . get_bloginfo('charset') . "\"\r\n");
     if ($result) {
         $output(true, __('Message sent.', $this->domain));
     } else {
         $output(false, __("Error occured. Message couldn't be sent.", $this->domain));
//.........这里部分代码省略.........
开发者ID:xpander54,项目名称:wp-drz,代码行数:101,代码来源:theme.php

示例11: akismet_stats_display

function akismet_stats_display()
{
    global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
    $blog = urlencode(get_option('home'));
    $url = "http://" . akismet_get_key() . ".web.akismet.com/1.0/user-stats.php?blog={$blog}";
    ?>
	<div class="wrap">
	<iframe src="<?php 
    echo $url;
    ?>
" width="100%" height="100%" frameborder="0" id="akismet-stats-frame"></iframe>
	</div>
	<?php 
}
开发者ID:SymbiSoft,项目名称:litprojects,代码行数:14,代码来源:akismet.php

示例12: digressit_live_spam_check_comment

function digressit_live_spam_check_comment($comment)
{
    global $akismet_api_host, $akismet_api_port;
    if (function_exists('akismet_verify_key')) {
        if (akismet_verify_key(akismet_get_key())) {
            $comment['user_ip'] = $_SERVER['REMOTE_ADDR'];
            $comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
            $comment['referrer'] = $_SERVER['HTTP_REFERER'];
            $comment['blog'] = get_option('home');
            $comment['blog_lang'] = get_locale();
            $comment['blog_charset'] = get_option('blog_charset');
            $comment['permalink'] = get_permalink($comment['comment_post_ID']);
            $comment['user_role'] = akismet_get_user_roles($comment['user_ID']);
            $ignore = array('HTTP_COOKIE');
            foreach ($_SERVER as $key => $value) {
                if (!in_array($key, $ignore) && is_string($value)) {
                    $comment["{$key}"] = $value;
                }
            }
            $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;
            }
            return false;
        }
    }
    return false;
}
开发者ID:angelmoratilla,项目名称:digressit,代码行数:32,代码来源:comments-functions.php


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