summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-09-13 15:13:21 +0200
committerFlorian Pritz <bluewind@xssn.at>2010-09-13 15:13:21 +0200
commit1563e6b6b3f4062ad5013d9b3fd55e8c4d91ad16 (patch)
treec69d6b3416c9b1c570904761405d5eba838d415a
parent943fbc2867fae66cbc2dcfb1b3c0d1e883ed772f (diff)
clean up file_mod->random_id()
Signed-off-by: Florian Pritz <bluewind@xssn.at>
-rw-r--r--system/application/models/file_mod.php8
1 files changed, 2 insertions, 6 deletions
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;