retrocode
2023-01-29 12:05:03 +08:00
```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);
}
```
// 后面业务内容随便整