mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-09-07 05:34:12 +08:00
Better cPanel integration #697
This commit is contained in:
parent
3948b11998
commit
b44da10e27
3 changed files with 40 additions and 12 deletions
|
@ -29,15 +29,6 @@
|
||||||
*/
|
*/
|
||||||
//define('APP_DATA_FOLDER_PATH', dirname(__DIR__) . '/snappymail-data/');
|
//define('APP_DATA_FOLDER_PATH', dirname(__DIR__) . '/snappymail-data/');
|
||||||
//define('APP_DATA_FOLDER_PATH', '/var/external-snappymail-data-folder/');
|
//define('APP_DATA_FOLDER_PATH', '/var/external-snappymail-data-folder/');
|
||||||
if (isset($_ENV['CPANEL']) && isset($_ENV['TMPDIR'])) {
|
|
||||||
define('APP_DATA_FOLDER_PATH', $_ENV['TMPDIR'] . '/snappymail/');
|
|
||||||
/*
|
|
||||||
$_ENV['USER'] => <username>
|
|
||||||
$_ENV['HOME'] => /home/<username>
|
|
||||||
$_ENV['TMPDIR'] => /home/<username>/tmp
|
|
||||||
$_ENV['REAL_DBOWNER'] => <username>
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additional configuration file name
|
* Additional configuration file name
|
||||||
|
|
27
snappymail/v/0.0.0/cpanel.php
Normal file
27
snappymail/v/0.0.0/cpanel.php
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// cPanel https://github.com/the-djmaze/snappymail/issues/697
|
||||||
|
if (defined('APP_PLUGINS_PATH') && !empty($_ENV['CPANEL']) && !is_dir(APP_PLUGINS_PATH.'login-remote')) {
|
||||||
|
$asApi = $_ENV['SNAPPYMAIL_INCLUDE_AS_API'];
|
||||||
|
$_ENV['SNAPPYMAIL_INCLUDE_AS_API'] = true;
|
||||||
|
|
||||||
|
\SnappyMail\Repository::installPackage('plugin', 'login-remote');
|
||||||
|
|
||||||
|
$aList = \SnappyMail\Repository::getEnabledPackagesNames();
|
||||||
|
$aList[] = 'login-remote';
|
||||||
|
$oConfig = \RainLoop\Api::Config();
|
||||||
|
$oConfig->Set('plugins', 'enable', true);
|
||||||
|
$oConfig->Set('plugins', 'enabled_list', \implode(',', \array_unique($aList)));
|
||||||
|
$oConfig->Set('login', 'default_domain', 'cpanel');
|
||||||
|
$oConfig->Save();
|
||||||
|
|
||||||
|
$sFile = APP_PRIVATE_DATA.'domains/cpanel.json';
|
||||||
|
if (!file_exists($sFile)) {
|
||||||
|
$config = json_decode(file_get_contents(__DIR__ . '/app/domains/default.json'), true);
|
||||||
|
$config['IMAP']['shortLogin'] = true;
|
||||||
|
$config['SMTP']['shortLogin'] = true;
|
||||||
|
file_put_contents($sFile, json_encode($config, JSON_PRETTY_PRINT));
|
||||||
|
}
|
||||||
|
|
||||||
|
$_ENV['SNAPPYMAIL_INCLUDE_AS_API'] = $asApi;
|
||||||
|
}
|
|
@ -71,16 +71,21 @@ define('APP_PRIVATE_DATA_NAME', $sPrivateDataFolderInternalName ?: '_default_');
|
||||||
unset($sPrivateDataFolderInternalName);
|
unset($sPrivateDataFolderInternalName);
|
||||||
|
|
||||||
if (!defined('APP_DATA_FOLDER_PATH')) {
|
if (!defined('APP_DATA_FOLDER_PATH')) {
|
||||||
$sCustomDataPath = function_exists('__get_custom_data_full_path') ? rtrim(trim(__get_custom_data_full_path()), '\\/') : $sCustomDataPath;
|
// cPanel https://github.com/the-djmaze/snappymail/issues/697
|
||||||
|
if (!empty($_ENV['CPANEL']) && isset($_ENV['TMPDIR'])) {
|
||||||
|
$sCustomDataPath = $_ENV['TMPDIR'] . '/snappymail';
|
||||||
|
} else {
|
||||||
|
$sCustomDataPath = function_exists('__get_custom_data_full_path') ? rtrim(trim(__get_custom_data_full_path()), '\\/') : $sCustomDataPath;
|
||||||
|
}
|
||||||
define('APP_DATA_FOLDER_PATH', strlen($sCustomDataPath) ? $sCustomDataPath.'/' : APP_INDEX_ROOT_PATH.'data/');
|
define('APP_DATA_FOLDER_PATH', strlen($sCustomDataPath) ? $sCustomDataPath.'/' : APP_INDEX_ROOT_PATH.'data/');
|
||||||
unset($sCustomDataPath);
|
|
||||||
}
|
}
|
||||||
|
unset($sCustomDataPath);
|
||||||
|
|
||||||
if (!defined('APP_CONFIGURATION_NAME')) {
|
if (!defined('APP_CONFIGURATION_NAME')) {
|
||||||
define('APP_CONFIGURATION_NAME', function_exists('__get_additional_configuration_name')
|
define('APP_CONFIGURATION_NAME', function_exists('__get_additional_configuration_name')
|
||||||
? trim(__get_additional_configuration_name()) : $sCustomConfiguration);
|
? trim(__get_additional_configuration_name()) : $sCustomConfiguration);
|
||||||
unset($sCustomConfiguration);
|
|
||||||
}
|
}
|
||||||
|
unset($sCustomConfiguration);
|
||||||
|
|
||||||
$sData = is_file(APP_DATA_FOLDER_PATH.'DATA.php') ? file_get_contents(APP_DATA_FOLDER_PATH.'DATA.php') : '';
|
$sData = is_file(APP_DATA_FOLDER_PATH.'DATA.php') ? file_get_contents(APP_DATA_FOLDER_PATH.'DATA.php') : '';
|
||||||
define('APP_PRIVATE_DATA', APP_DATA_FOLDER_PATH.'_data_'.($sData ? md5($sData) : '').'/'.APP_PRIVATE_DATA_NAME.'/');
|
define('APP_PRIVATE_DATA', APP_DATA_FOLDER_PATH.'_data_'.($sData ? md5($sData) : '').'/'.APP_PRIVATE_DATA_NAME.'/');
|
||||||
|
@ -158,6 +163,11 @@ if (!ini_get('zlib.output_compression') && !ini_get('brotli.output_compression')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cPanel https://github.com/the-djmaze/snappymail/issues/697
|
||||||
|
if (!empty($_ENV['CPANEL']) && !is_dir(APP_PLUGINS_PATH.'login-remote')) {
|
||||||
|
require __DIR__ . '/cpanel.php';
|
||||||
|
}
|
||||||
|
|
||||||
if (class_exists('RainLoop\\Api')) {
|
if (class_exists('RainLoop\\Api')) {
|
||||||
RainLoop\Api::Handle();
|
RainLoop\Api::Handle();
|
||||||
// NextCloud/OwnCloud?
|
// NextCloud/OwnCloud?
|
||||||
|
|
Loading…
Add table
Reference in a new issue