⚝
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 :
edithead.php
<?php // 1. 引入数据库 require_once __DIR__ . '/sql.php'; // 要编辑的那条记录(如果以后需要编辑不同的 id,可以换成 $_GET['id']) $id = 1; // 2. 如果是提交表单,则先进行更新 if ($_SERVER['REQUEST_METHOD'] === 'POST') { // 接收表单数据(用 ?? 避免 undefined) $site_name = $_POST['site_name'] ?? ''; $keywords = $_POST['keywords'] ?? ''; $description = $_POST['description'] ?? ''; $language = $_POST['language'] ?? ''; $copyright = $_POST['copyright'] ?? ''; // 旧的图标 / logo(用于没上传新文件时继续使用旧值) $icon = $_POST['old_icon'] ?? ''; $logo = $_POST['old_logo'] ?? ''; // 3. 处理上传 icon if (!empty($_FILES['icon']['name'])) { $uploadDir = __DIR__ . '/uploads/'; if (!is_dir($uploadDir)) { mkdir($uploadDir, 0755, true); } $filename = time() . '_icon_' . basename($_FILES['icon']['name']); $path = $uploadDir . $filename; if (move_uploaded_file($_FILES['icon']['tmp_name'], $path)) { // 存到数据库里的路径,一般写成相对路径 $icon = 'uploads/' . $filename; } } // 4. 处理上传 logo if (!empty($_FILES['logo']['name'])) { $uploadDir = __DIR__ . '/uploads/'; if (!is_dir($uploadDir)) { mkdir($uploadDir, 0755, true); } $filename = time() . '_logo_' . basename($_FILES['logo']['name']); $path = $uploadDir . $filename; if (move_uploaded_file($_FILES['logo']['tmp_name'], $path)) { $logo = 'uploads/' . $filename; } } // 5. 更新到 head 表(注意这里表名改成 head) $sql = "UPDATE head SET site_name = ?, keywords = ?, description = ?, icon = ?, logo = ?, language = ?, copyright = ?, updated_at = NOW() WHERE id = ?"; $stmt = $conn->prepare($sql); $stmt->bind_param( "sssssssi", $site_name, $keywords, $description, $icon, $logo, $language, $copyright, $id ); if ($stmt->execute()) { // 更新成功可以带个提示参数 header("Location: edithead.php?msg=success"); exit; } else { echo "更新失败: " . $conn->error; } } // 6. 每次加载页面(包括更新后重定向回来),都从数据库取最新数据 $sql = "SELECT * FROM head WHERE id = ?"; $stmt = $conn->prepare($sql); $stmt->bind_param("i", $id); $stmt->execute(); $data = $stmt->get_result()->fetch_assoc(); ?> <!DOCTYPE html> <html> <head> <title>后台管理</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.1/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js"></script> <style> .bd-placeholder-img{font-size:1.125rem;text-anchor:middle;-webkit-user-select:none;-moz-user-select:none;user-select:none} @media (min-width:768px){.bd-placeholder-img-lg{font-size:3.5rem}} .b-example-divider{height:3rem;background-color:rgba(0,0,0,.1);border:solid rgba(0,0,0,.15);border-width:1px 0;box-shadow:inset 0 .5em 1.5em rgba(0,0,0,.1),inset 0 .125em .5em rgba(0,0,0,.15)} </style> </head> <body> <main> <div class="container"> <header class="d-flex flex-wrap align-items-center justify-content-center justify-content-md-between py-3 mb-4 border-bottom"> <a href="/" class="d-flex align-items-center col-md-3 mb-2 mb-md-0 text-dark text-decoration-none"> <span class="fs-4">Admin</span> </a> <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0"> <li><a href="admin.php" class="nav-link px-2 link-secondary">管理中心</a></li> <li><a href="#" class="nav-link px-2 link-dark">Features</a></li> <li><a href="#" class="nav-link px-2 link-dark">Pricing</a></li> <li><a href="#" class="nav-link px-2 link-dark">FAQs</a></li> <li><a href="#" class="nav-link px-2 link-dark">About</a></li> </ul> <div class="col-md-3 text-end"> <button type="button" class="btn btn-outline-primary me-2">Add blog</button> <button type="button" class="btn btn-primary">log out</button> </div> </header> </div> <div class="container mt-4"> <?php if (!empty($_GET['msg']) && $_GET['msg']==='success'): ?> <div class="alert alert-success">更新成功!</div> <?php endif; ?> <h3 class="mb-3">修改网站设置</h3> <!-- action 留空 = 提交到当前页面 --> <form action="" method="post" enctype="multipart/form-data"> <!-- 隐藏ID --> <input type="hidden" name="id" value="<?= htmlspecialchars($data['id']) ?>"> <!-- 保存旧的 icon/logo 路径(用于没上传新文件时保留旧值) --> <input type="hidden" name="old_icon" value="<?= htmlspecialchars($data['icon']) ?>"> <input type="hidden" name="old_logo" value="<?= htmlspecialchars($data['logo']) ?>"> <!-- 标题 --> <div class="mb-3 mt-3"> <label class="form-label">网站标题(site_name)</label> <input type="text" class="form-control" name="site_name" value="<?= htmlspecialchars($data['site_name'] ?? '') ?>"> </div> <!-- keywords --> <div class="mb-3 mt-3"> <label class="form-label">关键词(keywords)</label> <input type="text" class="form-control" name="keywords" value="<?= htmlspecialchars($data['keywords'] ?? '') ?>"> </div> <!-- description --> <div class="mb-3 mt-3"> <label class="form-label">描述(description)</label> <textarea class="form-control" rows="5" name="description"><?= htmlspecialchars($data['description'] ?? '') ?></textarea> </div> <!-- icon --> <div class="mb-3 mt-3"> <label class="form-label">网站 Icon</label><br> <?php if (!empty($data['icon'])): ?> 当前:<img src="<?= htmlspecialchars($data['icon']) ?>" width="40"><br><br> <?php endif; ?> <input type="file" name="icon"> </div> <!-- logo --> <div class="mb-3 mt-3"> <label class="form-label">网站 Logo</label><br> <?php if (!empty($data['logo'])): ?> 当前:<img src="<?= htmlspecialchars($data['logo']) ?>" width="80"><br><br> <?php endif; ?> <input type="file" name="logo"> </div> <!-- language --> <div class="mb-3 mt-3"> <label class="form-label">语言(language)</label> <input type="text" class="form-control" name="language" value="<?= htmlspecialchars($data['language'] ?? '') ?>"> </div> <!-- copyright --> <div class="mb-3 mt-3"> <label class="form-label">版权信息(copyright)</label> <input type="text" class="form-control" name="copyright" value="<?= htmlspecialchars($data['copyright'] ?? '') ?>"> </div> <button type="submit" class="btn btn-primary">更新</button> </form> </div> </main> </body> </html>