From 1563e6b6b3f4062ad5013d9b3fd55e8c4d91ad16 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 13 Sep 2010 15:13:21 +0200 Subject: clean up file_mod->random_id() Signed-off-by: Florian Pritz --- system/application/models/file_mod.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/application/models/file_mod.php b/system/application/models/file_mod.php index 0694a509d..b9b534065 100644 --- a/system/application/models/file_mod.php +++ b/system/application/models/file_mod.php @@ -302,20 +302,16 @@ class File_mod extends Model { } // Generate a random ID - // TODO: speed up private function random_id($min_length, $max_length) { $random = ''; $char_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $char_list .= "abcdefghijklmnopqrstuvwxyz"; $char_list .= "1234567890"; + $length = rand()%($max_length-$min_length) + $min_length; for($i = 0; $i < $max_length; $i++) { - if (strlen($random) >= $min_length) { - if (rand()%2 == 1) { - break; - } - } + if (strlen($random) == $length) break; $random .= substr($char_list,(rand()%(strlen($char_list))), 1); } return $random; -- cgit v1.2.3-24-g4f1b