1
0
mirror of https://github.com/ZeroDream-CN/PHPMC7 synced 2024-11-27 23:02:52 +08:00
PHPMC7/include/core/PHPMC/Csrf.php

24 lines
468 B
PHP
Raw Normal View History

<?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'];
}
}