From 90bbd32427e28e8a2cd66779a747031547652382 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 21 Jan 2006 23:26:15 +0000 Subject: [PATCH] Removing one of the loops from Functions::rand() and making sure that the desired length matches the actual one --- functions.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/functions.php b/functions.php index 714dfe4..32543ee 100644 --- a/functions.php +++ b/functions.php @@ -434,39 +434,37 @@ class Functions // Generate ints for ($i = 0; $i < $intcount; $i++) { - $string[] = rand(0, 9); + $string[ mt_rand() ] = rand(0, 9); } // Generate upper chars for ($i = 0; $i < $upperchars; $i++) { - $string[] = chr(rand(65, 90)); + $string[ mt_rand() ] = chr(rand(65, 90)); } // Generate lower chars for ($i = 0; $i < $lowerchars; $i++) { - $string[] = chr(rand(97, 122)); + $string[ mt_rand() ] = chr(rand(97, 122)); } - // Randomly key the chars - foreach ($string AS $char) + if ($length != count($string)) { - $rand = mt_rand(); - $newstr["$rand"] = $char; + return $this->rand($length); } // Sort the chars by thier random assignment - ksort($newstr); + ksort($string); // Flatten the array - $string = ''; - foreach ($newstr AS $char) + $return = ''; + foreach ($string AS $char) { - $string .= $char; + $return .= $char; } - return $string; + return $return; } // ################################################################### -- 2.22.5