<?php

session_start();
unset($_SESSION['admin']);
session_destroy();
require_once 'lib/GrlxView.php';
require_once 'lib/GrlxView_Login.php';
$view = new GrlxView_Login();
$view->page_title('Logged out');
$view->headline('See you next time');
$view->main_id('logout');
$view->action('<div><a class="btn primary login" href="panl.login.php"><i></i>Login again</a></div>');
/*****
 * Display
 */
$output = $view->open_view();
$output .= '<p>You are now logged out of the Grawlix Panel.</p>';
$output .= $view->format_actions();
$output .= $view->close_view();
print $output;
<?php

/* ! Setup * * * * * * * */
$except = true;
require_once 'panl.init.php';
require_once '../_system/password.php';
// Send admin to specific page
$ref = $_GET['ref'];
$ref ? $ref : ($ref = $_POST['ref']);
$ref ? $ref : ($ref = 'book.view.php');
$view = new GrlxView_Login();
$view->page_title('Login');
$view->headline('Login to your Grawlix Panel');
$view->main_id('password');
// Set a cookie good for the entire domain
// Show the admin bar on the front-end
function grlx_cookie()
{
    $expiry = 86400 * 30;
    // 86400 = 1 day
    setcookie('grlx_bar', true, time() + $expiry, '/');
    return;
}
if ($_POST['submit'] == 'Login') {
    $var_list = array('username', 'extra');
    if ($var_list) {
        foreach ($var_list as $key => $val) {
            ${$val} = register_variable($val);
        }
    }
    if ($username && $extra) {
<?php

/*****
 * Setup
 */
$except = true;
require_once 'panl.init.php';
require_once '../_system/password.php';
$var_list = array('email', 'new_password', 's');
if ($var_list) {
    foreach ($var_list as $key => $val) {
        ${$val} = register_variable($val);
    }
}
$view = new GrlxView_Login();
$view->page_title('Reset password: step two');
$view->headline('Reset password: step two');
$view->main_id('reset');
$form = new GrlxForm();
$form->send_to($_SERVER['SCRIPT_NAME']);
/*****
 * Updates
 */
// When the user submits a form
if ($new_password && $s) {
    // Give the user a new serial number.
    for ($i = 0; $i < 16; $i++) {
        $new_serial .= rand(0, 9);
    }
    $new_hash = password_hash($new_password, PASSWORD_BCRYPT);
    if (password_verify($new_password, $new_hash)) {
<?php

/*****
 * Setup
 */
$except = true;
require_once 'panl.init.php';
$var_list = array('email', 'new_password', 's');
if ($var_list) {
    foreach ($var_list as $key => $val) {
        ${$val} = register_variable($val);
    }
}
$view = new GrlxView_Login();
$view->page_title('Reset password: step one');
$view->headline('Reset password: step one');
$view->main_id('forgot');
$form = new GrlxForm();
$form->send_to($_SERVER['SCRIPT_NAME']);
/*****
 * Updates
 */
// When the user submits a form
if ($email && !$s) {
    // Check if valid user
    $user = $db->where('email', $email)->getOne('user', 'count(*) AS count');
    if ($user['count'] == 1) {
        // Give the user a new serial number.
        for ($i = 0; $i < 16; $i++) {
            $new_serial .= rand(0, 9);
        }