Skip to content
Snippets Groups Projects
Commit 5b4ad7de authored by Bob Mottram's avatar Bob Mottram
Browse files

Fix password generation temp file

parent 395c16b8
No related branches found
No related tags found
No related merge requests found
......@@ -8,16 +8,22 @@ if (isset($_POST['submitacceptpassword'])) {
$username = htmlspecialchars($_POST['myuser']);
$newpassword = htmlspecialchars($_POST['mypassword']);
// Get a random temp file name
// Note that we don't use the temp file directly because it gets
// deleted when out of scope of this function
// On this sytem temp files are only stored on a ram disk
$temp_file = tmpfile();
$password_file_path = stream_get_meta_data($temp_file)['uri'];
$password_file_path = stream_get_meta_data($temp_file)['uri'].random_int(0,9999);
fclose($temp_file);
$temp_file = fopen($password_file_path, "w") or die("Unable to create temp file");
fwrite($temp_file, $username.",".$newpassword);
fclose($temp_file);
$password_file = fopen("changepassword.dat", "w") or die("Unable to create changepassword file");
fwrite($password_file, $password_file_path);
fclose($password_file);
fwrite($temp_file, $username.",".$newpassword);
fclose($temp_file);
sleep(5);
$output_filename = "password_changed.html";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment