FaZeBookSocialNetwork / www / public / index.php
index.php
Raw
<?php

// RedBeanPHP's single file (rb.php) does not support autoloading
require_once(__DIR__ . '/../lib/RedBeanPHP/rb.php');

spl_autoload_register(function($class) {
    $file = '../src/' . str_replace('\\','/', $class) . '.php';
    if(file_exists($file)) { require_once($file); }
});

use FaZeBook\Session;
use FaZeBook\Permission;

if (!Session::getInstance()->isLoggedIn()) {
    $app = new \FaZeBook\LoginApplication();

    $pageLogin = new \FaZeBook\Page\Login();
    $pageRegister = new \FaZeBook\Page\Register();

    $app->addPage($pageLogin);
    $app->addPage($pageRegister);
} else {
    if (!isset($lazyLoad)) {
        $app = new \FaZeBook\Application();
    } else {
        $app = new \FaZeBook\LazyLoadApplication();
    }

    $pageStart = new \FaZeBook\Page\Start();
    $pageLogout = new \FaZeBook\Page\Logout();
    $pageViewProfile = new \FaZeBook\Page\ViewProfile();
    $pageEditProfile = new \FaZeBook\Page\EditProfile();
    $pageMessengerAPI = new \FaZeBook\Page\MessengerAPI();
    $pageSearchResults = new \FaZeBook\Page\Search();
    $pageActivityFeedAPI = new \FaZeBook\Page\ActivityFeedAPI();

    $app->addPage($pageStart);
    $app->addPage($pageViewProfile);
    $app->addPage($pageEditProfile);
    $app->addPage($pageMessengerAPI);
    $app->addPage($pageSearchResults);
    $app->addPage($pageActivityFeedAPI);

    if(Session::getInstance()->currentUser()->hasPermissions(Permission::ADMIN)){
        $pageAdministration = new \FaZeBook\Page\Administration();
        $app->addPage($pageAdministration);
    }

    $app->addPage($pageLogout);
}

$app->generateNavigationItems();
$app->run();