コード例 #1
0
ファイル: session.php プロジェクト: arjayads/php-simple-auth
     redirect("/profile.php");
 } else {
     if (isset($_POST['signin'])) {
         $errors = [];
         if (!isset($_POST['session']['email'])) {
             $errors[] = 'Input email';
         }
         if (count($errors) > 0) {
             $data['errors'] = $errors;
             $data['session'] = $_POST['session'];
             loadView('_signin_form.php', $data);
         } else {
             $user = new User();
             $user = $user->findOneBy("email = '" . $_POST['session']['email'] . "'");
             if ($user && $user->isActive && $user->isAuthenticated('password', $_POST['session']['password'])) {
                 Session::logIn($user);
                 if (isset($_POST['session']['remember_me']) && $_POST['session']['remember_me'] == '1') {
                     Session::remember($user);
                 } else {
                     Session::forget($user);
                 }
                 Session::redirectBackOr('profile.php');
             } else {
                 $data['session'] = $_POST['session'];
                 $data['errors'] = ['Invalid email and password combination'];
                 loadView('_signin_form.php', $data);
             }
         }
     } else {
         loadView('_signin_form.php');
     }
コード例 #2
0
ファイル: signup.php プロジェクト: helloworldprojects/FoodWeb
if (isset($_POST['register'])) {
    if ($_POST['password'] != $_POST['con_password']) {
        $err = 1;
    } else {
        $user = new User();
        $user->name = $_POST['name'];
        $user->phone = $_POST['phone'];
        $user->email = $_POST['email'];
        $user->address = $_POST['address'];
        $user->password = $_POST['password'];
        $user->save();
        /*if($_POST['email']==$admin_username&&$_POST['password']==$admin_password){
            $session->logIn(0, Session::USER_ADMIN);
            header('Location: ./admin/index.php');
          }*/
        $session->logIn($user->id, Session::USER_REGULAR);
        header('Location: ./customer/index.php');
    }
} else {
    //  header('Location: index.php');
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
  <title>FoodWeb</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link href="./public/css/styles.css" rel="stylesheet" />
  <script type="text/javascript" src="./public/js/jquery.min.js"></script>
コード例 #3
0
ファイル: login.php プロジェクト: helloworldprojects/FoodWeb
<?php

require __DIR__ . '/./vendor/autoload.php';
require './config.php';
require_once './classes/session.php';
require './classes/boot.php';
require_once './classes/User.php';
$session = new Session();
$session->redirectIfLogged('./customer/index.php', './admin/index.php');
if (isset($_POST['email']) && isset($_POST['password'])) {
    if ($_POST['email'] == $admin_username && $_POST['password'] == $admin_password) {
        $session->logIn(0, Session::USER_ADMIN);
        header('Location: ./admin/index.php');
    }
    $u = User::where('email', $_POST['email'])->where('password', $_POST['password'])->first();
    //var_dump($u);
    if ($u) {
        $session->logIn($u->id, Session::USER_REGULAR);
        header('Location: ./customer/index.php');
    }
} else {
    //  header('Location: index.php');
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
  <title>FoodWeb</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
コード例 #4
0
ファイル: login.php プロジェクト: helloworldprojects/Autism
use Illuminate\Validation\Factory as ValidatorFactory;
use Symfony\Component\Translation\Translator;
$error = 0;
const ERROR_DB = 1;
const ERROR_INVALID = 3;
const ERROR_VALFAIL = 4;
const ERROR_MAILTAKEN = 5;
$session = new Session();
$session->redirectIfAuth('./admin/index.php', './trainer/index.php', './doctor/index.php', './index.php');
$factory = new ValidatorFactory(new Translator('en'));
$messages = getErrorMessages();
if (isset($_POST['type'])) {
    $type = $_POST['type'];
    if ($type == "login") {
        if ($_POST['email'] == $admin_email && $_POST['password'] == $admin_password) {
            $session->logIn(1, Session::USER_ADMIN);
            $session->redirectIfAuth('./admin/index.php', './trainer/index.php', './doctor/index.php', './index.php');
        }
        $validator = $factory->make($_POST, ['email' => 'required', 'password' => 'required'], $messages);
        if ($validator->passes()) {
            $u = User::where('email', $_POST['email'])->where('password', $_POST['password'])->first();
            if ($u) {
                $session->logIn($u->id, $u->type);
                $session->redirectIfAuth('./admin/index.php', './trainer/index.php', './doctor/index.php', './index.php');
            } else {
                $error = ERROR_INVALID;
            }
        } else {
            $error = ERRROR_VALFAIL;
        }
    } else {
コード例 #5
0
ファイル: login.php プロジェクト: anasanzari/tathva-organizer
<?php

require_once 'connection.php';
require_once "modules/mac.php";
$session = new Session();
if (isset($_POST["signin"])) {
    $user = $_POST['username'];
    $pass = $_POST['password'];
    $user = User::selectWithPass($db, $user, $pass);
    if ($user && $user->getValidate() == 1) {
        $code = $user->getEventcode();
        switch ($code) {
            case 'admin':
                $session->logIn($user->getName(), Session::USER_ADMIN);
                break;
            case '-pr':
                $session->logIn($user->getName(), Session::USER_PROOFREADER);
                break;
            case '-nu':
                $session->logIn($user->getName(), Session::USER_REGULAR);
                break;
            default:
                $session->logIn($user->getName(), Session::USER_MANAGER);
                break;
        }
        if ($session->getLoggedin()) {
            header("Location:" . $user->getPage());
        }
    } else {
        if ($user && $user->getValidate() != 1) {
            $msg = "Sorry. You are not yet validated. Contact Events Incharge.";
コード例 #6
0
ファイル: login.php プロジェクト: jetmirhaxhisefa/rezervime
<?php

require_once '../model/paths.php';
$session = new Session();
$user = new User();
$database = new Database();
$username = $database->escapeString($_POST['username']);
$password = $database->escapeString($_POST['password']);
if ($username == "" || $password == "") {
    // if user or password fields are empty
    redirect("../login.php?error=fill");
} else {
    $user->setUsername($username);
    $user->setPassword($password);
    // 		check the user
    if ($user->authenticate($database)) {
        $session->logIn($user);
        $database->disconnectDb();
        $path = "../logs";
        $dateTime = strftime("%Y-%m-%d %H:%M:%S");
        $text = "Logged In";
        $content = $dateTime . " " . $_SESSION['USNM'] . ": " . $text;
        $user->setId($_SESSION['USID']);
        $user->storeLog($content, $path);
        redirect("../cms-admin.php");
    } else {
        redirect("../login.php?error=login");
    }
    $database->disconnectDb();
}