Пример #1
0
 public function __construct($login, $password = '', $firstName = '', $lastName = '', $sex = '', $email = '', $birthDate = '', $address = '', $postalCode = '', $city = '', $phoneNumber = '')
 {
     $this->login = $login;
     $this->password = empty($password) ? Transitive\Utils\Passwords::randomPassword() : $password;
     $this->firstName = $firstName;
     $this->lastName = $lastName;
     $this->sex = $sex;
     $this->email = $email;
     $this->birthDate = $birthDate;
     $this->address = $address;
     $this->postalCode = $postalCode;
     $this->city = $city;
     $this->phoneNumber = $phoneNumber;
 }
    if (strpos($_SERVER['HTTP_USER_AGENT'], $agent) !== false) {
        $bot = true;
        break;
    }
}
if (isset($_SESSION['cocktailsUser']) && get_class($_SESSION['cocktailsUser']) == 'User') {
    $request->redirect('index');
} elseif (isset($_POST['submit'])) {
    if ($_POST['user'] == '' || $_POST['password'] == '') {
        $badInput = true;
    } elseif (!$bot) {
        //require MODELS_INC.'UserDAO.class.php';
        //require 'passwordHash.inc.php';
        $user = UserDAO::getByLogin($_POST['user']);
        if ($user != NULL) {
            if (empty($user) || !Transitive\Utils\Passwords::validate_password($_POST['password'], $user->getPassword())) {
                $badInput = true;
                sleep(1);
            } else {
                $_SESSION['cocktailsUser'] = $user;
                FavoriteDAO::sync();
                if (!empty($_SESSION['referrer']) && $_SESSION['referrer'] != 'login' && $_SESSION['referrer'] != 'logout') {
                    $request->redirect($_SESSION['referrer']);
                } else {
                    $request->redirect('index');
                }
                exit;
            }
        } else {
            $badInput = true;
        }