diff --git a/customer_domains.php b/customer_domains.php index 2fba8e382d..944b41432f 100644 --- a/customer_domains.php +++ b/customer_domains.php @@ -389,6 +389,23 @@ } else { Response::standardError('domains_canteditdomain'); } + } elseif ($action == 'jqSpeciallogfileNote') { + $domainid = intval($_POST['id']); + $newval = intval($_POST['newval']); + try { + $json_result = SubDomains::getLocal($userinfo, [ + 'id' => $domainid + ])->get(); + } catch (Exception $e) { + Response::dynamicError($e->getMessage()); + } + $result = json_decode($json_result, true)['data']; + if ($newval != $result['speciallogfile']) { + echo json_encode(['changed' => true, 'info' => lng('admin.speciallogwarning')]); + exit(); + } + echo 0; + exit(); } } elseif ($page == 'domainssleditor') { require_once __DIR__ . '/ssl_editor.php'; diff --git a/lib/Froxlor/Api/Commands/SubDomains.php b/lib/Froxlor/Api/Commands/SubDomains.php index e49c09cd58..1711c3ef8e 100644 --- a/lib/Froxlor/Api/Commands/SubDomains.php +++ b/lib/Froxlor/Api/Commands/SubDomains.php @@ -67,6 +67,8 @@ class SubDomains extends ApiCommand implements ResourceEntity * optional, php-settings-id, if empty the $domain value is used * @param int $redirectcode * optional, redirect-code-id from TABLE_PANEL_REDIRECTCODES + * @param int $speciallogfile + * optional, whether to create an exclusive web-logfile for this domain (1) or not (0) or inherit value from parentdomain (2, default) * @param bool $sslenabled * optional, whether or not SSL is enabled for this domain, regardless of the assigned ssl-ips, default * 1 (true) @@ -107,6 +109,7 @@ public function add() $openbasedir_path = $this->getParam('openbasedir_path', true, 0); $phpsettingid = $this->getParam('phpsettingid', true, 0); $redirectcode = $this->getParam('redirectcode', true, Settings::Get('customredirect.default')); + $speciallogfile = intval($this->getParam('speciallogfile', true, 2)); $isemaildomain = $this->getParam('isemaildomain', true, 0); if (Settings::Get('system.use_ssl')) { $sslenabled = $this->getBoolParam('sslenabled', true, 1); @@ -276,6 +279,11 @@ public function add() $ssl_redirect = 2; } + // validate speciallogfile value + if ($speciallogfile < 0 || $speciallogfile > 2) { + $speciallogfile = 2; // inherit from parent-domain + } + // get the phpsettingid from parentdomain, #107 $phpsid_stmt = Database::prepare(" SELECT `phpsettingid` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `id` = :id @@ -354,7 +362,7 @@ public function add() "openbasedir" => $domain_check['openbasedir'], "openbasedir_path" => $openbasedir_path, "phpenabled" => $domain_check['phpenabled'], - "speciallogfile" => $domain_check['speciallogfile'], + "speciallogfile" => $speciallogfile == 2 ? $domain_check['speciallogfile'] : $speciallogfile, "specialsettings" => $domain_check['specialsettings'], "ssl_specialsettings" => $domain_check['ssl_specialsettings'], "include_specialsettings" => $domain_check['include_specialsettings'], @@ -591,6 +599,11 @@ private function validateDomainDocumentRoot($path = null, $url = null, $customer * optional, php-settings-id, if empty the $domain value is used * @param int $redirectcode * optional, redirect-code-id from TABLE_PANEL_REDIRECTCODES + * @param bool $speciallogfile + * optional, whether to create an exclusive web-logfile for this domain + * @param bool $speciallogverified + * optional, when setting $speciallogfile to false, this needs to be set to true to confirm the action, + * default 0 (false) * @param bool $sslenabled * optional, whether or not SSL is enabled for this domain, regardless of the assigned ssl-ips, default * 1 (true) @@ -648,6 +661,8 @@ public function update() $openbasedir_path = $this->getParam('openbasedir_path', true, $result['openbasedir_path']); $phpsettingid = $this->getParam('phpsettingid', true, $result['phpsettingid']); $redirectcode = $this->getParam('redirectcode', true, Domain::getDomainRedirectId($id)); + $speciallogfile = $this->getBoolParam('speciallogfile', true, $result['speciallogfile']); + $speciallogverified = $this->getBoolParam('speciallogverified', true, 0); if (Settings::Get('system.use_ssl')) { $sslenabled = $this->getBoolParam('sslenabled', true, $result['ssl_enabled']); $ssl_redirect = $this->getBoolParam('ssl_redirect', true, $result['ssl_redirect']); @@ -757,6 +772,10 @@ public function update() $ssl_redirect = 2; } + if ($speciallogfile != $result['speciallogfile'] && $speciallogverified != '1') { + $speciallogfile = $result['speciallogfile']; + } + // is-email-domain flag changed - remove mail accounts and mail-addresses if (($result['isemaildomain'] == '1') && $isemaildomain == '0') { $params = [ @@ -789,7 +808,21 @@ public function update() Domain::updateRedirectOfDomain($id, $redirectcode); } - if ($path != $result['documentroot'] || $isemaildomain != $result['isemaildomain'] || $wwwserveralias != $result['wwwserveralias'] || $iswildcarddomain != $result['iswildcarddomain'] || $aliasdomain != (int)$result['aliasdomain'] || $openbasedir_path != $result['openbasedir_path'] || $ssl_redirect != $result['ssl_redirect'] || $letsencrypt != $result['letsencrypt'] || $hsts_maxage != $result['hsts'] || $hsts_sub != $result['hsts_sub'] || $hsts_preload != $result['hsts_preload'] || $phpsettingid != $result['phpsettingid'] || $http2 != $result['http2']) { + if ($path != $result['documentroot'] + || $isemaildomain != $result['isemaildomain'] + || $wwwserveralias != $result['wwwserveralias'] + || $iswildcarddomain != $result['iswildcarddomain'] + || $aliasdomain != (int)$result['aliasdomain'] + || $openbasedir_path != $result['openbasedir_path'] + || $ssl_redirect != $result['ssl_redirect'] + || $letsencrypt != $result['letsencrypt'] + || $hsts_maxage != $result['hsts'] + || $hsts_sub != $result['hsts_sub'] + || $hsts_preload != $result['hsts_preload'] + || $phpsettingid != $result['phpsettingid'] + || $http2 != $result['http2'] + || ($speciallogfile != $result['speciallogfile'] && $speciallogverified == '1') + ) { $stmt = Database::prepare(" UPDATE `" . TABLE_PANEL_DOMAINS . "` SET `documentroot` = :documentroot, @@ -805,7 +838,8 @@ public function update() `hsts` = :hsts, `hsts_sub` = :hsts_sub, `hsts_preload` = :hsts_preload, - `phpsettingid` = :phpsettingid + `phpsettingid` = :phpsettingid, + `speciallogfile` = :speciallogfile WHERE `customerid`= :customerid AND `id`= :id "); $params = [ @@ -823,6 +857,7 @@ public function update() "hsts_sub" => $hsts_sub, "hsts_preload" => $hsts_preload, "phpsettingid" => $phpsettingid, + "speciallogfile" => $speciallogfile, "customerid" => $customer['customerid'], "id" => $id ]; diff --git a/lib/formfields/customer/domains/formfield.domains_add.php b/lib/formfields/customer/domains/formfield.domains_add.php index 029516dec5..610cf45aa4 100644 --- a/lib/formfields/customer/domains/formfield.domains_add.php +++ b/lib/formfields/customer/domains/formfield.domains_add.php @@ -89,7 +89,18 @@ 'type' => 'select', 'select_var' => $phpconfigs, 'selected' => (int)Settings::Get('phpfpm.enabled') == 1 ? Settings::Get('phpfpm.defaultini') : Settings::Get('system.mod_fcgid_defaultini') - ] + ], + 'speciallogfile' => [ + 'label' => lng('admin.speciallogfile.title'), + 'desc' => lng('admin.speciallogfile.description'), + 'type' => 'select', + 'select_var' => [ + 0 => lng('panel.no'), + 1 => lng('panel.yes'), + 2 => lng('domain.inherited') + ], + 'selected' => 2 + ], ] ], 'section_bssl' => [ diff --git a/lib/formfields/customer/domains/formfield.domains_edit.php b/lib/formfields/customer/domains/formfield.domains_edit.php index 6d89369c23..cd7d1553ad 100644 --- a/lib/formfields/customer/domains/formfield.domains_edit.php +++ b/lib/formfields/customer/domains/formfield.domains_edit.php @@ -104,7 +104,18 @@ 'type' => 'select', 'select_var' => $phpconfigs, 'selected' => $result['phpsettingid'] - ] + ], + 'speciallogfile' => [ + 'label' => lng('admin.speciallogfile.title'), + 'desc' => lng('admin.speciallogfile.description'), + 'type' => 'checkbox', + 'value' => '1', + 'checked' => $result['speciallogfile'] + ], + 'speciallogverified' => [ + 'type' => 'hidden', + 'value' => '0' + ], ] ], 'section_bssl' => [ diff --git a/lng/de.lng.php b/lng/de.lng.php index 9c5eb363a9..46be6c990d 100644 --- a/lng/de.lng.php +++ b/lng/de.lng.php @@ -647,6 +647,7 @@ ], 'domain' => [ 'openbasedirpath' => 'OpenBasedir-Pfad', + 'inherited' => 'Gleich wie Elterndomain', 'docroot' => 'Oben angegebener Pfad', 'homedir' => 'Heimverzeichnis', 'docparent' => 'Elternverzeichnis des oben angegebenen Pfads', diff --git a/lng/en.lng.php b/lng/en.lng.php index 5f755c5c1a..2f3b0471ae 100644 --- a/lng/en.lng.php +++ b/lng/en.lng.php @@ -714,6 +714,7 @@ ], 'domain' => [ 'openbasedirpath' => 'OpenBasedir-path', + 'inherited' => 'Same as parent-domain', 'docroot' => 'Path from field above', 'homedir' => 'Home directory', 'docparent' => 'Parent-directory of path from field above', diff --git a/templates/Froxlor/src/js/components/domains.js b/templates/Froxlor/src/js/components/domains.js index fe5611fc8e..8d7512a5b6 100644 --- a/templates/Froxlor/src/js/components/domains.js +++ b/templates/Froxlor/src/js/components/domains.js @@ -36,7 +36,7 @@ $(function() { $('#speciallogfile').removeClass('is-invalid'); $('#speciallogverified').val(0); $.ajax({ - url: "admin_domains.php?page=overview&action=jqSpeciallogfileNote", + url: window.location.pathname.substring(1) + "?page=overview&action=jqSpeciallogfileNote", type: "POST", data: { id: $('input[name=id]').val(), newval: +$('#speciallogfile').is(':checked')