public function actionLogin()
 {
     $email = '';
     $password = '';
     if (isset($_POST['submit'])) {
         $email = $_POST['email'];
         $password = $_POST['password'];
         $error = false;
         if (!User::checkEmail($email)) {
             $errors[] = 'Неправльный email';
         }
         if (!User::checkPassword($password)) {
             $errors[] = 'Пароль не должен быть короче 6 символов';
         }
         $userId = User::checkUserData($email, $password);
         if ($userId == false) {
             $errors[] = 'Неправльные данные для входа на сайт';
         } else {
             User::auth($userId);
             header('Location: /cabinet/');
         }
     }
     require_once ROOT . '/views/user/login.php';
     return true;
 }
Example #2
0
 public function actionLogin()
 {
     $email = '';
     $password = '';
     if (isset($_POST['submit'])) {
         $email = $_POST['email'];
         $password = $_POST['password'];
         $errors = false;
         //Валидация
         if (!User::checkEmail($email)) {
             $errors[] = 'Неправельный email';
         }
         if (!User::checkPassword($password)) {
             $errors[] = 'Пароль не должен быть короче 6-ти символов';
         }
         //Проверка пользователя
         $userId = User::checkUserData($email, $password);
         if ($userId == false) {
             $errors[] = 'Неправильные данные для входа на сайт';
         } else {
             User::auth($userId);
             //redirect
             header("Location: /");
         }
     }
     require_once ROOT . '/views/user/login.php';
 }
function _newUser()
{
    $user = new User(getdbh());
    $email = $user->checkEmail($_POST['email']);
    if (isset($email['ID'])) {
        $data['msg'][] = " Acest email nu este disponibil! Va rugam alegeti altul!";
        $data['redirect'][] = 'main/new';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    } else {
        $result = $user->addUser($_POST['email'], $_POST['password1'], $_POST['nume'], $_POST['prenume']);
        if ($result > 0) {
            $setToken = $user->newUserToken($result);
            if ($setToken != false) {
                $body = 'Pentru a activa contul apasa   <a href="' . WEB_DOMAIN . WEB_FOLDER . 'ops/newUserToken/' . $setToken . '"> AICI </a>';
                if (sendEmail('Email confirmare cont', $body, '*****@*****.**', $_POST['email'])) {
                    $data['msg'][] = "Emailul cu linkul de confirmare cont a fost trimis";
                    $data['redirect'][] = 'main/index';
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                } else {
                    $data['msg'][] = "Emailul cu linkul de confirmare nu a fost trimis";
                    $data['redirect'][] = 'main/index';
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                }
            } else {
                $data['msg'][] = "Eroare la generarea tokenului";
                $data['redirect'][] = 'main/index';
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            }
        } else {
            $data['msg'][] = "Eroare la crearea contului!";
            $data['redirect'][] = 'main/index';
            View::do_dump(VIEW_PATH . 'layout.php', $data);
        }
    }
}
Example #4
0
 /**
  * Action для страницы "Контакты"
  */
 public function actionContact()
 {
     $userEmail = false;
     $userText = false;
     $result = false;
     if (isset($_POST['submit'])) {
         $userEmail = $_POST['userEmail'];
         $userText = $_POST['userText'];
         $errors = false;
         if (!User::checkEmail($userEmail)) {
             $errors[] = 'Неправильный email';
         }
         if ($errors == false) {
             // Если ошибок нет
             // Отправляем письмо администратору
             $adminEmail = '*****@*****.**';
             $message = "Текст: {$userText}. От {$userEmail}";
             $subject = 'Тема письма';
             $result = mail($adminEmail, $subject, $message);
             $result = true;
         }
     }
     require_once ROOT . '/views/site/contact.php';
     return true;
 }
Example #5
0
 public function actionLogin()
 {
     $email = '';
     $password = '';
     if (isset($_POST['submit'])) {
         $email = $_POST['email'];
         $password = $_POST['password'];
         $errors = false;
         //validarea cimpurilor
         if (!User::checkEmail($email)) {
             $errors[] = 'Nu este corect emailul';
         }
         if (!User::checkPassword($password)) {
             $errors[] = 'Parola nu trebue sa fie mai scurta de 6 simboluri';
         }
         //verificam daca exista utilizatorul
         $userId = User::checkUserData($email, $password);
         if ($userId == false) {
             //Daca datele nu sunt corecte afisham eroare
             $errors[] = 'Datele is incorecte , pentru a intra pe site';
         } else {
             //daca datele is corecte , memoram utilizatorul in sesiune
             User::auth($userId);
             //directionam utilizatorul in partea inchisa a cabinetului
             header("Location: /cabinet/");
         }
     }
     require_once ROOT . '/views/user/login.php';
     return true;
 }
