prepare($getAppSql); if (!$stmt) { log_error("应用所有权验证查询准备失败: " . $conn->error, __FILE__, __LINE__); header('Location: dashboard.php?error=验证应用所有权失败'); exit; } $stmt->bind_param("ii", $appId, $developerId); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows === 0) { header('Location: dashboard.php?error=App不存在或无权访问'); exit; } $app = $result->fetch_assoc(); $platforms = json_decode($app['platforms'], true); $success = ''; $error = ''; // 处理版本上传请求 if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['upload_version'])) { // 验证版本信息 if (empty($_POST['version']) || empty($_FILES['app_file']['name'])) { $error = '版本号和安装包不能为空'; } else { // 处理App文件上传 $uploadDir = '../files/'; if (!is_dir($uploadDir)) { mkdir($uploadDir, 0755, true); } $fileName = basename($_FILES['app_file']['name']); $targetPath = $uploadDir . $fileName; if (move_uploaded_file($_FILES['app_file']['tmp_name'], $targetPath)) { $version = $_POST['version']; $changelog = $_POST['changelog'] ?? ''; // 插入新版本记录 $insertVersionSql = "INSERT INTO app_versions (app_id, version, changelog, file_path) VALUES (?, ?, ?, ?)"; $verStmt = $conn->prepare($insertVersionSql); if (!$verStmt) { log_error("版本插入准备失败: " . $conn->error, __FILE__, __LINE__); $error = '版本保存失败,请稍后再试'; unlink($targetPath); // 清理已上传文件 } else { $verStmt->bind_param("isss", $appId, $version, $changelog, $targetPath); if ($verStmt->execute()) { // 更新应用表中的最新版本 // 更新应用表中的最新版本 $updateAppSql = "UPDATE apps SET version = ? WHERE id = ?"; $updStmt = $conn->prepare($updateAppSql); if (!$updStmt) { log_error("应用版本更新准备失败: " . $conn->error, __FILE__, __LINE__); $error = '更新应用版本失败,请稍后再试'; unlink($targetPath); // 数据库更新失败,删除文件 } else { $updStmt->bind_param("si", $version, $appId); $updStmt->execute(); $success = '版本上传成功'; } } else { $error = '版本保存失败: '. $conn->error; unlink($targetPath); // 数据库更新失败,删除文件 } } } else { $error = '文件上传失败'; } } } // 获取现有版本列表 $versions = []; $getVersionsSql = "SELECT * FROM app_versions WHERE app_id = ? ORDER BY id DESC"; $verStmt = $conn->prepare($getVersionsSql); if (!$verStmt) { log_error("版本查询准备失败: " . $conn->error, __FILE__, __LINE__); $error = '获取版本列表失败,请稍后再试'; } else { $verStmt->bind_param("i", $appId); $verStmt->execute(); $versionsResult = $verStmt->get_result(); while ($ver = $versionsResult->fetch_assoc()) { $versions[] = $ver; } } ?> 版本控制 - <?php echo htmlspecialchars($app['name']); ?>

应用版本控制:

上传新版本

返回

版本历史

暂无版本记录
版本号 上传时间 更新日志 操作
下载 当前版本