个人博客的鉴权方案
source link: https://www.v2ex.com/t/911271
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
7gugu 3 小时 53 分钟前 1 直接用 wordpress 一步到位
|
gra 3 小时 52 分钟前 做个登录呗,最次一个字段,没注册,简单登录验证最方便
|
opengps 3 小时 51 分钟前 我就是自己用了一个特别的路径,自己知道,然后再所有添加修改的地方,增加一个密码框就行了
|
boks 3 小时 49 分钟前 ?p=xxxxxx
|
loading 3 小时 41 分钟前 建议 localhost
|
Kinnice 3 小时 35 分钟前 不要在线的后台了,只搭建个本地的后台编辑器,每次本机编辑好,生成静态文件,同步到服务器
|
retrocode 3 小时 32 分钟前
```php
<?php
$auth = array('密码 1','密码 2');
if (empty($_COOKIE["token"])||!in_array($_COOKIE["token"],$auth)) {
// 校验失败,不显示后续内容
$loginhtml = <<<EOT
<html>
<head>
<meta charset="utf-8">
<title>验证失败</title>
</head>
<body>
<h1>认证已过期,请输入密码</h1>
<input type="tel" id="mobile" description="输入你的密码即可" />
<button type="button" onclick="save()">提交</button>
</body>
<script type="text/javascript">
function save() {
var mobile = document.getElementById('mobile').value;
var exp = new Date();
exp.setTime(exp.getTime() + 30 * 24 * 60 * 60 * 1000);
document.cookie = "token=" + mobile + ";expires=" + exp.toGMTString();
location.reload();
}
</script>
</html>
EOT;
echo $loginhtml;exit();
} else {
// 记录密码访问记录
$log_file = './log/log_'.date('Ymd',time()).'.log';
$content = date('Y-m-d H:i:s',time()).' '.$_COOKIE["token"]."\r\n";
file_put_contents($log_file,$content, FILE_APPEND);
}
```
// 后面业务内容随便整
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK