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


PHP Captcha::check方法代码示例

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


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

示例1: check

 /**
  * Vérifie un email
  * @return object 2 attributs, bool success et array string msg
  */
 private function check()
 {
     $std = (object) array('success' => false, 'msg' => array());
     if (!$_SESSION['user']) {
         if (($res = Membre::checkPseudo($this->pseudo)) !== true) {
             $std->msg[] = $res;
         }
         if (($res = Membre::checkEmail($this->email)) !== true) {
             $std->msg[] = $res;
         }
         $captcha = new Captcha();
         if (($res = $captcha->check($this->captcha)) !== true) {
             $std->msg[] = $res;
         }
     }
     if (($res = $this->checkSujet($this->sujet)) !== true) {
         $std->msg[] = $res;
     }
     if (($res = $this->checkMessage($this->message)) !== true) {
         $std->msg[] = $res;
     }
     if (empty($std->msg)) {
         $std->success = true;
     }
     return $std;
 }
开发者ID:alexdu98,项目名称:technote,代码行数:30,代码来源:Contact.php

示例2: Database

    $errormsg = 'Sorry, registration on this instance of ThinkTank is closed. <br /><br /><a href="http://github.com/ginatrapani/thinktank/tree/master">Install ThinkTank on your own server</a> or go back to <a href="' . $THINKTANK_CFG['site_root_path'] . 'public.php">the public timeline</a>.';
} else {
    $db = new Database($THINKTANK_CFG);
    $conn = $db->getConnection();
    $od = new OwnerDAO($db);
    $s->assign('closed', false);
    $captcha = new Captcha($THINKTANK_CFG);
    if ($_POST['Submit'] == 'Register') {
        if (strlen($_POST['email']) < 5) {
            $errormsg = "Incorrect email. Please enter valid email address.";
        }
        if (strcmp($_POST['pass1'], $_POST['pass2']) || empty($_POST['pass1'])) {
            if (!isset($errormsg)) {
                $errormsg = "Password does not match or empty.";
            }
        } elseif (!$captcha->check()) {
            //Captcha not valid, captcha handles message...
        } else {
            if ($od->doesOwnerExist($_POST['email'])) {
                $errormsg = "User account already exists.";
            } else {
                $es = new SmartyThinkTank();
                $es->caching = false;
                $activ_code = rand(1000, 9999);
                $cryptpass = $session->pwdcrypt($_POST['pass2']);
                $server = $_SERVER['HTTP_HOST'];
                $od->create($_POST['email'], $cryptpass, $_POST['country'], $activ_code, $_POST['full_name']);
                $es->assign('apptitle', $THINKTANK_CFG['app_title']);
                $es->assign('server', $server);
                $es->assign('site_root_path', $THINKTANK_CFG['site_root_path']);
                $es->assign('email', urlencode($_POST[email]));
开发者ID:BenBtg,项目名称:thinktank,代码行数:31,代码来源:register.php

示例3: control

 public function control()
 {
     if ($this->isLoggedIn()) {
         $controller = new DashboardController(true);
         return $controller->go();
     } else {
         $this->disableCaching();
         $config = Config::getInstance();
         if (!$config->getValue('is_registration_open')) {
             $this->addToView('closed', true);
             $this->addErrorMessage('<p>Sorry, registration is closed on this ThinkUp installation.</p>' . '<p><a href="http://github.com/ginatrapani/thinkup/tree/master">Install ThinkUp on your own ' . 'server.</a></p>');
         } else {
             $owner_dao = DAOFactory::getDAO('OwnerDAO');
             $this->addToView('closed', false);
             $captcha = new Captcha();
             if (isset($_POST['Submit']) && $_POST['Submit'] == 'Register') {
                 foreach ($this->REQUIRED_PARAMS as $param) {
                     if (!isset($_POST[$param]) || $_POST[$param] == '') {
                         $this->addErrorMessage('Please fill out all required fields.');
                         $this->is_missing_param = true;
                     }
                 }
                 if (!$this->is_missing_param) {
                     if (!Utils::validateEmail($_POST['email'])) {
                         $this->addErrorMessage("Incorrect email. Please enter valid email address.");
                     } elseif (strcmp($_POST['pass1'], $_POST['pass2']) || empty($_POST['pass1'])) {
                         $this->addErrorMessage("Passwords do not match.");
                     } elseif (!$captcha->check()) {
                         // Captcha not valid, captcha handles message...
                     } else {
                         if ($owner_dao->doesOwnerExist($_POST['email'])) {
                             $this->addErrorMessage("User account already exists.");
                         } else {
                             $es = new SmartyThinkUp();
                             $es->caching = false;
                             $session = new Session();
                             $activ_code = rand(1000, 9999);
                             $cryptpass = $session->pwdcrypt($_POST['pass2']);
                             $server = $_SERVER['HTTP_HOST'];
                             $owner_dao->create($_POST['email'], $cryptpass, $activ_code, $_POST['full_name']);
                             $es->assign('server', $server);
                             $es->assign('email', urlencode($_POST['email']));
                             $es->assign('activ_code', $activ_code);
                             $message = $es->fetch('_email.registration.tpl');
                             Mailer::mail($_POST['email'], "Activate Your " . $config->getValue('app_title') . " Account", $message);
                             unset($_SESSION['ckey']);
                             $this->addSuccessMessage("Success! Check your email for an activation link.");
                         }
                     }
                 }
                 if (isset($_POST["full_name"])) {
                     $this->addToView('name', $_POST["full_name"]);
                 }
                 if (isset($_POST["email"])) {
                     $this->addToView('mail', $_POST["email"]);
                 }
             }
             $challenge = $captcha->generate();
             $this->addToView('captcha', $challenge);
         }
         return $this->generateView();
     }
 }
开发者ID:NickBall,项目名称:ThinkUp,代码行数:63,代码来源:class.RegisterController.php

示例4: function

<?php

Validator::extend(Config::get('latrell-captcha.validator_name'), function ($attribute, $value, $parameters) {
    return Captcha::check($value);
});
开发者ID:latrell,项目名称:captcha,代码行数:5,代码来源:validation.php

示例5: checkSendMailLostPass

 /**
  * Vérifie que l'email d'oubli de mot de passe peut etre envoyé
  * @param array $param Les attributs de la demande d'envoi d'email
  * @return object True si l'email peut etre envoyé, un message sinon
  * @static
  */
 public static function checkSendMailLostPass(&$param)
 {
     $std = (object) array('success' => false, 'msg' => array());
     $captcha = new Captcha();
     if (($res = $captcha->check($param['g-recaptcha-response'])) === true) {
         $membreDAO = new MembreDAO(BDD::getInstancePDO());
         if (empty($param['pseudoEmail'])) {
             $std->msg[] = 'Le pseudo ou l\'email n\'est pas renseigné';
             return $std;
         }
         if (($res = $membreDAO->checkMembreExiste($param['pseudoEmail'])) === false) {
             $std->msg[] = 'Le pseudo ou l\'email n\'existe pas';
         } else {
             return $res;
         }
     } else {
         $std->msg[] = $res;
     }
     return $std;
 }
开发者ID:alexdu98,项目名称:technote,代码行数:26,代码来源:Membre.php

示例6: actionRegister

 public function actionRegister()
 {
     $message_name = "register";
     if ($this->request->register) {
         /*-регистрация пользователя обработка-*/
         $user_old_1 = new UserDB();
         $user_old_1->loadOnEmail($this->request->email);
         //проверка уникальности emaul
         $user_old_2 = new UserDB();
         $user_old_2->loadOnLogin($this->request->login);
         //проверка уникальности login
         $captcha = $this->request->captcha;
         //вывд картинки с кодом
         $checks = array(array(Captcha::check($captcha), true, "ERROR_CAPTCHA_CONTENT"));
         //каптча не верная
         $checks[] = array($this->request->password, $this->request->password_conf, "ERROR_PASSWORD_CONF");
         //пароль не совпадает
         $checks[] = array($user_old_1->isSaved(), false, "ERROR_EMAIL_ALREADY_EXISTS");
         //ошибка email уже зарегистрирован
         $checks[] = array($user_old_2->isSaved(), false, "ERROR_LOGIN_ALREADY_EXISTS");
         //ошибка login уже зарегистрирован
         $user = new UserDB();
         //формируем объект пользователя
         $fields = array("name", "login", "email", array("setPassword()", $this->request->password));
         //создаем массив объекта
         $user = $this->fp->process($message_name, $user, $fields, $checks);
         if ($user instanceof UserDB) {
             //если пользователь не нуль обрабатываем
             $this->mail->send($user->email, array("user" => $user, "link" => URL::get("activate", "", array("login" => $user->login, "key" => $user->activation), false, Config::ADDRESS)), "register");
             //создаем ссылку для активации пользователя из почты
             $this->redirect(URL::get("sregister"));
         }
     }
     $this->title = "Регистрация на сайте " . Config::SITENAME;
     $this->meta_desc = "Регистрация на сайте " . Config::SITENAME . ".";
     $this->meta_key = "регистрация сайт " . mb_strtolower(Config::SITENAME) . ", зарегистрироваться сайт " . mb_strtolower(Config::SITENAME);
     $hornav = $this->getHornav();
     //горизонтальная навигация
     $hornav->addData("Регистрация");
     $form = new Form();
     //форма для регистрации
     $form->hornav = $hornav;
     $form->header = "Регистрация";
     $form->name = "register";
     $form->action = URL::current();
     //переход на эту же страницу
     $form->message = $this->fp->getSessionMessage($message_name);
     $form->text("name", "Имя и/или фамилия:", $this->request->name);
     //сами поля
     $form->text("login", "Логин:", $this->request->login);
     $form->text("email", "E-mail:", $this->request->email);
     $form->password("password", "Пароль:");
     $form->password("password_conf", "Подтвердите пароль:");
     $form->captcha("captcha", "Введите код с картинки:");
     $form->submit("Регистрация");
     $form->addJSV("name", $this->jsv->name());
     // проверка полей
     $form->addJSV("login", $this->jsv->login());
     $form->addJSV("email", $this->jsv->email());
     $form->addJSV("password", $this->jsv->password("password_conf"));
     $form->addJSV("captcha", $this->jsv->captcha());
     $this->render($form);
     //вывод формы
 }
开发者ID:andreiBall,项目名称:main-site,代码行数:64,代码来源:maincontroller_class.php

示例7: unset

                $_SESSION[$name] = $value;
            } else {
                unset($_SESSION[$name]);
            }
        } else {
            return isset($_SESSION[$name]) ? $_SESSION[$name] : '';
        }
    }
}
session_start();
$obj = new Captcha($sname);
# 創建Captcha類對象
# $sname為保存captcha的session name,可留空,留空則為'm_captcha'
$param = array('width' => 13, 'height' => 18, 'pnum' => 100, 'lnum' => 2);
$obj->create($length, $param);
# 創建Captcha并輸出圖片
# $length為Captcha長度,可留空,默認為4
/* $param = array(
        'width' => 13		captcha 字符寬度
        'height' => 18		captcha 字符高度
        'pnum' => 100		干擾點個數
        'lnum' => 2			干擾線條數
        )
        可留空
*/
$obj->check($captcha, $flag);
# 檢查用戶輸入的驗證碼是否正確,true or false
# $captcha為用戶輸入的驗證碼,必填
# $flag 可留空,默認為1
#		1:當驗證成功后自動清除captcha session
#		0:當驗證成功后不清除captcha session,用於ajax檢查
开发者ID:Birjemin,项目名称:Study,代码行数:31,代码来源:Captcha.class.php

