username not found.'); } // Change password $salt = uniqid(); $password = md5(uniqid()); $passwordHash = sha1($password.$salt); $decode['admin']['salt'] = $salt; $decode['admin']['password'] = $passwordHash; $decode['admin']['role'] = 'admin'; // Create the new database file $data = "".PHP_EOL; $data .= json_encode($decode, JSON_PRETTY_PRINT); // Save the new database file if (file_put_contents($userDatabaseFile, $data, LOCK_EX)) { echo PHP_EOL; echo 'Username: admin'.PHP_EOL; echo 'New password: '.$password.PHP_EOL; echo PHP_EOL; if (unlink(__FILE__)===false) { echo '>> Delete this file now, do not keep it on the system <<'.PHP_EOL; } else { echo '>> The file recovery.php was deleted automatically for security reasons. <<'.PHP_EOL; } } else { die('Error when try to save the new database file.'); }