<?php
// ============================================================
// Design2Clothes — Configuration
// ============================================================
// --- API Keys ---
define('GEMINI_API_KEY', ''); // Google Gemini API key
// --- n8n Webhooks ---
define('N8N_BASE_URL', 'https://raspin8n.airebros.com');
define('N8N_WEBHOOK_CLOTHES', N8N_BASE_URL . '/webhook/clothes');
// --- App URLs ---
define('APP_BASE_URL', 'https://xamp.airebros.com/clothes');
define('APP_BASE_PATH', '/clothes'); // subfolder under XAMPP htdocs
// --- File paths (absolute) ---
define('UPLOAD_DIR', __DIR__ . '/media/uploads/');
define('OUTPUT_DIR', __DIR__ . '/media/output/');
define('MODELS_DIR', __DIR__ . '/media/models/');
// --- Upload limits ---
define('MAX_UPLOAD_SIZE', 10 * 1024 * 1024); // 10 MB
define('ALLOWED_MIMES', ['image/png', 'image/jpeg', 'image/svg+xml']);
define('ALLOWED_EXTS', ['png', 'jpg', 'jpeg', 'svg']);
// --- Session ---
define('SESSION_NAME', 'd2c_session');
// --- Debug (set false in production) ---
define('DEBUG_MODE', true);
// ── Create required directories if missing ──────────────────
foreach ([UPLOAD_DIR, OUTPUT_DIR, MODELS_DIR] as $dir) {
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
}
// ── CORS headers for API endpoints ──────────────────────────
function d2c_cors_headers(): void {
header('Content-Type: application/json; charset=utf-8');
header('Access-Control-Allow-Origin: ' . APP_BASE_URL);
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type, X-Requested-With');
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { http_response_code(204); exit; }
}
// ── JSON helper ─────────────────────────────────────────────
function d2c_json(array $data, int $code = 200): never {
http_response_code($code);
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
exit;
}
// ── Error handler for API ────────────────────────────────────
function d2c_error(string $message, int $code = 400): never {
d2c_json(['success' => false, 'error' => $message], $code);
}