示例8: actionRegister

 public function actionRegister()
 {
     $message_name = "register";
     if ($this->request->register) {
         $user_old_1 = new UserDB();
         $user_old_1->loadOnEmail($this->request->email);
         $user_old_2 = new UserDB();
         $user_old_2->loadOnLogin($this->request->login);
         $captcha = $this->request->captcha;
         $checks = array(array(Captcha::check($captcha), true, "ERROR_CAPTCHA_CONTENT"));
         $checks[] = array($this->request->password, $this->request->password_conf, "ERROR_PASSWORD_CONF");
         $checks[] = array($user_old_1->isSaved(), false, "ERROR_EMAIL_ALREADY_EXISTS");
         $checks[] = array($user_old_2->isSaved(), false, "ERROR_LOGIN_ALREADY_EXISTS");
         $user = new UserDB();
         $fields = array("name", "login", "email", array("setPassword()", $this->request->password));
         $user = $this->fp->process($message_name, $user, $fields, $checks);
         if ($user instanceof UserDB) {
             $this->mail->send($user->email, array("user" => $user, "link" => URL::get("activate", "", array("login" => $user->login, "key" => $user->activation), false, Config::ADDRESS)), "register");
             $this->redirect(URL::get("sregister"));
         }
     }
     $this->title = "Регистрация на сайте " . Config::SITENAME;
     $this->meta_desc = "Регистрация на сайте " . Config::SITENAME . ".";
     $this->meta_key = "регистрация сайт " . mb_strtolower(Config::SITENAME) . ", зарегистрироваться сайт " . mb_strtolower(Config::SITENAME);
     $hornav = $this->getHornav();
     $hornav->addData("Регистрация");
     $form = new Form();
     $form->hornav = $hornav;
     $form->header = "Регистрация";
     $form->name = "register";
     $form->action = URL::current();
     $form->message = $this->fp->getSessionMessage($message_name);
     $form->text("name", "Имя и/или фамилия:", $this->request->name);
     $form->text("login", "Логин:", $this->request->login);
     $form->text("email", "E-mail:", $this->request->email);
     $form->password("password", "Пароль:");
     $form->password("password_conf", "Подтвердите пароль:");
     $form->captcha("captcha", "Введите код с картинки:");
     $form->submit("Регистрация");
     $form->addJSV("name", $this->jsv->name());
     $form->addJSV("login", $this->jsv->login());
     $form->addJSV("email", $this->jsv->email());
     $form->addJSV("password", $this->jsv->password("password_conf"));
     $form->addJSV("captcha", $this->jsv->captcha());
     $this->render($form);
 }
