show ssl-related settings only if customer has ssl-ip assigned (not yet checked per domain); fix hsts-includeSubdomain setting for fresh installations

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2016-11-29 09:34:33 +01:00
parent 56276a19d1
commit 225539d2e7
4 changed files with 18 additions and 16 deletions

View File

@@ -517,7 +517,12 @@ if ($page == 'overview') {
// check if we at least have one ssl-ip/port, #1179 // check if we at least have one ssl-ip/port, #1179
$ssl_ipsandports = ''; $ssl_ipsandports = '';
$ssl_ip_stmt = Database::prepare("SELECT COUNT(*) as countSSL FROM `panel_ipsandports` WHERE `ssl`='1'"); $ssl_ip_stmt = Database::prepare("
SELECT COUNT(*) as countSSL
FROM `".TABLE_PANEL_IPSANDPORTS."` pip
LEFT JOIN `".TABLE_DOMAINTOIP."` dti ON dti.id_ipandports = pip.id
WHERE pip.`ssl`='1'
");
Database::pexecute($ssl_ip_stmt); Database::pexecute($ssl_ip_stmt);
$resultX = $ssl_ip_stmt->fetch(PDO::FETCH_ASSOC); $resultX = $ssl_ip_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($resultX['countSSL']) && (int)$resultX['countSSL'] > 0) { if (isset($resultX['countSSL']) && (int)$resultX['countSSL'] > 0) {
@@ -797,8 +802,13 @@ if ($page == 'overview') {
// check if we at least have one ssl-ip/port, #1179 // check if we at least have one ssl-ip/port, #1179
$ssl_ipsandports = ''; $ssl_ipsandports = '';
$ssl_ip_stmt = Database::prepare("SELECT COUNT(*) as countSSL FROM `panel_ipsandports` WHERE `ssl`='1'"); $ssl_ip_stmt = Database::prepare("
Database::pexecute($ssl_ip_stmt); SELECT COUNT(*) as countSSL
FROM `".TABLE_PANEL_IPSANDPORTS."` pip
LEFT JOIN `".TABLE_DOMAINTOIP."` dti ON dti.id_ipandports = pip.id
WHERE `dti`.`id_domain` = :id_domain AND pip.`ssl`='1'
");
Database::pexecute($ssl_ip_stmt, array("id_domain" => $result['id']));
$resultX = $ssl_ip_stmt->fetch(PDO::FETCH_ASSOC); $resultX = $ssl_ip_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($resultX['countSSL']) && (int)$resultX['countSSL'] > 0) { if (isset($resultX['countSSL']) && (int)$resultX['countSSL'] > 0) {
$ssl_ipsandports = 'notempty'; $ssl_ipsandports = 'notempty';

View File

@@ -544,7 +544,7 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES
('system', 'mail_smtp_user', ''), ('system', 'mail_smtp_user', ''),
('system', 'mail_smtp_passwd', ''), ('system', 'mail_smtp_passwd', ''),
('system', 'hsts_maxage', '0'), ('system', 'hsts_maxage', '0'),
('system', 'hsts_sub', '0'), ('system', 'hsts_incsub', '0'),
('system', 'hsts_preload', '0'), ('system', 'hsts_preload', '0'),
('panel', 'decimal_places', '4'), ('panel', 'decimal_places', '4'),
('panel', 'adminmail', 'admin@SERVERNAME'), ('panel', 'adminmail', 'admin@SERVERNAME'),

View File

@@ -76,10 +76,9 @@ return array(
'section_bssl' => array( 'section_bssl' => array(
'title' => $lng['admin']['webserversettings_ssl'], 'title' => $lng['admin']['webserversettings_ssl'],
'image' => 'icons/domain_add.png', 'image' => 'icons/domain_add.png',
'visible' => Settings::Get('system.use_ssl') == '1' ? true : false, 'visible' => Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports != '' ? true : false) : false,
'fields' => array( 'fields' => array(
'ssl_redirect' => array( 'ssl_redirect' => array(
'visible' => ($ssl_ipsandports != '' ? true : false),
'label' => $lng['domains']['ssl_redirect']['title'], 'label' => $lng['domains']['ssl_redirect']['title'],
'desc' => $lng['domains']['ssl_redirect']['description'], 'desc' => $lng['domains']['ssl_redirect']['description'],
'type' => 'checkbox', 'type' => 'checkbox',
@@ -89,7 +88,7 @@ return array(
'value' => array() 'value' => array()
), ),
'letsencrypt' => array( 'letsencrypt' => array(
'visible' => (Settings::Get('system.leenabled') == '1' ? ($ssl_ipsandports != '' ? true : false) : false), 'visible' => (Settings::Get('system.leenabled') == '1' ? true : false),
'label' => $lng['customer']['letsencrypt']['title'], 'label' => $lng['customer']['letsencrypt']['title'],
'desc' => $lng['customer']['letsencrypt']['description'], 'desc' => $lng['customer']['letsencrypt']['description'],
'type' => 'checkbox', 'type' => 'checkbox',
@@ -99,7 +98,6 @@ return array(
'value' => array() 'value' => array()
), ),
'hsts_maxage' => array( 'hsts_maxage' => array(
'visible' => ($ssl_ipsandports != '' ? true : false),
'label' => $lng['admin']['domain_hsts_maxage']['title'], 'label' => $lng['admin']['domain_hsts_maxage']['title'],
'desc' => $lng['admin']['domain_hsts_maxage']['description'], 'desc' => $lng['admin']['domain_hsts_maxage']['description'],
'type' => 'int', 'type' => 'int',
@@ -108,7 +106,6 @@ return array(
'value' => 0 'value' => 0
), ),
'hsts_sub' => array( 'hsts_sub' => array(
'visible' => ($ssl_ipsandports != '' ? true : false),
'label' => $lng['admin']['domain_hsts_incsub']['title'], 'label' => $lng['admin']['domain_hsts_incsub']['title'],
'desc' => $lng['admin']['domain_hsts_incsub']['description'], 'desc' => $lng['admin']['domain_hsts_incsub']['description'],
'type' => 'checkbox', 'type' => 'checkbox',
@@ -118,7 +115,6 @@ return array(
'value' => array() 'value' => array()
), ),
'hsts_preload' => array( 'hsts_preload' => array(
'visible' => ($ssl_ipsandports != '' ? true : false),
'label' => $lng['admin']['domain_hsts_preload']['title'], 'label' => $lng['admin']['domain_hsts_preload']['title'],
'desc' => $lng['admin']['domain_hsts_preload']['description'], 'desc' => $lng['admin']['domain_hsts_preload']['description'],
'type' => 'checkbox', 'type' => 'checkbox',

View File

@@ -87,10 +87,9 @@ return array(
'section_bssl' => array( 'section_bssl' => array(
'title' => $lng['admin']['webserversettings_ssl'], 'title' => $lng['admin']['webserversettings_ssl'],
'image' => 'icons/domain_edit.png', 'image' => 'icons/domain_edit.png',
'visible' => Settings::Get('system.use_ssl') == '1' ? true : false, 'visible' => Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports != '' ? (domainHasSslIpPort($result['id']) ? true : false) : false) : false,
'fields' => array( 'fields' => array(
'ssl_redirect' => array( 'ssl_redirect' => array(
'visible' => (Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports != '' ? (domainHasSslIpPort($result['id']) ? true : false) : false) : false),
'label' => $lng['domains']['ssl_redirect']['title'], 'label' => $lng['domains']['ssl_redirect']['title'],
'desc' => $lng['domains']['ssl_redirect']['description'] . ($result['temporary_ssl_redirect'] > 1 ? $lng['domains']['ssl_redirect_temporarilydisabled'] : ''), 'desc' => $lng['domains']['ssl_redirect']['description'] . ($result['temporary_ssl_redirect'] > 1 ? $lng['domains']['ssl_redirect_temporarilydisabled'] : ''),
'type' => 'checkbox', 'type' => 'checkbox',
@@ -100,7 +99,7 @@ return array(
'value' => array($result['ssl_redirect']) 'value' => array($result['ssl_redirect'])
), ),
'letsencrypt' => array( 'letsencrypt' => array(
'visible' => (Settings::Get('system.use_ssl') == '1' ? (Settings::Get('system.leenabled') == '1' ? ($ssl_ipsandports != '' ? (domainHasSslIpPort($result['id']) ? true : false) : false) : false) : false), 'visible' => Settings::Get('system.leenabled') == '1' ? true : false,
'label' => $lng['customer']['letsencrypt']['title'], 'label' => $lng['customer']['letsencrypt']['title'],
'desc' => $lng['customer']['letsencrypt']['description'], 'desc' => $lng['customer']['letsencrypt']['description'],
'type' => 'checkbox', 'type' => 'checkbox',
@@ -110,7 +109,6 @@ return array(
'value' => array($result['letsencrypt']) 'value' => array($result['letsencrypt'])
), ),
'hsts_maxage' => array( 'hsts_maxage' => array(
'visible' => ($ssl_ipsandports != '' ? true : false),
'label' => $lng['admin']['domain_hsts_maxage']['title'], 'label' => $lng['admin']['domain_hsts_maxage']['title'],
'desc' => $lng['admin']['domain_hsts_maxage']['description'], 'desc' => $lng['admin']['domain_hsts_maxage']['description'],
'type' => 'int', 'type' => 'int',
@@ -119,7 +117,6 @@ return array(
'value' => $result['hsts'] 'value' => $result['hsts']
), ),
'hsts_sub' => array( 'hsts_sub' => array(
'visible' => ($ssl_ipsandports != '' ? true : false),
'label' => $lng['admin']['domain_hsts_incsub']['title'], 'label' => $lng['admin']['domain_hsts_incsub']['title'],
'desc' => $lng['admin']['domain_hsts_incsub']['description'], 'desc' => $lng['admin']['domain_hsts_incsub']['description'],
'type' => 'checkbox', 'type' => 'checkbox',
@@ -129,7 +126,6 @@ return array(
'value' => array($result['hsts_sub']) 'value' => array($result['hsts_sub'])
), ),
'hsts_preload' => array( 'hsts_preload' => array(
'visible' => ($ssl_ipsandports != '' ? true : false),
'label' => $lng['admin']['domain_hsts_preload']['title'], 'label' => $lng['admin']['domain_hsts_preload']['title'],
'desc' => $lng['admin']['domain_hsts_preload']['description'], 'desc' => $lng['admin']['domain_hsts_preload']['description'],
'type' => 'checkbox', 'type' => 'checkbox',