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


PHP Captcha::valid方法代码示例

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


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

示例1: action_login

 public function action_login()
 {
     if (HTTP_Request::POST == $this->request->method() && Security::check(Arr::get($this->request->post(), 'csrf', '')) && Captcha::valid($_POST['captcha'])) {
         $remember = array_key_exists('remember', $this->request->post()) ? (bool) $this->request->post('remember') : FALSE;
         $user = Auth::instance()->login($this->request->post('username'), $this->request->post('password'), $remember);
         if ($user) {
             HTTP::redirect($this->config->get('admin_url'));
         } else {
             Session::instance()->set('error', 'Логин или пароль не верный');
             $errors = array('Логин или пароль не верный.');
         }
     }
     $this->template = 'login';
     parent::before();
     $captcha = Captcha::instance();
     $csrf = Security::token(true);
     $this->template->title = 'Вход в админ панель';
     $this->template->bind('errors', $errors)->bind('csrf', $csrf)->bind('captcha', $captcha);
     $errors = null;
     if (Auth::instance()->get_user()) {
         $auth = Auth::instance();
         $has_admin_role = $auth->logged_in('admin');
         if ($has_admin_role) {
             $session = Session::instance();
             $session->set('redirectAfterLogin', $_SERVER['REQUEST_URI']);
             HTTP::redirect('/' . $this->admin_url . '/');
         }
     }
 }
开发者ID:upers,项目名称:kwartira.com,代码行数:29,代码来源:Main.php

示例2: action_register

 public function action_register()
 {
     //check user logged in or not
     if (Auth::instance()->logged_in()) {
         Request::instance()->redirect('/');
         //go to home page
     }
     $captcha = Captcha::instance('login');
     if (Request::$method == "POST") {
         if (Captcha::valid($_POST['captcha'])) {
             $user = new User();
             $post = $user->validate_register($_POST);
             if ($post->check()) {
                 $post = $post->as_array();
                 $user->email = $post['email'];
                 $user->username = $post['username'];
                 $user->active = false;
                 $user->sex = $post['sex'];
                 $user->active_code = md5(time());
                 $user->save();
                 Session::set('reg_email', $user->email);
                 Request::instance()->redirect('/site/register_done');
             } else {
                 $_POST = $post->as_array();
                 $data['errors'] = $post->errors();
             }
         } else {
             $data['errors'] = array('captcha' => 'Mã bảo mật không đúng!');
         }
     }
     $this->template->title = __('Đăng ký tài khoản');
     $data['captcha'] = $captcha;
     $this->template->content = View::factory('frontend/site/register', $data);
 }
开发者ID:abdul-baten,项目名称:hbcms,代码行数:34,代码来源:site.php

