This commit is contained in:
2024-01-16 19:24:40 +01:00
parent 00208e3d03
commit dbda11e974
6 changed files with 178 additions and 90 deletions

View File

@@ -1,8 +1,7 @@
<?php
require "secrets/config.php";
require "templates/navpages.php";
session_start();
require "lib/navpages.php";
require "lib/routing.php";
$default_page = "domov";
@@ -17,12 +16,8 @@ $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"]);;
$srvname = $_SERVER["SERVER_NAME"];
$protocol = $_SERVER['PROTOCOL'] = isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) ? "https://" : "http://";
$page_name = basename($_SERVER["QUERY_STRING"]);
$protocol = getProtocol();
if (empty($tld)){
header("Location: $protocol$default_site.$subdomain.$domain/$default_page");
@@ -34,31 +29,8 @@ if (empty($page_name)){
return;
}
$dynamic_page_file = $static_page_dir . $subdomain . "/" . $page_name . ".php";
$page_file = $static_page_dir . $subdomain . "/" . $page_name . ".html";
$dynamic_page_file_global = $static_page_dir . "global/" . $page_name . ".php";
$page_file_global = $static_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");
}
session_set_cookie_params(0, '/', ".$domain.$tld", true, true);
session_start();
$navpages = generateNavigation($static_page_dir, $protocol, $subdomain, $domain, $tld, $default_page, $page_name);