mirror of
https://github.com/danpros/htmly.git
synced 2026-04-18 19:46:21 +05:30
added CSRF Token
This commit is contained in:
parent
630fe3fc3f
commit
e852052790
11 changed files with 88 additions and 16 deletions
|
|
@ -1702,4 +1702,27 @@ function file_cache($request) {
|
|||
readfile($cachefile);
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
function generate_csrf_token()
|
||||
{
|
||||
$_SESSION[config("site.url")]['csrf_token'] = sha1(microtime(true).mt_rand(10000,90000));
|
||||
}
|
||||
|
||||
function get_csrf()
|
||||
{
|
||||
if(! isset($_SESSION[config("site.url")]['csrf_token']) || empty($_SESSION[config("site.url")]['csrf_token']))
|
||||
{
|
||||
generate_csrf_token();
|
||||
}
|
||||
return $_SESSION[config("site.url")]['csrf_token'];
|
||||
}
|
||||
|
||||
function is_csrf_proper($csrf_token)
|
||||
{
|
||||
if($csrf_token == get_csrf())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue