<?php

mb_internal_encoding("utf-8"); // Internal encoding set to UTF-8, should fix some charset issues.

session_start(); // Start PHP session, so we can handle session-data on all pages.

require_once("include.php"); // Our includes.

/*
 * Check if user is logged in. If not, show login page.
 


if (User::checkLogin() != true) {
    header("Location: login.php");
}

*/

if (isset($_GET['page'])) { // Figure out what page needs to be displayed
    $page = $_GET['page'];
} else { // If nothing is defined, lets assume we have to display the frontpage/index
    header('Location: ' . Config::$sys_url .'?page=home');
    //$page = "home"; // Setting page to home.php - Note: This is possible, but we would rather want to redirect to the home instead - For searchengines you know..
}
/* Sidenote: Its important to specify the dir content, as we dont want people to be able to just ../ to another dir. */
if (IS_FILE("content/" . $page . ".php")) { // Check if the file exists, if yes lets show it - If not, lets show our 404
    include 'content/' . $page . '.php';
} else {
    include 'content/error.php';
}

/*
 * Perform LOG procedure to all page calls, unless debug mode is enabled.
 */
if (Config::$debug == false) {
    Log::writeLog("1", $_SESSION['user'], "Visited page $page");
}