Remove all Lucee references — uploads now live under /opt/payfrit-api
- Moved uploads from Lucee webroot to /opt/payfrit-api/uploads/ - Updated nginx on both dev and biz to alias /uploads/ to new path - Replaced luceeWebroot() with uploadsRoot() helper - Temp files now use /opt/payfrit-api/temp/ - No more /opt/lucee or /var/www/biz.payfrit.com references Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
28d86ba6e5
commit
aa986507fd
11 changed files with 20 additions and 34 deletions
|
|
@ -15,7 +15,7 @@ if ($userId <= 0) {
|
||||||
apiAbort(['OK' => false, 'ERROR' => 'not_logged_in', 'MESSAGE' => 'Authentication required']);
|
apiAbort(['OK' => false, 'ERROR' => 'not_logged_in', 'MESSAGE' => 'Authentication required']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$uploadsDir = luceeWebroot() . '/uploads/users';
|
$uploadsDir = uploadsRoot() . '/users';
|
||||||
$avatarUrl = baseUrl() . '/uploads/users/';
|
$avatarUrl = baseUrl() . '/uploads/users/';
|
||||||
|
|
||||||
// Find existing avatar (check multiple extensions)
|
// Find existing avatar (check multiple extensions)
|
||||||
|
|
|
||||||
|
|
@ -191,8 +191,8 @@ function baseUrl(): string {
|
||||||
return isDev() ? 'https://dev.payfrit.com' : 'https://biz.payfrit.com';
|
return isDev() ? 'https://dev.payfrit.com' : 'https://biz.payfrit.com';
|
||||||
}
|
}
|
||||||
|
|
||||||
function luceeWebroot(): string {
|
function uploadsRoot(): string {
|
||||||
return '/opt/lucee/tomcat/webapps/ROOT';
|
return '/opt/payfrit-api/uploads';
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================
|
// ============================================
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,7 @@ try {
|
||||||
|
|
||||||
// Build items lookup by CategoryID
|
// Build items lookup by CategoryID
|
||||||
$itemsByCategory = [];
|
$itemsByCategory = [];
|
||||||
$uploadsDir = luceeWebroot() . '/uploads/items';
|
$uploadsDir = uploadsRoot() . '/items';
|
||||||
foreach ($qItemRows as $item) {
|
foreach ($qItemRows as $item) {
|
||||||
$catID = (int) $item['CategoryItemID'];
|
$catID = (int) $item['CategoryItemID'];
|
||||||
$itemID = (int) $item['ID'];
|
$itemID = (int) $item['ID'];
|
||||||
|
|
|
||||||
|
|
@ -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']);
|
jsonResponse(['OK' => false, 'ERROR' => 'no_file', 'MESSAGE' => 'No file was uploaded']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$headersDir = luceeWebroot() . '/uploads/headers';
|
$headersDir = uploadsRoot() . '/headers';
|
||||||
if (!is_dir($headersDir)) {
|
if (!is_dir($headersDir)) {
|
||||||
mkdir($headersDir, 0755, true);
|
mkdir($headersDir, 0755, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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"]);
|
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)
|
// Determine uploads directory
|
||||||
$itemsDir = luceeWebroot() . '/uploads/items';
|
$itemsDir = uploadsRoot() . '/items';
|
||||||
if (!is_dir($itemsDir)) {
|
if (!is_dir($itemsDir)) {
|
||||||
mkdir($itemsDir, 0755, true);
|
mkdir($itemsDir, 0755, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ try {
|
||||||
$imageResult = json_decode($responseText, true);
|
$imageResult = json_decode($responseText, true);
|
||||||
if ($imageResult === null) {
|
if ($imageResult === null) {
|
||||||
// Save debug file
|
// 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);
|
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");
|
throw new Exception("JSON parse error for image " . ($imgIndex + 1) . ". Debug saved to /uploads/debug_claude.json");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -626,14 +626,13 @@ JSEOF;
|
||||||
$targetUrl = '';
|
$targetUrl = '';
|
||||||
$playwrightImages = [];
|
$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
|
// Helper: expand a URL path to a local file path
|
||||||
$expandPath = function(string $urlPath) use ($webroot): string {
|
$expandPath = function(string $urlPath): string {
|
||||||
return $webroot . $urlPath;
|
// /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
|
// Helper: convert 24h time to 12h format string
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,7 @@ try {
|
||||||
throw new Exception('businessID is required');
|
throw new Exception('businessID is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
$uploadsPath = '/var/www/biz.payfrit.com/uploads';
|
$uploadsPath = uploadsRoot();
|
||||||
if (isDev()) {
|
|
||||||
$uploadsPath = '/opt/lucee/tomcat/webapps/ROOT/uploads';
|
|
||||||
}
|
|
||||||
|
|
||||||
$logosPath = "$uploadsPath/logos";
|
$logosPath = "$uploadsPath/logos";
|
||||||
$headersPath = "$uploadsPath/headers";
|
$headersPath = "$uploadsPath/headers";
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,7 @@ set_time_limit(300);
|
||||||
|
|
||||||
$response = ['OK' => false, 'steps' => [], 'errors' => []];
|
$response = ['OK' => false, 'steps' => [], 'errors' => []];
|
||||||
|
|
||||||
$uploadsPath = isDev()
|
$itemsDir = uploadsRoot() . '/items';
|
||||||
? '/opt/lucee/tomcat/webapps/ROOT/uploads'
|
|
||||||
: '/var/www/biz.payfrit.com/uploads';
|
|
||||||
$itemsDir = "$uploadsPath/items";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resize image maintaining aspect ratio, fitting within maxSize box.
|
* Resize image maintaining aspect ratio, fitting within maxSize box.
|
||||||
|
|
@ -691,10 +688,7 @@ try {
|
||||||
// Clean up temp folder from ZIP upload
|
// Clean up temp folder from ZIP upload
|
||||||
$tempFolder = is_string($data['tempFolder'] ?? null) ? trim($data['tempFolder']) : '';
|
$tempFolder = is_string($data['tempFolder'] ?? null) ? trim($data['tempFolder']) : '';
|
||||||
if (strlen($tempFolder) && preg_match('/^[a-f0-9]{32}$/', $tempFolder)) {
|
if (strlen($tempFolder) && preg_match('/^[a-f0-9]{32}$/', $tempFolder)) {
|
||||||
$webroot = isDev()
|
$tempFolderPath = "/opt/payfrit-api/temp/menu-import/$tempFolder";
|
||||||
? '/opt/lucee/tomcat/webapps/ROOT'
|
|
||||||
: '/var/www/biz.payfrit.com';
|
|
||||||
$tempFolderPath = "$webroot/temp/menu-import/$tempFolder";
|
|
||||||
if (is_dir($tempFolderPath)) {
|
if (is_dir($tempFolderPath)) {
|
||||||
exec("rm -rf " . escapeshellarg($tempFolderPath));
|
exec("rm -rf " . escapeshellarg($tempFolderPath));
|
||||||
$response['steps'][] = "Cleaned up temp folder: $tempFolder";
|
$response['steps'][] = "Cleaned up temp folder: $tempFolder";
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,7 @@ runAuth();
|
||||||
$response = ['OK' => false, 'MESSAGE' => '', 'URL' => ''];
|
$response = ['OK' => false, 'MESSAGE' => '', 'URL' => ''];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$webroot = isDev()
|
$tempBaseDir = "/opt/payfrit-api/temp/menu-import";
|
||||||
? '/opt/lucee/tomcat/webapps/ROOT'
|
|
||||||
: '/var/www/biz.payfrit.com';
|
|
||||||
$tempBaseDir = "$webroot/temp/menu-import";
|
|
||||||
|
|
||||||
// Create temp directory if needed
|
// Create temp directory if needed
|
||||||
if (!is_dir($tempBaseDir)) {
|
if (!is_dir($tempBaseDir)) {
|
||||||
|
|
|
||||||
|
|
@ -68,11 +68,10 @@ try {
|
||||||
$customerPhotoUrl = '';
|
$customerPhotoUrl = '';
|
||||||
$customerUserID = (int) ($qTask['CustomerUserID'] ?? 0);
|
$customerUserID = (int) ($qTask['CustomerUserID'] ?? 0);
|
||||||
if ($customerUserID > 0) {
|
if ($customerUserID > 0) {
|
||||||
$baseDir = '/uploads/users/';
|
|
||||||
foreach (['jpg', 'png', 'PNG'] as $ext) {
|
foreach (['jpg', 'png', 'PNG'] as $ext) {
|
||||||
$checkPath = luceeWebroot() . $baseDir . $customerUserID . '.' . $ext;
|
$checkPath = uploadsRoot() . '/users/' . $customerUserID . '.' . $ext;
|
||||||
if (file_exists($checkPath)) {
|
if (file_exists($checkPath)) {
|
||||||
$customerPhotoUrl = baseUrl() . $baseDir . $customerUserID . '.' . $ext;
|
$customerPhotoUrl = baseUrl() . '/uploads/users/' . $customerUserID . '.' . $ext;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue