1
0

ajax aoc panel (main site)

This commit is contained in:
2020-01-06 21:58:09 +01:00
parent c12b217b37
commit a6539cf081
11 changed files with 99 additions and 17 deletions

View File

@@ -405,3 +405,18 @@ function get_client_ip() {
else if(isset($_SERVER['REMOTE_ADDR'])) return $_SERVER['REMOTE_ADDR'];
else return 'UNKNOWN';
}
function getRandomToken($length = 32)
{
try
{
if(!isset($length) || intval($length) <= 8 ) $length = 32;
if (function_exists('random_bytes')) return bin2hex(random_bytes($length));
if (function_exists('mcrypt_create_iv')) return bin2hex(mcrypt_create_iv($length, MCRYPT_DEV_URANDOM));
if (function_exists('openssl_random_pseudo_bytes')) return bin2hex(openssl_random_pseudo_bytes($length));
}
catch (Exception $e) { throw new InvalidArgumentException($e); }
throw new InvalidArgumentException("No random");
}