Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class InvalidLoginException extends Exception {}
- $action = false;
- $lusername = false;
- $lpassword = false;
- $rusername = false;
- $rpassword = false;
- $confirm = false;
- $name = false;
- $city = false;
- $subscribe = false;
- $errors = array();
- if (!empty($_POST) && is_array($_POST)) {
- if (isset($_POST['action']) && $_POST['action'] == 'login') {
- $action = 'login';
- $lusername = strtolower(trim($_POST['lusername']));
- if (!$lusername) {
- $errors['lusername'] = 'Имя пользователя не может быть пустым';
- }
- $lpassword = strtolower(trim($_POST['lpassword']));
- if (!$lpassword) {
- $errors['lpassword'] = 'Пароль не может быть пустым';
- }
- if (!count($errors)) {
- try {
- try {
- $login_service->login($auth, array(
- 'username' => $lusername,
- 'password' => $lpassword
- ));
- $userdata = $auth->getUserData();
- } catch (\Aura\Auth\Exception\UsernameMissing $e) {
- // $log->notice("The 'username' field is missing or empty.");
- throw new InvalidLoginException();
- } catch (\Aura\Auth\Exception\PasswordMissing $e) {
- // $log->notice("The 'password' field is missing or empty.");
- throw new InvalidLoginException();
- } catch (\Aura\Auth\Exception\UsernameNotFound $e) {
- // $log->warning("The username you entered was not found.");
- throw new InvalidLoginException();
- } catch (\Aura\Auth\Exception\MultipleMatches $e) {
- // $log->warning("There is more than one account with that username.");
- throw new InvalidLoginException();
- } catch (\Aura\Auth\Exception\PasswordIncorrect $e) {
- // $log->notice("The password you entered was incorrect.");
- throw new InvalidLoginException();
- } catch (\Aura\Auth\Exception\ConnectionFailed $e) {
- // $log->notice("Cound not connect to IMAP or LDAP server.");
- // $log->info("This could be because the username or password was wrong,");
- // $log->info("or because the the connect operation itself failed in some way. ");
- // $log->info($e->getMessage());
- throw new InvalidLoginException();
- } catch (\Aura\Auth\Exception\BindFailed $e) {
- // $log->notice("Cound not bind to LDAP server.");
- // $log->info("This could be because the username or password was wrong,");
- // $log->info("or because the the bind operation itself failed in some way. ");
- // $log->info($e->getMessage());
- throw new InvalidLoginException();
- }
- } catch (InvalidLoginException $e) {
- $errors['invalid'] = "Введены неверные данные. Попробуйте еще раз.";
- }
- }
- } elseif (isset($_POST['action']) && $_POST['action'] == 'register') {
- $action = 'register';
- $rusername = strtolower(trim($_POST['rusername']));
- if (!$rusername) {
- $errors['rusername'] = 'Имя пользователя не может быть пустым';
- }
- $rpassword = trim($_POST['rpassword']);
- $confirm = trim($_POST['confirm']);
- if (!$rpassword) {
- $errors['rpassword'] = 'Пароль не может быть пустым';
- }
- if ($rpassword !== $confirm) {
- $errors['confirm'] = 'Пароль и потверждение пароля не совпадают';
- }
- $name = strtolower(trim($_POST['name']));
- if (!$name) {
- $errors['name'] = 'Имя не может быть пустым';
- }
- $city = strtolower(trim($_POST['city']));
- if (!$city) {
- $errors['city'] = 'Город не может быть пустым';
- }
- $subscribe = (int)$_POST['subscribe'];
- if (!count($errors)) {
- }
- }
- }
- include_once ($view_path . "user_auth.php");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement