Show number of subdomains that use a php-config; fixes #532
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -30,7 +30,9 @@ if ($page == 'overview') {
|
|||||||
if ($action == '') {
|
if ($action == '') {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$json_result = PhpSettings::getLocal($userinfo)->listing();
|
$json_result = PhpSettings::getLocal($userinfo, array(
|
||||||
|
'with_subdomains' => true
|
||||||
|
))->listing();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dynamic_error($e->getMessage());
|
dynamic_error($e->getMessage());
|
||||||
}
|
}
|
||||||
@@ -44,10 +46,14 @@ if ($page == 'overview') {
|
|||||||
$row['description'] = "<b>" . $row['description'] . "</b>";
|
$row['description'] = "<b>" . $row['description'] . "</b>";
|
||||||
}
|
}
|
||||||
$domains = "";
|
$domains = "";
|
||||||
|
$subdomains_count = $row['subdomains_count'];
|
||||||
foreach ($row['domains'] as $configdomain) {
|
foreach ($row['domains'] as $configdomain) {
|
||||||
$domains .= $configdomain . "<br>";
|
$domains .= $configdomain . "<br>";
|
||||||
}
|
}
|
||||||
$count++;
|
$count++;
|
||||||
|
if ($subdomains_count == 0 && empty($domains)) {
|
||||||
|
$domains = $lng['admin']['phpsettings']['notused'];
|
||||||
|
}
|
||||||
eval("\$tablecontent.=\"" . getTemplate("phpconfig/overview_overview") . "\";");
|
eval("\$tablecontent.=\"" . getTemplate("phpconfig/overview_overview") . "\";");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ class PhpSettings extends ApiCommand implements ResourceEntity
|
|||||||
/**
|
/**
|
||||||
* lists all php-setting entries
|
* lists all php-setting entries
|
||||||
*
|
*
|
||||||
|
* @param bool $with_subdomains
|
||||||
|
* optional, also include subdomains to the list domains that use the config, default 0 (false)
|
||||||
|
*
|
||||||
* @access admin
|
* @access admin
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @return array count|list
|
* @return array count|list
|
||||||
@@ -30,6 +33,8 @@ class PhpSettings extends ApiCommand implements ResourceEntity
|
|||||||
if ($this->isAdmin()) {
|
if ($this->isAdmin()) {
|
||||||
$this->logger()->logAction(ADM_ACTION, LOG_NOTICE, "[API] list php-configs");
|
$this->logger()->logAction(ADM_ACTION, LOG_NOTICE, "[API] list php-configs");
|
||||||
|
|
||||||
|
$with_subdomains = $this->getBoolParam('with_subdomains', true, false);
|
||||||
|
|
||||||
$result = Database::query("
|
$result = Database::query("
|
||||||
SELECT c.*, fd.description as fpmdesc
|
SELECT c.*, fd.description as fpmdesc
|
||||||
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
|
FROM `" . TABLE_PANEL_PHPCONFIGS . "` c
|
||||||
@@ -44,8 +49,11 @@ class PhpSettings extends ApiCommand implements ResourceEntity
|
|||||||
);
|
);
|
||||||
|
|
||||||
$query = "SELECT * FROM `" . TABLE_PANEL_DOMAINS . "`
|
$query = "SELECT * FROM `" . TABLE_PANEL_DOMAINS . "`
|
||||||
WHERE `phpsettingid` = :id
|
WHERE `phpsettingid` = :id";
|
||||||
AND `parentdomainid` = '0'";
|
|
||||||
|
if (!$with_subdomains) {
|
||||||
|
$query .= " AND `parentdomainid` = '0'";
|
||||||
|
}
|
||||||
|
|
||||||
if ((int) $this->getUserDetail('domains_see_all') == 0) {
|
if ((int) $this->getUserDetail('domains_see_all') == 0) {
|
||||||
$query .= " AND `adminid` = :adminid";
|
$query .= " AND `adminid` = :adminid";
|
||||||
@@ -66,12 +74,17 @@ class PhpSettings extends ApiCommand implements ResourceEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
$domains = array();
|
$domains = array();
|
||||||
|
$subdomains_count = 0;
|
||||||
$domainresult_stmt = Database::prepare($query);
|
$domainresult_stmt = Database::prepare($query);
|
||||||
Database::pexecute($domainresult_stmt, $query_params, true, true);
|
Database::pexecute($domainresult_stmt, $query_params, true, true);
|
||||||
|
|
||||||
if (Database::num_rows() > 0) {
|
if (Database::num_rows() > 0) {
|
||||||
while ($row2 = $domainresult_stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($row2 = $domainresult_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
$domains[] = $row2['domain'];
|
if ($row2['parentdomainid'] != 0) {
|
||||||
|
$subdomains_count++;
|
||||||
|
} else {
|
||||||
|
$domains[] = $row2['domain'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,16 +93,13 @@ class PhpSettings extends ApiCommand implements ResourceEntity
|
|||||||
$domains[] = Settings::Get('system.hostname');
|
$domains[] = Settings::Get('system.hostname');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($domains)) {
|
|
||||||
$domains[] = $this->lng['admin']['phpsettings']['notused'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// check whether this is our default config
|
// check whether this is our default config
|
||||||
if ((Settings::Get('system.mod_fcgid') == '1' && Settings::Get('system.mod_fcgid_defaultini') == $row['id']) || (Settings::Get('phpfpm.enabled') == '1' && Settings::Get('phpfpm.defaultini') == $row['id'])) {
|
if ((Settings::Get('system.mod_fcgid') == '1' && Settings::Get('system.mod_fcgid_defaultini') == $row['id']) || (Settings::Get('phpfpm.enabled') == '1' && Settings::Get('phpfpm.defaultini') == $row['id'])) {
|
||||||
$row['is_default'] = true;
|
$row['is_default'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$row['domains'] = $domains;
|
$row['domains'] = $domains;
|
||||||
|
$row['subdomains_count'] = $subdomains_count;
|
||||||
$phpconfigs[] = $row;
|
$phpconfigs[] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<tr class="top">
|
<tr class="top">
|
||||||
<td><strong>{$row['description']}</strong></td>
|
<td><strong>{$row['description']}</strong></td>
|
||||||
<td>{$domains}</td>
|
<td>{$domains}<if 0 < $subdomains_count><if !empty($domains)>+ </if>{$subdomains_count} {$lng['customer']['subdomains']}</if></td>
|
||||||
<if Settings::Get('phpfpm.enabled') == '1'>
|
<if Settings::Get('phpfpm.enabled') == '1'>
|
||||||
<td>{$row['fpmdesc']}</td>
|
<td>{$row['fpmdesc']}</td>
|
||||||
<else>
|
<else>
|
||||||
|
|||||||
Reference in New Issue
Block a user