mirror of
https://github.com/ZeroDream-CN/PHPMC7
synced 2024-11-27 23:02:52 +08:00
KasuganoSoras
01b9046021
增加登录页面 Csrf 验证 修复 Daemon 管理页面显示问题 修复一些操作时的判断问题 修复 AJAX 请求参数构造错误问题 修复控制台字体全绿问题
24 lines
468 B
PHP
24 lines
468 B
PHP
<?php
|
|
class Csrf {
|
|
|
|
public function isemptyCsrfToken() {
|
|
SESSION_START();
|
|
return $_SESSION['token'] == "";
|
|
}
|
|
|
|
public function createCsrfToken() {
|
|
SESSION_START();
|
|
$_SESSION['token'] = md5(uniqid(rand(0, 10000000), TRUE));
|
|
}
|
|
|
|
public function verifyCsrfToken($data) {
|
|
SESSION_START();
|
|
if(empty($_SESSION['token'])) {
|
|
return false;
|
|
}
|
|
if(empty($data['csrf_token'])) {
|
|
return false;
|
|
}
|
|
return $data['csrf_token'] == $_SESSION['token'];
|
|
}
|
|
} |