One Hat Cyber Team
Your IP :
3.145.199.42
Server IP :
50.28.103.30
Server :
Linux host.jcukjv-lwsites.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
Server Software :
nginx/1.24.0
PHP Version :
8.3.12
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
www
/
wwwroot
/
english.electronharmony.com
/
View File Name :
index.php
<?php // 连接数据库 $conn = new mysqli("localhost", "sql_english_elec", "6146a92d624b4", "sql_english_elec"); // 处理上传 if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_FILES["audio_file"])) { $description = $_POST['description']; $uploadDir = "uploads/"; if (!file_exists($uploadDir)) { mkdir($uploadDir, 0777, true); } $fileName = basename($_FILES["audio_file"]["name"]); $filePath = $uploadDir . $fileName; $fileType = pathinfo($filePath, PATHINFO_EXTENSION); $allowedTypes = ["mp3", "wav", "ogg"]; if (in_array($fileType, $allowedTypes)) { if (move_uploaded_file($_FILES["audio_file"]["tmp_name"], $filePath)) { $stmt = $conn->prepare("INSERT INTO audio_files (filename, filepath, description) VALUES (?, ?, ?)"); $stmt->bind_param("sss", $fileName, $filePath, $description); $stmt->execute(); header("Location: index.php?upload_success=1"); exit(); } else { echo "<div class='alert alert-danger'>文件上传失败!</div>"; } } else { echo "<div class='alert alert-warning'>仅支持 MP3、WAV、OGG 格式!</div>"; } } // 处理删除 if (isset($_GET['delete'])) { $id = intval($_GET['delete']); $stmt = $conn->prepare("SELECT filepath FROM audio_files WHERE id = ?"); $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($filePath); if ($stmt->fetch()) { unlink($filePath); // 删除文件 } $stmt->close(); $stmt = $conn->prepare("DELETE FROM audio_files WHERE id = ?"); $stmt->bind_param("i", $id); $stmt->execute(); header("Location: index.php?delete_success=1"); exit(); } // 分页逻辑 $limit = 20; // 每页 20 条数据 $page = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1; $offset = ($page - 1) * $limit; // 获取音频文件数据 $totalResult = $conn->query("SELECT COUNT(*) AS total FROM audio_files"); $totalRows = $totalResult->fetch_assoc()['total']; $totalPages = ceil($totalRows / $limit); $result = $conn->query("SELECT * FROM audio_files ORDER BY uploaded_at DESC LIMIT $limit OFFSET $offset"); ?> <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>音频上传系统</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <script> let audioPlayers = []; document.addEventListener("DOMContentLoaded", function () { audioPlayers = document.querySelectorAll(".audio-player"); audioPlayers.forEach((player, index) => { player.addEventListener("ended", function () { if (!player.hasAttribute("loop")) { nextTrack(index); } }); }); }); function toggleLoop(index) { let audio = document.getElementById("audio-" + index); let button = document.getElementById("loop-btn-" + index); if (audio.hasAttribute("loop")) { audio.removeAttribute("loop"); button.textContent = "单曲循环"; button.classList.remove("btn-success"); button.classList.add("btn-secondary"); } else { audio.setAttribute("loop", "loop"); button.textContent = "取消循环"; button.classList.remove("btn-secondary"); button.classList.add("btn-success"); } } function nextTrack(index) { if (index < audioPlayers.length - 1) { audioPlayers[index].pause(); audioPlayers[index].currentTime = 0; audioPlayers[index + 1].play(); } } </script> </head> <body class="container mt-4"> <h2 class="mb-4">上传音频文件</h2> <form action="" method="post" enctype="multipart/form-data" class="mb-4"> <div class="mb-3"> <label for="audio_file" class="form-label">选择音频文件 (MP3, WAV, OGG)</label> <input type="file" class="form-control" name="audio_file" id="audio_file" accept=".mp3,.wav,.ogg" required> </div> <div class="mb-3"> <label for="description" class="form-label">音频描述</label> <textarea class="form-control" name="description" id="description" rows="2"></textarea> </div> <button type="submit" class="btn btn-primary">上传</button> </form> <h3 class="mb-3">已上传音频</h3> <div class="list-group"> <?php $index = 0; ?> <?php while ($row = $result->fetch_assoc()) { ?> <div class="list-group-item d-flex justify-content-between align-items-center"> <div> <h5><?php echo htmlspecialchars($row['filename']); ?></h5> <p><?php echo nl2br(htmlspecialchars($row['description'])); ?></p> <button id="loop-btn-<?php echo $index; ?>" class="btn btn-secondary btn-sm" onclick="toggleLoop(<?php echo $index; ?>)">单曲循环</button> <audio id="audio-<?php echo $index; ?>" controls class="mt-2 audio-player"> <source src="<?php echo $row['filepath']; ?>" type="audio/mpeg"> 您的浏览器不支持音频播放 </audio> </div> <a href="?delete=<?php echo $row['id']; ?>" class="btn btn-danger btn-sm" onclick="return confirm('确定删除此音频吗?');">删除</a> </div> <?php $index++; ?> <?php } ?> </div> <!-- 分页导航 --> <nav class="mt-4"> <ul class="pagination"> <?php if ($page > 1) { ?> <li class="page-item"><a class="page-link" href="?page=<?php echo $page - 1; ?>">上一页</a></li> <?php } ?> <?php for ($i = 1; $i <= $totalPages; $i++) { ?> <li class="page-item <?php echo $i == $page ? 'active' : ''; ?>"> <a class="page-link" href="?page=<?php echo $i; ?>"><?php echo $i; ?></a> </li> <?php } ?> <?php if ($page < $totalPages) { ?> <li class="page-item"><a class="page-link" href="?page=<?php echo $page + 1; ?>">下一页</a></li> <?php } ?> </ul> </nav> </body> </html>