mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-09-13 00:24:24 +08:00
Bugfix MULTIDOMAIN and cleanup localhost and fix the default.ini
This commit is contained in:
parent
f92d453e8b
commit
6d958081c4
6 changed files with 33 additions and 51 deletions
16
snappymail/v/0.0.0/app/domains/default.ini
Normal file
16
snappymail/v/0.0.0/app/domains/default.ini
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
imap_host = "localhost"
|
||||||
|
imap_port = 143
|
||||||
|
imap_secure = "None"
|
||||||
|
imap_short_login = Off
|
||||||
|
sieve_use = Off
|
||||||
|
sieve_host = "localhost"
|
||||||
|
sieve_port = 4190
|
||||||
|
sieve_secure = "None"
|
||||||
|
smtp_host = "localhost"
|
||||||
|
smtp_port = 25
|
||||||
|
smtp_secure = "None"
|
||||||
|
smtp_short_login = Off
|
||||||
|
smtp_auth = On
|
||||||
|
smtp_set_sender = Off
|
||||||
|
smtp_php_mail = Off
|
||||||
|
white_list = ""
|
|
@ -1,7 +0,0 @@
|
||||||
imap_host = "IMAP_HOST"
|
|
||||||
imap_port = IMAP_PORT
|
|
||||||
imap_secure = "SSL"
|
|
||||||
smtp_host = "SMTP_HOST"
|
|
||||||
smtp_port = SMTP_PORT
|
|
||||||
smtp_secure = "SSL"
|
|
||||||
smtp_auth = On
|
|
|
@ -59,7 +59,7 @@ class Http
|
||||||
public function CheckLocalhost(string $sServer) : bool
|
public function CheckLocalhost(string $sServer) : bool
|
||||||
{
|
{
|
||||||
return \in_array(\strtolower(\trim($sServer)), array(
|
return \in_array(\strtolower(\trim($sServer)), array(
|
||||||
'localhost', '127.0.0.1', '::1', '::1/128', '0:0:0:0:0:0:0:1'
|
'localhost', '127.0.0.1', '::1'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -810,7 +810,6 @@ class Actions
|
||||||
if ($bAdmin) {
|
if ($bAdmin) {
|
||||||
$aResult['Auth'] = $this->IsAdminLoggined(false);
|
$aResult['Auth'] = $this->IsAdminLoggined(false);
|
||||||
if ($aResult['Auth']) {
|
if ($aResult['Auth']) {
|
||||||
$aResult['AdminDomain'] = APP_SITE;
|
|
||||||
$aResult['AdminLogin'] = (string)$oConfig->Get('security', 'admin_login', '');
|
$aResult['AdminLogin'] = (string)$oConfig->Get('security', 'admin_login', '');
|
||||||
$aResult['AdminTOTP'] = (string)$oConfig->Get('security', 'admin_totp', '');
|
$aResult['AdminTOTP'] = (string)$oConfig->Get('security', 'admin_totp', '');
|
||||||
$aResult['UseTokenProtection'] = (bool)$oConfig->Get('security', 'csrf_protection', true);
|
$aResult['UseTokenProtection'] = (bool)$oConfig->Get('security', 'csrf_protection', true);
|
||||||
|
|
|
@ -230,7 +230,7 @@ class Service
|
||||||
$sContentSecurityPolicy = \preg_replace('/(img-src[^;]+)\\shttp:(\\s|;|$)/D', '$1$2', $sContentSecurityPolicy);
|
$sContentSecurityPolicy = \preg_replace('/(img-src[^;]+)\\shttp:(\\s|;|$)/D', '$1$2', $sContentSecurityPolicy);
|
||||||
}
|
}
|
||||||
// Internet Explorer does not support 'nonce'
|
// Internet Explorer does not support 'nonce'
|
||||||
if (!isset($_SERVER['HTTP_USER_AGENT']) || (!\strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/') && !\strpos($_SERVER['HTTP_USER_AGENT'], 'Edge/1'))) {
|
if (!$_SERVER['HTTP_USER_AGENT'] || (!\strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/') && !\strpos($_SERVER['HTTP_USER_AGENT'], 'Edge/1'))) {
|
||||||
if ($sScriptNonce) {
|
if ($sScriptNonce) {
|
||||||
$sContentSecurityPolicy = \str_replace('script-src', "script-src 'nonce-{$sScriptNonce}'", $sContentSecurityPolicy);
|
$sContentSecurityPolicy = \str_replace('script-src', "script-src 'nonce-{$sScriptNonce}'", $sContentSecurityPolicy);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,17 +44,6 @@ define('APP_VERSION_ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
|
|
||||||
$sSite = strtolower(trim(empty($_SERVER['HTTP_HOST']) ? (empty($_SERVER['SERVER_NAME']) ? '' : $_SERVER['SERVER_NAME']) : $_SERVER['HTTP_HOST']));
|
|
||||||
$sSite = 'www.' === substr($sSite, 0, 4) ? substr($sSite, 4) : $sSite;
|
|
||||||
$sSite = trim(preg_replace('/^.+@/', '', preg_replace('/:[\d]+$/', '', $sSite)));
|
|
||||||
$sSite = in_array($sSite, array('', 'localhost', '127.0.0.1', '::1', '::1/128', '0:0:0:0:0:0:0:1')) ? 'localhost' : $sSite;
|
|
||||||
|
|
||||||
define('APP_SITE', $sSite);
|
|
||||||
unset($sSite);
|
|
||||||
|
|
||||||
$sPrivateDataFolderInternalName = defined('MULTIDOMAIN') ? APP_SITE : '';
|
|
||||||
define('APP_PRIVATE_DATA_NAME', $sPrivateDataFolderInternalName ?: '_default_');
|
|
||||||
|
|
||||||
define('APP_DUMMY', '********');
|
define('APP_DUMMY', '********');
|
||||||
|
|
||||||
$sCustomDataPath = '';
|
$sCustomDataPath = '';
|
||||||
|
@ -65,6 +54,15 @@ if (is_file(APP_INDEX_ROOT_PATH.'include.php'))
|
||||||
include_once APP_INDEX_ROOT_PATH.'include.php';
|
include_once APP_INDEX_ROOT_PATH.'include.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sPrivateDataFolderInternalName = '';
|
||||||
|
if (defined('MULTIDOMAIN')) {
|
||||||
|
$sPrivateDataFolderInternalName = strtolower(trim(empty($_SERVER['HTTP_HOST']) ? (empty($_SERVER['SERVER_NAME']) ? '' : $_SERVER['SERVER_NAME']) : $_SERVER['HTTP_HOST']));
|
||||||
|
$sPrivateDataFolderInternalName = 'www.' === substr($sPrivateDataFolderInternalName, 0, 4) ? substr($sPrivateDataFolderInternalName, 4) : $sPrivateDataFolderInternalName;
|
||||||
|
$sPrivateDataFolderInternalName = preg_replace('/^.+@/', '', preg_replace('/(.+\\..+):[\d]+$/', '$1', $sPrivateDataFolderInternalName));
|
||||||
|
$sPrivateDataFolderInternalName = in_array($sPrivateDataFolderInternalName, array('', '127.0.0.1', '::1')) ? 'localhost' : $sPrivateDataFolderInternalName;
|
||||||
|
}
|
||||||
|
define('APP_PRIVATE_DATA_NAME', $sPrivateDataFolderInternalName ?: '_default_');
|
||||||
|
|
||||||
defined('APP_USE_APCU_CACHE') || define('APP_USE_APCU_CACHE', true);
|
defined('APP_USE_APCU_CACHE') || define('APP_USE_APCU_CACHE', true);
|
||||||
|
|
||||||
$sCustomDataPath = function_exists('__get_custom_data_full_path') ? rtrim(trim(__get_custom_data_full_path()), '\\/') : $sCustomDataPath;
|
$sCustomDataPath = function_exists('__get_custom_data_full_path') ? rtrim(trim(__get_custom_data_full_path()), '\\/') : $sCustomDataPath;
|
||||||
|
@ -139,47 +137,23 @@ if (APP_VERSION !== $sInstalled || (!is_dir(APP_PRIVATE_DATA) && strlen($sPrivat
|
||||||
|
|
||||||
if (!file_exists(APP_PRIVATE_DATA.'domains/disabled') && is_dir(APP_PRIVATE_DATA.'domains'))
|
if (!file_exists(APP_PRIVATE_DATA.'domains/disabled') && is_dir(APP_PRIVATE_DATA.'domains'))
|
||||||
{
|
{
|
||||||
$sFile = $sNewFile = $sNewFileName = '';
|
$sFile = $sNewFile = '';
|
||||||
$aFiles = glob(APP_VERSION_ROOT_PATH.'app/domains/*');
|
$aFiles = glob(APP_VERSION_ROOT_PATH.'app/domains/*');
|
||||||
|
if (is_array($aFiles) && count($aFiles))
|
||||||
if (is_array($aFiles) && 0 < count($aFiles))
|
|
||||||
{
|
{
|
||||||
foreach ($aFiles as $sFile)
|
foreach ($aFiles as $sFile)
|
||||||
{
|
{
|
||||||
if (is_file($sFile))
|
if (is_file($sFile))
|
||||||
{
|
{
|
||||||
$sNewFileName = basename($sFile);
|
$sNewFile = APP_PRIVATE_DATA.'domains/'.basename($sFile);
|
||||||
if ('default.ini.dist' !== $sNewFileName)
|
if (!file_exists($sNewFile))
|
||||||
{
|
{
|
||||||
$sNewFile = APP_PRIVATE_DATA.'domains/'.$sNewFileName;
|
copy($sFile, $sNewFile);
|
||||||
if (!file_exists($sNewFile))
|
|
||||||
{
|
|
||||||
copy($sFile, $sNewFile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
unset($aFiles, $sFile, $sNewFile);
|
||||||
// $sClearedSiteName = preg_replace('/^(www|demo|snappymail|webmail|email|mail|imap|imap4|smtp)\./i', '', trim(APP_SITE));
|
|
||||||
// if (!empty($sClearedSiteName) && file_exists(APP_VERSION_ROOT_PATH.'app/domains/default.ini.dist') &&
|
|
||||||
// !file_exists(APP_PRIVATE_DATA.'domains/'.$sClearedSiteName.'.ini'))
|
|
||||||
// {
|
|
||||||
// $sConfigTemplate = file_get_contents(APP_VERSION_ROOT_PATH.'app/domains/default.ini.dist');
|
|
||||||
// if (!empty($sConfigTemplate))
|
|
||||||
// {
|
|
||||||
// file_put_contents(APP_PRIVATE_DATA.'domains/'.$sClearedSiteName.'.ini', strtr($sConfigTemplate, array(
|
|
||||||
// 'IMAP_HOST' => 'localhost' !== $sClearedSiteName? 'imap.'.$sClearedSiteName : $sClearedSiteName,
|
|
||||||
// 'IMAP_PORT' => '993',
|
|
||||||
// 'SMTP_HOST' => 'localhost' !== $sClearedSiteName? 'smtp.'.$sClearedSiteName : $sClearedSiteName,
|
|
||||||
// 'SMTP_PORT' => '465'
|
|
||||||
// )));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// unset($sConfigTemplate);
|
|
||||||
// }
|
|
||||||
|
|
||||||
unset($aFiles, $sFile, $sNewFileName, $sNewFile);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue