At least it's indented correctly, unlike most of this developer's other code:
function generate_password($length,$level){
list($usec, $sec) = explode(' ', microtime());
srand((float) $sec + ((float) $usec * 100000));
$validchars[1] = "0123456789";
$validchars[2] = "abcdfghjkmnpqrstvwxyz";
$validchars[3] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$validchars[4] = "0123456789abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$password = "";
$counter = 0;
while ($counter < $length) {
$actChar = substr($validchars[$level], rand(0, strlen($validchars[$level])-1), 1);
// All character must be different
if (!strstr($password, $actChar)) {
$password .= $actChar;
$counter++;
}
}
return $password;
}