function _request_new_password()
{
    if (isset($_POST['email'])) {
        $user = new User(getdbh());
        $ID = $user->checkEmail($_POST['email']);
        if (isset($ID['ID'])) {
            $setToken = $user->setRecover($ID['ID'], $_POST['email']);
            if ($setToken != false) {
                $body = 'Pentru a schimba parola apasa   <a href="' . WEB_DOMAIN . WEB_FOLDER . 'ops/recover_password/' . $setToken . '"> AICI </a>';
                if (sendEmail('Schimbare parola', $body, '*****@*****.**', $_POST['email'])) {
                    $data['msg'][] = "Emailul cu linkul de resetare a parolei a fost trimis";
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                } else {
                    $data['msg'][] = "Emailul nu a fost trimis";
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                }
            } else {
                $data['msg'][] = "Tokenul este gresit sau au trecut mai mult de 2 zile de la cererea de recuperare parola";
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            }
        } else {
            $data['msg'][] = "Acest user nu exista";
            View::do_dump(VIEW_PATH . 'layout.php', $data);
        }
    } else {
        redirect('main/index');
    }
}
Example #7
0
 /**
  * Action для страницы просмотра товара
  * @param integer $productId <p>id товара</p>
  */
 public function actionView($productId)
 {
     $categories = Category::getCategoriesList();
     $product = Product::getProductById($productId);
     $comments = Product::getComments($productId);
     $userEmail = false;
     $userName = false;
     $userComment = false;
     // Флаг результата
     $result = false;
     if (isset($_POST['submit'])) {
         $userEmail = $_POST['userEmail'];
         $userName = $_POST['userName'];
         $userComment = $_POST['userComment'];
         // Флаг ошибок
         $errors = false;
         if (!User::checkName($userName)) {
             $errors[] = 'Имя не должно быть короче 2-х символов';
         }
         if (!User::checkEmail($userEmail)) {
             $errors[] = 'Неверный Email';
         }
         if (strlen($userComment) <= 0) {
             $errors[] = 'Ведите текст';
         }
         if ($errors == false) {
             $result = Product::addComment($userName, $userEmail, $userComment, $productId);
             header("Location: /product/{$productId}");
         }
     }
     require_once ROOT . '/views/product/view.php';
     return true;
 }
 public function actionLogin()
 {
     $email = '';
     $password = '';
     if (isset($_POST['submit'])) {
         $email = $_POST['email'];
         $password = $_POST['password'];
         $errors = false;
         //Валидация полей
         if (User::checkEmail($email)) {
             $errors[] = 'Ошибка, Не верный email';
         }
         if (User::checkPassword($password)) {
             $errors[] = 'Ошибка, пароль должен состоять минимум из 6 символов';
         }
         //Проверяем существует ли пользователь
         $userId = User::checkUserData($email, $password);
         if ($userId == false) {
             //Если данные не верные - показываем ошибку
             $errors[] = 'Ошибка входа на сайт Введенные данные неправильные!';
         } else {
             //Если данные правильные, запоминаем пользователя (сессия)
             User::auth($userId);
             //Перенаправляем пользователя в закрытую часть (cabinet)
             header("Location: /cabinet/");
         }
     }
     require_once ROOT . '/views/user/login.php';
     return true;
 }
Example #9
0
 public function actionContact()
 {
     $categories = Category::getCategoryList();
     if (!$categories) {
         $categories = array();
     }
     $email = '';
     $subject = '';
     $message = '';
     $result = '';
     if (isset($_POST['submit'])) {
         $email = FunctionLibrary::clearStr($_POST['email']);
         $subject = FunctionLibrary::clearStr($_POST['subject']);
         $message = FunctionLibrary::clearStr($_POST['message']);
         $errors = array();
         if (!User::checkEmail($email)) {
             $errors[] = 'Невалидный Email.';
         }
         if (!User::checkName($subject)) {
             $errors[] = 'Тема должна быть больше 1 символа.';
         }
         if (!User::checkName($message)) {
             $errors[] = 'Сообщение должно быть больше 1 символа.';
         }
         if (empty($errors)) {
             $adminEmail = '*****@*****.**';
             $sub = "Тема письма: {$subject}. От: {$email}";
             $mess = "Текст письма: {$message}";
             $result = mail($adminEmail, $sub, $mess);
         }
     }
     require_once ROOT . '/views/site/contact.php';
     return true;
 }
