本文整理汇总了PHP中PhpCaptcha::Validate方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpCaptcha::Validate方法的具体用法?PHP PhpCaptcha::Validate怎么用?PHP PhpCaptcha::Validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpCaptcha
的用法示例。
在下文中一共展示了PhpCaptcha::Validate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _processCaptcha
/**
* @return void
*/
private function _processCaptcha()
{
@session_start();
$captchaHandler = CampRequest::GetVar('f_captcha_handler', '', 'POST');
if (!empty($captchaHandler)) {
$captcha = Captcha::factory($captchaHandler);
if (!$captcha->validate()) {
$this->m_error = new PEAR_Error('The code you entered is not the same as the one shown.',
ACTION_SUBMIT_COMMENT_ERR_INVALID_CAPTCHA_CODE);
return FALSE;
}
} else {
$f_captcha_code = CampRequest::GetVar('f_captcha_code');
if (is_null($f_captcha_code) || empty($f_captcha_code)) {
$this->m_error = new PEAR_Error('Please enter the code shown in the image.',
ACTION_SUBMIT_COMMENT_ERR_NO_CAPTCHA_CODE);
return FALSE;
}
if (!PhpCaptcha::Validate($f_captcha_code, true)) {
$this->m_error = new PEAR_Error('The code you entered is not the same with the one shown in the image.',
ACTION_SUBMIT_COMMENT_ERR_INVALID_CAPTCHA_CODE);
return FALSE;
}
}
return TRUE;
}
示例2: isFlooding
public function isFlooding()
{
$uid = GWF_Session::getUserID();
$uname = GWF_Shoutbox::generateUsername();
$euname = GDO::escape($uname);
$table = GDO::table('GWF_Shoutbox');
$max = $uid === 0 ? $this->module->cfgMaxPerDayGuest() : $this->module->cfgMaxPerDayUser();
// $cut = GWF_Time::getDate(GWF_Time::LEN_SECOND, time()-$this->module->cfgTimeout());
// $cnt = $table->countRows("shout_uname='$euname' AND shout_date>'$cut'");
# Check captcha
if ($this->module->cfgCaptcha()) {
require_once GWF_CORE_PATH . 'inc/3p/Class_Captcha.php';
if (!PhpCaptcha::Validate(Common::getPostString('captcha'), true)) {
return GWF_HTML::err('ERR_WRONG_CAPTCHA');
}
}
# Check date
$timeout = $this->module->cfgTimeout();
$last_date = $table->selectVar('MAX(shout_date)', "shout_uid={$uid} AND shout_uname='{$euname}'");
$last_time = $last_date === NULL ? 0 : GWF_Time::getTimestamp($last_date);
$next_time = $last_time + $timeout;
if ($last_time + $timeout > time()) {
return $this->module->error('err_flood_time', array(GWF_Time::humanDuration($next_time - time())));
}
# Check amount
$today = GWF_Time::getDate(GWF_Date::LEN_SECOND, time() - $timeout);
$count = $table->countRows("shout_uid={$uid} AND shout_date>='{$today}'");
if ($count >= $max) {
return $this->module->error('err_flood_limit', array($max));
}
# All fine
return false;
}
示例3: doClean
protected function doClean($value)
{
$clean = (string) $value;
if (!PhpCaptcha::Validate($clean)) {
throw new sfValidatorError($this, 'invalid', array('value' => $value));
}
return $clean;
}
示例4: __construct
/**
* Reads the input parameters and sets up the blogcomment action.
*
* @param array $p_input
*/
public function __construct(array $p_input)
{
$this->m_name = 'submit_blogcomment';
$this->m_defined = true;
$this->m_properties['blogentry_id'] = $p_input['f_blogentry_id'];
$BlogEntry = new BlogEntry($this->m_properties['blogentry_id']);
if (!$BlogEntry->exists()) {
$this->m_error = new PEAR_Error('None or invalid blogentry was given.', ACTION_BLOGCOMMENT_ERR_INVALID_ENTRY);
return;
}
/*
if (!isset($p_input['f_blogcomment_title']) || empty($p_input['f_blogcomment_title'])) {
$this->m_error = new PEAR_Error('The comment subject was not filled in.', ACTION_BLOGCOMMENT_ERR_NO_TITLE);
return;
}
*/
if (!isset($p_input['f_blogcomment_content']) || empty($p_input['f_blogcomment_content'])) {
$this->m_error = new PEAR_Error('The comment content was not filled in.', ACTION_BLOGCOMMENT_ERR_NO_CONTENT);
return;
}
if (SystemPref::Get('PLUGIN_BLOGCOMMENT_USE_CAPTCHA') == 'Y') {
@session_start();
$f_captcha_code = $p_input['f_captcha_code'];
if (is_null($f_captcha_code) || empty($f_captcha_code)) {
$this->m_error = new PEAR_Error('Please enter the code shown in the image.', ACTION_BLOGCOMMENT_ERR_NO_CAPTCHA_CODE);
return false;
}
if (!PhpCaptcha::Validate($f_captcha_code, true)) {
$this->m_error = new PEAR_Error('The code you entered is not the same with the one shown in the image.', ACTION_BLOGCOMMENT_ERR_INVALID_CAPTCHA_CODE);
return false;
}
}
$this->m_properties['title'] = $p_input['f_blogcomment_title'];
$this->m_properties['content'] = $p_input['f_blogcomment_content'];
$this->m_properties['mood_id'] = $p_input['f_blogcomment_mood_id'];
$this->m_properties['user_name'] = $p_input['f_blogcomment_user_name'];
$this->m_properties['user_email'] = $p_input['f_blogcomment_user_email'];
$this->m_blogcomment = new BlogComment($p_input['f_blogcomment_id']);
}
示例5: validate
public static function validate($checkType, $value)
{
$blnReturn = FALSE;
if (array_key_exists($checkType, self::$checks)) {
if (empty(self::$checks[$checkType])) {
$blnReturn = TRUE;
} else {
switch ($checkType) {
case VFORM_CAPTCHA:
$blnReturn = PhpCaptcha::Validate(ValidForm::get($value));
break;
default:
$blnReturn = preg_match(self::$checks[$checkType], $value);
}
}
} else {
$blnReturn = preg_match($checkType, $value);
}
return $blnReturn;
}
示例6: checkCommentWithCaptcha
/**
* Check posted comment with CAPTCHA
*/
function checkCommentWithCaptcha()
{
global $config, $pathToIndex, $userName, $sessionState, $app;
require $pathToIndex . '/plugins/captcha/php-captcha.inc.php';
switch ($config['language']) {
case 'japanese':
$textParts = array('コメント認証', 'コメント内容が認証出来ません。');
break;
default:
$textParts = array('Not Allowed', 'Request Not Allowed.');
break;
}
if (PhpCaptcha::Validate($_POST['captcha_phrase'])) {
return true;
} else {
$additionalTitle = $textParts[0];
$content = '<h2>' . $textParts[0] . '</h2>' . "\n" . '<div class="important warning">' . "\n" . '<p>' . $textParts[1] . '</p>' . "\n" . '</div>' . "\n";
$item = array('title' => $app->setTitle($additionalTitle), 'contents' => $content, 'result' => '', 'pager' => '');
$app->display($item, $sessionState);
exit;
}
}
示例7: fn_image_verification
function fn_image_verification($condition, $req)
{
if (fn_needs_image_verification($condition) == false) {
return true;
}
$verification_id = !empty($req['verification_id']) ? $req['verification_id'] : '';
$verification_answer = !empty($req['verification_answer']) ? $req['verification_answer'] : '';
if (PhpCaptcha::Validate($verification_id, $verification_answer) == false) {
fn_set_notification('E', __('error'), __('error_confirmation_code_invalid'));
return false;
}
// Do no use verification after first correct validation
if (Registry::get('settings.Image_verification.hide_after_validation') == 'Y') {
$_SESSION['image_verification_ok'] = true;
}
return true;
}
示例8: pageheader
$recipient_email_warning = '<div class="cpg_message_error">' . $lang_ecard_php['invalid_email'] . ' (' . $recipient_email . ')</div>';
}
$gallery_url_prefix = $CONFIG['ecards_more_pic_target'] . (substr($CONFIG['ecards_more_pic_target'], -1) == '/' ? '' : '/');
pageheader($lang_ecard_php['title']);
if ($superCage->post->keyExists('submit')) {
//Check if the form token is valid
if (!checkFormToken()) {
cpg_die(ERROR, $lang_errors['invalid_form_token'], __FILE__, __LINE__);
}
// Create and send the e-card
if ($superCage->post->keyExists('sender_name') && $valid_sender_email && $valid_recipient_email) {
if ($CONFIG['ecard_captcha'] == 1 || $CONFIG['ecard_captcha'] == 2 && !USER_ID) {
if (!captcha_plugin_enabled('ecard')) {
require "include/captcha.inc.php";
$matches = $superCage->post->getMatched('confirmCode', '/^[a-zA-Z0-9]+$/');
if (!$matches[0] || !PhpCaptcha::Validate($matches[0])) {
if ($CONFIG['log_mode'] != 0) {
log_write('Captcha authentication for ecard failed for user ' . $USER_DATA['user_name'] . ' at ' . $hdr_ip, CPG_SECURITY_LOG);
}
cpg_die(ERROR, $lang_errors['captcha_error'], __FILE__, __LINE__);
}
} else {
CPGPluginAPI::action('captcha_ecard_validate', null);
}
}
require 'include/mailer.inc.php';
if ($CONFIG['make_intermediate'] && max($row['pwidth'], $row['pheight']) > $CONFIG['picture_width']) {
$n_picname = get_pic_url($row, 'normal');
} else {
$n_picname = get_pic_url($row, 'fullsize');
}
示例9: reply
function reply()
{
include BASE_DIR . 'include' . DS . 'smilies.inc.php';
include BASE_DIR . 'include' . DS . 'mailer.inc.php';
$vars = array();
$errors = array();
$authorizer = check_model::getInstance();
$vars['topic_id'] = $this->validate->get->getInt('id');
if (!$authorizer->is_topic_id($vars['topic_id'])) {
cpg_die(ERROR, Lang::item('error.wrong_topic_id'), __FILE__, __LINE__);
}
if (!$authorizer->can_reply($vars['topic_id'])) {
cpg_die(ERROR, Lang::item('error.perm_denied'), __FILE__, __LINE__);
}
$vars['nagavitor'] = $this->forum->get_nagavitor();
$vars['icons'] = $this->forum->get_icons();
$topic = $this->forum->get_topic_data($vars['topic_id'], 'board_id');
$messages = $this->forum->get_message($vars['topic_id'], 'subject', 'msg_id asc', '1');
$data = array('icon' => 'icon1', 'subject' => Lang::item('topic.re') . $messages[0]['subject']);
if ($this->validate->post->keyExists('submit')) {
$data = array('topic_id' => $vars['topic_id'], 'icon' => $this->validate->post->getRaw('icon'), 'subject' => $this->validate->post->getEscaped('subject'), 'body' => $this->validate->post->getRaw('body'), 'board_id' => $topic['board_id'], 'poster_time' => time(), 'poster_id' => USER_ID, 'poster_name' => USER_NAME, 'poster_ip' => Config::item('hdr_ip'), 'smileys_enabled' => 1);
if (Config::item('fr_msg_icons') == 0 && $data['icon'] == '') {
$data['icon'] = 'icon1';
}
if ($data['subject'] == '') {
$errors[] = Lang::item('error.empty_subject');
}
if ($data['icon'] == '') {
$errors[] = Lang::item('error.no_msg_icon');
}
if ($data['body'] == '') {
$errors[] = Lang::item('error.empty_body');
}
if (strlen($data['body']) > Config::item('fr_msg_max_size') && Config::item('fr_msg_max_size')) {
$data['body'] = substr($data['body'], 0, Config::item('fr_msg_max_size'));
}
global $CONFIG;
if ($CONFIG['comment_captcha'] == 1 || $CONFIG['comment_captcha'] == 2 && !USER_ID) {
if (!captcha_plugin_enabled('comment')) {
global $lang_errors;
$superCage = Inspekt::makeSuperCage();
require "include/captcha.inc.php";
$matches = $superCage->post->getMatched('confirmCode', '/^[a-zA-Z0-9]+$/');
if (!$matches[0] || !PhpCaptcha::Validate($matches[0])) {
$errors[] = $lang_errors['captcha_error'];
}
} else {
CPGPluginAPI::action('captcha_comment_validate', null);
}
}
if (count($errors) == 0) {
if ($authorizer->double_post()) {
cpg_die(ERROR, Lang::item('error.already_post'), __FILE__, __LINE__);
} else {
$msg_id = $this->forum->insert_message($data);
// to-do: send notify email
$users = $this->forum->get_notify_user('', $vars['topic_id']);
foreach ($users as $user) {
if ($user['user_id'] == USER_ID) {
continue;
}
$user = $this->forum->get_user_data($user['user_id'], 'user_email');
// prepare email
$email_subject = Lang::item('topic.topic_reply') . $data['subject'];
$email_body = sprintf(Lang::item('topic.notify_email'), Config::item('fr_prefix_url') . 'profile.php?uid=' . USER_ID, USER_NAME, Config::item('fr_prefix_url') . forum::link('message', '', $msg_id), Config::item('fr_prefix_url') . forum::link('message', '', $msg_id), Config::item('fr_prefix_url') . forum::link('topic', 'notify', $vars['topic_id']), Config::item('fr_prefix_url') . forum::link('topic', 'notify', $vars['topic_id']), Config::item('fr_title'));
// send mail
cpg_mail($user['user_email'], $email_subject, $email_body, 'text/html', Config::item('fr_title'), Config::item('gallery_admin_email'));
// set send = 0
$this->forum->set_topic_notify($vars['topic_id'], 0, $user['user_id']);
}
if ($this->validate->post->getInt('notify') === 1) {
$this->forum->set_topic_notify($vars['topic_id'], $this->validate->post->getInt('notify'));
}
if ($this->validate->post->getInt('notify') === 0) {
$this->forum->unnotify_topic($vars['topic_id']);
}
forum::message(Lang::item('common.message'), sprintf(Lang::item('message.new_msg_success'), $data['subject']), 'forum.php?c=message&id=' . $msg_id);
}
}
}
$vars['errors'] = $errors;
$vars['form'] = $data;
$this->view->render('topic/reply', $vars);
}
示例10: PhpCaptcha
function validate_captcha($value)
{
require_once 'AMP/Form/Element/Captcha.inc.php';
$captcha = new PhpCaptcha(array());
return $captcha->Validate($value);
}
示例11: failsCaptcha
/**
* Tests what user typed against the captcha
*
* @param string $code Captcha code typed by user
* @return bool
*/
function failsCaptcha($code)
{
$rval = true;
return false;
if (C_IMAGE_VERIFICATION == 'true' && !empty($code)) {
//Some templates may not have the iamge verification enabled
if (!PhpCaptcha::Validate($code)) {
$rval = false;
}
}
return $rval;
}
示例12: verify
public function verify()
{
$response = PhpCaptcha::Validate($this->trellis->input['antispam']);
if (!$response) {
$this->error = 'antispam_phpcaptcha_fail';
}
return $response;
}
示例13: validateCaptcha
function validateCaptcha()
{
if ($this->hasCaptcha()) {
include_once GORUM_DIR . '/captcha/php-captcha.inc.php';
if (!PhpCaptcha::Validate($_POST['captchaField'])) {
return Roll::setFormInvalid("invalidCaptcha");
}
}
return TRUE;
}
示例14: sed_import
/* ====================
Seditio - Website engine
Copyright Neocrome
http://www.neocrome.net
[BEGIN_SED]
File=plugins/captcha/captcha.validate.php
Version=100
Updated=2006-apr-21
Type=Plugin
Author=riptide
Description=Plugin to protect the registration process with a CAPTCHA.
[END_SED]
[BEGIN_SED_EXTPLUGIN]
Code=captcha
Part=validation
File=captcha.validate
Hooks=users.register.add.first
Tags=
Order=10
[END_SED_EXTPLUGIN]
==================== */
$rverify = sed_import('rverify', 'P', 'TXT');
require "inc/php-captcha.inc.php";
require 'lang/captcha.' . $usr['lang'] . '.lang.php';
if (!PhpCaptcha::Validate($rverify)) {
$error_string .= $L['plu_verification_failed'] . "<br />";
}
示例15: checkCaptcha
function checkCaptcha($code)
{
$msg = '';
if (!PhpCaptcha::Validate($_POST['code'])) {
$msg = $_SESSION['text']['common']["Invalid code entered"];
$this->flagErr = true;
}
return $msg;
}