mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-11 20:21:16 +00:00
add getToken() for generating a random string
This commit is contained in:
parent
e129cd0d11
commit
c5a78839df
|
@ -598,6 +598,20 @@ function getBaseUrl() { /* {{{ */
|
|||
return "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'];
|
||||
} /* }}} */
|
||||
|
||||
function getToken($length){
|
||||
$token = "";
|
||||
$codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
$codeAlphabet.= "abcdefghijklmnopqrstuvwxyz";
|
||||
$codeAlphabet.= "0123456789";
|
||||
$max = strlen($codeAlphabet);
|
||||
|
||||
for ($i=0; $i < $length; $i++) {
|
||||
$token .= $codeAlphabet[random_int(0, $max-1)];
|
||||
}
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
class SeedDMS_CSRF {
|
||||
|
||||
protected $secret;
|
||||
|
|
Loading…
Reference in New Issue
Block a user