Example #10
0
 /**
  * Action для страницы "Вход на сайт"
  */
 public function actionLogin()
 {
     $email = false;
     $password = false;
     if (isset($_POST['submit'])) {
         $email = $_POST['email'];
         $password = $_POST['password'];
         $errors = false;
         if (!User::checkEmail($email)) {
             $errors[] = 'Неправильный email';
         }
         if (!User::checkPassword($password)) {
             $errors[] = 'Пароль не должен быть короче 6-ти символов';
         }
         $userId = User::checkUserData($email, $password);
         if ($userId == false) {
             $errors[] = 'Неправильные данные для входа на сайт';
         } else {
             // Если данные правильные, запоминаем пользователя (сессия)
             User::auth($userId);
             header("Location: /cabinet");
         }
     }
     require_once ROOT . '/views/user/login.php';
     return true;
 }
Example #11
0
 /**
  * Action для страницы "Контакты"
  */
 public function actionContact()
 {
     // Переменные для формы
     $userEmail = false;
     $userText = false;
     $result = false;
     // Обработка формы
     if (isset($_POST['submit'])) {
         // Если форма отправлена
         // Получаем данные из формы
         $userEmail = $_POST['userEmail'];
         $userText = $_POST['userText'];
         // Флаг ошибок
         $errors = false;
         // Валидация полей
         if (!User::checkEmail($userEmail)) {
             $errors[] = 'Неправильный email';
         }
         if ($errors == false) {
             // Если ошибок нет
             // Отправляем письмо администратору
             $adminEmail = '*****@*****.**';
             $message = "Текст: {$userText}. От {$userEmail}";
             $subject = 'Тема письма';
             $result = mail($adminEmail, $subject, $message);
             $result = true;
         }
     }
     // Подключаем вид
     require_once ROOT . '/views/site/contact.php';
     return true;
 }
 public function actionCreate()
 {
     $name = '';
     $email = '';
     $password = '';
     if (isset($_POST['submit'])) {
         $name = FunctionLibrary::clearStr($_POST['name']);
         $email = FunctionLibrary::clearStr($_POST['email']);
         $password = FunctionLibrary::clearStr($_POST['password']);
         $errors = array();
         if (!User::checkName($name)) {
             $errors[] = 'Имя должно быть больше 1 символа.';
         }
         if (!User::checkEmail($email)) {
             $errors[] = 'Невалидный email.';
         }
         if (User::checkEmailExists($email)) {
             $errors[] = 'Такой email уже существует.';
         }
         if (!User::checkPassword($password)) {
             $errors[] = 'Пароль должен быть больше 5 символов.';
         }
         if (empty($errors)) {
             $result = User::registerAdmin($name, $email, $password);
             if (!$result) {
                 $message = 'Произошла ошибка при регистрации админа!';
             } else {
                 FunctionLibrary::redirectTo('/admin/user');
             }
         }
     }
     require_once ROOT . '/views/admin-user/create.php';
     return true;
 }
 public function actionLogin()
 {
     $userData = array('name' => '', 'email' => '', 'password' => '');
     if (isset($_POST['submit'])) {
         $user = new User('', $_POST['email'], $_POST['password']);
         $errors = false;
         if (!$user->checkEmail()) {
             $errors[] = 'Неправильный email';
         }
         if (!$user->checkPassword()) {
             $errors[] = 'Пароль не должен быть короче 6-ти символов';
         }
         if (empty($errors)) {
             $userAuth = $user->checkUserData();
             if ($userAuth) {
                 $user->auth();
                 header("Location: /cabinet/");
             } else {
                 $errors[] = 'Неправельные данные для авторизации';
             }
         }
         $userData = $user->getUserData();
     }
     require_once ROOT . '/views/user/login.php';
     return true;
 }
