diff --git a/api/auth/avatar.php b/api/auth/avatar.php index 86b3470..3a4445a 100644 --- a/api/auth/avatar.php +++ b/api/auth/avatar.php @@ -15,7 +15,7 @@ if ($userId <= 0) { apiAbort(['OK' => false, 'ERROR' => 'not_logged_in', 'MESSAGE' => 'Authentication required']); } -$uploadsDir = luceeWebroot() . '/uploads/users'; +$uploadsDir = uploadsRoot() . '/users'; $avatarUrl = baseUrl() . '/uploads/users/'; // Find existing avatar (check multiple extensions) diff --git a/api/helpers.php b/api/helpers.php index b16135f..2a4d178 100644 --- a/api/helpers.php +++ b/api/helpers.php @@ -191,8 +191,8 @@ function baseUrl(): string { return isDev() ? 'https://dev.payfrit.com' : 'https://biz.payfrit.com'; } -function luceeWebroot(): string { - return '/opt/lucee/tomcat/webapps/ROOT'; +function uploadsRoot(): string { + return '/opt/payfrit-api/uploads'; } // ============================================ diff --git a/api/menu/getForBuilder.php b/api/menu/getForBuilder.php index 9a84be9..c6c52d5 100644 --- a/api/menu/getForBuilder.php +++ b/api/menu/getForBuilder.php @@ -292,7 +292,7 @@ try { // Build items lookup by CategoryID $itemsByCategory = []; - $uploadsDir = luceeWebroot() . '/uploads/items'; + $uploadsDir = uploadsRoot() . '/items'; foreach ($qItemRows as $item) { $catID = (int) $item['CategoryItemID']; $itemID = (int) $item['ID']; diff --git a/api/menu/uploadHeader.php b/api/menu/uploadHeader.php index 45da4a1..9c5b7b9 100644 --- a/api/menu/uploadHeader.php +++ b/api/menu/uploadHeader.php @@ -22,7 +22,7 @@ if (!isset($_FILES['header']) || $_FILES['header']['error'] !== UPLOAD_ERR_OK) { jsonResponse(['OK' => false, 'ERROR' => 'no_file', 'MESSAGE' => 'No file was uploaded']); } -$headersDir = luceeWebroot() . '/uploads/headers'; +$headersDir = uploadsRoot() . '/headers'; if (!is_dir($headersDir)) { mkdir($headersDir, 0755, true); } diff --git a/api/menu/uploadItemPhoto.php b/api/menu/uploadItemPhoto.php index 8316ba9..9325958 100644 --- a/api/menu/uploadItemPhoto.php +++ b/api/menu/uploadItemPhoto.php @@ -25,8 +25,8 @@ if (!in_array($ext, $allowedExtensions)) { jsonResponse(['OK' => false, 'ERROR' => 'invalid_type', 'MESSAGE' => "Only image files are accepted (jpg, jpeg, gif, png, webp, heic). Got: $ext"]); } -// Determine uploads directory (must be in Lucee webroot, not PHP docroot) -$itemsDir = luceeWebroot() . '/uploads/items'; +// Determine uploads directory +$itemsDir = uploadsRoot() . '/items'; if (!is_dir($itemsDir)) { mkdir($itemsDir, 0755, true); } diff --git a/api/setup/analyzeMenuImages.php b/api/setup/analyzeMenuImages.php index 5f72786..748f954 100644 --- a/api/setup/analyzeMenuImages.php +++ b/api/setup/analyzeMenuImages.php @@ -169,7 +169,7 @@ try { $imageResult = json_decode($responseText, true); if ($imageResult === null) { // Save debug file - $uploadsPath = isDev() ? '/opt/lucee/tomcat/webapps/ROOT/uploads' : '/var/www/biz.payfrit.com/uploads'; + $uploadsPath = uploadsRoot(); file_put_contents("$uploadsPath/debug_claude.json", $responseText); throw new Exception("JSON parse error for image " . ($imgIndex + 1) . ". Debug saved to /uploads/debug_claude.json"); } diff --git a/api/setup/analyzeMenuUrl.php b/api/setup/analyzeMenuUrl.php index 8da61e8..2d4b1aa 100644 --- a/api/setup/analyzeMenuUrl.php +++ b/api/setup/analyzeMenuUrl.php @@ -626,14 +626,13 @@ JSEOF; $targetUrl = ''; $playwrightImages = []; - // Helper: webroot path - $webroot = isDev() - ? '/opt/lucee/tomcat/webapps/ROOT' - : '/var/www/biz.payfrit.com'; - // Helper: expand a URL path to a local file path - $expandPath = function(string $urlPath) use ($webroot): string { - return $webroot . $urlPath; + $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; }; // Helper: convert 24h time to 12h format string diff --git a/api/setup/downloadImages.php b/api/setup/downloadImages.php index 20a3b8c..2926840 100644 --- a/api/setup/downloadImages.php +++ b/api/setup/downloadImages.php @@ -25,10 +25,7 @@ try { throw new Exception('businessID is required'); } - $uploadsPath = '/var/www/biz.payfrit.com/uploads'; - if (isDev()) { - $uploadsPath = '/opt/lucee/tomcat/webapps/ROOT/uploads'; - } + $uploadsPath = uploadsRoot(); $logosPath = "$uploadsPath/logos"; $headersPath = "$uploadsPath/headers"; diff --git a/api/setup/saveWizard.php b/api/setup/saveWizard.php index c36a960..c80f9c0 100644 --- a/api/setup/saveWizard.php +++ b/api/setup/saveWizard.php @@ -17,10 +17,7 @@ set_time_limit(300); $response = ['OK' => false, 'steps' => [], 'errors' => []]; -$uploadsPath = isDev() - ? '/opt/lucee/tomcat/webapps/ROOT/uploads' - : '/var/www/biz.payfrit.com/uploads'; -$itemsDir = "$uploadsPath/items"; +$itemsDir = uploadsRoot() . '/items'; /** * Resize image maintaining aspect ratio, fitting within maxSize box. @@ -691,10 +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)) { - $webroot = isDev() - ? '/opt/lucee/tomcat/webapps/ROOT' - : '/var/www/biz.payfrit.com'; - $tempFolderPath = "$webroot/temp/menu-import/$tempFolder"; + $tempFolderPath = "/opt/payfrit-api/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 6657b14..a76e3c9 100644 --- a/api/setup/uploadSavedPage.php +++ b/api/setup/uploadSavedPage.php @@ -12,10 +12,7 @@ runAuth(); $response = ['OK' => false, 'MESSAGE' => '', 'URL' => '']; try { - $webroot = isDev() - ? '/opt/lucee/tomcat/webapps/ROOT' - : '/var/www/biz.payfrit.com'; - $tempBaseDir = "$webroot/temp/menu-import"; + $tempBaseDir = "/opt/payfrit-api/temp/menu-import"; // Create temp directory if needed if (!is_dir($tempBaseDir)) { diff --git a/api/tasks/getDetails.php b/api/tasks/getDetails.php index 08bc116..9eebfaa 100644 --- a/api/tasks/getDetails.php +++ b/api/tasks/getDetails.php @@ -68,11 +68,10 @@ try { $customerPhotoUrl = ''; $customerUserID = (int) ($qTask['CustomerUserID'] ?? 0); if ($customerUserID > 0) { - $baseDir = '/uploads/users/'; foreach (['jpg', 'png', 'PNG'] as $ext) { - $checkPath = luceeWebroot() . $baseDir . $customerUserID . '.' . $ext; + $checkPath = uploadsRoot() . '/users/' . $customerUserID . '.' . $ext; if (file_exists($checkPath)) { - $customerPhotoUrl = baseUrl() . $baseDir . $customerUserID . '.' . $ext; + $customerPhotoUrl = baseUrl() . '/uploads/users/' . $customerUserID . '.' . $ext; break; } }