本文整理汇总了PHP中Akismet::isKeyValid方法的典型用法代码示例。如果您正苦于以下问题:PHP Akismet::isKeyValid方法的具体用法?PHP Akismet::isKeyValid怎么用?PHP Akismet::isKeyValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Akismet
的用法示例。
在下文中一共展示了Akismet::isKeyValid方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate_api_key
public function validate_api_key($key, $control, $form)
{
$endpoint = $form->provider->value == 'Akismet' ? self::SERVER_AKISMET : self::SERVER_TYPEPAD;
$a = new Akismet(Site::get_url('habari'), $key);
$a->setAkismetServer($endpoint);
if (!$a->isKeyValid()) {
return array(sprintf(_t('Sorry, the %s API key %s is <b>invalid</b>. Please check to make sure the key is entered correctly.'), $form->provider->value, $key));
}
return array();
}
示例2: doModel
function doModel()
{
switch ($this->action) {
case 'spamNbots':
// calling the spam and bots view
$akismet_key = osc_akismet_key();
$akismet_status = 3;
if ($akismet_key != '') {
require_once osc_lib_path() . 'Akismet.class.php';
$akismet_obj = new Akismet(osc_base_url(), $akismet_key);
$akismet_status = 2;
if ($akismet_obj->isKeyValid()) {
$akismet_status = 1;
}
}
View::newInstance()->_exportVariableToView('akismet_status', $akismet_status);
$this->doView('settings/spamNbots.php');
break;
case 'akismet_post':
// updating spam and bots option
osc_csrf_check();
$updated = 0;
$akismetKey = Params::getParam('akismetKey');
$akismetKey = trim($akismetKey);
$updated = osc_set_preference('akismetKey', $akismetKey);
if ($akismetKey == '') {
osc_add_flash_info_message(_m('Your Akismet key has been cleared'), 'admin');
} else {
osc_add_flash_ok_message(_m('Your Akismet key has been updated'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=spamNbots');
break;
case 'recaptcha_post':
// updating spam and bots option
osc_csrf_check();
$iUpdated = 0;
$recaptchaPrivKey = Params::getParam('recaptchaPrivKey');
$recaptchaPrivKey = trim($recaptchaPrivKey);
$recaptchaPubKey = Params::getParam('recaptchaPubKey');
$recaptchaPubKey = trim($recaptchaPubKey);
$iUpdated += osc_set_preference('recaptchaPrivKey', $recaptchaPrivKey);
$iUpdated += osc_set_preference('recaptchaPubKey', $recaptchaPubKey);
if ($recaptchaPubKey == '') {
osc_add_flash_info_message(_m('Your reCAPTCHA key has been cleared'), 'admin');
} else {
osc_add_flash_ok_message(_m('Your reCAPTCHA key has been updated'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=spamNbots');
break;
}
}
示例3: checkSpam
function checkSpam($api, $blogUrl, $name, $email, $url, $comment, &$msgA)
{
require_once JPATH_COMPONENT . DS . 'assets' . DS . 'akismet' . DS . 'Akismet.class.php';
$akismet = new Akismet($blogUrl, $api);
$akismet->setCommentAuthor($name);
$akismet->setCommentAuthorEmail($email);
$akismet->setCommentAuthorURL($url);
$akismet->setCommentContent($comment);
if ($akismet->isKeyValid()) {
} else {
$msgA = 'Akismet: Key is invalid';
}
//trigger_error("Akismet: ".$akismet->isCommentSpam(),E_USER_WARNING);
return $akismet->isCommentSpam();
}
示例4: doModel
//.........这里部分代码省略.........
$msg .= _m("Here's the content you have to add to the <b>.htaccess</b> file. If you can't create the file, please deactivate the <em>Friendly URLs</em> option.");
$msg .= "</p><pre>" . htmlentities($htaccess, ENT_COMPAT, "UTF-8") . '</pre><p>';
if ($errors > 0) {
$msg .= $msg_error;
}
osc_add_flash_error_message($msg, 'admin');
break;
case 4:
$msg = _m("File <b>.htaccess</b> couldn't be filled out with the right content.");
$msg .= " ";
$msg .= _m("Here's the content you have to add to the <b>.htaccess</b> file. If you can't create the file or experience some problems with the URLs, please deactivate the <em>Friendly URLs</em> option.");
$msg .= "</p><pre>" . htmlentities($htaccess, ENT_COMPAT, "UTF-8") . '</pre><p>';
if ($errors > 0) {
$msg .= $msg_error;
}
osc_add_flash_error_message($msg, 'admin');
break;
}
} else {
Preference::newInstance()->update(array('s_value' => '0'), array('s_name' => 'rewriteEnabled'));
Preference::newInstance()->update(array('s_value' => '0'), array('s_name' => 'mod_rewrite_loaded'));
osc_add_flash_ok_message(_m('Friendly URLs successfully deactivated'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=permalinks');
break;
case 'spamNbots':
// calling the spam and bots view
$akismet_key = osc_akismet_key();
$akismet_status = 3;
if ($akismet_key != '') {
require_once osc_lib_path() . 'Akismet.class.php';
$akismet_obj = new Akismet(osc_base_url(), $akismet_key);
$akismet_status = 2;
if ($akismet_obj->isKeyValid()) {
$akismet_status = 1;
}
}
View::newInstance()->_exportVariableToView('akismet_status', $akismet_status);
$this->doView('settings/spamNbots.php');
break;
case 'akismet_post':
// updating spam and bots option
$updated = 0;
$akismetKey = Params::getParam('akismetKey');
$akismetKey = trim($akismetKey);
$updated = Preference::newInstance()->update(array('s_value' => $akismetKey), array('s_name' => 'akismetKey'));
if ($akismetKey == '') {
osc_add_flash_info_message(_m('Your Akismet key has been cleared'), 'admin');
} else {
osc_add_flash_ok_message(_m('Your Akismet key has been updated'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=spamNbots');
break;
case 'recaptcha_post':
// updating spam and bots option
$iUpdated = 0;
$recaptchaPrivKey = Params::getParam('recaptchaPrivKey');
$recaptchaPrivKey = trim($recaptchaPrivKey);
$recaptchaPubKey = Params::getParam('recaptchaPubKey');
$recaptchaPubKey = trim($recaptchaPubKey);
$iUpdated += Preference::newInstance()->update(array('s_value' => $recaptchaPrivKey), array('s_name' => 'recaptchaPrivKey'));
$iUpdated += Preference::newInstance()->update(array('s_value' => $recaptchaPubKey), array('s_name' => 'recaptchaPubKey'));
if ($recaptchaPubKey == '') {
osc_add_flash_info_message(_m('Your reCAPTCHA key has been cleared'), 'admin');
} else {
osc_add_flash_ok_message(_m('Your reCAPTCHA key has been updated'), 'admin');
示例5: akismet_showpage
function akismet_showpage()
{
global $main_smarty, $the_template, $current_user, $db;
force_authentication();
$canIhaveAccess = 0;
$canIhaveAccess = $canIhaveAccess + checklevel('admin');
if ($canIhaveAccess == 1) {
$navwhere['text1'] = 'Akismet';
$navwhere['link1'] = URL_akismet;
define('pagename', 'akismet');
$main_smarty->assign('pagename', pagename);
define('modulename', 'akismet');
$main_smarty->assign('modulename', modulename);
if (isset($_REQUEST['view'])) {
$view = sanitize($_REQUEST['view'], 3);
} else {
$view = '';
}
if ($view == '') {
$wordpress_key = get_misc_data('wordpress_key');
if ($wordpress_key == '') {
header('Location: ' . URL_akismet . '&view=manageKey');
die;
}
$main_smarty->assign('spam_links_count', akismet_get_link_count());
$main_smarty->assign('spam_comments_count', akismet_get_comment_count());
$main_smarty = do_sidebar($main_smarty, $navwhere);
$main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'));
$main_smarty->assign('tpl_center', akismet_tpl_path . 'main');
$main_smarty->display($template_dir . '/admin/admin.tpl');
}
if ($view == 'updateKey') {
if ($_REQUEST['key']) {
$wordpress_key = sanitize($_REQUEST['key'], 3);
// Verify key before save
if (phpnum() >= 5) {
include akismet_lib_path . 'Akismet.class_5.php';
$akismet = new Akismet(my_base_url . my_pligg_base, $wordpress_key);
if (!$akismet->isKeyValid()) {
$main_smarty->assign('error', 1);
} else {
misc_data_update('wordpress_key', $wordpress_key);
}
} else {
include akismet_lib_path . 'Akismet.class_4.php';
$akismet = new Akismet(my_base_url . my_pligg_base, $wordpress_key);
if (!$akismet->_isValidApiKey($wordpress_key)) {
$main_smarty->assign('error', 1);
} else {
misc_data_update('wordpress_key', $wordpress_key);
}
}
} else {
$wordpress_key = '';
misc_data_update('wordpress_key', $wordpress_key);
}
$view = 'manageKey';
}
if ($view == 'manageKey') {
$wordpress_key = get_misc_data('wordpress_key');
$main_smarty->assign('wordpress_key', $wordpress_key);
$main_smarty = do_sidebar($main_smarty, $navwhere);
$main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'));
$main_smarty->assign('tpl_center', akismet_tpl_path . 'manageKey');
$main_smarty->display($template_dir . '/admin/admin.tpl');
}
if ($view == 'manageSpam') {
$sql = "SELECT " . table_links . ".*, " . table_users . ".user_login FROM " . table_links . " \r\n\t\t\t\t\tLEFT JOIN " . table_users . " ON link_author=user_id \r\n\t\t\t\t\tLEFT JOIN " . table_prefix . "spam_links ON linkid=link_id\r\n\t\t\t\t\tWHERE !ISNULL(linkid)";
$link_data = $db->get_results($sql);
if (sizeof($link_data)) {
$main_smarty->assign('link_data', object_2_array($link_data));
} else {
header("Location: " . my_pligg_base . "/admin/admin_index.php");
// header('Location: ' . URL_akismet);
die;
}
$main_smarty = do_sidebar($main_smarty, $navwhere);
$main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'));
$main_smarty->assign('tpl_center', akismet_tpl_path . 'manageSpam');
$main_smarty->display($template_dir . '/admin/admin.tpl');
}
if ($view == 'manageSettings') {
$main_smarty = do_sidebar($main_smarty, $navwhere);
$main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'));
$main_smarty->assign('tpl_center', akismet_tpl_path . 'manageSettings');
$main_smarty->display($template_dir . '/admin/admin.tpl');
}
if ($view == 'manageSpamcomments') {
$sql = "SELECT * FROM " . table_prefix . "spam_comments ";
$link_data = $db->get_results($sql);
if (sizeof($link_data)) {
$user_cmt = new User();
$user_cmt_link = new Link();
$spam_output .= ' <form name="bulk_moderate" action="' . URL_akismet_isSpamcomment . '&action=bulkmod" method="post">';
$spam_output .= '<table class="table table-bordered table-striped">';
$spam_output .= "<thead>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<th>Author</th>\r\n\t\t\t\t\t\t\t\t\t\t<th>Content</th>\r\n\t\t\t\t\t\t\t\t\t\t<th style='width:65px;text-align:center;'><input type='checkbox' name='all1' onclick='mark_all_spam();' style='display:none;'><a onclick='mark_all_spam();' style='cursor:pointer;text-decoration:none;'>Spam</a></th>\r\n\t\t\t\t\t\t\t\t\t\t<th style='width:80px;text-align:center;'><input type='checkbox' name='all2' onclick='mark_all_notspam();' style='display:none;'><a onclick='mark_all_notspam();' style='cursor:pointer;text-decoration:none;'>Not Spam</a></th>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t<tbody>";
foreach ($link_data as $spam_cmts) {
$user_cmt->id = $spam_cmts->userid;
$user_cmt->read();
$user_name = $user_cmt->username;
//.........这里部分代码省略.........
示例6: postAntispam
/**
* Handles POST requests to the antispam config form
*
* @access public
* @return \Illuminate\Support\Facades\Redirect
*/
public function postAntispam()
{
// Define Akismet key validation logic
Validator::extend('akismet_key', function ($attribute, $value, $parameters) {
$akismet = new Akismet(Request::url(), $value);
return $akismet->isKeyValid();
});
// Define validation rules
$validator = Validator::make(Input::all(), array('php_key' => 'required_if:flag_php,1', 'php_days' => 'required_if:flag_php,1|integer|between:0,255', 'php_score' => 'required_if:flag_php,1|integer|between:0,255', 'php_type' => 'required_if:flag_php,1|integer|between:0,255', 'flood_threshold' => 'required_if:flag_noflood,1|integer|between:0,60', 'akismet_key' => 'required_if:flag_akismet,1|akismet_key'));
// Run the validator
if ($validator->passes()) {
$services = Antispam::services();
$flags = array();
// Convert the service flags to CSV
foreach ($services as $service) {
if (Input::has('flag_' . $service)) {
$flags[] = $service;
}
}
// Inject flag data to the configuration
$config = array_merge(Input::all(), array('services' => implode('|', $flags)));
Site::config('antispam', $config);
Session::flash('messages.success', Lang::get('admin.antispam_updated'));
return Redirect::to('admin/antispam');
} else {
Session::flash('messages.error', $validator->messages()->all('<p>:message</p>'));
return Redirect::to('admin/antispam')->withInput();
}
}
示例7: array
static function admin_comment_settings($admin)
{
if (!Visitor::current()->group->can("change_settings")) {
show_403(__("Access Denied"), __("You do not have sufficient privileges to change settings."));
}
if (empty($_POST)) {
return $admin->display("comment_settings");
}
if (!isset($_POST['hash']) or $_POST['hash'] != Config::current()->secure_hashkey) {
show_403(__("Access Denied"), __("Invalid security key."));
}
$config = Config::current();
$set = array($config->set("allowed_comment_html", explode(", ", $_POST['allowed_comment_html'])), $config->set("default_comment_status", $_POST['default_comment_status']), $config->set("comments_per_page", $_POST['comments_per_page']), $config->set("auto_reload_comments", $_POST['auto_reload_comments']), $config->set("enable_reload_comments", isset($_POST['enable_reload_comments'])), $config->set("allow_nested_comments", isset($_POST['allow_nested_comments'])));
if (!empty($_POST['akismet_api_key'])) {
$_POST['akismet_api_key'] = trim($_POST['akismet_api_key']);
$akismet = new Akismet($config->url, $_POST['akismet_api_key']);
if (!$akismet->isKeyValid()) {
Flash::warning(__("Invalid Akismet API key."), "/admin/?action=comment_settings");
$set[] = false;
} else {
$set[] = $config->set("akismet_api_key", $_POST['akismet_api_key']);
}
}
if (!in_array(false, $set)) {
Flash::notice(__("Settings updated."), "/admin/?action=comment_settings");
}
}
示例8: run_spam_checks
function run_spam_checks($owner, $email_address, $story)
{
include_once '../includes/Akismet.config.php';
include_once '../includes/Akismet.class.php';
$akismet = new Akismet($base_url, $AkismetAPIKey);
if ($akismet->isKeyValid()) {
$akismet->setCommentAuthor($owner);
$akismet->setCommentAuthorEmail($email_address);
$akismet->setCommentContent($story);
if ($akismet->isCommentSpam()) {
$is_spam = true;
} else {
$is_spam = false;
}
} else {
$is_spam = false;
}
}
示例9: asacp_display_options
function asacp_display_options(&$options, &$error, $u_action)
{
global $config, $template, $user;
$submit = isset($_POST['submit']) ? true : false;
$new_config = $config;
$cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $new_config;
validate_config_vars($options, $cfg_array, $error);
// Validate Akismet API key
if ($submit && isset($cfg_array['asacp_akismet_enable']) && $cfg_array['asacp_akismet_enable'] && isset($cfg_array['asacp_akismet_key']) && $cfg_array['asacp_akismet_key'] && isset($cfg_array['asacp_akismet_domain']) && $cfg_array['asacp_akismet_domain']) {
if (!class_exists('Akismet')) {
global $phpbb_root_path, $phpEx;
include $phpbb_root_path . 'antispam/Akismet.class.' . $phpEx;
}
$akismet = new Akismet($cfg_array['asacp_akismet_domain'], $cfg_array['asacp_akismet_key']);
if (!$akismet->isKeyValid()) {
$error[] = $user->lang['ASACP_AKISMET_INVALID_KEY'];
}
}
foreach ($options as $config_name => $null) {
if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) {
continue;
}
$new_config[$config_name] = $config_value = $cfg_array[$config_name];
if ($submit && !sizeof($error)) {
set_config($config_name, $config_value);
}
}
if ($submit && !sizeof($error)) {
add_log('admin', 'LOG_ASACP_SETTINGS');
trigger_error($user->lang['ASACP_SETTINGS_UPDATED'] . adm_back_link($u_action));
}
foreach ($options as $config_key => $vars) {
if (!is_array($vars) && strpos($config_key, 'legend') === false) {
continue;
}
if (strpos($config_key, 'legend') !== false) {
$template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => isset($user->lang[$vars]) ? $user->lang[$vars] : $vars));
continue;
}
$type = explode(':', $vars['type']);
$l_explain = '';
if ($vars['explain'] && isset($vars['lang_explain'])) {
$l_explain = isset($user->lang[$vars['lang_explain']]) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
} else {
if ($vars['explain']) {
$l_explain = isset($user->lang[$vars['lang'] . '_EXPLAIN']) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
}
}
$content = build_cfg_template($type, $config_key, $new_config, $config_key, $vars);
if (empty($content)) {
continue;
}
$template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => isset($user->lang[$vars['lang']]) ? $user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => $vars['explain'], 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => $content));
unset($options[$config_key]);
}
}
示例10: Akismet
function test_akismet_key()
{
require_once 'lib/akismet.php';
$akismet = new Akismet($this->settings['site_address'], $this->settings['wordpress_api_key'], $this->version);
$response = $akismet->isKeyValid() ? 'Key is Valid!' : 'Key is Invalid!';
return $this->message('Test Akismet Key', $response, 'Continue', 'admin.php', 0);
}
示例11: akismet_check_server_connectivity
public function akismet_check_server_connectivity()
{
global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
// $akismet = new Akismet($this->params['HTTPHOST'], $this->params['APIKEY']);
$akismet = new Akismet($this->blogURL, $this->wordPressAPIKey);
$test_host = 'rest.akismet.com';
$ips = gethostbynamel($test_host);
if (!$ips || !is_array($ips) || !count($ips)) {
return array();
}
$servers = array();
foreach ($ips as $ip) {
if ($akismet->isKeyValid()) {
$servers[$ip] = true;
} else {
$servers[$ip] = false;
}
}
return $servers;
}
示例12: html
"/></a></td></tr>
<tr><th>Google Adsense Client-ID:</th><td><INPUT type="text" name="google_adsense_clientid" value="<?php
echo html(isset($config["google"]["adsense"]["clientid"]) ? $config["google"]["adsense"]["clientid"] : "");
?>
" placeholder="pub-123456789"/></td><td rowspan="2"><a class="datalink" href="http://www.google.de/adsense" target="_blank" TITLE="zu Google Adsense"><img src="<?php
echo get_path("skins/default/images/icons/import_html.png");
?>
"/></a></td></tr>
<tr><th>Google Adsense Slot(rechts):</th><td><INPUT type="text" name="google_adsense_slot_widget" value="<?php
echo html(isset($config["google"]["adsense"]["slot"]["widget"]) ? $config["google"]["adsense"]["slot"]["widget"] : "");
?>
" placeholder="123456789"/></td></tr>
<tr><th>Custom Search Engine ID:</th><td><INPUT type="text" name="google_cse_id" value="<?php
echo html(isset($config["google"]["cse"]["id"]) ? $config["google"]["cse"]["id"] : "");
?>
" placeholder="123456789"/></td></tr>
</table>
</fieldset>
<fieldset>
<legend>Amazon</legend>
<table class="std01">
<tr><th>PartnerNet-ID:</th><td><INPUT type="text" name="amazon_partnernet_id" value="<?php
echo html(isset($config["amazon"]["partnernet"]["id"]) ? $config["amazon"]["partnernet"]["id"] : "");
?>
" placeholder="muster-21"/></td><td><a class="datalink" href="https://partnernet.amazon.de" target="_blank" TITLE="zu Amazon PartnerNet"><img src="<?php
echo get_path("skins/default/images/icons/import_html.png");
?>
"/></a></td></tr>
</table>
</fieldset>