Example #14
0
 public function actionLogin()
 {
     $email = '';
     $password = '';
     $remember = '';
     if (isset($_POST['submit'])) {
         $email = FunctionLibrary::clearStr($_POST['email']);
         $password = FunctionLibrary::clearStr($_POST['password']);
         if (isset($_POST['remember'])) {
             $remember = FunctionLibrary::clearStr($_POST['remember']);
         }
         $errors = array();
         if (!User::checkEmail($email)) {
             $errors[] = 'Невалидный email.';
         }
         $user = User::login($email, $password, $remember);
         if ($user) {
             User::auth($user);
             FunctionLibrary::redirectTo('/cabinet');
         } else {
             $errors[] = 'Неправильные данные для входа на сайт.';
         }
     }
     require_once ROOT . '/views/user/login.php';
     return true;
 }
Example #15
0
 public function actionRegister()
 {
     $name = '';
     $email = '';
     $password = '';
     $result = false;
     $errors = [];
     if (isset($_POST['submit'])) {
         $name = filter_var($_POST['name'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
         $email = filter_var($_POST['email'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
         $password = filter_var($_POST['password'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
         $errors = false;
         /*if (USER::checkName($name)) {
               echo $name;
           } else {
               $errors[] = 'Имя не должно быть короче 2-х символов';
           }*/
         //sra poxaren tak@ grum enq aveli karch
         if (!User::checkName($name)) {
             $errors[] = 'Имя не должно быть короче 2-х символов';
         }
         if (!User::checkEmail($email)) {
             $errors[] = 'Неправильный email';
         }
         if (!User::checkPassword($password)) {
             $errors[] = 'Пароль не должен быть короче 6-ти символов';
         }
         if (User::checkEmailExists($email)) {
             $errors[] = 'Такой email уже используется';
         }
         if (!$errors) {
             $result = User::register($name, $email, $password);
         }
     }
     $view = new View();
     $view->result = $result;
     $view->name = $name;
     $view->email = $email;
     $view->password = $password;
     $view->errors = $errors;
     $view->display('user/register.php');
     //       require_once(ROOT . '/views/user/register.php');
     return true;
 }
Example #16
0
 /**
  * Action для страницы "Вход на сайт"
  */
 public function actionLogin()
 {
     // Переменные для формы
     $email = false;
     $password = false;
     // Обработка формы
     if (isset($_POST['submit_log'])) {
         // Если форма отправлена
         // Получаем данные из формы
         $email = $_POST['email'];
         $password = $_POST['password'];
         // Флаг ошибок
         $errors = false;
         // Валидация полей
         if (!User::checkEmail($email)) {
             $errors[] = 'Неправильный email';
         }
         if (!User::checkPassword($password)) {
             $errors[] = 'Пароль не должен быть короче 6-ти символов';
         }
         // Проверяем существует ли пользователь
         $userId = User::checkUserData($email, $password);
         if ($userId == false) {
             // Если данные неправильные - показываем ошибку
             $errors[] = 'Неправильные данные для входа на сайт';
         } else {
             // Если данные правильные, запоминаем пользователя (сессия)
             User::auth($userId);
             $user = User::getUserById($userId);
             // Если роль текущего пользователя "admin", пускаем его в админпанель
             if ($user['role'] == 'admin') {
                 require_once ROOT . '/views/admin/index.php';
             } else {
                 // Перенаправляем пользователя в закрытую часть - кабинет
                 header("Location: /cabinet");
             }
         }
     }
     //        // Подключаем вид
     require_once ROOT . '/views/user/login.php';
     return true;
 }
 /**
  * Action для страницы "Регистрация"
  */
 public function actionRegister()
 {
     // Переменные для формы
     $name = '';
     $email = '';
     $password = '';
     $result = false;
     if (isset($_POST['submit'])) {
         // Если форма отправлена
         // Получаем данные из формы
         $name = $_POST['name'];
         $email = $_POST['email'];
         $password = $_POST['password'];
         // Флаг ошибок
         $errors = false;
         // Валидация полей
         if (!User::checkName($name)) {
             $errors[] = 'Имя не должно быть короче 2-х символов';
         }
         if (!User::checkEmail($email)) {
             $errors[] = 'Неправильный email';
         }
         if (!User::checkPassword($password)) {
             $errors[] = 'Неправильный пароль';
         }
         if (User::checkEmailExist($email)) {
             $errors[] = 'Такой email уже используется';
         }
         if ($errors == false) {
             // Если ошибок нет
             // Регистрируем пользователя
             $result = User::register($name, $email, $password);
         }
     }
     require_once ROOT . '/views/user/register.php';
     return true;
 }
Example #18
0
 public function actionContact()
 {
     $userEmail = '';
     $userText = '';
     $result = false;
     if (isset($_POST['submit'])) {
         $userEmail = $_POST['userEmail'];
         $userText = $_POST['userText'];
         $errors = false;
         //validarea cimpurilor
         if (!User::checkEmail($userEmail)) {
             $errors[] = 'Emailul este incorect';
         }
         if ($errors == false) {
             $mail = '*****@*****.**';
             $message = "Text:{$userText}. De la {$userEmail}";
             $subject = 'Tema scrisorii';
             $result = mail($mail, $subject, $message);
             $result = true;
         }
     }
     require_once ROOT . '/views/site/contact.php';
     return true;
 }
Example #19
0
 /**
  * Returns false incase it went correct (?) pretty weird
  * 
  * TODO: make work with WikiPotion::setError();
  * 
  * @param Database $db
  * @return bool|string
  */
 function register($db)
 {
     $handle = htmlentities($_POST['handle']);
     $handle = str_replace(' ', '', $handle);
     $email = $_POST['email'];
     $passwd = $_POST['passwd'];
     if ($passwd != $_POST['passwd_verify']) {
         return 'Password does not match verification password.';
     }
     $user = new User($db, array('name' => $handle, 'password' => md5($passwd), 'accesslevel' => 30, 'email' => $email));
     if ($email && !$user->checkEmail($email)) {
         return 'Incorrect Email Address Supplied';
     }
     if (!$user->isUniqueName()) {
         // The username should be unique
         return 'Unable to register [' . $handle . '], this handle is already registered';
     }
     $user->insert();
     $_SESSION['user_id'] = $user->id;
     $_SESSION['user_name'] = $user->name;
     $_SESSION['user_pwd'] = $user->password;
     $_SESSION['access'] = $user->accesslevel;
     return false;
 }
Example #20
0
 public function ajax()
 {
     $type = Input::get('type');
     $return = array();
     if ($type) {
         switch ($type) {
             case 'validateusername':
                 $input = Input::all();
                 $rules = array('user_username' => 'Required|max:20|unique:tbl_users');
                 $validator = Validator::make($input, $rules);
                 if ($validator->fails()) {
                     $result = $validator->messages();
                 } else {
                     $result = 0;
                 }
                 return Response::json(array('result' => $result));
                 break;
                 //...validate user email...
             //...validate user email...
             case 'validateuseremail':
                 $input = Input::all();
                 $rules = array('user_email' => 'Required|unique:tbl_users|email');
                 $validator = Validator::make($input, $rules);
                 if ($validator->fails()) {
                     $result = "Not unique";
                 } else {
                     $email = Input::get('user_email');
                     $explode = explode('.', $email);
                     $result = "unique";
                 }
                 return Response::json(array('result' => $result));
                 break;
             case 'validateifemail':
                 $result = "";
                 $rules = array('user_email' => 'Required|exists:tbl_users|email');
                 $validator = Validator::make(Input::all(), $rules);
                 foreach ($validator->errors()->all() as $err) {
                     if ($err == 'The selected user email is invalid.') {
                         $err = 'The email you have entered is not yet registered.';
                     }
                     $result = $result . " " . $err;
                 }
                 return Response::json(array('result' => $result));
                 break;
             case 'validateUsernameCredential':
                 $userModel = new User();
                 $u = $userModel->checkUsername(Input::get('user_username'));
                 if ($u) {
                     echo 'false';
                 } else {
                     echo 'true';
                 }
                 break;
             case 'validateEmailCredential':
                 $userModel = new User();
                 $u = $userModel->checkEmail(Input::get('user_email'));
                 if ($u) {
                     echo 'false';
                 } else {
                     echo 'true';
                 }
                 break;
             case 'resend-verification':
                 $email = Input::get('email');
                 $ctr = DB::table('tbl_users')->where('user_email', '=', $email)->count();
                 if ($ctr > 0) {
                     $passCode = str_random(25);
                     DB::table('tbl_users')->where('user_email', $email)->update(array('user_emailverification' => $passCode));
                     $_user = $this->GlobalModel->getModelRowListByColumnName('tbl_users', 'user_email', $email, null);
                     foreach ($_user as $user) {
                         $data = array('email' => "{$user->user_email}", 'fname' => "{$user->user_fname}", 'lname' => "{$user->user_lname}", 'salutation' => "{$user->user_salutation}", 'user_username' => "{$user->user_username}", 'confirmation_code' => "{$passCode}", 'verify' => 0);
                         try {
                             Mail::send('emails.user.firstEmailVerification', $data, function ($message) use($data) {
                                 $message->from('*****@*****.**', 'El Sitio Filipino');
                                 $message->to($data['email'], $data['fname'] . ' ' . $data['lname'])->subject('El Sitio Filipino Account Verification');
                             });
                         } catch (Exception $ex) {
                         }
                     }
                 }
                 return Response::json(array('counts' => $ctr));
                 break;
             case 'checkEmailAdd':
                 $user = new User();
                 $currEmail = Input::get('id');
                 if ($currEmail == 'null') {
                     echo 'true';
                 } else {
                     echo $user->checkEmailAddExist($currEmail);
                 }
                 break;
             case 'checkUserEx':
                 $user = new User();
                 $userCheck = Input::get('id');
                 if ($userCheck == 'null') {
                     echo 'true';
                 } else {
                     echo $user->checkUserExist($userCheck);
                 }
                 break;
         }
     }
 }
Example #21
0
     $err .= "Password field can't be empty";
 } else {
     if ($password != $con_passwd) {
         $err .= "Password didn't match";
     }
 }
 $my_user = new User('', '', '', $company, $email, $password, $reg_date, $last_log, $status, $act_code);
 $my_user->setFirstname($firstname);
 $my_user->setLastname($lastname);
 $my_user->setComapny($company);
 $act_code = $my_user->gen_actcode();
 $my_user->setAct_code($act_code);
 $my_user->setStatus(_INACTIVE);
 $my_user->setRegdate($dateTime);
 $my_user->setLastlog(null);
 $valemail = $my_user->checkEmail($email);
 if ($_POST['email'] != "") {
     if (isset($valemail) && ($valemail = $email)) {
         $my_user->setEmail($email);
     } else {
         $err .= "Email already exits";
     }
 }
 $pass = $my_user->setPassword($password);
 if ($password != "") {
     if (isset($pass) && $pass == FALSE) {
         $err .= "Password needs to be more than 6 characters";
     }
 }
 echo $err;
 if ($err == "") {
Example #22
0
 /**
  * Create new Admin users. 
  * 
  * The first Admin user created will be a God user. 
  * TODO: get the highest ranked user from the engine.ini file and use that as first user.
  * TODO: the ADMIN_ACCESSLEVEL constant should be dynamically assigned in VoodooController
  */
 function createAdmin()
 {
     $db = $this->controller->DBConnect();
     $sql = "SELECT USER_ID FROM TBL_USER WHERE USER_ACCESSLEVEL >= ??";
     $q = $db->query($sql);
     $q->bind_values(ADMIN_ACCESSLEVEL);
     $q->execute();
     $firstAdmin = !(bool) $q->rows();
     if (!$firstAdmin && !$this->hasRights($_SESSION['access'], 'admin', 'create')) {
         return array('Error', VoodooError::displayError('No Permission'));
     }
     $template =& VoodooTemplate::getInstance();
     $template->setDir(WIKI_TEMPLATES);
     $args = array('prepath' => PATH_TO_DOCROOT, 'loginpath' => 'setup/CreateAdmin');
     if (!empty($_POST['handle'])) {
         $user = new User($db);
         if ($_POST['passwd'] != $_POST['passwd_verify']) {
             $args['message'] = VoodooError::displayError('Passwords dont match');
         } elseif (!$user->checkEmail($_POST['email'])) {
             $args['message'] = VoodooError::displayError('Passwords dont match');
         } else {
             $user->name = $_POST['handle'];
             $user->password = md5($_POST['passwd']);
             $user->email = $_POST['email'];
             $rv = $this->controller->convertAccessLevel($firstAdmin ? 'God' : 'Admin');
             $user->accesslevel = array_pop($rv);
             $user->insert();
             header(sprintf('Location: %s/setup/Login', PATH_TO_DOCROOT));
             exit;
         }
     }
     return array('Create New Admin User', $template->parse('wiki.register', $args));
 }
 } catch (Exception $e) {
     $errors['gender'] = $e->getMessage();
 }
 var_dump($errors);
 $user = new User();
 try {
     if ($user->checkUsername($userName)) {
         throw new Exception("Username has been taken");
     }
 } catch (Exception $e) {
     if ($userName != NULL) {
         $errors['username'] = $e->getMessage();
     }
 }
 try {
     if ($user->checkEmail($email)) {
         throw new Exception("Email is already in use");
     }
 } catch (Exception $e) {
     if ($email != NULL) {
         $errors['email'] = $e->getMessage();
     }
 }
 if (empty($errors)) {
     $formattedDate = $dateTimeObject->format('Y-m-d');
     $user->username = $userName;
     $user->first_name = $firstName;
     $user->last_name = $lastName;
     $user->hash = password_hash($confirmPassword, PASSWORD_BCRYPT);
     $user->email = $email;
     $user->birth_date = $formattedDate;
 public function actionLogin()
 {
     $email = '';
     $password = '';
     $user = new User();
     if (isset($_POST['login_btn'])) {
         $email = $_POST['login_email'];
         $password = $_POST['login_password'];
         $errors = false;
         //Валидация полей
         if (!User::checkEmail($email)) {
             $errors[] = 'Неправильный Email';
         }
         if (!User::checkPassword($password)) {
             $errors[] = 'Пароль не должен быть короче 6-ти символов';
         }
         //Проверка существует ли пользователь
         $userId = $user->checkUserData($email, $password);
         $userProfile = $user->checkProfileData($userId);
         if ($userId == false) {
             $errors[] = 'Не верные данные для входа на сайт';
         } else {
             $user->auth($userId);
             if ($userProfile == false) {
                 header('Location: /user/profile');
             } else {
                 header('Location: /');
             }
         }
     }
     require_once ROOT . '/views/user/login.php';
     return true;
 }
Example #25
0
<?php

include_once "DBConnect.php";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (isset($_POST['username'])) {
        $person = new User($_POST['username'], $_POST['email'], $_POST['telephone'], $_POST['password']);
        $validation[] = $person->checkPass($person->_password, $_POST['password_confirm']);
        $validation[] = $person->checkPhone($person->_telephone);
        $validation[] = $person->checkEmail($person->_email);
        $validation[] = $person->checkName($person->_name);
        if (!in_array(0, $validation)) {
            //Check if some function returned 0
            $registerResult = $person->registerUser($person->_name, $person->_email, $person->_telephone, $person->_password);
            if ($registerResult == true) {
                if (!isset($_FILES['image'])) {
                    echo '
                    <div class="alert alert-success alert-dismissible" role="alert">
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        Cadastro de <b>' . $person->_name . '</b> efetuado. (sem imagem)
                    </div>';
                } else {
                    $person->uploadFile($_FILES['image'], $_POST['MAX_FILE_SIZE']);
                }
                echo '<div class="alert alert-info" role="alert"><span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span> Redirecionando...</div>';
                echo "<meta http-equiv=\"refresh\" content=\"3;url=login.php\">";
            }
        }
    }
    if (isset($_POST['compname'])) {
        if ($_POST['lat'] != "" && $_POST['lng'] != "" && $_POST['address'] != "") {
            $location = "" . $_POST['lat'] . " " . $_POST['lng'] . "";
Example #26
0
 public function updateUser(User $user)
 {
     $inputs = ['email' => Input::get('email'), 'username' => Input::get('username'), 'password' => Input::get('password'), 'password_confirmation' => Input::get('password_confirmation')];
     $valid = Validator::make($inputs, User::$rulesUpd);
     if (User::cmpPassword($inputs['password'], $inputs['password_confirmation']) == 1) {
         return Redirect::back()->withErrors(trans('messages.PACANE'));
     }
     if (isset($inputs['username']) && $user->checkUsername($inputs['username']) == 1) {
         return Redirect::back()->withErrors(trans('messages.TUAXTAO'));
     }
     if (isset($inputs['email']) && $user->checkEmail($inputs['email']) == 1) {
         return Redirect::back()->withErrors(trans('messages.TEAXTAO'));
     }
     if ($valid->passes()) {
         $user->username = $inputs['username'];
         $user->email = $inputs['email'];
         if (isset($inputs['password']) && $inputs['password'] != '') {
             $user->password = Hash::make($inputs['password']);
         }
         $user->save();
         return Redirect::back()->with('success', Lang::choice('messages.Users', 1) . ' ' . trans('messages.is updated'));
     } else {
         return Redirect::back()->withErrors($valid)->withInput();
     }
 }
<?php

require_once '../template/Input.php';
require_once '../template/user.php';
if (Input::has('create_user')) {
    if (Input::get('password') !== Input::get('confirm_password')) {
        $passwordError = "Password confirmation doesn't match password.";
    }
    $new_user = new User();
    if (!$new_user->checkEmail(Input::get('email'))) {
        $hashed_password = password_hash(trim(Input::get('password')), PASSWORD_DEFAULT);
        $new_user->first_name = Input::get('first_name');
        $new_user->last_name = Input::get('last_name');
        $new_user->email = Input::get('email');
        $new_user->password = $hashed_password;
        // $new_user->avatar_img = Input::get('avatar_img');
        if ($new_user->insert()) {
            header("Location: /");
            exit;
        } else {
            $emailError = "Cannot create new account with this email.";
        }
    }
}
?>
<html>
    <?php 
include '../views/partials/header.php';
?>

            <main>
 public function actionEdit()
 {
     $user = new User();
     //Получаем информацию о пользователе из сессии
     $userId = $user->checkLogged();
     //получаем инф-ию о пользователе из БД
     $userProfile = $user->getUserById($userId);
     $profileData = $user->getProfileByUserId($userId);
     $email = $userProfile['email'];
     $password = $userProfile['password'];
     $name = $profileData['name'];
     $sname = $profileData['sname'];
     $phone = $profileData['phone'];
     $country = $profileData['country'];
     $region = $profileData['region'];
     $city = $profileData['city'];
     $address = $profileData['address'];
     $city_index = $profileData['city_index'];
     $result = false;
     if (isset($_POST['save_edit'])) {
         $email = $_POST['email'];
         $name = $_POST['uname'];
         $sname = $_POST['usname'];
         $phone = $_POST['uphone'];
         $country = $_POST['ucountry'];
         $region = $_POST['uregion'];
         $city = $_POST['ucity'];
         $address = $_POST['uaddress'];
         $city_index = $_POST['uindex'];
         $n_password = $_POST['n_password'];
         $o_password = $_POST['o_password'];
         $errors = false;
         if ($_POST['o_password'] or $_POST['n_password']) {
             if (empty($o_password)) {
                 $errors[] = 'Не указан старый пароль';
             }
             if (empty($n_password)) {
                 $errors[] = 'Не указан новый пароль';
             }
             if (!$user->checkedPassword($password, $o_password)) {
                 $errors[] = 'Старый пароль указан неверно';
             }
             if ($errors == false) {
                 $npassword = $_POST['n_password'];
             }
         }
         if (!User::checkEmail($email)) {
             $errors[] = 'Неправильный Email';
         }
         if (!User::checkName($name)) {
             $errors[] = 'Имя должно быть более 2-х символов';
         }
         if (!User::checkSname($sname)) {
             $errors[] = 'Фамилия должна быть более 2-х символов';
         }
         if (!User::checkPhone($phone)) {
             $errors[] = 'Телефон должен быть более 7-ми символов';
         }
         if (!User::checkCountry($country)) {
             $errors[] = 'Страна должна быть более 2-х символов';
         }
         if (!User::checkRegion($region)) {
             $errors[] = 'Область должна быть более 2-х символов';
         }
         if (!User::checkCity($city)) {
             $errors[] = 'Город должен быть более 2-х символов';
         }
         if (!User::checkAddress($address)) {
             $errors[] = 'Адрес должен быть более 5-ти символов';
         }
         if (!User::checkIndex($city_index)) {
             $errors[] = 'Индекс должен быть более 4-х символов';
         }
         if ($errors == false) {
             $result = $user->edit($userId, $email, $password, $npassword, $name, $sname, $phone, $country, $region, $city, $address, $city_index);
         }
     }
     require_once ROOT . '/views/cabinet/edit.php';
     return true;
 }
Example #29
0
<?php

session_start();
ini_set('display_errors', '0');
include 'settings.php';
require 'class/DBAccess.class.php';
require 'class/User.class.php';
require 'class/Fbuser.class.php';
$email = $_POST['email'];
//echo $email;
if ($email) {
    $user = new User();
    $r_email = $user->checkEmail($email);
    if (count($r_email) >= 1) {
        echo "1";
    }
}