2024-01-11 09:27:03 +01:00
|
|
|
<?php
|
|
|
|
require "secrets/config.php";
|
|
|
|
|
|
|
|
session_start();
|
|
|
|
|
|
|
|
$default_page = "domov";
|
|
|
|
|
2024-01-12 15:37:02 +01:00
|
|
|
$default_site = "home";
|
|
|
|
|
2024-01-11 09:27:03 +01:00
|
|
|
$template_dir = "templates/";
|
|
|
|
|
2024-01-11 16:00:36 +01:00
|
|
|
$static_page_dir = "pages/";
|
2024-01-11 09:27:03 +01:00
|
|
|
|
|
|
|
$dynamic_page_dir = "dynamic/";
|
|
|
|
|
|
|
|
$subdomain = basename(explode('.', $_SERVER['HTTP_HOST'])[0]);
|
2024-01-11 09:56:09 +01:00
|
|
|
$domain = basename(explode('.', $_SERVER['HTTP_HOST'])[1]);
|
|
|
|
$tld = basename(explode('.', $_SERVER['HTTP_HOST'])[2]);
|
2024-01-11 09:27:03 +01:00
|
|
|
$page_name = basename($_SERVER["QUERY_STRING"]);;
|
|
|
|
|
2024-01-11 09:44:21 +01:00
|
|
|
|
2024-01-11 09:27:03 +01:00
|
|
|
$srvname = $_SERVER["SERVER_NAME"];
|
|
|
|
|
2024-01-11 09:47:52 +01:00
|
|
|
$protocol = $_SERVER['PROTOCOL'] = isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) ? "https://" : "http://";
|
|
|
|
|
2024-01-12 15:37:02 +01:00
|
|
|
if (empty($tld)){
|
|
|
|
header("Location: $protocol$default_site.$subdomain.$domain/$default_page");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-01-11 09:47:52 +01:00
|
|
|
if (empty($page_name)){
|
2024-01-12 15:37:02 +01:00
|
|
|
header("Location: $protocol$subdomain.$domain.$tld/$default_page");
|
2024-01-11 09:47:52 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-01-11 16:00:36 +01:00
|
|
|
$dynamic_page_file = $static_page_dir . $subdomain . "/" . $page_name . ".php";
|
|
|
|
$page_file = $static_page_dir . $subdomain . "/" . $page_name . ".html";
|
2024-01-11 09:27:03 +01:00
|
|
|
|
2024-01-11 16:00:36 +01:00
|
|
|
$dynamic_page_file_global = $static_page_dir . "global/" . $page_name . ".php";
|
|
|
|
$page_file_global = $static_page_dir . "global/" . $page_name . ".html";
|
2024-01-11 09:27:03 +01:00
|
|
|
|
|
|
|
$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-11 10:14:21 +01:00
|
|
|
$navpages = include_once $template_dir . "navpages.php";
|
|
|
|
|
|
|
|
$nav = str_replace("__NAV_PAGES__", $navpages, $nav);
|
2024-01-11 09:27:03 +01:00
|
|
|
|
|
|
|
$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);
|
|
|
|
|
|
|
|
echo $out;
|
|
|
|
|
|
|
|
?>
|