Initial commit
This commit is contained in:
commit
05c65aad4d
155 changed files with 93617 additions and 0 deletions
24
viewer/admin/api/upload_schema.php
Normal file
24
viewer/admin/api/upload_schema.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
require __DIR__ . '/common.php';
|
||||
|
||||
$root = workspace_root();
|
||||
|
||||
// expects multipart/form-data with field 'file' and 'target' in POST (values: 'settings' or 'env')
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
http_response_code(405); json_response(['error'=>'method_not_allowed']);
|
||||
}
|
||||
|
||||
$target = $_POST['target'] ?? $_GET['target'] ?? null;
|
||||
if (!$target) { http_response_code(400); json_response(['error'=>'missing_target']); }
|
||||
|
||||
if ($target === 'settings') {
|
||||
$dest = $root . '/viewer-settings.schema.json';
|
||||
} elseif ($target === 'env') {
|
||||
$dest = $root . '/scripts/.env.schema.json';
|
||||
} else {
|
||||
http_response_code(400); json_response(['error'=>'invalid_target']);
|
||||
}
|
||||
|
||||
$res = save_uploaded_schema($dest);
|
||||
if (isset($res['ok'])) json_response($res);
|
||||
http_response_code(400); json_response($res);
|
||||
Loading…
Add table
Add a link
Reference in a new issue