Beispiel #1
0
 public function login()
 {
     $session = \helpers\session::id();
     if ($this->_model->get_session($session)) {
         url::redirect('');
     }
     $data['title'] = 'Вход';
     if (!empty($_POST)) {
         //print_r($_POST);
         //exit;
         if (!isset($_POST['captcha']) || empty($_POST['captcha'])) {
             $error[] = 'Введите данные с каринки';
         } else {
             $captcha = new \helpers\raincaptcha();
             if (!$captcha->checkAnswer($_POST['captcha'])) {
                 $error[] = 'Некорректные цифры с картинки';
             }
         }
         if (!isset($_POST['login']) || empty($_POST['login'])) {
             $error[] = 'Введите логин';
         } else {
             $username = $_POST['login'];
         }
         if (!isset($_POST['password']) || empty($_POST['password'])) {
             $error[] = 'Введите пароль';
         } else {
             $password = $_POST['password'];
         }
         if (\helpers\password::verify($password, $this->_model->getLogin($username)) == 0) {
             $error[] = 'Неверные логин или пароль';
         }
         if (!$error) {
             $data = array('session' => $session);
             $where = array('login' => $username);
             $this->_model->setSession($data, $where);
             url::redirect('');
         }
     }
     view::rendertemplate('header', $data);
     view::render('login', $data, $error);
     view::rendertemplate('footer');
 }
Beispiel #2
0
<?php

defined('_EXEC') or die;
$rainCaptcha = new \helpers\raincaptcha();
?>
            <div class="row">
                <div class="col-md-4 col-sm-6 col-md-offset-4 col-sm-offset-3">
                    <?php 
echo \core\error::display($error);
?>
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title">Войти</h3>
                        </div>
                        <div class="panel-body">
                            <form role="form" method="post">
                            <fieldset>
                                <div class="form-group">
                                    <input class="form-control" placeholder="Логин" name="login" type="text" value="<?php 
echo $_POST['login'];
?>
">
                                </div>
                                <div class="form-group">
                                        <input class="form-control" placeholder="Пароль" name="password" type="password" value="">
                                </div>
                                
                                <div class="form-group">
                                    <div class="row">
                                        <div class="col-xs-12 text-center">
                                            <img id="captchaImage" src="<?php