feat: make the website load for different subdomains

This commit is contained in:
David Bailey 2024-01-11 10:37:19 +01:00
parent f00e97d294
commit d39595d577
4 changed files with 80 additions and 54 deletions

View file

@ -7,7 +7,20 @@ require_once 'vendor/autoload.php';
require_once 'post_adapter.php';
require_once 'fontawesome.php';
$adapter = new PostHandler();
use Symfony\Component\Yaml\Yaml;
$SERVER_HOST = $_SERVER['HTTP_HOST'];
if(!preg_match('/^[\w\.]+$/', $SERVER_HOST)) {
die();
}
$SERVER_PREFIX = "https://" . $SERVER_HOST;
$SITE_CONFIG = Yaml::parseFile('secrets/' . $SERVER_HOST . '.config.yml');
$SITE_CONFIG['uri_prefix'] = $SERVER_PREFIX;
$SITE_CONFIG['HTTP_HOST'] = $SERVER_HOST;
$adapter = new PostHandler($SITE_CONFIG);
$loader = new \Twig\Loader\FilesystemLoader(['./templates', './user_content']);