X-Git-Url: https://git.defcon.no/?a=blobdiff_plain;f=api%2Flib%2Fuser_functions.php;fp=api%2Flib%2Fuser_functions.php;h=e22412a6516ab2f80bd5d72d29895147b7ac447d;hb=ad1d2910ca34f0d69be10b637a4294a400beceb8;hp=3a53c88582967c099745c638737e799eea5efc6d;hpb=d84439cb61f1964534363219d800036e28112cd4;p=hermes diff --git a/api/lib/user_functions.php b/api/lib/user_functions.php index 3a53c88..e22412a 100644 --- a/api/lib/user_functions.php +++ b/api/lib/user_functions.php @@ -5,11 +5,16 @@ require_once('lib/db_functions.php'); $config = get_config(); +// Default length 24 characters to provide a long password +// that still is short enough that Cisco SPA phones can use it function generate_password( $length = 24 ) { $string = ""; while ( strlen( $string ) < $length ) - $string .= substr(md5(rand().rand()), 0, $length); + { + $string .= crypt(substr(md5(rand().rand()), 0, $length)); + $string = preg_replace( '/\W/', '', $string); + } return substr( $string, 0, $length ); }