<?php if (!defined('DASHBOARD_ROOT')) { http_response_code(403); exit; } $file = $_POST['file'] ?? ''; if (!$file) { echo '<div class="alert-error"><span>No file specified.</span></div>'; return; } $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); $allowed = ['jpg','jpeg','png','webp']; if (!in_array($ext, $allowed)) { echo '<div class="alert-error"><span>Invalid file type.</span></div>'; return; } $encName = bin2hex(random_bytes(16)) . '.' . $ext; $srcPath = (defined('UPLOAD_QUARANTINE_DIR') ? UPLOAD_QUARANTINE_DIR : DASHBOARD_ROOT . '/uploads/quarantine') . '/' . basename($file); $destPath = (defined('UPLOAD_PRODUCTS_DIR') ? UPLOAD_PRODUCTS_DIR : DASHBOARD_ROOT . '/uploads/products') . '/' . $encName; if (file_exists($srcPath)) { rename($srcPath, $destPath); echo '<div class="alert-success"><span>Encrypted filename: ' . UI::e($encName) . '</span></div>'; echo '<div class="preview"><span class="code">' . UI::e($encName) . '</span></div>'; } else { echo '<div class="alert-error"><span>Source file not found in quarantine.</span></div>'; } 