开发者ID:itservicedv,项目名称:engine_rusakov_source,代码行数:46,代码来源:maincontroller_class.php

示例9: Reporter_DB

	<div class="container">
	<?php 
require_once "mysqli.php";
require_once "captcha.php";
$db = new Reporter_DB();
$db->start();
$trivia = new Trivia_DB();
$trivia->start();
list($equation, $hashedCaptcha) = Captcha::calculate();
$all_reasons = $db->get_all_reasons();
$all_themes_names = $trivia->get_themes_array();
if ($_POST["selReason"] && $_POST["txtQuestion"] && $_POST["txtCaptcha"] && $_POST["selTheme"]) {
    if (!$db->check_reason_exists($_POST["selReason"])) {
        echo '<div id="user_alert" class="alert alert-danger col-sm-8 col-sm-offset-2">Invalid type of mistake.</div>';
    } else {
        if (Captcha::check($_POST["txtCaptcha"], $_POST["hashedCaptcha"])) {
            if (array_key_exists($_POST["selTheme"], $all_themes_names)) {
                $theme_id = $_POST["selTheme"];
            } else {
                $theme_id = 1;
            }
            if ($db->add_report($_POST["selReason"], $_POST["txtQuestion"], $_POST["txtComment"], $theme_id)) {
                echo '<div id="user_alert" class="alert alert-success col-sm-8 col-sm-offset-2">Report successfully submitted. ' . 'Thank you for notifying us about this mistake.</div>';
            } else {
                echo '<div id="user_alert" class="alert alert-danger col-sm-8 col-sm-offset-2">Error occured when submitting report. ' . 'Please try again later.</div>';
            }
        } else {
            echo '<div id="user_alert" class="alert alert-danger col-sm-8 col-sm-offset-2">The answer to the equation is ' . '<b>incorrect</b>. Try again.</div>';
        }
    }
} else {
开发者ID:linostar,项目名称:trivia-report,代码行数:31,代码来源:index.php

示例10: validate_captcha

 private static function validate_captcha(sForms $Field, &$errors)
 {
     if (!Captcha::check($Field->getValue())) {
         $errors['captcha'] = true;
     }
 }
开发者ID:baochung26,项目名称:happy-c,代码行数:6,代码来源:sforms.class.php

示例11: error_reporting

<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
require "../Captcha.php";
if (isset($_GET["check"])) {
    $isok = Captcha::check($_GET["check"]) ? TRUE : FALSE;
    header("Content-Type: application/json");
    echo json_encode(["isok" => $isok]);
} else {
    try {
        Captcha::make();
    } catch (\Exception $ex) {
        var_dump($ex->getMessage());
    }
}
开发者ID:donvercety,项目名称:php.class.Captcha,代码行数:17,代码来源:main.php


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