forked from Adleraci/adlerka.top
test
This commit is contained in:
parent
3b3a504c9f
commit
f1dc7d866f
26
lib/page.php
26
lib/page.php
@ -1,8 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
function renderDynamicPage($page_file): false|string
|
function renderDynamicPage($page_file): array
|
||||||
{
|
{
|
||||||
require_once $page_file;
|
require_once $page_file;
|
||||||
return render();
|
$page_parameters = get_parameters();
|
||||||
|
$page_content = render();
|
||||||
|
return ["output" => $page_content, "parameters" => $page_parameters];
|
||||||
}
|
}
|
||||||
|
|
||||||
function parsePageTag($input): array
|
function parsePageTag($input): array
|
||||||
@ -49,16 +51,26 @@ function getPage($page_name = null): array|false|string
|
|||||||
$nav = file_get_contents($routerConfig["template_dir"] . "nav.html");
|
$nav = file_get_contents($routerConfig["template_dir"] . "nav.html");
|
||||||
|
|
||||||
if (file_exists($dynamic_page_file_global)){
|
if (file_exists($dynamic_page_file_global)){
|
||||||
$page = renderDynamicPage($dynamic_page_file_global);
|
$pageMetadata = renderDynamicPage($dynamic_page_file_global);
|
||||||
|
$page = $pageMetadata["output"];
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif (file_exists($page_file_global)){
|
elseif (file_exists($page_file_global)){
|
||||||
$page = file_get_contents($page_file_global);
|
$pagetmp = file_get_contents($page_file_global);
|
||||||
|
|
||||||
|
$pageMetadata = parsePageTag($pagetmp);
|
||||||
|
$page = $pageMetadata["output"];
|
||||||
}
|
}
|
||||||
elseif (file_exists($dynamic_page_file)){
|
elseif (file_exists($dynamic_page_file)){
|
||||||
$page = renderDynamicPage($dynamic_page_file);
|
$pageMetadata = renderDynamicPage($dynamic_page_file);
|
||||||
|
|
||||||
|
$page = $pageMetadata["output"];
|
||||||
}
|
}
|
||||||
elseif (file_exists($page_file)){
|
elseif (file_exists($page_file)){
|
||||||
$page = file_get_contents($page_file);
|
$pagetmp = file_get_contents($page_file);
|
||||||
|
|
||||||
|
$pageMetadata = parsePageTag($pagetmp);
|
||||||
|
$page = $pageMetadata["output"];
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$page = file_get_contents($routerConfig["template_dir"] . "404.html");
|
$page = file_get_contents($routerConfig["template_dir"] . "404.html");
|
||||||
@ -85,9 +97,11 @@ function getPage($page_name = null): array|false|string
|
|||||||
if($page_required_permission < $_SESSION["privilegelevel"]){
|
if($page_required_permission < $_SESSION["privilegelevel"]){
|
||||||
if($is_secret_page == 1) {
|
if($is_secret_page == 1) {
|
||||||
$page = file_get_contents($routerConfig["template_dir"] . "404.html"); //fake 404 error
|
$page = file_get_contents($routerConfig["template_dir"] . "404.html"); //fake 404 error
|
||||||
|
http_response_code(404);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$page = file_get_contents($routerConfig["template_dir"] . "403.html"); //deny access if doesnt have permissions
|
$page = file_get_contents($routerConfig["template_dir"] . "403.html"); //deny access if doesnt have permissions
|
||||||
|
http_response_code(403);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,12 @@
|
|||||||
|
|
||||||
require_once "lib/router.php";
|
require_once "lib/router.php";
|
||||||
|
|
||||||
function render(): false|string
|
function get_parameters():array
|
||||||
|
{
|
||||||
|
return ["minimal_permission_level" => 0, "secret" => 0, "page_title" => "Domov"];
|
||||||
|
}
|
||||||
|
|
||||||
|
function render(): string
|
||||||
{
|
{
|
||||||
global $routerConfig;
|
global $routerConfig;
|
||||||
|
|
||||||
|
6
templates/500.html
Normal file
6
templates/500.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<div class="wrapper-500">
|
||||||
|
<h2>Niekto to pobabral</h2>
|
||||||
|
<h1 class="error-code">500</h1>
|
||||||
|
<h3><i class="fa-solid fa-circle-exclamation error"></i> Nejaký neschopný vývojár nevedel robiť túto stránku: <span class="error">__TEMPLATE_PAGE_NAME__</span>. <i class="fa-solid fa-circle-exclamation error"></i></h3>
|
||||||
|
<a href="/domov" class="back"><i class="fa-solid fa-arrow-left"></i> SPÄŤ DOMOV</a>
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user