From 5b580a23bab64a575cad6f987c19f53b303ed1e6 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Wed, 14 Aug 2019 12:02:18 -0600 Subject: [PATCH] Update functions.php --- resources/functions.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/resources/functions.php b/resources/functions.php index 9b0c1ab8ba..70cb9372ba 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -2147,4 +2147,19 @@ function number_pad($number,$n) { } } +//add a random_bytes function when it doesn't exist for older versions of PHP + if (!function_exists('random_bytes')) { + function random_bytes($length) { + $charset .= "0123456789"; + $charset .= "abcdefghijkmnopqrstuvwxyz"; + $charset .= "ABCDEFGHIJKLMNPQRSTUVWXYZ"; + srand((double)microtime() * rand(1000000, 9999999)); + while ($length > 0) { + $string .= $charset[rand(0, strlen($charset)-1)]; + $length--; + } + return $string.' '; + } + } + ?>