fix IpsAndPorts.delete
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -372,7 +372,12 @@ class IpsAndPorts extends ApiCommand implements ResourceEntity
|
|||||||
inserttask('4');
|
inserttask('4');
|
||||||
|
|
||||||
$this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] changed IP/port from '" . $result['ip'] . ":" . $result['port'] . "' to '" . $ip . ":" . $port . "'");
|
$this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] changed IP/port from '" . $result['ip'] . ":" . $result['port'] . "' to '" . $ip . ":" . $port . "'");
|
||||||
return $this->response(200, "successfull", $upd_data);
|
|
||||||
|
$json_result = IpsAndPorts::getLocal($this->getUserData(), array(
|
||||||
|
'id' => $result['id']
|
||||||
|
))->get();
|
||||||
|
$result = json_decode($json_result, true)['data'];
|
||||||
|
return $this->response(200, "successfull", $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception("Not allowed to execute given command.", 403);
|
throw new Exception("Not allowed to execute given command.", 403);
|
||||||
@@ -397,7 +402,7 @@ class IpsAndPorts extends ApiCommand implements ResourceEntity
|
|||||||
'id' => $id
|
'id' => $id
|
||||||
))->get();
|
))->get();
|
||||||
$result = json_decode($json_result, true)['data'];
|
$result = json_decode($json_result, true)['data'];
|
||||||
|
|
||||||
$result_checkdomain_stmt = Database::prepare("
|
$result_checkdomain_stmt = Database::prepare("
|
||||||
SELECT `id_domain` as `id` FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_ipandports` = :id
|
SELECT `id_domain` as `id` FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_ipandports` = :id
|
||||||
");
|
");
|
||||||
@@ -405,9 +410,12 @@ class IpsAndPorts extends ApiCommand implements ResourceEntity
|
|||||||
'id' => $id
|
'id' => $id
|
||||||
), true, true);
|
), true, true);
|
||||||
|
|
||||||
if ($result_checkdomain['id'] == '') {
|
if (empty($result_checkdomain)) {
|
||||||
if (! in_array($result['id'], explode(',', Settings::Get('system.defaultip'))) && ! in_array($result['id'], explode(',', Settings::Get('system.defaultsslip')))) {
|
if (! in_array($result['id'], explode(',', Settings::Get('system.defaultip'))) && ! in_array($result['id'], explode(',', Settings::Get('system.defaultsslip')))) {
|
||||||
|
|
||||||
|
// check whether there is the same IP with a different port
|
||||||
|
// in case this ip-address is the system.ipaddress and therefore
|
||||||
|
// when there is one - we have an alternative
|
||||||
$result_sameipotherport_stmt = Database::prepare("
|
$result_sameipotherport_stmt = Database::prepare("
|
||||||
SELECT `id` FROM `" . TABLE_PANEL_IPSANDPORTS . "`
|
SELECT `id` FROM `" . TABLE_PANEL_IPSANDPORTS . "`
|
||||||
WHERE `ip` = :ip AND `id` <> :id");
|
WHERE `ip` = :ip AND `id` <> :id");
|
||||||
@@ -417,37 +425,29 @@ class IpsAndPorts extends ApiCommand implements ResourceEntity
|
|||||||
));
|
));
|
||||||
|
|
||||||
if (($result['ip'] != Settings::Get('system.ipaddress')) || ($result['ip'] == Settings::Get('system.ipaddress') && $result_sameipotherport['id'] != '')) {
|
if (($result['ip'] != Settings::Get('system.ipaddress')) || ($result['ip'] == Settings::Get('system.ipaddress') && $result_sameipotherport['id'] != '')) {
|
||||||
$result_stmt = Database::prepare("
|
|
||||||
SELECT `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "`
|
$del_stmt = Database::prepare("
|
||||||
WHERE `id` = :id");
|
DELETE FROM `" . TABLE_PANEL_IPSANDPORTS . "`
|
||||||
$result = Database::pexecute_first($result_stmt, array(
|
WHERE `id` = :id
|
||||||
|
");
|
||||||
|
Database::pexecute($del_stmt, array(
|
||||||
'id' => $id
|
'id' => $id
|
||||||
));
|
), true, true);
|
||||||
if ($result['ip'] != '') {
|
|
||||||
|
// also, remove connections to domains (multi-stack)
|
||||||
$del_stmt = Database::prepare("
|
$del_stmt = Database::prepare("
|
||||||
DELETE FROM `" . TABLE_PANEL_IPSANDPORTS . "`
|
DELETE FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_ipandports` = :id
|
||||||
WHERE `id` = :id
|
");
|
||||||
");
|
Database::pexecute($del_stmt, array(
|
||||||
Database::pexecute($del_stmt, array(
|
'id' => $id
|
||||||
'id' => $id
|
), true, true);
|
||||||
));
|
|
||||||
|
inserttask('1');
|
||||||
// also, remove connections to domains (multi-stack)
|
// Using nameserver, insert a task which rebuilds the server config
|
||||||
$del_stmt = Database::prepare("
|
inserttask('4');
|
||||||
DELETE FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_ipandports` = :id
|
|
||||||
");
|
$this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] deleted IP/port '" . $result['ip'] . ":" . $result['port'] . "'");
|
||||||
Database::pexecute($del_stmt, array(
|
return $this->response(200, "successfull", $result);
|
||||||
'id' => $id
|
|
||||||
));
|
|
||||||
|
|
||||||
inserttask('1');
|
|
||||||
// Using nameserver, insert a task which rebuilds the server config
|
|
||||||
inserttask('4');
|
|
||||||
|
|
||||||
$this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] deleted IP/port '" . $result['ip'] . ":" . $result['port'] . "'");
|
|
||||||
return $this->response(200, "successfull", $result);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
standard_error('cantdeletesystemip', '', true);
|
standard_error('cantdeletesystemip', '', true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ $lng['mysql']['description'] = 'Here you can create and change your MySQL-databa
|
|||||||
$lng['serversettings']['paging']['title'] = 'Entries per page';
|
$lng['serversettings']['paging']['title'] = 'Entries per page';
|
||||||
$lng['serversettings']['paging']['description'] = 'How many entries shall be shown on one page? (0 = disable paging)';
|
$lng['serversettings']['paging']['description'] = 'How many entries shall be shown on one page? (0 = disable paging)';
|
||||||
$lng['error']['ipstillhasdomains'] = 'The IP/Port combination you want to delete still has domains assigned to it, please reassign those to other IP/Port combinations before deleting this IP/Port combination.';
|
$lng['error']['ipstillhasdomains'] = 'The IP/Port combination you want to delete still has domains assigned to it, please reassign those to other IP/Port combinations before deleting this IP/Port combination.';
|
||||||
$lng['error']['cantdeletedefaultip'] = 'You cannot delete the default reseller IP/Port combination, please make another IP/Port combination default for resellers before deleting this IP/Port combination.';
|
$lng['error']['cantdeletedefaultip'] = 'You cannot delete the default IP/Port combination, please make another IP/Port combination default for before deleting this IP/Port combination.';
|
||||||
$lng['error']['cantdeletesystemip'] = 'You cannot delete the last system IP, either create a new IP/Port combination for the system IP or change the system IP.';
|
$lng['error']['cantdeletesystemip'] = 'You cannot delete the last system IP, either create a new IP/Port combination for the system IP or change the system IP.';
|
||||||
$lng['error']['myipaddress'] = '\'IP\'';
|
$lng['error']['myipaddress'] = '\'IP\'';
|
||||||
$lng['error']['myport'] = '\'Port\'';
|
$lng['error']['myport'] = '\'Port\'';
|
||||||
|
|||||||
Reference in New Issue
Block a user