<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/bootstrap.php';
\MyClasses\Auth\AuthMaster::redirectIfLoggedIn('/');
$page['title'] = 'New User';
echo get_partial('header.php', ['page' => $page]);
?>

<div class="jumbotron">
    <h1>Log In</h1>
    <form action="/sessions/create.php" method="POST" class="form-horizontal">
        <div class="form-group">
            <div class="col-sm-5">
                <label class="sr-only">Email</label>
                <input type="email" name="email" placeholder="Your Email" class="form-control input-lg">
            </div>
            <div class="col-sm-5">
                <label class="sr-only">Password</label>
                <input type="password" name="password" placeholder="Your Password" class="form-control input-lg">
            </div>
            <div class="col-sm-2">
                <button class="btn btn-lg btn-block btn-primary">Log In</button>
            </div>
        </div>
    </form>
</div>

<?php 
echo get_partial('footer.php');
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/bootstrap.php';
$rules = ['email' => ["email"], 'password' => ["not_empty"]];
$validator = new \MyClasses\Validation\Validator();
$validator->validate($rules, $_POST);
$validator->redirectWithErrorsIfFailed('/users/login.php');
$user = \MyClasses\Models\User::getOneBy('email', $_POST['email']);
$hashed = $user['encrypted_password'];
$password_is_correct = password_verify($_POST['password'], $hashed);
if ($password_is_correct) {
    \MyClasses\Auth\AuthMaster::logUserInUsingId($user['id']);
    redirect_user('/users/index.php', "Log in success. Congratulations, {$user['first_name']}!");
} else {
    redirect_user('/users/login.php', "Wrong password! Try again...");
}
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/bootstrap.php';
\MyClasses\Auth\AuthMaster::redirectIfNotLoggedIn();
$page['title'] = 'People';
echo get_partial('header.php', ['page' => $page]);
$wheres = [];
$order_bys = [];
if (!empty($_GET['older_than'])) {
    $wheres[] = ['age', '>=', $_GET['older_than']];
}
if (!empty($_GET['order_by'])) {
    $order_bys[] = $_GET['order_by'];
}
$people = \MyClasses\Models\Person::getAll($wheres, $order_bys);
$existing_query_params = $_GET;
?>

<div class="row">
    <div class="col-sm-4">
        <h1>All People</h1>
    </div>
    <div class="col-sm-8">
        <form action="">
            <div class="row" style="padding-top: 40px;">
                <div class="col-sm-3 text-right">
                    <label>Minimum Age: </label>
                </div>
                <div class="col-sm-3">
                    <input type="number" min="18" name="older_than" value="<?php 
echo !empty($_GET['older_than']) ? $_GET['older_than'] : '';
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/bootstrap.php';
\MyClasses\Auth\AuthMaster::logOut();
redirect_user('/', 'You have been logged out');
<?php

$links_logged_in = ['/logout.php' => 'Log Out'];
$links_logged_out = ['/users/new.php' => 'Sign Up', '/users/login.php' => 'Log In'];
$links_general = ['/users/index.php' => 'Users', '/uploads/index.php' => 'Image Gallery'];
$links_dropdown = ['/people/index.php' => 'Top Secret', '/people/index.php' => 'P - Index', '/people/new.php' => 'P - New', '/people/show.php' => 'P - Show', '/people/edit.php' => 'P - Edit', '/register_pet.php' => 'Pet Form', '/pets.php' => 'Pets', '/table.php' => 'A Table', '/multiplication.php' => 'Multiplication', '/contact.php' => 'Contact Form'];
$links_primary = \MyClasses\Auth\AuthMaster::checkIfLoggedIn() ? $links_logged_in : $links_logged_out;
$links_primary = array_merge($links_primary, $links_general);
?>
<nav class="navbar navbar-default" role="navigation">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="/">Vanilla PHP Wonderland</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse navbar-ex1-collapse">
        <ul class="nav navbar-nav navbar-right">

            <?php 
foreach ($links_primary as $href => $link_text) {
    ?>
                <li class="<?php 
    echo strpos($_SERVER['REQUEST_URI'], preg_replace('/\\.php/', '', trim($href, "/"))) ? 'active' : '';
    ?>
<?php

session_start();
$current_user = \MyClasses\Auth\AuthMaster::getCurrentUser();