mirror of
https://github.com/Froxlor/Froxlor.git
synced 2024-09-21 10:27:29 +00:00
remove certificate entry for LE if admin/customer disables LE for a domain
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
parent
76c200a56c
commit
ec6ddd054d
@ -39,7 +39,7 @@ return array(
|
||||
'varname' => 'le_froxlor_enabled',
|
||||
'type' => 'bool',
|
||||
'default' => false,
|
||||
'save_method' => 'storeSettingField',
|
||||
'save_method' => 'storeSettingClearCertificates',
|
||||
'visible' => Settings::Get('system.leenabled')
|
||||
),
|
||||
'system_le_froxlor_redirect' => array(
|
||||
|
@ -1081,8 +1081,12 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
} elseif ($action == 'edit' && $id != 0) {
|
||||
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT `d`.*, `c`.`customerid` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`)
|
||||
WHERE `d`.`parentdomainid` = '0' AND `d`.`id` = :id" . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid"));
|
||||
SELECT `d`.*, `c`.`customerid`
|
||||
FROM `" . TABLE_PANEL_DOMAINS . "` `d`
|
||||
LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`)
|
||||
WHERE `d`.`parentdomainid` = '0'
|
||||
AND `d`.`id` = :id" . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid")
|
||||
);
|
||||
$params = array(
|
||||
'id' => $id
|
||||
);
|
||||
@ -1640,6 +1644,16 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
$log->logAction(ADM_ACTION, LOG_NOTICE, "deleted domain #" . $id . " from mail-tables");
|
||||
}
|
||||
|
||||
// check whether LE has been disabled, so we remove the certificate
|
||||
if ($letsencrypt == '0' && $result['letsencrypt'] == '1') {
|
||||
$del_stmt = Database::prepare("
|
||||
DELETE FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE `domainid` = :id
|
||||
");
|
||||
Database::pexecute($del_stmt, array(
|
||||
'id' => $id
|
||||
));
|
||||
}
|
||||
|
||||
$updatechildren = '';
|
||||
|
||||
if ($subcanemaildomain == '0' && $result['subcanemaildomain'] != '0') {
|
||||
|
@ -720,11 +720,20 @@ if ($page == 'overview') {
|
||||
// trigger when domain id for alias destination has changed: both for old and new destination
|
||||
triggerLetsEncryptCSRForAliasDestinationDomain($result['aliasdomain'], $log);
|
||||
triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $log);
|
||||
} else
|
||||
if ($result['wwwserveralias'] != $wwwserveralias || $result['letsencrypt'] != $letsencrypt) {
|
||||
// or when wwwserveralias or letsencrypt was changed
|
||||
triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $log);
|
||||
}
|
||||
} elseif ($result['wwwserveralias'] != $wwwserveralias || $result['letsencrypt'] != $letsencrypt) {
|
||||
// or when wwwserveralias or letsencrypt was changed
|
||||
triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $log);
|
||||
}
|
||||
|
||||
// check whether LE has been disabled, so we remove the certificate
|
||||
if ($letsencrypt == '0' && $result['letsencrypt'] == '1') {
|
||||
$del_stmt = Database::prepare("
|
||||
DELETE FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE `domainid` = :id
|
||||
");
|
||||
Database::pexecute($del_stmt, array(
|
||||
'id' => $id
|
||||
));
|
||||
}
|
||||
|
||||
inserttask('1');
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2003-2009 the SysCP Team (see authors).
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Functions
|
||||
*
|
||||
*/
|
||||
|
||||
function storeSettingClearCertificates($fieldname, $fielddata, $newfieldvalue) {
|
||||
|
||||
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
||||
|
||||
if ($returnvalue !== false
|
||||
&& is_array($fielddata)
|
||||
&& isset($fielddata['settinggroup'])
|
||||
&& $fielddata['settinggroup'] == 'system'
|
||||
&& isset($fielddata['varname'])
|
||||
&& $fielddata['varname'] == 'le_froxlor_enabled'
|
||||
&& $newfieldvalue == '0'
|
||||
) {
|
||||
Database::query("
|
||||
DELETE FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE `domainid` = '0'
|
||||
");
|
||||
}
|
||||
|
||||
return $returnvalue;
|
||||
}
|
Loading…
Reference in New Issue
Block a user