Your new password entries did not match!
Please try again.
exit(1); } if (strlen($newpwd) < 5) { ?>Your new password must be at least 5 characters long!
Please try again.
exit(1); } if (!file_exists($passwdfile)) { copy($pwdfile, $passwdfile); } $fp_temp = fopen($temp_passwdfile, "w"); if (!$fp_temp) { echo "Unable to update files. Please go back and try again.
"; exit(1); } $fp = fopen ($passwdfile, "r"); $passwordok = 0; while(!feof($fp)) { $line = trim(fgets($fp, 4096)); if ($line == "") continue; if (preg_match("/^$StudentNo/", $line)) { list($user,$password, $name) = explode(':',$line); if ($user == $StudentNo) { if ($password == crypt($passwd,substr($password,0,2))) { $passwordok = 1; // Next part to generate a random salt with letters and/or numbers mt_srand((double)microtime()*1000000); $chars = array_merge(range('a','z'),range('A','Z'),range(0,9)); for($i=0;$i<2;$i++) { $salt .= $chars[mt_rand(0,count($chars)-1)]; } // Now encrypt the the password with the random salt $crypted_pwd = crypt($newpwd,$salt); fputs($fp_temp,implode(":",array($user,$crypted_pwd,$name))."\n"); } else { ?>Password Authentication Failed!
Please try again.
fclose($fp_temp); unlink($temp_passwdfile); exit(1); } } else { fputs($fp_temp, $line."\n"); } } else { fputs($fp_temp, $line."\n"); } } fclose($fp); if ($passwordok == 0) { ?>Password Authentication Failed!
Please try again.
fclose($fp_temp); unlink($temp_passwdfile); exit(1); } rename($temp_passwdfile, $passwdfile); ?>Your password is changed successfully.
break; } ?>