* @desc   if session user get Dashboard
* @desc   if not redirecto to login page
*/
$p->route('/', function () use($p) {
    if (Session::exists('user')) {
        // show dashboard
        $p->view('index', ['title' => $p::$lang['Dashboard'], 'pages' => count(File::scan(ROOTBASE . DS . 'storage' . DS . 'pages', 'md')), 'images' => count(File::scan(ROOTBASE . DS . 'public' . DS . 'images')), 'uploads' => count(File::scan(ROOTBASE . DS . 'public' . DS . 'uploads')), 'blocks' => count(File::scan(ROOTBASE . DS . 'storage' . DS . 'blocks', 'md')), 'themes' => count(Dir::scan(ROOTBASE . DS . 'themes' . DS)), 'plugins' => count(Dir::scan(ROOTBASE . DS . 'plugins' . DS))]);
    } else {
        // empty error
        $error = '';
        if (Request::post('login')) {
            if (Request::post('csrf')) {
                if (Request::post('pass') == $p::$site['backend_password'] && Request::post('email') == $p::$site['autor']['email']) {
                    @Session::start();
                    Session::set('user', uniqid('morfy_user'));
                    Request::redirect($p::$site['url'] . '/' . $p::$site['backend_folder']);
                } else {
                    // password not correct show error
                    $error = '<span class="login-error error">' . $p::$lang['Password_Error'] . '</span>';
                }
            } else {
                // crsf
                die('crsf detect');
            }
        }
        // get template login
        $p->view('login', ['error' => $error]);
    }
});
/*
* @name   Pages
* @desc   if session user get Pages
Example #2
0
/*
** CONTEST PORTAL v3 
** Created By Andy Sturzu (sturzu.org)
*/
require_once dirname(__FILE__) . '/app/config/config.php';
require_once dirname(__FILE__) . '/app/frameworks/panel.php';
require_once dirname(__FILE__) . '/app/functions/functions.php';
session_start();
session_regenerate_id();
date_default_timezone_set('America/Chicago');
$panel = new Panel('panel', false, 'logs/' . date('Y-m-d') . '.txt');
//include default routing engine with logs enabled
$panel->route('/', function ($panel) {
    //index router, check for login
    $schools = json_decode(file_get_contents(dirname(__FILE__) . "/app/config/schools.json"), true);
    if (!isLoggedIn()) {
        return $panel->render("login.html", ["title" => title, "contest_name" => contest_name, "schools" => $schools]);
    }
    return $panel->render("home.html", ["title" => title, "contest_name" => contest_name, "t" => $_SESSION['team'], "navbar_title" => navbar_title, "written" => getTeamWritten(), "info" => getTeamInfo(), "pizza_ordered" => hasOrderedPizza($_SESSION['team'])]);
});
$panel->route('/scoreboard', function ($panel) {
    $schools = json_decode(file_get_contents(dirname(__FILE__) . "/app/config/schools.json"), true);
    if (!isLoggedIn()) {
        return $panel->render("login.html", ["title" => title, "contest_name" => contest_name, "schools" => $schools]);
    }
    return $panel->render("scoreboard.html", ["title" => title, "contest_name" => contest_name]);
});
$panel->route('/admin', function ($panel) {
    if (adminIsLoggedIn()) {
        return $panel->render("admin.html", []);
    }
    return $panel->render("adminlogin.html", []);
<?php

defined('PANEL_ACCESS') or die('No direct script access.');
// new panel
$p = new Panel();
/*  PAGES AND BLOCKS SECTION GOES HERE
------------------------------------------------*/
include_once 'inc/pages.php';
/*  ACTIONS GOES HERE
------------------------------------------------*/
$inc = array('search', 'preview', 'edit', 'newfile', 'newfolder', 'rename', 'removefile', 'removefolder');
foreach ($inc as $inc_file) {
    include_once "inc/{$inc_file}.php";
}
/*
* @name   Logout
* @desc   rediterct to hombe url
*/
$p->route('/action/logout', function () use($p) {
    if (Session::exists('user')) {
        Session::delete('user');
        Session::destroy();
        Request::redirect($p::$site['url']);
    }
});
// start
$p->lauch();