\n"; //--: GENPWD() // // Generate passwords. Syntax: genpwd( int len, int type ); // function genpwd( $pwdLen=8, $usables=PWD_ALLOW_DFLT ) { //--: Initialize local variables. // $pwdSource = ""; $result = ""; //--: Construct a source string. The parameter $usables is a boolean switch // which allows or disallows numerics, lower case and upper case. This // should be generated at calling time by 'or'ing PWD_ALLOW_NUM, PWD_ALLOW_LC // and PWD_ALLOW_UC. // // For example: genpwd( 10, PWD_ALLOW_NUM | PWD_ALLOW_LC); // // would generate a 10 character password containing only numerics and // lower case characters. // if ( $usables & ( 1 << 0 )) $pwdSource .= "1234567890"; if ( $usables & ( 1 << 1 )) $pwdSource .= "abcdefghijklmnopqrstuvwxyz"; if ( $usables & ( 1 << 2 )) $pwdSource .= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //--: Seed the random number generator. // srand ((double) microtime() * 1000000); //--: Generate the password. // while ( $pwdLen ) { $result .= substr( $pwdSource, rand( 0, strlen( $pwdSource )), 1); $pwdLen--; } return( $result ); } ?>