2024-01-16 19:24:40 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
function getProtocol(){
|
|
|
|
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && !empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
|
|
|
|
return "https://";
|
|
|
|
} else {
|
|
|
|
return "http://";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getPage($routerConfig){
|
2024-01-16 19:38:42 +01:00
|
|
|
$page_dir = "pages/";
|
2024-01-16 19:24:40 +01:00
|
|
|
|
|
|
|
$dynamic_page_file = $page_dir . $subdomain . "/" . $page_name . ".php";
|
|
|
|
$page_file = $page_dir . $subdomain . "/" . $page_name . ".html";
|
|
|
|
|
|
|
|
$dynamic_page_file_global = $page_dir . "global/" . $page_name . ".php";
|
|
|
|
$page_file_global = $page_dir . "global/" . $page_name . ".html";
|
|
|
|
|
|
|
|
$skeleton = file_get_contents($template_dir . "skeleton.html");
|
|
|
|
$nav = file_get_contents($template_dir . "nav.html");
|
|
|
|
|
|
|
|
if (file_exists($dynamic_page_file_global)){
|
|
|
|
$page = include_once $dynamic_page_file_global;
|
|
|
|
}
|
|
|
|
elseif (file_exists($page_file_global)){
|
|
|
|
$page = file_get_contents($page_file_global);
|
|
|
|
}
|
|
|
|
elseif (file_exists($dynamic_page_file)){
|
|
|
|
$page = include_once $dynamic_page_file;
|
|
|
|
}
|
|
|
|
elseif (file_exists($page_file)){
|
|
|
|
$page = file_get_contents($page_file);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$page = file_get_contents($template_dir . "404.html");
|
2024-01-16 19:38:42 +01:00
|
|
|
}
|
|
|
|
$navpages = generateNavigation($static_page_dir, $protocol, $subdomain, $domain, $tld, $default_page, $page_name);
|
|
|
|
|
|
|
|
$nav = str_replace("__NAV_PAGES__", $navpages, $nav);
|
|
|
|
|
|
|
|
$out = $skeleton;
|
|
|
|
$out = str_replace("__TEMPLATE__NAV__", $nav, $out);
|
|
|
|
$out = str_replace("__TEMPLATE__PAGE__", $page, $out);
|
|
|
|
$out = str_replace("__TEMPLATE_PAGE_NAME__", $page_name, $out);
|
|
|
|
return $out;
|
2024-01-16 19:24:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|