diff options
Diffstat (limited to 'application/helpers')
-rw-r--r-- | application/helpers/filebin_helper.php | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/application/helpers/filebin_helper.php b/application/helpers/filebin_helper.php index 3dcd03794..ac09da7d2 100644 --- a/application/helpers/filebin_helper.php +++ b/application/helpers/filebin_helper.php @@ -182,17 +182,21 @@ function is_cli_client() return false; } -function random_id($min_length, $max_length) +function random_alphanum($min_length, $max_length = null) { $random = ''; $char_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $char_list .= "abcdefghijklmnopqrstuvwxyz"; $char_list .= "1234567890"; - $length = rand()%($max_length-$min_length) + $min_length; + + if ($max_length === null) { + $max_length = $min_length; + } + $length = mt_rand($min_length, $max_length); for($i = 0; $i < $max_length; $i++) { if (strlen($random) == $length) break; - $random .= substr($char_list,(rand()%(strlen($char_list))), 1); + $random .= substr($char_list, mt_rand(0, strlen($char_list)), 1); } return $random; } |