diff --git a/admin_domains.php b/admin_domains.php
index 59755968..c295387c 100644
--- a/admin_domains.php
+++ b/admin_domains.php
@@ -114,15 +114,11 @@ if ($page == 'domains' || $page == 'overview') {
} elseif ($alias_check['count'] > 0) {
Response::standardError('domains_cantdeletedomainwithaliases');
} else {
- $showcheck = false;
- if (Domain::domainHasMainSubDomains($id)) {
- $showcheck = true;
- }
- HTML::askYesNoWithCheckbox('admin_domain_reallydelete', 'remove_subbutmain_domains', $filename, [
+ HTML::askYesNo('admin_domain_reallydelete', $filename, [
'id' => $id,
'page' => $page,
'action' => $action
- ], $idna_convert->decode($result['domain']), $showcheck);
+ ], $idna_convert->decode($result['domain']));
}
}
} elseif ($action == 'add') {
@@ -252,21 +248,6 @@ if ($page == 'domains' || $page == 'overview') {
$domains[$row_domain['id']] = $idna_convert->decode($row_domain['domain']) . ' (' . $row_domain['loginname'] . ')';
}
- $subtodomains = [
- 0 => lng('domains.nosubtomaindomain')
- ];
- $result_domains_stmt = Database::prepare("
- SELECT `d`.`id`, `d`.`domain`, `c`.`loginname` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c`
- WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = 0 AND `d`.`ismainbutsubto` = 0 " . $standardsubdomains . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . "
- AND `d`.`customerid`=`c`.`customerid` ORDER BY `loginname`, `domain` ASC
- ");
- // params from above still valid
- Database::pexecute($result_domains_stmt, $params);
-
- while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
- $subtodomains[$row_domain['id']] = $idna_convert->decode($row_domain['domain']) . ' (' . $row_domain['loginname'] . ')';
- }
-
$phpconfigs = [];
$configs = Database::query("
SELECT c.*, fc.description as interpreter
@@ -287,7 +268,7 @@ if ($page == 'domains' || $page == 'overview') {
1 => lng('domain.homedir'),
2 => lng('domain.docparent')
];
-
+
// create serveralias options
$serveraliasoptions = [
0 => lng('domains.serveraliasoption_wildcard'),
@@ -469,27 +450,6 @@ if ($page == 'domains' || $page == 'overview') {
$domains[$row_domain['id']] = $idna_convert->decode($row_domain['domain']);
}
- $subtodomains = [
- 0 => lng('domains.nosubtomaindomain')
- ];
- $result_domains_stmt = Database::prepare("
- SELECT `d`.`id`, `d`.`domain` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c`
- WHERE `d`.`aliasdomain` IS NULL AND `d`.`parentdomainid` = '0' AND `d`.`id` <> :id
- AND `c`.`standardsubdomain`<>`d`.`id` AND `c`.`customerid`=`d`.`customerid`" . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid") . "
- ORDER BY `d`.`domain` ASC
- ");
- $params = [
- 'id' => $result['id']
- ];
- if ($userinfo['customers_see_all'] == '0') {
- $params['adminid'] = $userinfo['adminid'];
- }
- Database::pexecute($result_domains_stmt, $params);
-
- while ($row_domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) {
- $subtodomains[$row_domain['id']] = $idna_convert->decode($row_domain['domain']);
- }
-
if ($userinfo['ip'] == "-1") {
$result_ipsandports_stmt = Database::query("
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `ssl`='0' ORDER BY `ip`, `port` ASC
@@ -556,7 +516,7 @@ if ($page == 'domains' || $page == 'overview') {
1 => lng('domain.homedir'),
2 => lng('domain.docparent')
];
-
+
$serveraliasoptions = [
0 => lng('domains.serveraliasoption_wildcard'),
1 => lng('domains.serveraliasoption_www'),
diff --git a/install/froxlor.sql.php b/install/froxlor.sql.php
index 62c626f2..8b680cfe 100644
--- a/install/froxlor.sql.php
+++ b/install/froxlor.sql.php
@@ -278,7 +278,6 @@ CREATE TABLE `panel_domains` (
`phpsettingid` INT( 11 ) UNSIGNED NOT NULL DEFAULT '1',
`mod_fcgid_starter` int(4) default '-1',
`mod_fcgid_maxrequests` int(4) default '-1',
- `ismainbutsubto` int(11) unsigned NOT NULL default '0',
`letsencrypt` tinyint(1) NOT NULL default '0',
`hsts` varchar(10) NOT NULL default '0',
`hsts_sub` tinyint(1) NOT NULL default '0',
diff --git a/install/updates/froxlor/update_2.x.inc.php b/install/updates/froxlor/update_2.x.inc.php
index 228fdac1..5c035172 100644
--- a/install/updates/froxlor/update_2.x.inc.php
+++ b/install/updates/froxlor/update_2.x.inc.php
@@ -492,3 +492,11 @@ if (Froxlor::isFroxlorVersion('2.0.18')) {
Update::showUpdateStep("Updating from 2.0.18 to 2.0.19", false);
Froxlor::updateToVersion('2.0.19');
}
+
+if (Froxlor::isDatabaseVersion('202304260')) {
+ Update::showUpdateStep("Cleaning domains table");
+ Database::query("ALTER TABLE `" . TABLE_PANEL_DOMAINS . "` DROP COLUMN `ismainbutsubto`;");
+ Update::lastStepStatus(0);
+
+ Froxlor::updateToDbVersion('202305231');
+}
diff --git a/lib/Froxlor/Api/Commands/Domains.php b/lib/Froxlor/Api/Commands/Domains.php
index ea318e97..ab81efd5 100644
--- a/lib/Froxlor/Api/Commands/Domains.php
+++ b/lib/Froxlor/Api/Commands/Domains.php
@@ -190,9 +190,6 @@ class Domains extends ApiCommand implements ResourceEntity
* optional, whether to create an exclusive web-logfile for this domain, default 0 (false)
* @param int $alias
* optional, domain-id of a domain that the new domain should be an alias of, default 0 (none)
- * @param int $issubof
- * optional, domain-id of a domain this domain is a subdomain of (required for webserver-cronjob to
- * generate the correct order), default 0 (none)
* @param string $registration_date
* optional, date of domain registration in form of YYYY-MM-DD, default empty (none)
* @param string $termination_date
@@ -298,7 +295,6 @@ class Domains extends ApiCommand implements ResourceEntity
$serveraliasoption = $this->getParam('selectserveralias', true, Settings::Get('system.domaindefaultalias'));
$speciallogfile = $this->getBoolParam('speciallogfile', true, 0);
$aliasdomain = intval($this->getParam('alias', true, 0));
- $issubof = $this->getParam('issubof', true, 0);
$registration_date = $this->getParam('registration_date', true, '');
$termination_date = $this->getParam('termination_date', true, '');
$caneditdomain = $this->getBoolParam('caneditdomain', true, 0);
@@ -665,10 +661,6 @@ class Domains extends ApiCommand implements ResourceEntity
$serveraliasoption = '0';
}
- if ($issubof <= 0) {
- $issubof = '0';
- }
-
$idna_convert = new IdnaWrapper();
if ($domain == '') {
Response::standardError([
@@ -723,7 +715,6 @@ class Domains extends ApiCommand implements ResourceEntity
'phpsettingid' => $phpsettingid,
'mod_fcgid_starter' => $mod_fcgid_starter,
'mod_fcgid_maxrequests' => $mod_fcgid_maxrequests,
- 'ismainbutsubto' => $issubof,
'letsencrypt' => $letsencrypt,
'http2' => $http2,
'hsts' => $hsts_maxage,
@@ -777,7 +768,6 @@ class Domains extends ApiCommand implements ResourceEntity
`phpsettingid` = :phpsettingid,
`mod_fcgid_starter` = :mod_fcgid_starter,
`mod_fcgid_maxrequests` = :mod_fcgid_maxrequests,
- `ismainbutsubto` = :ismainbutsubto,
`letsencrypt` = :letsencrypt,
`http2` = :http2,
`hsts` = :hsts,
@@ -1069,9 +1059,6 @@ class Domains extends ApiCommand implements ResourceEntity
* default 0 (false)
* @param int $alias
* optional, domain-id of a domain that the new domain should be an alias of, default 0 (none)
- * @param int $issubof
- * optional, domain-id of a domain this domain is a subdomain of (required for webserver-cronjob to
- * generate the correct order), default 0 (none)
* @param string $registration_date
* optional, date of domain registration in form of YYYY-MM-DD, default empty (none)
* @param string $termination_date
@@ -1191,7 +1178,6 @@ class Domains extends ApiCommand implements ResourceEntity
$speciallogfile = $this->getBoolParam('speciallogfile', true, $result['speciallogfile']);
$speciallogverified = $this->getBoolParam('speciallogverified', true, 0);
$aliasdomain = intval($this->getParam('alias', true, $result['aliasdomain']));
- $issubof = $this->getParam('issubof', true, $result['ismainbutsubto']);
$registration_date = $this->getParam('registration_date', true, $result['registration_date']);
$termination_date = $this->getParam('termination_date', true, $result['termination_date']);
$caneditdomain = $this->getBoolParam('caneditdomain', true, $result['caneditdomain']);
@@ -1640,10 +1626,6 @@ class Domains extends ApiCommand implements ResourceEntity
Response::standardError('domainisaliasorothercustomer', '', true);
}
- if ($issubof <= 0) {
- $issubof = '0';
- }
-
if ($serveraliasoption != '1' && $serveraliasoption != '2') {
$serveraliasoption = '0';
}
@@ -1666,7 +1648,6 @@ class Domains extends ApiCommand implements ResourceEntity
|| $writeaccesslog != $result['writeaccesslog']
|| $writeerrorlog != $result['writeerrorlog']
|| $aliasdomain != $result['aliasdomain']
- || $issubof != $result['ismainbutsubto']
|| $email_only != $result['email_only']
|| ($speciallogfile != $result['speciallogfile'] && $speciallogverified == '1')
|| $letsencrypt != $result['letsencrypt']
@@ -1837,7 +1818,6 @@ class Domains extends ApiCommand implements ResourceEntity
$update_data['writeerrorlog'] = $writeerrorlog;
$update_data['registration_date'] = $registration_date;
$update_data['termination_date'] = $termination_date;
- $update_data['ismainbutsubto'] = $issubof;
$update_data['letsencrypt'] = $letsencrypt;
$update_data['http2'] = $http2;
$update_data['hsts'] = $hsts_maxage;
@@ -1885,7 +1865,6 @@ class Domains extends ApiCommand implements ResourceEntity
`writeerrorlog` = :writeerrorlog,
`registration_date` = :registration_date,
`termination_date` = :termination_date,
- `ismainbutsubto` = :ismainbutsubto,
`letsencrypt` = :letsencrypt,
`http2` = :http2,
`hsts` = :hsts,
@@ -2073,9 +2052,6 @@ class Domains extends ApiCommand implements ResourceEntity
* optional, the domain-id
* @param string $domainname
* optional, the domainname
- * @param bool $delete_mainsubdomains
- * optional, remove also domains that are subdomains of this domain but added as main domains; default
- * false
* @param bool $is_stdsubdomain
* optional, default false, specify whether it's a std-subdomain you are deleting as it does not count
* as subdomain-resource
@@ -2091,7 +2067,6 @@ class Domains extends ApiCommand implements ResourceEntity
$dn_optional = $id > 0;
$domainname = $this->getParam('domainname', $dn_optional, '');
$is_stdsubdomain = $this->getParam('is_stdsubdomain', true, 0);
- $remove_subbutmain_domains = $this->getParam('delete_mainsubdomains', true, 0);
$result = $this->apiCall('Domains.get', [
'id' => $id,
@@ -2099,15 +2074,10 @@ class Domains extends ApiCommand implements ResourceEntity
]);
$id = $result['id'];
- // check for deletion of main-domains which are logically subdomains, #329
- $rsd_sql = '';
- if ($remove_subbutmain_domains) {
- $rsd_sql .= " OR `ismainbutsubto` = :id";
- }
-
$subresult_stmt = Database::prepare("
- SELECT `id` FROM `" . TABLE_PANEL_DOMAINS . "`
- WHERE (`id` = :id OR `parentdomainid` = :id " . $rsd_sql . ")");
+ SELECT `id` FROM `" . TABLE_PANEL_DOMAINS . "`
+ WHERE (`id` = :id OR `parentdomainid` = :id)
+ ");
Database::pexecute($subresult_stmt, [
'id' => $id
], true, true);
@@ -2129,23 +2099,10 @@ class Domains extends ApiCommand implements ResourceEntity
$this->logger()->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "[API] deleted domain/s from mail-tables");
}
- // if mainbutsubto-domains are not to be deleted, re-assign the (ismainbutsubto value of the main
- // domain which is being deleted) as their new ismainbutsubto value
- if ($remove_subbutmain_domains !== 1) {
- $upd_stmt = Database::prepare("
- UPDATE `" . TABLE_PANEL_DOMAINS . "` SET
- `ismainbutsubto` = :newIsMainButSubtoValue
- WHERE `ismainbutsubto` = :deletedMainDomainId
- ");
- Database::pexecute($upd_stmt, [
- 'newIsMainButSubtoValue' => $result['ismainbutsubto'],
- 'deletedMainDomainId' => $id
- ], true, true);
- }
-
$del_stmt = Database::prepare("
- DELETE FROM `" . TABLE_PANEL_DOMAINS . "`
- WHERE `id` = :id OR `parentdomainid` = :id " . $rsd_sql);
+ DELETE FROM `" . TABLE_PANEL_DOMAINS . "`
+ WHERE `id` = :id OR `parentdomainid` = :id
+ ");
Database::pexecute($del_stmt, [
'id' => $id
], true, true);
diff --git a/lib/Froxlor/Cron/Dns/Bind.php b/lib/Froxlor/Cron/Dns/Bind.php
index 939796d7..882b3d99 100644
--- a/lib/Froxlor/Cron/Dns/Bind.php
+++ b/lib/Froxlor/Cron/Dns/Bind.php
@@ -62,8 +62,8 @@ class Bind extends DnsBase
$this->bindconf_file = '# ' . Settings::Get('system.bindconf_directory') . 'froxlor_bind.conf' . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n\n";
foreach ($domains as $domain) {
- if ($domain['ismainbutsubto'] > 0) {
- // domains with ismainbutsubto>0 are handled by recursion within walkDomainList()
+ if ($domain['is_child']) {
+ // domains that are subdomains to other main domains are handled by recursion within walkDomainList()
continue;
}
$this->walkDomainList($domain, $domains);
@@ -114,7 +114,7 @@ class Bind extends DnsBase
$isFroxlorHostname = true;
}
- if ($domain['ismainbutsubto'] == 0) {
+ if (!$domain['is_child']) {
$zoneContent = (string)Dns::createDomainZone(($domain['id'] == 'none') ? $domain : $domain['id'], $isFroxlorHostname);
$domain['zonefile'] = 'domains/' . $domain['domain'] . '.zone';
$zonefile_name = FileDir::makeCorrectFile(Settings::Get('system.bindconf_directory') . '/' . $domain['zonefile']);
diff --git a/lib/Froxlor/Cron/Dns/DnsBase.php b/lib/Froxlor/Cron/Dns/DnsBase.php
index 5c9eb018..f9ceaede 100644
--- a/lib/Froxlor/Cron/Dns/DnsBase.php
+++ b/lib/Froxlor/Cron/Dns/DnsBase.php
@@ -26,6 +26,7 @@
namespace Froxlor\Cron\Dns;
use Froxlor\Database\Database;
+use Froxlor\Domain\Domain;
use Froxlor\FileDir;
use Froxlor\FroxlorLogger;
use Froxlor\PhpHelper;
@@ -210,7 +211,6 @@ abstract class DnsBase
`d`.`dkim`,
`d`.`dkim_id`,
`d`.`dkim_pubkey`,
- `d`.`ismainbutsubto`,
`c`.`loginname`,
`c`.`guid`
FROM
@@ -219,7 +219,7 @@ abstract class DnsBase
WHERE
`d`.`isbinddomain` = '1'
ORDER BY
- `d`.`domain` ASC
+ LENGTH(`d`.`domain`), `d`.`domain` ASC
");
$domains = [];
@@ -241,7 +241,6 @@ abstract class DnsBase
'bindserial' => date('Ymd') . '00',
'dkim' => '0',
'iswildcarddomain' => '1',
- 'ismainbutsubto' => '0',
'zonefile' => '',
'froxlorhost' => '1'
];
@@ -257,18 +256,23 @@ abstract class DnsBase
if (!isset($domains[$key]['children'])) {
$domains[$key]['children'] = [];
}
- if ($domains[$key]['ismainbutsubto'] > 0) {
- if (isset($domains[$domains[$key]['ismainbutsubto']])) {
- $domains[$domains[$key]['ismainbutsubto']]['children'][] = $domains[$key]['id'];
- } else {
- $domains[$key]['ismainbutsubto'] = 0;
+ if (!isset($domains[$key]['is_child'])) {
+ $domains[$key]['is_child'] = false;
+ }
+ $children = Domain::getMainSubdomainIds($key);
+ if (count($children) > 0) {
+ foreach ($children as $child) {
+ if (isset($domains[$child])) {
+ $domains[$key]['children'][] = $domains[$child]['id'];
+ $domains[$child]['is_child'] = true;
+ }
}
}
}
- $this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, str_pad('domId', 9, ' ') . str_pad('domain', 40, ' ') . 'ismainbutsubto ' . str_pad('parent domain', 40, ' ') . "list of child domain ids");
+ $this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, str_pad('domId', 9, ' ') . str_pad('domain', 40, ' ') . "list of child domain ids");
foreach ($domains as $domain) {
- $logLine = str_pad($domain['id'], 9, ' ') . str_pad($domain['domain'], 40, ' ') . str_pad($domain['ismainbutsubto'], 15, ' ') . str_pad(((isset($domains[$domain['ismainbutsubto']])) ? $domains[$domain['ismainbutsubto']]['domain'] : '-'), 40, ' ') . join(', ', $domain['children']);
+ $logLine = str_pad($domain['id'], 9, ' ') . str_pad($domain['domain'], 40, ' ') . join(', ', $domain['children']);
$this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, $logLine);
}
diff --git a/lib/Froxlor/Cron/Dns/PowerDNS.php b/lib/Froxlor/Cron/Dns/PowerDNS.php
index c3d8f20b..65fb25ca 100644
--- a/lib/Froxlor/Cron/Dns/PowerDNS.php
+++ b/lib/Froxlor/Cron/Dns/PowerDNS.php
@@ -50,8 +50,8 @@ class PowerDNS extends DnsBase
}
foreach ($domains as $domain) {
- if ($domain['ismainbutsubto'] > 0) {
- // domains with ismainbutsubto>0 are handled by recursion within walkDomainList()
+ if ($domain['is_child']) {
+ // domains that are subdomains to other main domains are handled by recursion within walkDomainList()
continue;
}
$this->walkDomainList($domain, $domains);
@@ -108,7 +108,7 @@ class PowerDNS extends DnsBase
$isFroxlorHostname = true;
}
- if ($domain['ismainbutsubto'] == 0) {
+ if (!$domain['is_child']) {
$zoneContent = Dns::createDomainZone(($domain['id'] == 'none') ? $domain : $domain['id'], $isFroxlorHostname);
if (count($subzones)) {
foreach ($subzones as $subzone) {
diff --git a/lib/Froxlor/Cron/Http/Apache.php b/lib/Froxlor/Cron/Http/Apache.php
index faa439ef..8fba3764 100644
--- a/lib/Froxlor/Cron/Http/Apache.php
+++ b/lib/Froxlor/Cron/Http/Apache.php
@@ -630,29 +630,6 @@ class Apache extends HttpConfigBase
}
}
- /**
- * Get the filename for the virtualhost
- */
- protected function getVhostFilename($domain, $ssl_vhost = false)
- {
- if ((int)$domain['parentdomainid'] == 0 && Domain::isCustomerStdSubdomain((int)$domain['id']) == false && ((int)$domain['ismainbutsubto'] == 0 || Domain::domainMainToSubExists($domain['ismainbutsubto']) == false)) {
- $vhost_no = '35';
- } elseif ((int)$domain['parentdomainid'] == 0 && Domain::isCustomerStdSubdomain((int)$domain['id']) == false && (int)$domain['ismainbutsubto'] > 0) {
- $vhost_no = '30';
- } else {
- // number of dots in a domain specifies it's position (and depth of subdomain) starting at 29 going downwards on higher depth
- $vhost_no = (string)(30 - substr_count($domain['domain'], ".") + 1);
- }
-
- if ($ssl_vhost === true) {
- $vhost_filename = FileDir::makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/' . $vhost_no . '_froxlor_ssl_vhost_' . $domain['domain'] . '.conf');
- } else {
- $vhost_filename = FileDir::makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/' . $vhost_no . '_froxlor_normal_vhost_' . $domain['domain'] . '.conf');
- }
-
- return $vhost_filename;
- }
-
/**
* We compose the virtualhost entry for one domain
*/
diff --git a/lib/Froxlor/Cron/Http/HttpConfigBase.php b/lib/Froxlor/Cron/Http/HttpConfigBase.php
index 7b400726..4226322a 100644
--- a/lib/Froxlor/Cron/Http/HttpConfigBase.php
+++ b/lib/Froxlor/Cron/Http/HttpConfigBase.php
@@ -28,6 +28,7 @@ namespace Froxlor\Cron\Http;
use Froxlor\Cron\Http\LetsEncrypt\AcmeSh;
use Froxlor\Cron\Http\Php\Fpm;
use Froxlor\Database\Database;
+use Froxlor\Domain\Domain;
use Froxlor\FileDir;
use Froxlor\Froxlor;
use Froxlor\FroxlorLogger;
@@ -187,4 +188,18 @@ class HttpConfigBase
}
return false;
}
+
+ /**
+ * Get the filename for the virtualhost
+ */
+ protected function getVhostFilename(array $domain, bool $ssl_vhost = false, bool $filename_only = false)
+ {
+ // number of dots in a domain specifies its position (and depth of subdomain) starting at 35 going downwards on higher depth
+ $vhost_no = (string)(35 - substr_count($domain['domain'], ".") + 1);
+ $filename = $vhost_no . '_froxlor_' . ($ssl_vhost ? 'ssl' : 'normal') . '_vhost_' . $domain['domain'] . '.conf';
+ if ($filename_only) {
+ return $filename;
+ }
+ return FileDir::makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/' . $filename);
+ }
}
diff --git a/lib/Froxlor/Cron/Http/Lighttpd.php b/lib/Froxlor/Cron/Http/Lighttpd.php
index 233236a0..968ab62c 100644
--- a/lib/Froxlor/Cron/Http/Lighttpd.php
+++ b/lib/Froxlor/Cron/Http/Lighttpd.php
@@ -336,24 +336,9 @@ class Lighttpd extends HttpConfigBase
$_pos = strrpos($_tmp_path, '/');
$_inc_path = substr($_tmp_path, $_pos + 1);
- // maindomain
- if ((int)$domain['parentdomainid'] == 0 && Domain::isCustomerStdSubdomain((int)$domain['id']) == false && ((int)$domain['ismainbutsubto'] == 0 || Domain::domainMainToSubExists($domain['ismainbutsubto']) == false)) {
- $vhost_no = '50';
- } elseif ((int)$domain['parentdomainid'] == 0 && Domain::isCustomerStdSubdomain((int)$domain['id']) == false && (int)$domain['ismainbutsubto'] > 0) {
- // sub-but-main-domain
- $vhost_no = '51';
- } else {
- // subdomains
- // number of dots in a domain specifies it's position (and depth of subdomain) starting at 89 going downwards on higher depth
- $vhost_no = (string)(90 - substr_count($domain['domain'], ".") + 1);
- }
-
- if ($ssl == '1') {
- $vhost_no = (int)$vhost_no += 10;
- }
-
- $vhost_filename = FileDir::makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/vhosts/' . $vhost_no . '_' . $domain['domain'] . '.conf');
- $included_vhosts[] = $_inc_path . '/vhosts/' . $vhost_no . '_' . $domain['domain'] . '.conf';
+ $filename = self::getVhostFilename($domain, ($ssl == '1'), true);
+ $vhost_filename = FileDir::makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/vhosts/' . $filename);
+ $included_vhosts[] = $_inc_path . '/vhosts/' . $filename;
}
if (!isset($this->lighttpd_data[$vhost_filename])) {
diff --git a/lib/Froxlor/Cron/Http/Nginx.php b/lib/Froxlor/Cron/Http/Nginx.php
index 51230334..3d2ad85e 100644
--- a/lib/Froxlor/Cron/Http/Nginx.php
+++ b/lib/Froxlor/Cron/Http/Nginx.php
@@ -467,26 +467,6 @@ class Nginx extends HttpConfigBase
}
}
- protected function getVhostFilename($domain, $ssl_vhost = false)
- {
- if ((int)$domain['parentdomainid'] == 0 && Domain::isCustomerStdSubdomain((int)$domain['id']) == false && ((int)$domain['ismainbutsubto'] == 0 || Domain::domainMainToSubExists($domain['ismainbutsubto']) == false)) {
- $vhost_no = '35';
- } elseif ((int)$domain['parentdomainid'] == 0 && Domain::isCustomerStdSubdomain((int)$domain['id']) == false && (int)$domain['ismainbutsubto'] > 0) {
- $vhost_no = '30';
- } else {
- // number of dots in a domain specifies it's position (and depth of subdomain) starting at 29 going downwards on higher depth
- $vhost_no = (string)(30 - substr_count($domain['domain'], ".") + 1);
- }
-
- if ($ssl_vhost === true) {
- $vhost_filename = FileDir::makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/' . $vhost_no . '_froxlor_ssl_vhost_' . $domain['domain'] . '.conf');
- } else {
- $vhost_filename = FileDir::makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/' . $vhost_no . '_froxlor_normal_vhost_' . $domain['domain'] . '.conf');
- }
-
- return $vhost_filename;
- }
-
protected function getVhostContent($domain, $ssl_vhost = false)
{
if ($ssl_vhost === true && $domain['ssl'] != '1' && $domain['ssl_redirect'] != '1') {
diff --git a/lib/Froxlor/Domain/Domain.php b/lib/Froxlor/Domain/Domain.php
index 21aeead0..0f7a300b 100644
--- a/lib/Froxlor/Domain/Domain.php
+++ b/lib/Froxlor/Domain/Domain.php
@@ -235,51 +235,30 @@ class Domain
}
/**
- * check whether a domain has subdomains added as full-domains
- * #329
+ * get ids of domains that are main domains but a subdomain of another main domain (for DNS)
*
- * @param int $id domain-id
+ * @param int $id main-domain to check
*
- * @return bool
+ * @return array
* @throws \Exception
*/
- public static function domainHasMainSubDomains(int $id): bool
+ public static function getMainSubdomainIds(int $id): array
{
$result_stmt = Database::prepare("
- SELECT COUNT(`id`) as `mainsubs` FROM `" . TABLE_PANEL_DOMAINS . "`
- WHERE `ismainbutsubto` = :id");
- $result = Database::pexecute_first($result_stmt, [
- 'id' => $id
- ]);
-
- if ($result && isset($result['mainsubs'])) {
- return $result['mainsubs'] > 0;
- }
- return false;
- }
-
- /**
- * check whether a subof-domain exists
- * #329
- *
- * @param int $id subof-domain-id
- *
- * @return bool
- * @throws \Exception
- */
- public static function domainMainToSubExists(int $id): bool
- {
- $result_stmt = Database::prepare("
- SELECT `id` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `id` = :id");
+ SELECT id
+ FROM `" . TABLE_PANEL_DOMAINS . "`
+ WHERE
+ isbinddomain = 1 AND
+ domain LIKE CONCAT('%.', ( SELECT d.domain FROM `" . TABLE_PANEL_DOMAINS . "` AS d WHERE d.id = :id ))
+ ");
Database::pexecute($result_stmt, [
'id' => $id
]);
- $result = $result_stmt->fetch(PDO::FETCH_ASSOC);
-
- if ($result && isset($result['id'])) {
- return $result['id'] > 0;
+ $result = [];
+ while ($entry = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
+ $result = $entry['id'];
}
- return false;
+ return $result;
}
/**
diff --git a/lib/formfields/admin/domains/formfield.domains_add.php b/lib/formfields/admin/domains/formfield.domains_add.php
index c48d0ce3..5400cc7d 100644
--- a/lib/formfields/admin/domains/formfield.domains_add.php
+++ b/lib/formfields/admin/domains/formfield.domains_add.php
@@ -60,12 +60,6 @@ return [
'type' => 'select',
'select_var' => $domains
],
- 'issubof' => [
- 'label' => lng('domains.issubof'),
- 'desc' => lng('domains.issubofinfo'),
- 'type' => 'select',
- 'select_var' => $subtodomains
- ],
'caneditdomain' => [
'label' => lng('admin.domain_editable.title'),
'desc' => lng('admin.domain_editable.desc'),
diff --git a/lib/formfields/admin/domains/formfield.domains_edit.php b/lib/formfields/admin/domains/formfield.domains_edit.php
index c8f81bea..b6a9c308 100644
--- a/lib/formfields/admin/domains/formfield.domains_edit.php
+++ b/lib/formfields/admin/domains/formfield.domains_edit.php
@@ -65,13 +65,6 @@ return [
'select_var' => $domains,
'selected' => $result['aliasdomain']
],
- 'issubof' => [
- 'label' => lng('domains.issubof'),
- 'desc' => lng('domains.issubofinfo'),
- 'type' => 'select',
- 'select_var' => $subtodomains,
- 'selected' => $result['ismainbutsubto']
- ],
'associated_info' => [
'label' => lng('domains.associated_with_domain'),
'type' => 'label',
diff --git a/lng/de.lng.php b/lng/de.lng.php
index 7ce6d207..b899a717 100644
--- a/lng/de.lng.php
+++ b/lng/de.lng.php
@@ -665,9 +665,6 @@ return [
'aliasdomains' => 'Aliasdomains',
'redirectifpathisurl' => 'Redirect-Code (Standard: leer)',
'redirectifpathisurlinfo' => 'Der Redirect-Code kann gewählt werden, wenn der eingegebene Pfad eine URL ist.
HINWEIS: Änderungen werden nur wirksam wenn der Pfad eine URL ist.',
- 'issubof' => 'Diese Domain ist eine Subdomain von der Domain',
- 'issubofinfo' => 'Diese Einstellung muss gesetzt werden, wenn Sie eine Subdomain einer Hauptdomain als Hauptdomain anlegen (z. B. soll "www.domain.tld" hinzugefügt werden, somit muss hier "domain.tld" ausgewählt werden).',
- 'nosubtomaindomain' => 'Keine Subdomain einer Hauptdomain',
'ipandport_multi' => [
'title' => 'IP-Adresse(n)',
'description' => 'Definieren Sie eine oder mehrere IP-Adresse(n) für diese Domain.