From 777991e0e3389704002c5906b703fd3cf23c0fa6 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Sun, 20 Nov 2022 12:22:03 +0100 Subject: [PATCH] honor caneditdomain flag correctly; corrected error messages; updated external URLs Signed-off-by: Michael Kaufmann --- customer_domains.php | 5 ++++ lib/Froxlor/Api/Commands/SubDomains.php | 4 ++++ .../admin/domains/formfield.domains_add.php | 16 ++++++------- .../admin/domains/formfield.domains_edit.php | 24 +++++++++---------- lng/de.lng.php | 7 +++--- lng/en.lng.php | 7 +++--- 6 files changed, 37 insertions(+), 26 deletions(-) diff --git a/customer_domains.php b/customer_domains.php index dfc5b884..26cebcb8 100644 --- a/customer_domains.php +++ b/customer_domains.php @@ -223,6 +223,11 @@ if ($page == 'overview' || $page == 'domains') { $result = json_decode($json_result, true)['data']; if (isset($result['customerid']) && $result['customerid'] == $userinfo['customerid']) { + + if ((int) $result['caneditdomain'] == 0) { + Response::standardError('domaincannotbeedited', $result['domain']); + } + if (isset($_POST['send']) && $_POST['send'] == 'send') { try { SubDomains::getLocal($userinfo, $_POST)->update(); diff --git a/lib/Froxlor/Api/Commands/SubDomains.php b/lib/Froxlor/Api/Commands/SubDomains.php index 9370f09a..1da11937 100644 --- a/lib/Froxlor/Api/Commands/SubDomains.php +++ b/lib/Froxlor/Api/Commands/SubDomains.php @@ -630,6 +630,10 @@ class SubDomains extends ApiCommand implements ResourceEntity ]); $id = $result['id']; + if ($this->isAdmin() == false && (int)$result['caneditdomain'] == 0) { + throw new Exception(lng('error.domaincannotbeedited', [$result['domain']]), 406); + } + // parameters $aliasdomain = $this->getParam('alias', true, 0); $path = $this->getParam('path', true, $result['documentroot']); diff --git a/lib/formfields/admin/domains/formfield.domains_add.php b/lib/formfields/admin/domains/formfield.domains_add.php index 1999b9ce..ed6248da 100644 --- a/lib/formfields/admin/domains/formfield.domains_add.php +++ b/lib/formfields/admin/domains/formfield.domains_add.php @@ -149,13 +149,6 @@ return [ 'select_var' => $serveraliasoptions, 'selected' => Settings::Get('system.domaindefaultalias') ], - 'speciallogfile' => [ - 'label' => lng('admin.speciallogfile.title'), - 'desc' => lng('admin.speciallogfile.description'), - 'type' => 'checkbox', - 'value' => '1', - 'checked' => false - ], 'specialsettings' => [ 'visible' => $userinfo['change_serversettings'] == '1', 'label' => lng('admin.ownvhostsettings'), @@ -185,7 +178,14 @@ return [ 'type' => 'checkbox', 'value' => '1', 'checked' => true - ] + ], + 'speciallogfile' => [ + 'label' => lng('admin.speciallogfile.title'), + 'desc' => lng('admin.speciallogfile.description'), + 'type' => 'checkbox', + 'value' => '1', + 'checked' => false + ], ] ], 'section_bssl' => [ diff --git a/lib/formfields/admin/domains/formfield.domains_edit.php b/lib/formfields/admin/domains/formfield.domains_edit.php index 61e0daa1..98197c1f 100644 --- a/lib/formfields/admin/domains/formfield.domains_edit.php +++ b/lib/formfields/admin/domains/formfield.domains_edit.php @@ -163,17 +163,6 @@ return [ 'select_var' => $serveraliasoptions, 'selected' => $result['iswildcarddomain'] == '1' ? 0 : ($result['wwwserveralias'] == '1' ? 1 : 2) ], - 'speciallogfile' => [ - 'label' => lng('admin.speciallogfile.title'), - 'desc' => lng('admin.speciallogfile.description'), - 'type' => 'checkbox', - 'value' => '1', - 'checked' => $result['speciallogfile'] - ], - 'speciallogverified' => [ - 'type' => 'hidden', - 'value' => '0' - ], 'specialsettings' => [ 'visible' => $userinfo['change_serversettings'] == '1', 'label' => lng('admin.ownvhostsettings'), @@ -212,7 +201,18 @@ return [ 'type' => 'checkbox', 'value' => '1', 'checked' => $result['writeerrorlog'] - ] + ], + '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 bd98f106..d6997c64 100644 --- a/lng/de.lng.php +++ b/lng/de.lng.php @@ -421,8 +421,8 @@ return [ 'description' => 'Die optionale "includeSubDomains" Direktive, wenn vorhanden, signalisiert dem UA, dass die HSTS Regel für diese Domain und auch jede Subdomain dieser gilt.', ], 'domain_hsts_preload' => [ - 'title' => 'Füge Domain in die HSTS preload Liste hinzu', - 'description' => 'Wenn die Domain in die HSTS preload Liste, verwaltet von Chrome (und genutzt von Firefox und Safari), hinzugefügt werden soll, dann aktivieren Sie diese Einstellung.
Die preload-Direktive zu senden kann PERMANTENTE KONSEQUENZEN haben und dazu führen, dass Benutzer auf diese Domain und auch Subdomains nicht zugreifen können.
Beachten Sie die Details unter hstspreload.appspot.com/#removal bevor ein Header mit "preload" gesendet wird.', + 'title' => 'Füge Domain in die HSTS preload Liste hinzu', + 'description' => 'Wenn die Domain in die HSTS preload Liste, verwaltet von Chrome (und genutzt von Firefox und Safari), hinzugefügt werden soll, dann aktivieren Sie diese Einstellung.
Die preload-Direktive zu senden kann PERMANTENTE KONSEQUENZEN haben und dazu führen, dass Benutzer auf diese Domain und auch Subdomains nicht zugreifen können.
Beachten Sie die Details unter https://hstspreload.org/#removal bevor ein Header mit "preload" gesendet wird.', ], 'domain_ocsp_stapling' => [ 'title' => 'OCSP stapling', @@ -724,7 +724,7 @@ return [ 'directorymustexist' => 'Das Verzeichnis "%s" muss existieren. Legen Sie es bitte mit Ihrem FTP-Programm an.', 'filemustexist' => 'Die Datei "%s" muss existieren.', 'allresourcesused' => 'Sie haben bereits alle Ihnen zur Verfügung stehenden Ressourcen verbraucht.', - 'domains_cantdeletemaindomain' => 'Sie können keine Domain, die als E-Mail-Domain verwendet wird, löschen. ', + 'domains_cantdeletemaindomain' => 'Sie können keine zugewiesene Domain löschen. ', 'domains_canteditdomain' => 'Sie können diese Domain nicht bearbeiten. Dies wurde durch den Admin verweigert.', 'domains_cantdeletedomainwithemail' => 'Sie können keine Domain löschen, die noch als E-Mail-Domain verwendet wird. Löschen Sie zuerst alle E-Mail-Adressen dieser Domain.', 'firstdeleteallsubdomains' => 'Sie müssen zuerst alle Subdomains löschen, bevor Sie eine Wildcarddomain anlegen können.', @@ -914,6 +914,7 @@ return [ 'notallowedphpconfigused' => 'Nutzung einer PHP-Konfiguration welche nicht dem Kunden zugeordnet ist', 'pathmustberelative' => 'Der Benutzer hat nicht die benötigten Berechtigungen, um Pfade außerhalb des Kunden-Heimatverzeichnisses anzugeben. Bitte einen relativen Pfad angeben (kein führendes /).', 'mysqlserverstillhasdbs' => 'Datenbank-Server kann für den Kunden nicht entfernt werden, da sich dort noch Datenbanken befinden.', + 'domaincannotbeedited' => 'Keine Berechtigung, um die Domain %s zu bearbeiten', ], 'extras' => [ 'description' => 'Hier können Sie zusätzliche Extras einrichten, wie zum Beispiel einen Verzeichnisschutz.
Die Änderungen sind erst nach einer kurzen Zeit wirksam.', diff --git a/lng/en.lng.php b/lng/en.lng.php index 2ab581b3..aeb066a4 100644 --- a/lng/en.lng.php +++ b/lng/en.lng.php @@ -428,8 +428,8 @@ return [ 'description' => 'The optional "includeSubDomains" directive, if present, signals the UA that the HSTS Policy applies to this HSTS Host as well as any subdomains of the host\'s domain name.', ], 'domain_hsts_preload' => [ - 'title' => 'Include domain in HSTS preload list', - 'description' => 'If you would like this domain to be included in the HSTS preload list maintained by Chrome (and used by Firefox and Safari), then use activate this.
Sending the preload directive from your site can have PERMANENT CONSEQUENCES and prevent users from accessing your site and any of its subdomains.
Please read the details at hstspreload.appspot.com/#removal before sending the header with "preload".', + 'title' => 'Include domain in HSTS preload list', + 'description' => 'If you would like this domain to be included in the HSTS preload list maintained by Chrome (and used by Firefox and Safari), then use activate this.
Sending the preload directive from your site can have PERMANENT CONSEQUENCES and prevent users from accessing your site and any of its subdomains.
Please read the details at https://hstspreload.org/#removal before sending the header with "preload".', ], 'domain_ocsp_stapling' => [ 'title' => 'OCSP stapling', @@ -788,7 +788,7 @@ return [ 'directorymustexist' => 'The directory %s must exist. Please create it with your FTP client.', 'filemustexist' => 'The file %s must exist.', 'allresourcesused' => 'You have already used all of your resources.', - 'domains_cantdeletemaindomain' => 'You cannot delete a domain which is used as an email-domain.', + 'domains_cantdeletemaindomain' => 'You cannot delete an assigned domain.', 'domains_canteditdomain' => 'You cannot edit this domain. It has been disabled by the admin.', 'domains_cantdeletedomainwithemail' => 'You cannot delete a domain which is used as an email-domain. Delete all email addresses first.', 'firstdeleteallsubdomains' => 'You have to delete all subdomains first before you can create a wildcard domain.', @@ -981,6 +981,7 @@ return [ 'notallowedphpconfigused' => 'Trying to use php-config which is not assigned to customer', 'pathmustberelative' => 'The user does not have the permission to specify directories outside the customers home-directory. Please specify a relative path (no leading /).', 'mysqlserverstillhasdbs' => 'Cannot remove database server from customers allow-list as there are still databases on it.', + 'domaincannotbeedited' => 'You are not permitted to edit the domain %s', ], 'extras' => [ 'description' => 'Here you can add some extras, for example directory protection.
The system will need some time to apply the new settings after every change.',