diff --git a/inc/inc.Utils.php b/inc/inc.Utils.php index 52b3102f2..3173c93e4 100644 --- a/inc/inc.Utils.php +++ b/inc/inc.Utils.php @@ -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;