adlerka.space/index.php
2024-01-16 19:25:03 +01:00

46 lines
1.1 KiB
PHP

<?php
require "secrets/config.php";
require "lib/navpages.php";
require "lib/routing.php";
$default_page = "domov";
$default_site = "home";
$template_dir = "templates/";
$static_page_dir = "pages/";
$dynamic_page_dir = "dynamic/";
$subdomain = basename(explode('.', $_SERVER['HTTP_HOST'])[0]);
$domain = basename(explode('.', $_SERVER['HTTP_HOST'])[1]);
$tld = basename(explode('.', $_SERVER['HTTP_HOST'])[2]);
$page_name = basename($_SERVER["QUERY_STRING"]);
$protocol = getProtocol();
if (empty($tld)){
header("Location: $protocol$default_site.$subdomain.$domain/$default_page");
return;
}
if (empty($page_name)){
header("Location: $protocol$subdomain.$domain.$tld/$default_page");
return;
}
session_set_cookie_params(0, '/', ".$domain.$tld", true, true);
session_start();
$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);
echo $out;
?>