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


PHP Akismet::verify_key方法代码示例

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


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

示例1: check_server_connectivity

 public static function check_server_connectivity()
 {
     $test_host = 'rest.akismet.com';
     // Some web hosts may disable one or both functions
     if (!function_exists('fsockopen') || !function_exists('gethostbynamel')) {
         return array();
     }
     $ips = gethostbynamel($test_host);
     if (!$ips || !is_array($ips) || !count($ips)) {
         return array();
     }
     $api_key = Akismet::get_api_key();
     $servers = array();
     foreach ($ips as $ip) {
         $response = Akismet::verify_key($api_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:valiror,项目名称:sharingdais_demo1,代码行数:24,代码来源:class.akismet-admin.php

示例2: display_notice

 public static function display_notice()
 {
     global $hook_suffix;
     if (in_array($hook_suffix, array('jetpack_page_akismet-key-config', 'settings_page_akismet-key-config', 'edit-comments.php')) && (int) get_option('akismet_alert_code') > 0) {
         Akismet::verify_key(Akismet::get_api_key());
         //verify that the key is still in alert state
         if (get_option('akismet_alert_code') > 0) {
             self::display_alert();
         }
     } elseif ($hook_suffix == 'plugins.php' && !Akismet::get_api_key()) {
         self::display_api_key_warning();
     } elseif ($hook_suffix == 'edit-comments.php' && wp_next_scheduled('akismet_schedule_cron_recheck')) {
         self::display_spam_check_warning();
     } elseif (in_array($hook_suffix, array('jetpack_page_akismet-key-config', 'settings_page_akismet-key-config')) && Akismet::get_api_key()) {
         self::display_status();
     }
 }
开发者ID:sb-xs,项目名称:que-pour-elle,代码行数:17,代码来源:class.akismet-admin.php

示例3: akismet_settings_callback

    static function akismet_settings_callback()
    {
        ?>
		<div class="clear"></div>
		<fieldset class="fscf_settings_group">


		<strong><?php 
        _e('Akismet Spam Prevention', 'si-contact-form');
        ?>
</strong>

		<a style="cursor:pointer;" title="<?php 
        esc_attr_e('Click for Help!', 'si-contact-form');
        ?>
" onclick="toggleVisibility('si_contact_akismet_tip');"><?php 
        _e('help', 'si-contact-form');
        ?>
</a>
		<div class="fscf_tip" id="si_contact_akismet_tip">
		<?php 
        _e('Akismet is a WordPress spam prevention plugin. When Akismet is installed and active, this form will be checked with Akismet to help prevent spam.', 'si-contact-form');
        ?>
		</div>
		<br /><br />

		<?php 
        $akismet_installed = 0;
        if (self::$form_options['akismet_disable'] == 'false') {
            if (is_callable(array('Akismet', 'verify_key')) || function_exists('akismet_verify_key')) {
                if (!isset(self::$form_options['akismet_check'])) {
                    echo '<span style="background-color:#99CC99;">' . __('Akismet is installed.', 'si-contact-form') . '</span>';
                    $akismet_installed = 1;
                }
                // Has an Akismet check been requested?
                if (strpos($_SERVER['REQUEST_URI'], 'akismet_check') !== false) {
                    $key_status = 'failed';
                    $key = get_option('wordpress_api_key');
                    if (empty($key)) {
                        $key_status = 'empty';
                    } else {
                        if (is_callable(array('Akismet', 'verify_key'))) {
                            $key_status = Akismet::verify_key($key);
                        } else {
                            $key_status = akismet_verify_key($key);
                        }
                        // akismet 2.xx
                    }
                    if ($key_status == 'valid') {
                        $akismet_installed = 1;
                        ?>
<div id="message" class="updated"><strong><?php 
                        echo __('Akismet is enabled and the key is valid. This form will be checked with Akismet to help prevent spam', 'si-contact-form');
                        ?>
</strong></div><?php 
                        echo '<div class="fsc-notice">' . __('Akismet is installed and the key is valid. This form will be checked with Akismet to help prevent spam.', 'si-contact-form') . '</strong></div>';
                    } else {
                        if ($key_status == 'invalid') {
                            ?>
<div id="message" class="error"><strong><?php 
                            echo __('Akismet plugin is enabled but key needs to be activated', 'si-contact-form');
                            ?>
</strong></div><?php 
                            echo '<div class="fsc-error">' . __('Akismet plugin is installed but key needs to be activated.', 'si-contact-form') . '</div>';
                        } else {
                            if (!empty($key) && $key_status == 'failed') {
                                ?>
<div id="message" class="error"><strong><?php 
                                echo __('Akismet plugin is enabled but key failed to verify', 'si-contact-form');
                                ?>
</strong></div><?php 
                                echo '<div class="fsc-error">' . __('Akismet plugin is installed but key failed to verify.', 'si-contact-form') . '</div>';
                            } else {
                                ?>
<div id="message" class="error"><strong><?php 
                                echo __('Akismet plugin is installed but key has not been entered.', 'si-contact-form');
                                ?>
</strong></div><?php 
                                echo '<div class="fsc-error">' . __('Akismet plugin is installed but key has not been entered.', 'si-contact-form') . '</div>';
                            }
                        }
                    }
                }
                ?>
				<br />
				  <input name="<?php 
                echo self::$form_option_name;
                ?>
[akismet_check]" id="si_contact_akismet_check" type="checkbox" value="true" />
				  <label for="<?php 
                echo self::$form_option_name;
                ?>
[akismet_check]"><?php 
                _e('Check this and click "Save Changes" to determine if Akismet key is active.', 'si-contact-form');
                ?>
</label>
				<br />
				<?php 
                echo '<a href="' . admin_url("options-general.php?page=akismet-key-config") . '">' . __('Configure Akismet', 'si-contact-form') . '</a>';
                ?>
//.........这里部分代码省略.........
开发者ID:Bakerpedia,项目名称:Developement_WPengine,代码行数:101,代码来源:class-fscf-options.php

示例4: check_server_ip_connectivity

 public static function check_server_ip_connectivity()
 {
     $servers = $ips = array();
     // Some web hosts may disable this function
     if (function_exists('gethostbynamel')) {
         $ips = gethostbynamel('rest.akismet.com');
         if ($ips && is_array($ips) && count($ips)) {
             $api_key = Akismet::get_api_key();
             foreach ($ips as $ip) {
                 $response = Akismet::verify_key($api_key, $ip);
                 // even if the key is invalid, at least we know we have connectivity
                 if ($response == 'valid' || $response == 'invalid') {
                     $servers[$ip] = 'connected';
                 } else {
                     $servers[$ip] = $response ? $response : 'unable to connect';
                 }
             }
         }
     }
     return $servers;
 }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:21,代码来源:class.akismet-admin.php

示例5: akismet_verify_key

function akismet_verify_key($key, $ip = null)
{
    _deprecated_function(__FUNCTION__, '3.0', 'Akismet::verify_key()');
    return Akismet::verify_key($key, $ip);
}
开发者ID:Didox,项目名称:beminfinito,代码行数:5,代码来源:wrapper.php

示例6: akismet_verify_key

function akismet_verify_key($key, $ip = null)
{
    return Akismet::verify_key($key, $ip);
}
开发者ID:TheHiddenHaku,项目名称:fuzzy-waddle,代码行数:4,代码来源:wrapper.php

示例7: _e

    ?>
  <input name="si_captcha_akismet_check" id="si_captcha_akismet_check" type="checkbox" value="1" />
  <label for="si_captcha_akismet_check"><?php 
    _e('Check this and click "Update Options" to determine if Akismet key is active.', 'si-captcha');
    ?>
</label>
   <?php 
    if (isset($_POST['si_captcha_akismet_check'])) {
        echo '<br/>';
        $key_status = 'failed';
        $key = get_option('wordpress_api_key');
        if (empty($key)) {
            $key_status = 'empty';
        } else {
            if (is_callable(array('Akismet', 'verify_key'))) {
                $key_status = Akismet::verify_key($key);
            } else {
                $key_status = akismet_verify_key($key);
            }
            // akismet 2.xx
        }
        if ($key_status == 'valid') {
            echo '<span style="background-color:#99CC99; padding:4px;">' . __('Akismet is installed and the key is valid. Comment posts will be checked with Akismet to help prevent spam.', 'si-captcha') . '</strong></span>';
        } else {
            if ($key_status == 'invalid') {
                echo '<span style="background-color:#FFE991; padding:4px;">' . __('Akismet plugin is installed but key needs to be activated.', 'si-captcha') . '</span>';
            } else {
                if (!empty($key) && $key_status == 'failed') {
                    echo '<span style="background-color:#FFE991; padding:4px;">' . __('Akismet plugin is installed but key failed to verify.', 'si-captcha') . '</span>';
                }
            }
开发者ID:kc596,项目名称:cse.nits.ac.in,代码行数:31,代码来源:si-captcha-admin.php

示例8: render_main_page_area


//.........这里部分代码省略.........
                foreach ($domain->find_associated_domains() as $r) {
                    $msg .= "<li>" . $r['domain'] . " (" . $r['domain_id'] . "): " . $r['match_count'] . " matches</li>";
                }
                $msg .= "</ul>";
            }
            break;
        case '/blacklist_domain':
            $domain = @$_REQUEST['domain'];
            if (!$is_admin) {
                $msg = "Sorry, only administrators can blacklist domains.";
            } elseif (!trim($domain)) {
                $msg = "Invalid domain";
            } else {
                $dom = new SpamDomain($domain);
                $dom->set_blacklisted(DOMAIN_BLACKLISTED_MANUALLY);
                foreach ($dom->find_associated_domains() as $assoc_domain) {
                    SpamDomain::recalculate_link_counts_for_domain_id($assoc_domain['domain_id']);
                }
            }
            // FALL THROUGH TO /common_domains
        // FALL THROUGH TO /common_domains
        case '/common_domains':
            if (!$is_admin) {
                $msg = "Sorry, only administrators can do this.";
            } else {
                list($total_domains, $total_blacklisted_domains) = SpamDomain::count_domains();
                $msg .= "<p>Most common domains (out of total {$total_domains}, {$total_blacklisted_domains} blacklisted) in comments:</p><ul>";
                foreach (SpamDomain::get_most_common_domains() as $dom) {
                    $msg .= "<li>" . $dom['active_count'] . " times: " . $dom['domain'] . ' ' . ($dom['blacklisted'] ? 'BLACKLISTED' : '') . ' (<a href="' . $page_url . '/blacklist_domain?domain=' . $dom['domain'] . '">blacklist domain</a> | <a href="' . $page_url . '/analyze_domain?domain=' . $dom['domain'] . '">analyze domain</a>)</li>';
                }
                $msg .= "</ul>";
            }
            break;
        case '/akismet_verify_key':
            global $akismet_key;
            if (!$is_admin) {
                $msg = "Sorry, only administrators can access Akismet at the moment.";
            } elseif (!$akismet_key) {
                $msg .= '<p>No Akismet key has been configured - Akismet is not active.</p>';
            } else {
                // global var $_base_url has been removed - please, use PA::$url static variable
                $msg .= "<p>verifying akismet key: {$akismet_key}</p>";
                $ak = new Akismet($akismet_key);
                $msg .= "<p>result: " . var_export($ak->verify_key(PA::$url . PA_ROUTE_USER_PUBLIC . '/' . $user->user_id), TRUE) . "</p>";
            }
            break;
        case '/akismet_check_spam':
            if (!$is_admin) {
                $msg = "Sorry, only administrators can access Akismet at the moment.";
            } else {
                global $akismet_key;
                $msg .= "<p>checking comment for spam</p>";
                $cmt = new Comment();
                try {
                    $cmt->load((int) $_REQUEST['comment']);
                } catch (PAException $e) {
                    if ($e->getCode() != COMMENT_NOT_EXIST) {
                        throw $e;
                    }
                    $msg .= "<p>Comment already deleted.</p>";
                    break;
                }
                $cmt->akismet_check();
                $msg .= "<p>result: " . var_export($cmt->akismet_spam, TRUE) . "</p>";
            }
            break;
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:67,代码来源:comment_management.php

示例9: akismet

 /**
  * Check if akismet is available
  *
  * ## OPTIONS
  *
  * ## EXAMPLES
  *
  *     wp ametu akismet
  *
  * @synopsis
  */
 public function akismet()
 {
     try {
         if (!class_exists('Akismet')) {
             throw new \Exception('Akismet is not installed.');
         }
         if (!($key = \Akismet::get_api_key())) {
             throw new \Exception('Akismet API key is not set.');
         }
         if ('valid' !== \Akismet::verify_key($key)) {
             throw new \Exception('Akismet API key is invalid.');
         }
         static::s('Akismet is available!');
     } catch (\Exception $e) {
         static::e($e->getMessage());
     }
 }
开发者ID:hametuha,项目名称:wpametu,代码行数:28,代码来源:WPametuCommand.php

示例10: akismet_is_active_and_registered

 /**
  * Is Akismet registered and active?
  *
  * @since 4.3.0
  *
  * @return bool|WP_Error True if Akismet is active and registered. Otherwise, a WP_Error instance with the corresponding error.
  */
 private function akismet_is_active_and_registered()
 {
     if (!file_exists(WP_PLUGIN_DIR . '/akismet/class.akismet.php')) {
         return new WP_Error('not_installed', esc_html__('Please install Akismet.', 'jetpack'), array('status' => 400));
     }
     if (!class_exists('Akismet')) {
         return new WP_Error('not_active', esc_html__('Please activate Akismet.', 'jetpack'), array('status' => 400));
     }
     // What about if Akismet is put in a sub-directory or maybe in mu-plugins?
     require_once WP_PLUGIN_DIR . '/akismet/class.akismet.php';
     require_once WP_PLUGIN_DIR . '/akismet/class.akismet-admin.php';
     $akismet_key = Akismet::verify_key(Akismet::get_api_key());
     if (!$akismet_key || 'invalid' === $akismet_key || 'failed' === $akismet_key) {
         return new WP_Error('invalid_key', esc_html__('Invalid Akismet key. Please contact support.', 'jetpack'), array('status' => 400));
     }
     return true;
 }
开发者ID:netmagik,项目名称:netmagik,代码行数:24,代码来源:class.jetpack-core-api-module-endpoints.php


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