'Forbidden']); exit; } require_once __DIR__ . '/../includes/db.php'; // Get current version $current = db()->query("SELECT version FROM app_version ORDER BY id DESC LIMIT 1")->fetchColumn() ?: '1.0.0'; [$major, $minor, $patch] = array_map('intval', explode('.', $current)); // Determine new version if (!empty($_GET['version'])) { $newVersion = trim($_GET['version']); } elseif (!empty($_GET['bump'])) { switch ($_GET['bump']) { case 'major': $newVersion = ($major+1).'.0.0'; break; case 'minor': $newVersion = $major.'.'.($minor+1).'.0'; break; default: $newVersion = $major.'.'.$minor.'.'.($patch+1); break; } } else { // Default: bump patch $newVersion = $major.'.'.$minor.'.'.($patch+1); } $notes = trim($_GET['notes'] ?? 'Build ' . date('Y-m-d H:i:s')); db()->prepare("INSERT INTO app_version (version, notes) VALUES (?, ?)") ->execute([$newVersion, $notes]); header('Content-Type: application/json'); echo json_encode([ 'success' => true, 'previous' => $current, 'new_version' => $newVersion, 'notes' => $notes, 'timestamp' => date('Y-m-d H:i:s'), ]);