$ok, 'msg' => $msg], $extra), JSON_UNESCAPED_UNICODE); exit; } $action = isset($_POST['action']) ? $_POST['action'] : ''; $file = isset($_POST['file']) ? $_POST['file'] : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; // 会话已登录或提供了正确密码之一即可 if (empty($_SESSION['admin_ok']) && $password !== $ADMIN_PASSWORD) { jsonOut(false, '管理员密码错误或未登录'); } if (!$action || !$file) { jsonOut(false, '缺少必要参数'); } // 基础安全处理,禁止路径穿越 $basename = basename($file); $pendingPath = $pendingDir . '/' . $basename; if (!is_file($pendingPath)) { jsonOut(false, '待审核文件不存在'); } if ($action === 'reject') { $ok = @unlink($pendingPath); @unlink($pendingPath . '.json'); jsonOut(!!$ok, $ok ? '已拒绝并删除' : '删除失败'); } if ($action === 'approve') { // 生成日期目录 $dateDir = date('Y-m-d'); $dstDir = $videosDirRoot . '/' . $dateDir; if (!is_dir($dstDir)) { @mkdir($dstDir, 0777, true); } // 根据扩展名生成唯一文件名 $ext = strtolower(pathinfo($basename, PATHINFO_EXTENSION)); if (!in_array($ext, ['mp4','webm','mov'])) { // 不支持的扩展也允许,但统一改成 mp4 $ext = 'mp4'; } $newName = 'video_' . date('Ymd_His') . '_' . mt_rand(1000,9999) . '.' . $ext; $dstPath = $dstDir . '/' . $newName; $ok = @rename($pendingPath, $dstPath); @rename($pendingPath . '.json', $dstPath . '.json'); if (!$ok) { jsonOut(false, '转存失败'); } // 返回相对路径,便于前端显示 $rel = 'videos/' . $dateDir . '/' . $newName; jsonOut(true, '审核通过,已入库', ['path' => $rel]); } jsonOut(false, '未知操作'); ?>