Enable multiple standard IPs
This commit is contained in:
@@ -55,7 +55,7 @@ return array(
|
|||||||
'settinggroup' => 'system',
|
'settinggroup' => 'system',
|
||||||
'varname' => 'defaultip',
|
'varname' => 'defaultip',
|
||||||
'type' => 'option',
|
'type' => 'option',
|
||||||
'option_mode' => 'one',
|
'option_mode' => 'multiple',
|
||||||
'option_options_method' => 'getIpPortCombinations',
|
'option_options_method' => 'getIpPortCombinations',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'save_method' => 'storeSettingDefaultIp',
|
'save_method' => 'storeSettingDefaultIp',
|
||||||
|
|||||||
@@ -913,10 +913,13 @@ if ($page == 'customers'
|
|||||||
$domainid = Database::lastInsertId();
|
$domainid = Database::lastInsertId();
|
||||||
|
|
||||||
// set ip <-> domain connection
|
// set ip <-> domain connection
|
||||||
$ins_stmt = Database::prepare("
|
$defaultips = explode(',', Settings::Get('system.defaultip'));
|
||||||
INSERT INTO `".TABLE_DOMAINTOIP."` SET `id_domain` = :domainid, `id_ipandports` = :ipid"
|
foreach ($defaultips as $defaultip) {
|
||||||
);
|
$ins_stmt = Database::prepare("
|
||||||
Database::pexecute($ins_stmt, array('domainid' => $domainid, 'ipid' => Settings::Get('system.defaultip')));
|
INSERT INTO `" . TABLE_DOMAINTOIP . "` SET `id_domain` = :domainid, `id_ipandports` = :ipid"
|
||||||
|
);
|
||||||
|
Database::pexecute($ins_stmt, array('domainid' => $domainid, 'ipid' => $defaultip));
|
||||||
|
}
|
||||||
|
|
||||||
$upd_stmt = Database::prepare("
|
$upd_stmt = Database::prepare("
|
||||||
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `standardsubdomain` = :domainid WHERE `customerid` = :customerid"
|
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `standardsubdomain` = :domainid WHERE `customerid` = :customerid"
|
||||||
@@ -937,7 +940,7 @@ if ($page == 'customers'
|
|||||||
SELECT ip, port FROM `".TABLE_PANEL_IPSANDPORTS."`
|
SELECT ip, port FROM `".TABLE_PANEL_IPSANDPORTS."`
|
||||||
WHERE `id` = :defaultip
|
WHERE `id` = :defaultip
|
||||||
");
|
");
|
||||||
$srv_ip = Database::pexecute_first($srv_ip_stmt, array('defaultip' => Settings::Get('system.defaultip')));
|
$srv_ip = Database::pexecute_first($srv_ip_stmt, array('defaultip' => reset(explode(',', Settings::Get('system.defaultip')))));
|
||||||
|
|
||||||
$replace_arr = array(
|
$replace_arr = array(
|
||||||
'FIRSTNAME' => $firstname,
|
'FIRSTNAME' => $firstname,
|
||||||
@@ -1272,10 +1275,13 @@ if ($page == 'customers'
|
|||||||
$domainid = Database::lastInsertId();
|
$domainid = Database::lastInsertId();
|
||||||
|
|
||||||
// set ip <-> domain connection
|
// set ip <-> domain connection
|
||||||
$ins_stmt = Database::prepare("
|
$defaultips = explode(',', Settings::Get('system.defaultip'));
|
||||||
INSERT INTO `".TABLE_DOMAINTOIP."` SET `id_domain` = :domainid, `id_ipandports` = :ipid"
|
foreach ($defaultips as $defaultip) {
|
||||||
);
|
$ins_stmt = Database::prepare("
|
||||||
Database::pexecute($ins_stmt, array('domainid' => $domainid, 'ipid' => Settings::Get('system.defaultip')));
|
INSERT INTO `" . TABLE_DOMAINTOIP . "` SET `id_domain` = :domainid, `id_ipandports` = :ipid"
|
||||||
|
);
|
||||||
|
Database::pexecute($ins_stmt, array('domainid' => $domainid, 'ipid' => $defaultip));
|
||||||
|
}
|
||||||
|
|
||||||
$upd_stmt = Database::prepare("
|
$upd_stmt = Database::prepare("
|
||||||
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `standardsubdomain` = :domainid WHERE `customerid` = :customerid"
|
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `standardsubdomain` = :domainid WHERE `customerid` = :customerid"
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ if ($page == 'ipsandports'
|
|||||||
$result_checkdomain = Database::pexecute_first($result_checkdomain_stmt, array('id' => $id));
|
$result_checkdomain = Database::pexecute_first($result_checkdomain_stmt, array('id' => $id));
|
||||||
|
|
||||||
if ($result_checkdomain['id'] == '') {
|
if ($result_checkdomain['id'] == '') {
|
||||||
if ($result['id'] != Settings::Get('system.defaultip')) {
|
if (!in_array($result['id'], explode(',', Settings::Get('system.defaultip')))) {
|
||||||
|
|
||||||
$result_sameipotherport_stmt = Database::prepare("
|
$result_sameipotherport_stmt = Database::prepare("
|
||||||
SELECT `id` FROM `" . TABLE_PANEL_IPSANDPORTS . "`
|
SELECT `id` FROM `" . TABLE_PANEL_IPSANDPORTS . "`
|
||||||
@@ -324,7 +324,7 @@ if ($page == 'ipsandports'
|
|||||||
$ssl_ca_file = '';
|
$ssl_ca_file = '';
|
||||||
$ssl_cert_chainfile = '';
|
$ssl_cert_chainfile = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($listen_statement != '1') {
|
if ($listen_statement != '1') {
|
||||||
$listen_statement = '0';
|
$listen_statement = '0';
|
||||||
}
|
}
|
||||||
@@ -344,7 +344,7 @@ if ($page == 'ipsandports'
|
|||||||
if ($ssl != '1') {
|
if ($ssl != '1') {
|
||||||
$ssl = '0';
|
$ssl = '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ssl_cert_file != '') {
|
if ($ssl_cert_file != '') {
|
||||||
$ssl_cert_file = makeCorrectFile($ssl_cert_file);
|
$ssl_cert_file = makeCorrectFile($ssl_cert_file);
|
||||||
}
|
}
|
||||||
@@ -426,7 +426,7 @@ if ($page == 'ipsandports'
|
|||||||
|
|
||||||
$ipsandports_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/ipsandports/formfield.ipsandports_edit.php';
|
$ipsandports_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/ipsandports/formfield.ipsandports_edit.php';
|
||||||
$ipsandports_edit_form = htmlform::genHTMLForm($ipsandports_edit_data);
|
$ipsandports_edit_form = htmlform::genHTMLForm($ipsandports_edit_data);
|
||||||
|
|
||||||
$title = $ipsandports_edit_data['ipsandports_edit']['title'];
|
$title = $ipsandports_edit_data['ipsandports_edit']['title'];
|
||||||
$image = $ipsandports_edit_data['ipsandports_edit']['image'];
|
$image = $ipsandports_edit_data['ipsandports_edit']['image'];
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||||
* @package Integrity
|
* @package Integrity
|
||||||
*
|
*
|
||||||
* IntegrityCheck - class
|
* IntegrityCheck - class
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class IntegrityCheck {
|
class IntegrityCheck {
|
||||||
@@ -28,7 +28,7 @@ class IntegrityCheck {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* Parses all available checks into $this->available
|
* Parses all available checks into $this->available
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
global $userinfo;
|
global $userinfo;
|
||||||
@@ -41,7 +41,7 @@ class IntegrityCheck {
|
|||||||
unset($this->available[array_search('checkAll', $this->available)]);
|
unset($this->available[array_search('checkAll', $this->available)]);
|
||||||
unset($this->available[array_search('fixAll', $this->available)]);
|
unset($this->available[array_search('fixAll', $this->available)]);
|
||||||
sort($this->available);
|
sort($this->available);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,9 +130,9 @@ class IntegrityCheck {
|
|||||||
while ($row = $adm_stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($row = $adm_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
if ($row['ip'] < 0 || is_null($row['ip']) || empty($row['ip'])) {
|
if ($row['ip'] < 0 || is_null($row['ip']) || empty($row['ip'])) {
|
||||||
// Admin uses default-IP
|
// Admin uses default-IP
|
||||||
$admips[$row['adminid']] = Settings::Get('system.defaultip');
|
$admips[$row['adminid']] = explode(',', Settings::Get('system.defaultip'));
|
||||||
} else {
|
} else {
|
||||||
$admips[$row['adminid']] = $row['ip'];
|
$admips[$row['adminid']] = [ $row['ip'] ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,19 +143,19 @@ class IntegrityCheck {
|
|||||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
$ips[$row['id']] = $row['ip'] . ':' . $row['port'];
|
$ips[$row['id']] = $row['ip'] . ':' . $row['port'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache all configured domains
|
// Cache all configured domains
|
||||||
$result_stmt = Database::prepare("SELECT `id`, `adminid` FROM `" . TABLE_PANEL_DOMAINS . "` ORDER BY `id` ASC");
|
$result_stmt = Database::prepare("SELECT `id`, `adminid` FROM `" . TABLE_PANEL_DOMAINS . "` ORDER BY `id` ASC");
|
||||||
Database::pexecute($result_stmt);
|
Database::pexecute($result_stmt);
|
||||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
$domains[$row['id']] = $row['adminid'];
|
$domains[$row['id']] = $row['adminid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if every domain to ip/port - association is valid in TABLE_DOMAINTOIP
|
// Check if every domain to ip/port - association is valid in TABLE_DOMAINTOIP
|
||||||
$result_stmt = Database::prepare("SELECT `id_domain`, `id_ipandports` FROM `" . TABLE_DOMAINTOIP . "`");
|
$result_stmt = Database::prepare("SELECT `id_domain`, `id_ipandports` FROM `" . TABLE_DOMAINTOIP . "`");
|
||||||
Database::pexecute($result_stmt);
|
Database::pexecute($result_stmt);
|
||||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
if (!array_key_exists($row['id_ipandports'], $ips)) {
|
if (!array_key_exists($row['id_ipandports'], $ips)) {
|
||||||
if ($fix) {
|
if ($fix) {
|
||||||
Database::pexecute($del_stmt, array('domainid' => $row['id_domain'], 'ipandportid' => $row['id_ipandports']));
|
Database::pexecute($del_stmt, array('domainid' => $row['id_domain'], 'ipandportid' => $row['id_ipandports']));
|
||||||
$this->_log->logAction(ADM_ACTION, LOG_WARNING, "found an ip/port-id in domain <> ip table which does not exist, integrity check fixed this");
|
$this->_log->logAction(ADM_ACTION, LOG_WARNING, "found an ip/port-id in domain <> ip table which does not exist, integrity check fixed this");
|
||||||
@@ -170,18 +170,20 @@ class IntegrityCheck {
|
|||||||
$this->_log->logAction(ADM_ACTION, LOG_WARNING, "found a domain-id in domain <> ip table which does not exist, integrity check fixed this");
|
$this->_log->logAction(ADM_ACTION, LOG_WARNING, "found a domain-id in domain <> ip table which does not exist, integrity check fixed this");
|
||||||
} else {
|
} else {
|
||||||
$this->_log->logAction(ADM_ACTION, LOG_NOTICE, "found a domain-id in domain <> ip table which does not exist, integrity check can fix this");
|
$this->_log->logAction(ADM_ACTION, LOG_NOTICE, "found a domain-id in domain <> ip table which does not exist, integrity check can fix this");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Save one IP/Port combination per domain, so we know, if one domain is missing an IP
|
// Save one IP/Port combination per domain, so we know, if one domain is missing an IP
|
||||||
$ipstodomains[$row['id_domain']] = $row['id_ipandports'];
|
$ipstodomains[$row['id_domain']] = $row['id_ipandports'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that all domains have at least one IP/Port combination
|
// Check that all domains have at least one IP/Port combination
|
||||||
foreach ($domains as $domainid => $adminid) {
|
foreach ($domains as $domainid => $adminid) {
|
||||||
if (!array_key_exists($domainid, $ipstodomains)) {
|
if (!array_key_exists($domainid, $ipstodomains)) {
|
||||||
if ($fix) {
|
if ($fix) {
|
||||||
Database::pexecute($ins_stmt, array('domainid' => $domainid, 'ipandportid' => $admips[$adminid]));
|
foreach ($admips[$adminid] as $defaultip) {
|
||||||
|
Database::pexecute($ins_stmt, array('domainid' => $domainid, 'ipandportid' => $defaultip));
|
||||||
|
}
|
||||||
$this->_log->logAction(ADM_ACTION, LOG_WARNING, "found a domain-id with no entry in domain <> ip table, integrity check fixed this");
|
$this->_log->logAction(ADM_ACTION, LOG_WARNING, "found a domain-id with no entry in domain <> ip table, integrity check fixed this");
|
||||||
} else {
|
} else {
|
||||||
$this->_log->logAction(ADM_ACTION, LOG_NOTICE, "found a domain-id with no entry in domain <> ip table, integrity check can fix this");
|
$this->_log->logAction(ADM_ACTION, LOG_NOTICE, "found a domain-id with no entry in domain <> ip table, integrity check can fix this");
|
||||||
@@ -220,7 +222,7 @@ class IntegrityCheck {
|
|||||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
$ips[$row['id']] = $row['ip'] . ':' . $row['port'];
|
$ips[$row['id']] = $row['ip'] . ':' . $row['port'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache all configured domains
|
// Cache all configured domains
|
||||||
$result_stmt = Database::prepare("SELECT `id`, `parentdomainid`, `ssl_redirect` FROM `" . TABLE_PANEL_DOMAINS . "` ORDER BY `id` ASC");
|
$result_stmt = Database::prepare("SELECT `id`, `parentdomainid`, `ssl_redirect` FROM `" . TABLE_PANEL_DOMAINS . "` ORDER BY `id` ASC");
|
||||||
$ip_stmt = Database::prepare("SELECT `id_domain`, `id_ipandports` FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :domainid");
|
$ip_stmt = Database::prepare("SELECT `id_domain`, `id_ipandports` FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = :domainid");
|
||||||
@@ -232,7 +234,7 @@ class IntegrityCheck {
|
|||||||
Database::pexecute($ip_stmt, array('domainid' => $row['id']));
|
Database::pexecute($ip_stmt, array('domainid' => $row['id']));
|
||||||
while ($iprow = $ip_stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($iprow = $ip_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
// If the parentdomain has an ip/port assigned which we know is SSL enabled, set the parentdomain to "true"
|
// If the parentdomain has an ip/port assigned which we know is SSL enabled, set the parentdomain to "true"
|
||||||
if (array_key_exists($iprow['id_ipandports'], $ips)) { $parentdomains[$row['id']] = true; }
|
if (array_key_exists($iprow['id_ipandports'], $ips)) { $parentdomains[$row['id']] = true; }
|
||||||
}
|
}
|
||||||
} elseif ($row['ssl_redirect'] == 1) {
|
} elseif ($row['ssl_redirect'] == 1) {
|
||||||
// All subdomains with enabled ssl_redirect enabled are stored
|
// All subdomains with enabled ssl_redirect enabled are stored
|
||||||
@@ -240,14 +242,14 @@ class IntegrityCheck {
|
|||||||
$subdomains[$row['parentdomainid']][] = $row['id'];
|
$subdomains[$row['parentdomainid']][] = $row['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if every parentdomain with enabled ssl_redirect as SSL enabled
|
// Check if every parentdomain with enabled ssl_redirect as SSL enabled
|
||||||
foreach ($parentdomains as $id => $sslavailable) {
|
foreach ($parentdomains as $id => $sslavailable) {
|
||||||
// This parentdomain has no subdomains
|
// This parentdomain has no subdomains
|
||||||
if (!isset($subdomains[$id])) { continue; }
|
if (!isset($subdomains[$id])) { continue; }
|
||||||
// This parentdomain has SSL enabled, doesn't matter what status the subdomains have
|
// This parentdomain has SSL enabled, doesn't matter what status the subdomains have
|
||||||
if ($sslavailable) { continue; }
|
if ($sslavailable) { continue; }
|
||||||
|
|
||||||
// At this point only parentdomains reside which have ssl_redirect enabled subdomains
|
// At this point only parentdomains reside which have ssl_redirect enabled subdomains
|
||||||
if ($fix) {
|
if ($fix) {
|
||||||
// We make a blanket update to all subdomains of this parentdomain, doesn't matter which one is wrong, all have to be disabled
|
// We make a blanket update to all subdomains of this parentdomain, doesn't matter which one is wrong, all have to be disabled
|
||||||
@@ -259,7 +261,7 @@ class IntegrityCheck {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($fix) {
|
if ($fix) {
|
||||||
return $this->SubdomainSslRedirect();
|
return $this->SubdomainSslRedirect();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ return array(
|
|||||||
'desc' => $lng['domains']['ipandport_multi']['description'],
|
'desc' => $lng['domains']['ipandport_multi']['description'],
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
'values' => $ipsandports,
|
'values' => $ipsandports,
|
||||||
'value' => array(Settings::Get('system.defaultip')),
|
'value' => explode(',', Settings::Get('system.defaultip')),
|
||||||
'is_array' => 1,
|
'is_array' => 1,
|
||||||
'mandatory' => true
|
'mandatory' => true
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function storeSettingDefaultIp($fieldname, $fielddata, $newfieldvalue) {
|
function storeSettingDefaultIp($fieldname, $fielddata, $newfieldvalue) {
|
||||||
|
$defaultips_old = Settings::Get('system.defaultip');
|
||||||
|
|
||||||
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
||||||
|
|
||||||
@@ -40,13 +41,27 @@ function storeSettingDefaultIp($fieldname, $fielddata, $newfieldvalue) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (count($ids) > 0) {
|
if (count($ids) > 0) {
|
||||||
$upd_stmt = Database::prepare("
|
$defaultips_new = explode(',', $newfieldvalue);
|
||||||
UPDATE `" . TABLE_DOMAINTOIP . "` SET
|
|
||||||
`id_ipandports` = :newval
|
// Delete the existing mappings linking to default IPs
|
||||||
WHERE `id_domain` IN ('" . implode(', ', $ids) . "')
|
$del_stmt = Database::prepare("
|
||||||
AND `id_ipandports` = :defaultip
|
DELETE FROM `" . TABLE_DOMAINTOIP . "`
|
||||||
|
WHERE `id_domain` IN (" . implode(', ', $ids) . ")
|
||||||
|
AND `id_ipandports` IN (" . $defaultips_old . ")
|
||||||
");
|
");
|
||||||
Database::pexecute($upd_stmt, array('newval' => $newfieldvalue, 'defaultip' => Settings::Get('system.defaultip')));
|
Database::pexecute($del_stmt);
|
||||||
|
|
||||||
|
// Insert the new mappings
|
||||||
|
$ins_stmt = Database::prepare("
|
||||||
|
INSERT INTO `" . TABLE_DOMAINTOIP . "`
|
||||||
|
SET `id_domain` = :domainid, `id_ipandports` = :ipandportid
|
||||||
|
");
|
||||||
|
|
||||||
|
foreach ($ids as $id) {
|
||||||
|
foreach ($defaultips_new as $defaultip_new) {
|
||||||
|
Database::pexecute($ins_stmt, array('domainid' => $id, 'ipandportid' => $defaultip_new));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user