diff options
Diffstat (limited to 'lib/general.lib.php')
-rw-r--r-- | lib/general.lib.php | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/lib/general.lib.php b/lib/general.lib.php index 56c75c28..65422c48 100644 --- a/lib/general.lib.php +++ b/lib/general.lib.php @@ -519,19 +519,32 @@ function get_file_extension( $filename ) { } } // get_file_extension -/** - * tbl_name - * This function takes a SQL table name and returns it with any prefix - * that might be needed to make it work, - * @package General - * @catagory Database +/** + * generate_password + * This generates a random password, of the specified + * length */ -function tbl_name($table) { - - /* For now we just return the table name */ - return $table; +function generate_password($length) { + + $vowels = 'aAeEuUyY12345'; + $consonants = 'bBdDgGhHjJmMnNpPqQrRsStTvVwWxXzZ6789'; + $password = ''; + + $alt = time() % 2; + + for ($i = 0; $i < $length; $i++) { + if ($alt == 1) { + $password .= $consonants[(rand() % 39)]; + $alt = 0; + } else { + $password .= $vowels[(rand() % 17)]; + $alt = 1; + } + } -} // tbl_name + return $password; + +} // generate_password /** * scrub_out |