diff options
author | Florian Pritz <bluewind@xinu.at> | 2012-04-09 13:46:31 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2012-04-09 20:48:17 +0200 |
commit | 5940316125c1672b72eb08186e6c43f5a91e71ef (patch) | |
tree | 1faaaa87d116a64d60fdbcf513139bd05c3ea4e6 /application/helpers | |
parent | c0f1755842211996a7a21ffb8773b260bb2be281 (diff) |
random_id() -> random_alphanum(); allow single argument
Signed-off-by: Florian Pritz <bluewind@xinu.at>
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; } |