diff --git a/admin/review_apps.php b/admin/review_apps.php index dccefa4..21f6d0c 100644 --- a/admin/review_apps.php +++ b/admin/review_apps.php @@ -1,6 +1,7 @@
下载链接: 点击下载
+ + +标签:
+开发者:
提交时间:
描述:
diff --git a/developer/version_control.php b/developer/version_control.php index 49dcaa6..a2f5ceb 100644 --- a/developer/version_control.php +++ b/developer/version_control.php @@ -91,6 +91,108 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['upload_version'])) { } } +// 处理版本修改请求 +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['version_id'])) { + $versionId = $_POST['version_id']; + $version = $_POST['version']; + $changelog = $_POST['changelog'] ?? ''; + + // 检查是否有新文件上传 + if (!empty($_FILES['new_app_file']['name'])) { + $uploadDir = '../files/'; + if (!is_dir($uploadDir)) { + mkdir($uploadDir, 0755, true); + } + $fileName = basename($_FILES['new_app_file']['name']); + $newFilePath = $uploadDir . $fileName; + + if (move_uploaded_file($_FILES['new_app_file']['tmp_name'], $newFilePath)) { + // 获取旧文件路径并删除 + $getOldPathSql = "SELECT file_path FROM app_versions WHERE id = ?"; + $getOldPathStmt = $conn->prepare($getOldPathSql); + if (!$getOldPathStmt) { + log_error("获取旧文件路径查询准备失败: " . $conn->error, __FILE__, __LINE__); + $error = '版本修改失败,请稍后再试'; + unlink($newFilePath); + } else { + $getOldPathStmt->bind_param("i", $versionId); + $getOldPathStmt->execute(); + $oldPathResult = $getOldPathStmt->get_result(); + if ($oldPathResult->num_rows > 0) { + $oldPathRow = $oldPathResult->fetch_assoc(); + $oldFilePath = $oldPathRow['file_path']; + if (file_exists($oldFilePath)) { + unlink($oldFilePath); + } + } + + // 更新版本信息 + $updateVersionSql = "UPDATE app_versions SET version = ?, changelog = ?, file_path = ? WHERE id = ?"; + $updateVersionStmt = $conn->prepare($updateVersionSql); + if (!$updateVersionStmt) { + log_error("版本更新查询准备失败: " . $conn->error, __FILE__, __LINE__); + $error = '版本修改失败,请稍后再试'; + unlink($newFilePath); + } else { + $updateVersionStmt->bind_param("sssi", $version, $changelog, $newFilePath, $versionId); + if ($updateVersionStmt->execute()) { + $success = '版本修改成功'; + } else { + $error = '版本修改失败: ' . $conn->error; + unlink($newFilePath); + } + } + } + } else { + $error = '文件上传失败'; + } + } else { + // 仅更新版本号和更新日志 + $updateVersionSql = "UPDATE app_versions SET version = ?, changelog = ? WHERE id = ?"; + $updateVersionStmt = $conn->prepare($updateVersionSql); + if (!$updateVersionStmt) { + log_error("版本更新查询准备失败: " . $conn->error, __FILE__, __LINE__); + $error = '版本修改失败,请稍后再试'; + } else { + $updateVersionStmt->bind_param("ssi", $version, $changelog, $versionId); + if ($updateVersionStmt->execute()) { + $success = '版本修改成功'; + } else { + $error = '版本修改失败: ' . $conn->error; + } + } + } +} + +// 处理版本删除请求 +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_version'])) { + $versionId = $_POST['version_id']; + $filePath = $_POST['file_path']; + + // 删除文件 + if (file_exists($filePath)) { + if (!unlink($filePath)) { + log_error("文件删除失败: " . $filePath, __FILE__, __LINE__); + $error = '版本删除失败,请稍后再试'; + } + } + + // 从数据库删除版本记录 + $deleteVersionSql = "DELETE FROM app_versions WHERE id = ?"; + $deleteVersionStmt = $conn->prepare($deleteVersionSql); + if (!$deleteVersionStmt) { + log_error("版本删除查询准备失败: " . $conn->error, __FILE__, __LINE__); + $error = '版本删除失败,请稍后再试'; + } else { + $deleteVersionStmt->bind_param("i", $versionId); + if ($deleteVersionStmt->execute()) { + $success = '版本删除成功'; + } else { + $error = '版本删除失败: ' . $conn->error; + } + } +} + // 获取现有版本列表 $versions = []; $getVersionsSql = "SELECT * FROM app_versions WHERE app_id = ? ORDER BY id DESC"; @@ -213,6 +315,8 @@ if (!$verStmt) {