Files
assetmgt/settings/settings_redirector.php
2025-03-13 12:41:11 +01:00

28 lines
919 B
PHP

<?php
//=========================================
//REDIRECTOR TO CONFIG FILE BASED ON DOMAIN
//=========================================
$parts = explode('.', $_SERVER['SERVER_NAME']);
$count = count($parts);
// For hostnames with enough parts to have a subdomain (at least 3 parts)
if ($count >= 3) {
// Return the second-to-last and third-to-last parts
$domain = $parts[$count - 2];
}
// For hostnames with just domain and TLD (2 parts)
else if ($count == 2) {
// Return just the domain part (without the TLD)
$domain = $parts[0];
}
// If it's a single part hostname
else {
$domain = $hostname;
}
$settings_location = ((file_exists(dirname(__FILE__).'/'.$domain.'/'.$domain.'_settings.php')) ? dirname(__FILE__).'/'.$domain.'/'.$domain.'_settings.php' : dirname(__FILE__).'/settings.php');
include $settings_location;
?>