make selection of config-services downloadable as json e.g. for config-services script

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-04-30 11:26:39 +02:00
parent 422950d386
commit c7226a16d2
3 changed files with 31 additions and 0 deletions

View File

@@ -80,6 +80,8 @@ class Ajax
return $this->editApiKey();
case 'getConfigDetails':
return $this->getConfigDetails();
case 'getConfigJsonExport':
return $this->getConfigJsonExport();
default:
return $this->errorResponse('Action not found!');
}
@@ -324,4 +326,19 @@ class Ajax
}
return $this->errorResponse('Not allowed', 403);
}
/**
* download JSON export of config-selection
*/
private function getConfigJsonExport()
{
if (isset($this->userinfo['adminsession']) && $this->userinfo['adminsession'] == 1 && $this->userinfo['change_serversettings'] == 1) {
$params = $_GET;
unset($params['action']);
unset($params['finish']);
header('Content-disposition: attachment; filename=froxlor-config-' . time() . '.json');
return $this->jsonResponse($params);
}
return $this->errorResponse('Not allowed', 403);
}
}