示例3: action_login

 public function action_login()
 {
     $captcha = Captcha::instance();
     $this->template->captcha = $captcha;
     $this->template->message = '';
     if (Auth::instance()->logged_in()) {
         $this->redirect('/');
     }
     $username = Arr::get($_POST, 'username', '');
     $password = Arr::get($_POST, 'password', '');
     $remember = (bool) Arr::get($_POST, 'remember', false);
     $error = false;
     $message = false;
     if ($this->request->method() == Request::POST) {
         $cpt = Captcha::valid($_POST['captcha']);
         if ($cpt) {
             if (Auth::instance()->login($username, $password, $remember)) {
                 $this->redirect('manage');
             } else {
                 $error = true;
                 //$this->set('error', true);
             }
         } else {
             $message = true;
             //$this->set('error', true);
         }
     }
     $this->set('username', $username)->set('remember', $remember ? 'checked' : '')->set('error', $error)->set('message', $message);
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:29,代码来源:Auth.php

示例4: action_index

 function action_index()
 {
     // Check if already logged in
     if ($this->admin->islogged() === TRUE) {
         $this->template->content = $this->admin->genpage();
     } else {
         $this->template->content = $this->admin->showlogin();
     }
     // Check if login data sended
     if (isset($_POST['login']) and isset($_POST['password']) and isset($_POST['captcha'])) {
         if (Captcha::valid($_POST['captcha'])) {
             // Check auth
             $auth = $this->admin->checklogin();
             if ($auth === TRUE) {
                 Session::instance()->set('islogged', 'on');
                 $this->request->redirect('admin');
             } else {
                 if (gettype($auth) == 'string') {
                     $this->template->err = $auth;
                 }
             }
         } else {
             $this->template->err = 'Неверно введена капча';
         }
     }
 }
开发者ID:purplexcite,项目名称:seagifts,代码行数:26,代码来源:admin.php

示例5: action_doreg

 public function action_doreg()
 {
     $mobile = Arr::get($_POST, 'mobile');
     $pwd = Arr::get($_POST, 'password');
     $checkcode = Arr::get($_POST, 'checkcode');
     $backurl = Arr::get($_POST, 'backurl');
     //验证码
     $checkcode = strtolower($checkcode);
     $flag = Model_Member::checkExist('mobile', $mobile);
     if (!$flag) {
         Common::showMsg('手机号码重复,请重新填写', '-1');
     }
     if (!Captcha::valid($checkcode)) {
         Common::showMsg('验证码错误', '-1');
     }
     $model = ORM::factory('member');
     $model->mobile = $mobile;
     $model->pwd = md5($pwd);
     $model->logintime = time();
     $model->nickname = substr_replace($mobile, '***', 3, 3);
     $model->save();
     if ($model->saved()) {
         Model_Member::login($mobile, $pwd);
         Common::showMsg('注册成功', $backurl);
     } else {
         //Common::showMsg('注册失败,请联系网站管理员','-1');
     }
 }
开发者ID:lz1988,项目名称:stourwebcms,代码行数:28,代码来源:user.php

示例6: action_register

 public function action_register()
 {
     if (!empty($_POST)) {
         $username = Arr::get($_POST, 'username');
         $password = Arr::get($_POST, 'password');
         $password2 = Arr::get($_POST, 'password2');
         $vcode = Arr::get($_POST, 'vcode');
         if ($password !== $password2) {
             exit('两次密码不匹配');
         }
         if (!Captcha::valid($vcode)) {
             exit('验证码错误');
         }
         $auth = Auth::instance('member');
         $password = $auth->hash($password);
         $user_data = array('username' => $username, 'password' => $password, 'created_at' => time());
         $m_member = Model::factory('member', 'admin');
         $user_exist = $m_member->has(array('username' => $username));
         if (!$user_exist) {
             $ret = $m_member->insert($user_data);
             if ($ret !== false) {
                 $user_data['id'] = $ret[0];
                 if ($auth->force_login($user_data)) {
                     $this->redirect(Request::$referrer);
                 }
             } else {
                 exit('注册失败');
             }
         } else {
             exit('用户名已存在');
         }
     }
     $this->content = View::factory('common/user_register');
 }
开发者ID:andygoo,项目名称:cms,代码行数:34,代码来源:User.php

示例7: rule_captcha

 protected function rule_captcha()
 {
     if ($this->value === '' or $this->value === NULL) {
         $this->errors['required'] = TRUE;
     } elseif (Captcha::valid($this->value, $this->group) == FALSE) {
         $this->errors['captcha'] = TRUE;
     }
 }
开发者ID:enormego,项目名称:EightPHP,代码行数:8,代码来源:captcha.php

示例8: validate_this

 protected function validate_this()
 {
     // use Captcha's buit-in validation
     if (!Captcha::valid(Input::instance()->post($this->name))) {
         $this->error = $this->error_msg;
         return $this->error;
     }
 }
开发者ID:carriercomm,项目名称:billing_cart,代码行数:8,代码来源:captcha.php

示例9: action_login

 function action_login()
 {
     if ($_POST) {
         if (Captcha::valid($_POST['captcha']) and $this->auth->login($_POST['username'], $_POST['password'], !empty($_POST['remember']) ? TRUE : FALSE) == TRUE) {
             $this->request->redirect('admin');
         } else {
             $this->request->redirect('admin');
         }
     }
 }
开发者ID:phpdude,项目名称:Purpled-Blog-Engine,代码行数:10,代码来源:main.php

示例10: index

 /**
  * The default action - show the home page
  */
 public function index()
 {
     if ($this->request->isPost()) {
         var_dump(Captcha::valid($this->request->getParam('vcode')));
     } else {
         //echo '<p><img src="' . $this->getBaseUrl(). 'captcha/basic"></p>';
         echo '<p><img src="' . $this->getBaseUrl() . 'captcha/alpha"></p>';
         //echo '<p><img src="' . $this->getBaseUrl(). 'captcha/black"></p>';
         echo '<form method="post"><input type="text" name="vcode"><input type="submit" value="Valid"></form>';
     }
     exit;
 }
开发者ID:atlas1308,项目名称:testtesttestfarm,代码行数:15,代码来源:captcha.php

示例11: action_signin

 public function action_signin()
 {
     //echo Auth::instance()->hash_password('hungxalo');
     #If user already signed-in
     if (Auth::instance()->logged_in() != 0) {
         #redirect to the user account
         Request::instance()->redirect('admin/site/index');
     }
     $captcha = Captcha::instance();
     $data = array();
     $data['captcha'] = $captcha;
     #If there is a post and $_POST is not empty
     if ($_POST) {
         //print_r($_POST);
         if (Captcha::valid($_POST['captcha'])) {
             #Instantiate a new user
             $array = Validate::factory($_POST)->rules('email', array('not_empty' => NULL, 'min_length' => array(4), 'max_length' => array(127), 'email' => NULL))->rules('password', array('not_empty' => null))->filter(TRUE, 'trim');
             // Get the remember login option
             $remember = isset($array['remember']);
             // Login starts out invalid
             $status = FALSE;
             if ($array->check()) {
                 $user = Auth::instance();
                 #Check Auth
                 $status = $user->login($array['email'], $array['password'], $remember);
                 #If the post data validates using the rules setup in the user model
                 if ($status) {
                     #redirect to the user account
                     Request::instance()->redirect('admin/site/index');
                 } else {
                     $array->error('email', 'username_available');
                     #Get errors for display in view
                     $data['errors'] = $array->errors('admin/login');
                 }
             } else {
                 $data['errors'] = $array->errors('admin/login');
             }
         } else {
             $data['errors'] = array('captcha' => 'Captcha invalid!');
         }
         // Captcha::invalid_count()
         //echo $captcha->invalid_count();
     }
     $this->template->title = "Đăng nhập vào hệ thống";
     $this->template->section_title = "Đăng nhập vào hệ thống";
     $this->template->content = View::factory('/admin/site/login', $data);
 }
开发者ID:abdul-baten,项目名称:hbcms,代码行数:47,代码来源:site.php

示例12: page1

 public function page1()
 {
     $view = new View('signup/page1');
     // Load Captcha library, you can supply the name of the config group you would like to use.
     $captcha = new Captcha();
     // Form info
     $form = array('username' => '', 'password' => '', 'password_confirm' => '', 'email' => '');
     //  copy the form as errors, so the errors will be stored with keys corresponding to the form field names
     $errors = $form;
     // Ban bots (that accept session cookies) after 50 invalid responses.
     // Be careful not to ban real people though! Set the threshold high enough.
     if ($captcha->invalid_count() > 49) {
         exit('Bye! Stupid bot.');
     }
     // Form submitted
     if ($_POST) {
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $valid_c = Captcha::valid($this->input->post('captcha_response'));
         $this->user = ORM::factory('user');
         $post = $this->input->post();
         if ($this->user->validate($post) && $valid_c) {
             $this->user->save();
             $this->session->set('uid', $this->user->id);
             $this->user->add(ORM::factory('role', 'login'));
             $this->auth->login($this->user, $post['password']);
             url::redirect('/signup/page2');
             exit(0);
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             $errors = arr::overwrite($errors, $post->errors('signup_errors'));
             if (!$valid_c) {
                 $errors['captcha_response'] = "Invalid";
             }
         }
     }
     // Put the vars in the template
     $view->set("errors", $errors);
     $this->template->content = $view;
     $this->template->content->captcha = $captcha;
     $this->template->content->form = $form;
 }
开发者ID:kiirti,项目名称:Ushahidi_MHI,代码行数:42,代码来源:signup.php

示例13: action_ajax_login

 public function action_ajax_login()
 {
     $checkcode = Arr::get($_POST, 'checkcode');
     $username = Arr::get($_POST, 'username');
     $password = Arr::get($_POST, 'password');
     $out = array();
     //验证码
     $checkcode = strtolower($checkcode);
     if (!Captcha::valid($checkcode)) {
         $out['status'] = 'checkcode_err';
         echo json_encode($out);
         exit;
     }
     //用户名密码验证
     $password = md5($password);
     $userinfo = ORM::factory('admin')->where("username='{$username}' and password='{$password}'")->find();
     if (!$userinfo->loaded()) {
         $out['status'] = 'password_err';
         echo json_encode($out);
         exit;
     }
     $logintime = time();
     $ip = $this->getIp();
     $userinfo->logintime = $logintime;
     $userinfo->loginip = $ip;
     $userinfo->update();
     $userinfo = $userinfo->as_array();
     //将用户信息保存到session
     $session = Session::instance();
     $serectkey = Common::authcode($userinfo['username'] . '||' . $userinfo['password'], '');
     $session->set('username', $serectkey);
     Cookie::set('username', $serectkey);
     $session->set('userid', $userinfo['id']);
     $session->set('roleid', $userinfo['roleid']);
     $rolemodule = ORM::factory('role_module')->where("roleid='{$userinfo['roleid']}'")->as_array();
     $session->set('rolemodule', $rolemodule);
     $out['status'] = 'ok';
     echo json_encode($out);
 }
开发者ID:lz1988,项目名称:stourwebcms,代码行数:39,代码来源:login.php

示例14: action_index

 public function action_index()
 {
     //смотрим шаблон для виджета
     $id = $this->request->param('id');
     $widget = new Model_Widget();
     $template = $widget->getTempalte('callback', $id);
     if ($template) {
         $this->template = View::factory('widgets/' . $template);
     }
     if (isset($_POST['callback-order'])) {
         if (Captcha::valid(Arr::get($_POST, 'comm-captcha'))) {
             $base = new Model_Base();
             $options = $base->getOptions();
             $vData = $_POST;
             $validation = Validation::factory($vData);
             $validation->rule('cb-name', 'not_empty');
             $validation->rule('cb-name', 'min_length', array(':value', '2'));
             $validation->rule('cb-name', 'max_length', array(':value', '250'));
             $validation->rule('cb-phone', 'not_empty');
             $validation->rule('cb-phone', 'phone');
             $validation->rule('cb-phone', 'min_length', array(':value', '6'));
             $validation->rule('cb-phone', 'max_length', array(':value', '15'));
             if (!$validation->check()) {
                 $this->errors = $validation->errors('callbackErrors');
             } else {
                 $name = Arr::get($_POST, 'cb-name', '');
                 $phone = Arr::get($_POST, 'cb-phone', '');
                 //отправляем письмо
                 $config = Kohana::$config->load('email');
                 Email::connect($config);
                 $to = $config['options']['callback_email'];
                 //$to = 'chernogolovka@list.ru';
                 $subject = 'Поступила заявка с сайта ' . $options['sitename'] . ' от ' . $name . '';
                 $from = $config['options']['username'];
                 $message = '<h2>Новая заявка</h2>';
                 $message .= 'Отправитель: <b>' . $name . ', </b><br>';
                 $message .= 'Тел: <b>' . $phone . ', </b><br>';
                 $message .= '<em>Отправлено: ' . date("G:i:s M j Y") . '</em>';
                 Email::send($to, $from, $subject, $message, $html = TRUE);
                 if (count($this->errors) > 0) {
                     $base = new Model_Base();
                     $options = $base->getOptions();
                     $to = $options['admin_email'];
                     $subject = 'Ошибки на сайте ' . $options['sitename'];
                     $from = $config['options']['username'];
                     foreach ($this->errors as $error) {
                         $message = '<h2>Ошибка</h2>';
                         $message .= $error;
                         $message .= ' <em>Отправлено: ' . date("G:i:s M j Y") . '</em>';
                     }
                     Email::send($to, $from, $subject, $message, $html = TRUE);
                 } else {
                     $this->messages[] = 'Спасибо! Ваш вопрос успешно отправлен.';
                 }
             }
         } else {
             $this->errors['captcha'] = "Код введен неверно";
         }
     }
     $captcha_image = Captcha::instance()->render();
     $this->template->captcha = $captcha_image;
     $this->template->errors = $this->errors;
     $this->template->messages = $this->messages;
 }
开发者ID:chernogolov,项目名称:blank,代码行数:64,代码来源:Callback.php

示例15: action_reminder

 public function action_reminder()
 {
     $reminder = false;
     $template = View::factory('reminder');
     if (!Auth::instance()->logged_in()) {
         if ($this->request->method() == Request::POST) {
             if (Captcha::valid($_POST['captcha'])) {
                 $user = ORM::factory('User')->where('username', '=', Arr::get($_POST, 'username', ''))->find();
                 if ($user->loaded() && $user->network_reg == 0 && empty($user->link_activate)) {
                     $date = date("Y-m-d H:i:s");
                     $code = md5($date . $user->password);
                     $save_code = ORM::factory('User', $user->id);
                     $save_code->link_recovery = $code;
                     $save_code->save();
                     $reminder = true;
                 } else {
                     $mas_err = array();
                     $mas_err[] = I18n::get("Пользователь с таким логином не зарегистрирован.");
                     $error = true;
                     $template->set('errors', $mas_err)->set('error', $error);
                 }
             } else {
                 $mas_err = array();
                 $mas_err[] = I18n::get("Неправильно ввели код подтверждения.");
                 $error = true;
                 $template->set('errors', $mas_err)->set('error', $error);
             }
         }
     }
     $template->set('reminder', $reminder)->set('return', '/')->render();
     $this->response->body($template->render());
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:32,代码来源:Login.php


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