diff --git a/api/helpers.php b/api/helpers.php index 2a4d178..830dbc8 100644 --- a/api/helpers.php +++ b/api/helpers.php @@ -191,8 +191,12 @@ function baseUrl(): string { return isDev() ? 'https://dev.payfrit.com' : 'https://biz.payfrit.com'; } +function appRoot(): string { + return '/var/www/payfrit-api'; +} + function uploadsRoot(): string { - return '/opt/payfrit-api/uploads'; + return appRoot() . '/uploads'; } // ============================================ diff --git a/api/setup/analyzeMenuUrl.php b/api/setup/analyzeMenuUrl.php index 2d4b1aa..f9bb574 100644 --- a/api/setup/analyzeMenuUrl.php +++ b/api/setup/analyzeMenuUrl.php @@ -628,11 +628,10 @@ JSEOF; // Helper: expand a URL path to a local file path $expandPath = function(string $urlPath): string { - // /uploads/items/123.jpg → /opt/payfrit-api/uploads/items/123.jpg if (str_starts_with($urlPath, '/uploads/')) { return uploadsRoot() . substr($urlPath, 8); } - return '/opt/payfrit-api' . $urlPath; + return appRoot() . $urlPath; }; // Helper: convert 24h time to 12h format string diff --git a/api/setup/saveWizard.php b/api/setup/saveWizard.php index c80f9c0..c647423 100644 --- a/api/setup/saveWizard.php +++ b/api/setup/saveWizard.php @@ -688,7 +688,7 @@ try { // Clean up temp folder from ZIP upload $tempFolder = is_string($data['tempFolder'] ?? null) ? trim($data['tempFolder']) : ''; if (strlen($tempFolder) && preg_match('/^[a-f0-9]{32}$/', $tempFolder)) { - $tempFolderPath = "/opt/payfrit-api/temp/menu-import/$tempFolder"; + $tempFolderPath = appRoot() . "/temp/menu-import/$tempFolder"; if (is_dir($tempFolderPath)) { exec("rm -rf " . escapeshellarg($tempFolderPath)); $response['steps'][] = "Cleaned up temp folder: $tempFolder"; diff --git a/api/setup/uploadSavedPage.php b/api/setup/uploadSavedPage.php index a76e3c9..cd2ff8a 100644 --- a/api/setup/uploadSavedPage.php +++ b/api/setup/uploadSavedPage.php @@ -12,7 +12,7 @@ runAuth(); $response = ['OK' => false, 'MESSAGE' => '', 'URL' => '']; try { - $tempBaseDir = "/opt/payfrit-api/temp/menu-import"; + $tempBaseDir = appRoot() . "/temp/menu-import"; // Create temp directory if needed if (!is_dir($tempBaseDir)) {