enhance listing of customer domains; add third openbasedir-option to make 'parentdirectory of domain-docroot' value possible (refs #515); corrected some formfield definitions

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-11-01 15:36:21 +01:00
parent 0f218914a2
commit a052333296
16 changed files with 43 additions and 18 deletions

View File

@@ -62,7 +62,7 @@ class SubDomains extends ApiCommand implements ResourceEntity
* optional, overwrites path value with an URL to generate a redirect, alternatively use the path
* parameter also for URLs
* @param int $openbasedir_path
* optional, either 0 for domains-docroot or 1 for customers-homedir
* optional, either 0 for domains-docroot, 1 for customers-homedir or 2 for parent-directory of domains-docroot
* @param int $phpsettingid
* optional, php-settings-id, if empty the $domain value is used
* @param int $redirectcode
@@ -202,7 +202,7 @@ class SubDomains extends ApiCommand implements ResourceEntity
$_doredirect = false;
$path = $this->validateDomainDocumentRoot($path, $url, $customer, $completedomain, $_doredirect);
if ($openbasedir_path != 1) {
if ($openbasedir_path > 2 && $openbasedir_path < 0) {
$openbasedir_path = 0;
}
@@ -583,7 +583,7 @@ class SubDomains extends ApiCommand implements ResourceEntity
* @param bool $isemaildomain
* optional
* @param int $openbasedir_path
* optional, either 0 for domains-docroot or 1 for customers-homedir
* optional, either 0 for domains-docroot, 1 for customers-homedir or 2 for parent-directory of domains-docroot
* @param int $phpsettingid
* optional, php-settings-id, if empty the $domain value is used
* @param int $redirectcode
@@ -704,7 +704,7 @@ class SubDomains extends ApiCommand implements ResourceEntity
}
// check changes of openbasedir-path variable
if ($openbasedir_path != 1) {
if ($openbasedir_path > 2 && $openbasedir_path < 0) {
$openbasedir_path = 0;
}
@@ -957,7 +957,7 @@ class SubDomains extends ApiCommand implements ResourceEntity
LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON `pd`.`id`=`d`.`parentdomainid`
WHERE `d`.`customerid` IN (" . implode(', ', $customer_ids) . ")
AND `d`.`email_only` = '0'
AND `d`.`id` NOT IN (" . implode(', ', $customer_stdsubs) . ")" . $this->getSearchWhere($query_fields, true) . " GROUP BY `d`.`id` ORDER BY `parentdomainname` " . $this->getOrderBy(true) . $this->getLimit());
AND `d`.`id` NOT IN (" . implode(', ', $customer_stdsubs) . ")" . $this->getSearchWhere($query_fields, true) . " GROUP BY `d`.`id` ORDER BY `parentdomainname` ASC, `d`.`parentdomainid` ASC " . $this->getOrderBy(true) . $this->getLimit());
$result = [];
Database::pexecute($domains_stmt, $query_fields, true, true);

View File

@@ -994,6 +994,8 @@ class Apache extends HttpConfigBase
if ($domain['openbasedir'] == '1') {
if ($domain['openbasedir_path'] == '1' || strstr($domain['documentroot'], ":") !== false) {
$_phpappendopenbasedir = Domain::appendOpenBasedirPath($domain['customerroot'], true);
} else if ($domain['openbasedir_path'] == '2' && strpos(dirname($domain['documentroot']).'/', $domain['customerroot']) !== false) {
$_phpappendopenbasedir = Domain::appendOpenBasedirPath(dirname($domain['documentroot']).'/', true);
} else {
$_phpappendopenbasedir = Domain::appendOpenBasedirPath($domain['documentroot'], true);
}

View File

@@ -172,6 +172,8 @@ class Fcgid
if ($this->domain['openbasedir_path'] == '0' && strstr($this->domain['documentroot'], ":") === false) {
$openbasedir = Domain::appendOpenBasedirPath($this->domain['documentroot'], true);
} else if ($this->domain['openbasedir_path'] == '2' && strpos(dirname($this->domain['documentroot']).'/', $this->domain['customerroot']) !== false) {
$openbasedir = Domain::appendOpenBasedirPath(dirname($this->domain['documentroot']).'/', true);
} else {
$openbasedir = Domain::appendOpenBasedirPath($this->domain['customerroot'], true);
}

View File

@@ -239,6 +239,8 @@ pm.max_children = 1
if ($this->domain['openbasedir_path'] == '0' && strstr($this->domain['documentroot'], ":") === false) {
$openbasedir = Domain::appendOpenBasedirPath($this->domain['documentroot'], true);
} else if ($this->domain['openbasedir_path'] == '2' && strpos(dirname($this->domain['documentroot']).'/', $this->domain['customerroot']) !== false) {
$openbasedir = Domain::appendOpenBasedirPath(dirname($this->domain['documentroot']).'/', true);
} else {
$openbasedir = Domain::appendOpenBasedirPath($this->domain['customerroot'], true);
}

View File

@@ -74,7 +74,11 @@ class Domain
public static function domainExternalLinkInfo(array $attributes)
{
$result = '<a href="http://' . $attributes['data'] . '" target="_blank">' . $attributes['data'] . '</a>';
$result = '';
if ($attributes['fields']['parentdomainid'] != 0) {
$result = '<i class="fa-solid fa-turn-up me-2 fa-rotate-90 opacity-50"></i>';
}
$result .= '<a href="http://' . $attributes['data'] . '" target="_blank">' . $attributes['data'] . '</a>';
// check for statistics if parentdomainid==0 to show stats-link for customers
if ((int)UI::getCurrentUser()['adminsession'] == 0 && $attributes['fields']['parentdomainid'] == 0) {
$statsapp = 'webalizer';

View File

@@ -90,9 +90,11 @@ class Pagination
} else {
// add default ordering by given order
if (!empty($default_sorting)) {
$this->sortfield = array_key_first($default_sorting);
$this->sortorder = array_shift($default_sorting) ?? $this->sortorder;
$this->addOrderBy($this->sortfield, $this->sortorder);
while (!empty($default_sorting)) {
$this->sortfield = array_key_first($default_sorting);
$this->sortorder = array_shift($default_sorting) ?? $this->sortorder;
$this->addOrderBy($this->sortfield, $this->sortorder);
}
}
// add default ordering by given fields
if (count($fields) > 0 && empty($this->sortfield)) {

View File

@@ -53,9 +53,10 @@ return [
],
'path' => [
'label' => lng('panel.path'),
'desc' => (Settings::Get('panel.pathedit') != 'Dropdown' ? lng('panel.pathDescriptionSubdomain') : null),
'desc' => (Settings::Get('panel.pathedit') != 'Dropdown' ? lng('panel.pathDescriptionSubdomain').(Settings::Get('system.documentroot_use_default_value') == 1 ? lng('panel.pathDescriptionEx') : '') : null),
'type' => $pathSelect['type'],
'select_var' => $pathSelect['select_var'] ?? '',
'selected' => $pathSelect['value'],
'value' => $pathSelect['value'],
'note' => $pathSelect['note'] ?? '',
],

View File

@@ -55,10 +55,12 @@ return [
],
'path' => [
'label' => lng('panel.path'),
'desc' => (Settings::Get('panel.pathedit') != 'Dropdown' ? lng('panel.pathDescriptionSubdomain') : null) . (isset($pathSelect['note']) ? '<br />' . $pathSelect['value'] : ''),
'desc' => (Settings::Get('panel.pathedit') != 'Dropdown' ? lng('panel.pathDescriptionSubdomain').(Settings::Get('system.documentroot_use_default_value') == 1 ? lng('panel.pathDescriptionEx') : '') : null),
'type' => $pathSelect['type'],
'select_var' => $pathSelect['value'],
'selected' => $pathSelect['value']
'selected' => $pathSelect['value'],
'value' => $pathSelect['value'],
'note' => $pathSelect['note'] ?? '',
],
'url' => [
'visible' => Settings::Get('panel.pathedit') == 'Dropdown',

View File

@@ -31,6 +31,7 @@ return [
'desc' => lng('panel.backuppath.description') . '<br>' . (Settings::Get('panel.pathedit') != 'Dropdown' ? lng('panel.pathDescription') : null),
'type' => $pathSelect['type'],
'select_var' => $pathSelect['select_var'] ?? '',
'selected' => $pathSelect['value'],
'value' => $pathSelect['value'],
'note' => $pathSelect['note'] ?? '',
],

View File

@@ -40,6 +40,7 @@ return [
'desc' => (Settings::Get('panel.pathedit') != 'Dropdown' ? lng('panel.pathDescription') : null),
'type' => $pathSelect['type'],
'select_var' => $pathSelect['select_var'] ?? '',
'selected' => $pathSelect['value'],
'value' => $pathSelect['value'],
'note' => $pathSelect['note'] ?? '',
'mandatory' => true

View File

@@ -41,6 +41,7 @@ return [
'desc' => (Settings::Get('panel.pathedit') != 'Dropdown' ? lng('panel.pathDescription') : null),
'type' => $pathSelect['type'],
'select_var' => $pathSelect['select_var'] ?? '',
'selected' => $pathSelect['value'],
'value' => $pathSelect['value'],
'note' => $pathSelect['note'] ?? '',
'mandatory' => true

View File

@@ -50,6 +50,7 @@ return [
'desc' => (Settings::Get('panel.pathedit') != 'Dropdown' ? lng('panel.pathDescription') : null),
'type' => $pathSelect['type'],
'select_var' => $pathSelect['select_var'] ?? '',
'selected' => $pathSelect['value'],
'value' => $pathSelect['value'],
'note' => $pathSelect['note'] ?? '',
'mandatory' => true

View File

@@ -42,8 +42,10 @@ return [
'desc' => (Settings::Get('panel.pathedit') != 'Dropdown' ? lng('panel.pathDescription') : null),
'type' => $pathSelect['type'],
'select_var' => $pathSelect['select_var'] ?? '',
'selected' => $pathSelect['value'],
'value' => $pathSelect['value'],
'note' => $pathSelect['note'] ?? '',
'mandatory' => true
],
'ftp_password' => [
'label' => lng('login.password'),