mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 12:48:26 +02:00
Issue #5458 Also adds support for site_hosts configuration option.
Minimum PHP version set to 8 during installation.
This commit is contained in:
@@ -73,6 +73,13 @@ class e107
|
|||||||
*/
|
*/
|
||||||
protected $HTTP_SCHEME;
|
protected $HTTP_SCHEME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Storage for host configuration from siteurl or e107_config $config['other']['site_hosts']
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $hosts = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for runtime caching of user extended struct
|
* Used for runtime caching of user extended struct
|
||||||
*
|
*
|
||||||
@@ -622,6 +629,11 @@ class e107
|
|||||||
$this->site_path = $this->makeSiteHash($e107_config_mysql_info['defaultdb'], $e107_config_mysql_info['prefix']);
|
$this->site_path = $this->makeSiteHash($e107_config_mysql_info['defaultdb'], $e107_config_mysql_info['prefix']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!empty($e107_config_override['site_hosts']))
|
||||||
|
{
|
||||||
|
$this->hosts = (array) $e107_config_override['site_hosts'];
|
||||||
|
}
|
||||||
|
|
||||||
// Set default folder (and override paths) if missing from e107_config.php
|
// Set default folder (and override paths) if missing from e107_config.php
|
||||||
$this->setDirs($e107_paths, $e107_config_override);
|
$this->setDirs($e107_paths, $e107_config_override);
|
||||||
|
|
||||||
@@ -5534,18 +5546,19 @@ class e107
|
|||||||
*/
|
*/
|
||||||
public function set_urls_deferred()
|
public function set_urls_deferred()
|
||||||
{
|
{
|
||||||
$siteurl = self::getPref('siteurl');
|
$siteurl = self::getPref('siteurl');
|
||||||
$configured_host = parse_url($siteurl, PHP_URL_HOST);
|
$defaultHost = (array) parse_url($siteurl, PHP_URL_HOST);
|
||||||
|
$hosts = !empty($this->hosts) ? $this->hosts : $defaultHost;
|
||||||
|
|
||||||
if(self::isCli())
|
if(self::isCli())
|
||||||
{
|
{
|
||||||
define('SITEURL', $siteurl);
|
define('SITEURL', $siteurl);
|
||||||
define('SITEURLBASE', rtrim(SITEURL,'/'));
|
define('SITEURLBASE', rtrim(SITEURL,'/'));
|
||||||
}
|
}
|
||||||
elseif(!empty($configured_host) && strpos($siteurl,'http')!== false && $configured_host !== $_SERVER['HTTP_HOST'] && substr($_SERVER['HTTP_HOST'], - strlen('.' . $configured_host)) !== ('.' . $configured_host))
|
elseif(!empty($hosts) && !$this->isAllowedHost($hosts, $_SERVER['HTTP_HOST']))
|
||||||
{
|
{
|
||||||
|
error_log('The configured siteurl in your preferences or e107_config "host" value does not match the HTTP_HOST: '.$_SERVER['HTTP_HOST']);
|
||||||
die('Site Configuration Issue Detected. Please contact your webmaster.');
|
die('Site Configuration Issue Detected. Please contact your webmaster.');
|
||||||
error_log('The configured siteurl in your preferences does not match the HTTP_HOST: '.$_SERVER['HTTP_HOST']);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -5553,7 +5566,6 @@ class e107
|
|||||||
define('SITEURL', SITEURLBASE.e_HTTP);
|
define('SITEURL', SITEURLBASE.e_HTTP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// login/signup
|
// login/signup
|
||||||
define('e_SIGNUP', SITEURL.(file_exists(e_BASE.'customsignup.php') ? 'customsignup.php' : 'signup.php'));
|
define('e_SIGNUP', SITEURL.(file_exists(e_BASE.'customsignup.php') ? 'customsignup.php' : 'signup.php'));
|
||||||
|
|
||||||
@@ -5565,6 +5577,34 @@ class e107
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the current host ($_SERVER['HTTP_HOST']) matches any configured host(s).
|
||||||
|
*
|
||||||
|
* @param array $allowedHosts Array of configured hostnames.
|
||||||
|
* @param string $httpHost HTTP_HOST being validated.
|
||||||
|
*
|
||||||
|
* @return bool True if host is allowed, false otherwise.
|
||||||
|
*/
|
||||||
|
private function isAllowedHost(array $allowedHosts, string $httpHost): bool
|
||||||
|
{
|
||||||
|
if (empty($allowedHosts))
|
||||||
|
{
|
||||||
|
error_log('The configured siteurl in your preferences does not contain a a domain name');
|
||||||
|
return true; // Allowed if no hosts.
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($allowedHosts as $host)
|
||||||
|
{
|
||||||
|
if ($httpHost === $host || str_ends_with($httpHost, '.' . $host))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines e_QUERY in a format that can be used in HTML and defines e_MENU
|
* Defines e_QUERY in a format that can be used in HTML and defines e_MENU
|
||||||
* @param boolean $no_cbrace remove curly brackets from the url
|
* @param boolean $no_cbrace remove curly brackets from the url
|
||||||
|
@@ -62,4 +62,4 @@ return [
|
|||||||
'other' => [
|
'other' => [
|
||||||
'site_path' => '000000test'
|
'site_path' => '000000test'
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// minimal software version
|
// minimal software version
|
||||||
define('MIN_PHP_VERSION', '7.4');
|
define('MIN_PHP_VERSION', '8.0');
|
||||||
define('MIN_MYSQL_VERSION', '4.1.2');
|
define('MIN_MYSQL_VERSION', '4.1.2');
|
||||||
define('MAKE_INSTALL_LOG', true);
|
define('MAKE_INSTALL_LOG', true);
|
||||||
|
|
||||||
@@ -1577,8 +1577,9 @@ return [
|
|||||||
'media' => '{$this->e107->e107_dirs['MEDIA_DIRECTORY']}',
|
'media' => '{$this->e107->e107_dirs['MEDIA_DIRECTORY']}',
|
||||||
'system' => '{$this->e107->e107_dirs['SYSTEM_DIRECTORY']}',
|
'system' => '{$this->e107->e107_dirs['SYSTEM_DIRECTORY']}',
|
||||||
],
|
],
|
||||||
'site' => [
|
'other' => [
|
||||||
'site_path' => '{$this->previous_steps['paths']['hash']}',
|
'site_path' => '{$this->previous_steps['paths']['hash']}',
|
||||||
|
// 'site_hosts' => ['localhost','parked-domain.com'],
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
";
|
";
|
||||||
|
Reference in New Issue
Block a user