$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 );
}
$result = sql_dbquery( $config['provision_db'], $query );
if ( !$result ) return null;
$list = array();
- while ( $row = mysql_fetch_row( $result ) )
+ while ( $row = @mysql_fetch_row( $result ) )
{
array_push( $list, array( "user" => $row[0], "displayname" => $row[1] ) );
}