Regarding modifications in the bootstrap.php, basically I am thinking to replace the following code:
// Where the Settings.php file is located
$settings_loc = __DIR__ . '/Settings.php';
With this:
global $dboardurl, $dhost, $tboardurl, $thost;
// Get default $boardurl and $cookiename from default Settings.php
$ds_loc = __DIR__ . '/Settings.php';
$bu_ori = array();
$handle = @fopen($ds_loc, 'r');
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle);
if(strpos($buffer, '$boardurl') !== FALSE)
$bu_ori[] = $buffer;
if(strpos($buffer, '$cookiename') !== FALSE)
$cn_ori[] = $buffer;
}
fclose($handle);
}
preg_match('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $bu_ori[0], $bu_match);
$dboardurl = $bu_match[0];
$dhost = parse_url($dboardurl, PHP_URL_HOST) . (!empty(parse_url($dboardurl, PHP_URL_PATH)) ? parse_url($dboardurl, PHP_URL_PATH) : '');
preg_match("/(?:(?:\"(?:\\\\\"|[^\"])+\")|(?:'(?:\\\'|[^'])+'))/is", $cn_ori[0], $cn_match);
$dcookie = str_replace("'", '', $cn_match[0]);
// Now define tenancy host and boardurl
$thost = $_SERVER['HTTP_HOST'] . (!empty(str_replace('/index.php', '', $_SERVER['SCRIPT_NAME'])) ? str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']) : '');
$tboardurl = parse_url($dboardurl, PHP_URL_SCHEME) . '://' . $thost;
// Where the Settings.php file is located
if ($dhost === $thost)
$settings_loc = $ds_loc;
else {
$settings_loc = __DIR__ . '/.tenancy/' . str_replace('/', '.', $thost) . '.php';
if (!file_exists($settings_loc)) {
copy($ds_loc, $settings_loc);
file_put_contents($settings_loc, str_replace($dhost, $thost, file_get_contents($settings_loc)));
file_put_contents($settings_loc, str_replace($dcookie, uniqid(), file_get_contents($settings_loc)));
}
}
This will basically check the default $boardurl and $cookiename in default Settings.php and create a new settings (copied from default) for each tenant in .tenancy folder with its own tenancy $boardurl and $cookiename.
Edited: I think this modification can be done via bootsrap.php extension like "class TenantBootstrap extend Bootstrap" something and then overwrite the whole "private function loadSettingsFile()" overriding with "public function bringUpBasics()" (since private cannot be overriden by child class or something like that) but I am not so sure on how to achieve that in ElkArte yet.
I think I might attend the later approach, later.