implemented step 10 by Gemini

- added 4. step of wizard for style and images
This commit is contained in:
2026-06-14 08:07:23 +02:00
parent 991ff9de00
commit c11f7e4d75
5 changed files with 440 additions and 10 deletions

View File

@ -30,11 +30,23 @@ try {
sendResponse(false, ['code' => 'METHOD_NOT_ALLOWED', 'message' => 'Only POST requests are allowed.'], 405);
}
// Read JSON input
// Read JSON input or FormData
$input = file_get_contents('php://input');
$data = json_decode($input, true);
if (json_last_error() !== JSON_ERROR_NONE) {
// If multipart/form-data, action and project_id are in $_POST
if (!$data && !empty($_POST)) {
$data = [
'action' => $_POST['action'] ?? null,
'project_id' => $_POST['project_id'] ?? null,
'payload' => $_POST['payload'] ?? []
];
if (is_string($data['payload'])) {
$data['payload'] = json_decode($data['payload'], true);
}
}
if (!$data && $_SERVER['REQUEST_METHOD'] === 'POST') {
sendResponse(false, ['code' => 'INVALID_JSON', 'message' => 'Invalid JSON input.'], 400);
}
@ -44,10 +56,10 @@ try {
sendResponse(false, ['code' => 'MISSING_ACTION', 'message' => 'Action is required.'], 400);
}
// Check X-User-ID header (except for initSession if we want to allow it)
$userId = $_SERVER['HTTP_X_USER_ID'] ?? null;
// Check X-User-ID header (except for initSession)
$userId = $_SERVER['HTTP_X_USER_ID'] ?? $_POST['X-User-ID'] ?? null;
if (!$userId && $action !== 'initSession') {
sendResponse(false, ['code' => 'UNAUTHORIZED', 'message' => 'X-User-ID header is missing.'], 401);
sendResponse(false, ['code' => 'UNAUTHORIZED', 'message' => 'X-User-ID is missing.'], 401);
}
// Router
@ -109,6 +121,15 @@ try {
sendResponse($success, ['message' => 'Consent saved successfully.']);
break;
case 'uploadAsset':
$projectId = $data['project_id'] ?? null;
if (!$projectId || empty($_FILES['file'])) {
sendResponse(false, ['code' => 'MISSING_DATA', 'message' => 'Project ID and file are required.'], 400);
}
$result = $projectActions->uploadAsset($userId, $projectId, $_FILES['file']);
sendResponse(true, $result);
break;
default:
sendResponse(false, ['code' => 'UNKNOWN_ACTION', 'message' => "Action '$action' is not defined."], 404);
break;