asdsd
This commit is contained in:
@@ -38,7 +38,7 @@ $publicPaths = [
|
||||
'auth/me',
|
||||
'module/pi_control/terminal_info',
|
||||
];
|
||||
$requiresGlobalAuth = in_array($uriPath, ['settings', 'users', 'modules', 'modules/install', 'debug'], true)
|
||||
$requiresGlobalAuth = in_array($uriPath, ['settings', 'users', 'modules', 'modules/install', 'debug', 'exports/database.sql'], true)
|
||||
|| str_starts_with($uriPath, 'modules/setup/');
|
||||
if (defined('APP_AUTH_ENABLED') && APP_AUTH_ENABLED && $requiresGlobalAuth && !in_array($uriPath, $publicPaths, true)) {
|
||||
$user = auth_user();
|
||||
@@ -76,6 +76,23 @@ if ($uriPath === 'auth/me') {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($uriPath === 'exports/database.sql') {
|
||||
require_admin();
|
||||
$pdo = app()->basePdo() ?: app()->pdo();
|
||||
if (!$pdo instanceof PDO) {
|
||||
http_response_code(500);
|
||||
exit('Keine Datenbankverbindung fuer den Export verfuegbar.');
|
||||
}
|
||||
|
||||
$filename = 'nexus-export-' . gmdate('Ymd-His') . '.sql';
|
||||
$sql = (new \App\SqlDataExporter())->export($pdo, 'nexus');
|
||||
header('Content-Type: application/sql; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
||||
header('X-Content-Type-Options: nosniff');
|
||||
echo $sql;
|
||||
exit;
|
||||
}
|
||||
|
||||
if (preg_match('~^api/module-auth/([a-zA-Z0-9_-]+)$~', $uriPath, $moduleAuthMatches)) {
|
||||
$moduleName = $moduleAuthMatches[1];
|
||||
$moduleMeta = app()->modules()->get($moduleName);
|
||||
|
||||
Reference in New Issue
Block a user