I'm trying to write a script that will loop through my database and replace old passwords with newly generated ones.
I thought the below would work but it doesn't - it just retiurns the same password for each loop. Can anyone tell me how I can get nice prounceable(ish) passwords in this way - or I am I totally on the wrong track.
TIA Tony
Code:
// Update the passwords
$result = $db_query("SELECT * FROM $table");
$numb = $db_num_rows($result);
$pass = substr($pass, 0, $length);
for ($i=0; $i < $numb; $i++){
$row = $db_fetch_array($result);
$id = $row[id];
$password = $row[password];
$newpass = $row[newpass];
/ generate the new password /
// This is the bit that doesn't work 🙁
$length = 7;
srand((double)microtime()*1000000);
$vowels = array("a", "e", "i", "o", "u");
$cons = array("b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "u", "v", "w", "tr", "cr", "br", "fr", "th", "dr", "ch", "ph", "wr", "st", "sp", "sw", "pr", "sl", "cl");
$num_vowels = count($vowels);
$num_cons = count($cons);
for($j = 0; $j < $length; $j++){
$pass .= $cons[rand(0, $num_cons - 1)] . $vowels[rand(0, $num_vowels - 1)];
}
Print"$password - $pass - $id<br>";
}