From 06c37481ccdc52735776c6ec24204a21f5a00d7f Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Tue, 3 Feb 2004 02:29:35 +0000 Subject: [PATCH] gen_random_string move ... not entirely sure about this ... may well return to user functions git-svn-id: file:///svn/phpbb/trunk@4785 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e0f9655cc8..fb1081bb66 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -86,6 +86,24 @@ function set_config($config_name, $config_value, $is_dynamic = FALSE) } } +// Generates an alphanumeric random string of given length +function gen_rand_string($num_chars) +{ + $chars = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9'); + + list($usec, $sec) = explode(' ', microtime()); + mt_srand($sec * $usec); + + $max_chars = count($chars) - 1; + $rand_str = ''; + for ($i = 0; $i < $num_chars; $i++) + { + $rand_str .= $chars[mt_rand(0, $max_chars)]; + } + + return $rand_str; +} + function get_userdata($user) { global $db; @@ -1087,14 +1105,6 @@ function msg_handler($errno, $msg_text, $errfile, $errline) switch ($errno) { - case E_WARNING: - case E_NOTICE: - if (defined('DEBUG_EXTRA')) - { -// echo "PHP Notice on line $errline in $errfile :: $msg_text
"; - } - break; - case E_USER_ERROR: if (isset($db)) {