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
|
||||||
|
$defaultips = explode(',', Settings::Get('system.defaultip'));
|
||||||
|
foreach ($defaultips as $defaultip) {
|
||||||
$ins_stmt = Database::prepare("
|
$ins_stmt = Database::prepare("
|
||||||
INSERT INTO `".TABLE_DOMAINTOIP."` SET `id_domain` = :domainid, `id_ipandports` = :ipid"
|
INSERT INTO `" . TABLE_DOMAINTOIP . "` SET `id_domain` = :domainid, `id_ipandports` = :ipid"
|
||||||
);
|
);
|
||||||
Database::pexecute($ins_stmt, array('domainid' => $domainid, 'ipid' => Settings::Get('system.defaultip')));
|
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
|
||||||
|
$defaultips = explode(',', Settings::Get('system.defaultip'));
|
||||||
|
foreach ($defaultips as $defaultip) {
|
||||||
$ins_stmt = Database::prepare("
|
$ins_stmt = Database::prepare("
|
||||||
INSERT INTO `".TABLE_DOMAINTOIP."` SET `id_domain` = :domainid, `id_ipandports` = :ipid"
|
INSERT INTO `" . TABLE_DOMAINTOIP . "` SET `id_domain` = :domainid, `id_ipandports` = :ipid"
|
||||||
);
|
);
|
||||||
Database::pexecute($ins_stmt, array('domainid' => $domainid, 'ipid' => Settings::Get('system.defaultip')));
|
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 . "`
|
||||||
|
|||||||
@@ -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'] ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,9 @@ class IntegrityCheck {
|
|||||||
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");
|
||||||
|
|||||||
@@ -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