forked from kaygb/KZHomePage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
25 lines (24 loc) · 936 Bytes
/
Copy pathadmin.php
File metadata and controls
25 lines (24 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
// === 配置区 ===
$file = 'index.html'; // 你要改的文件
$pass = '666666'; // 【重要】请把这里改成你自己想设的管理员密码!
// ==============
session_start();
// 1. 保存修改
if ($_POST['content']) {
file_put_contents($file, $_POST['content']);
echo '<div style="color:green">保存成功!<a href="index.html" target="_blank">查看网页</a></div>';
}
// 2. 登录逻辑
if ($_POST['p'] === $pass) { $_SESSION['admin'] = true; }
if (!$_SESSION['admin']) {
exit('<form method="post">密码:<input type="password" name="p"><button>登录</button></form>');
}
// 3. 读取当前内容
$text = file_get_contents($file);
?>
<form method="post">
<h3>网站内容编辑器</h3>
<textarea name="content" style="width:100%;height:500px;"><?php echo htmlspecialchars($text); ?></textarea>
<br><button style="padding:10px 20px;margin-top:10px;">保存修改</button>
</form>