ajax aoc panel (main site)
This commit is contained in:
@@ -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");
|
||||
}
|
||||
Reference in New Issue
Block a user