2018-06-12 07:53:27 +02:00
|
|
|
<?PHP
|
|
|
|
/**
|
|
|
|
* The main display file for standalone pages.
|
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@jrenslin.de>
|
|
|
|
*/
|
|
|
|
|
2018-06-15 11:26:25 +02:00
|
|
|
// Include functions and settings.
|
|
|
|
|
|
|
|
require_once __DIR__ . "/inc/functions.php";
|
|
|
|
|
2018-06-13 20:07:24 +02:00
|
|
|
// Check validity of request.
|
|
|
|
|
|
|
|
if (isset($_GET['id']) and !file_exists(__DIR__ . "/data/static/" . $_GET['id'] . ".json")) {
|
2018-06-21 13:25:38 +02:00
|
|
|
echo printErrorPage($settings, "File does not exist.");
|
2018-06-13 20:07:24 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure working environment for frontend.
|
|
|
|
|
2018-06-12 07:53:27 +02:00
|
|
|
ensureEnvironment();
|
2018-06-13 20:07:24 +02:00
|
|
|
$pages = loadPublicPages(); // Load overview of pages.
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Load data.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @var array $tPage The variable contains the main data on the displayed page.
|
|
|
|
*/
|
|
|
|
$tPage = [];
|
|
|
|
|
|
|
|
if (isset($_GET['id'])) $id = $_GET['id'];
|
|
|
|
else if (file_exists(__DIR__ . "/data/static/" . $settings['startPage'] . ".json")) {
|
|
|
|
$id = $settings['startPage'];
|
|
|
|
}
|
|
|
|
else {
|
2018-06-21 13:25:38 +02:00
|
|
|
echo printErrorPage($settings, "This file does not exist.");
|
2018-06-13 20:07:24 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$tPage = json_decode(file_get_contents(__DIR__ . "/data/static/" . $id . ".json"), true);
|
|
|
|
|
|
|
|
if (!$tPage['public']) {
|
|
|
|
if (!(isset($_GET['preview']) and checkPreviewAccess())) {
|
|
|
|
echo printErrorPage("This page is not public."); return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Output
|
|
|
|
*/
|
|
|
|
|
2018-06-15 11:26:25 +02:00
|
|
|
echo printPublicHead($settings, $id, $settings['pageTitle'], $settings['logo']);
|
2018-06-13 20:07:24 +02:00
|
|
|
echo printPublicHeader($settings['pageTitle']);
|
|
|
|
echo printStaticPagePart("banner", "header"); // Print aside (if need be)
|
|
|
|
|
2018-06-15 11:26:25 +02:00
|
|
|
echo generatePublicNav($pages);
|
2018-06-13 20:07:24 +02:00
|
|
|
|
|
|
|
echo '
|
|
|
|
<div id="mainWrapper">
|
|
|
|
';
|
|
|
|
|
|
|
|
// Print main content
|
|
|
|
echo '
|
|
|
|
<main>';
|
|
|
|
|
|
|
|
echo '<h1>' . $tPage['title'] . '</h1>';
|
2018-06-15 11:26:25 +02:00
|
|
|
echo checkForEmbeds($tPage['content'], $settings);
|
2018-06-13 20:07:24 +02:00
|
|
|
|
|
|
|
echo '
|
|
|
|
</main>
|
|
|
|
';
|
|
|
|
|
|
|
|
echo printStaticPagePart("aside", "aside"); // Print aside (if need be)
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</div>';
|
|
|
|
|
|
|
|
echo printStaticPagePart("footer", "footer"); // Print footer (if need be)
|
2018-06-12 07:53:27 +02:00
|
|
|
|
2018-06-13 20:07:24 +02:00
|
|
|
echo printPublicEnd();
|
2018-06-12 07:53:27 +02:00
|
|
|
|
|
|
|
?>
|
|
|
|
|