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

Check password length

parent d1c5db06
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ if (isset($_POST['submitnewuser'])) {
else {
// Don't rely on php PRNG
$newpassword = exec("openssl rand -base64 32 | tr -dc A-Za-z0-9 | head -c 10 ; echo -n ''");
if (preg_match('/[^A-Za-z0-9]/', $newpassword)) {
if ((preg_match('/[^A-Za-z0-9]/', $newpassword)) && (strlen($newpassword)>9)) {
$new_user_file = fopen(".new_user.txt", "w") or die("Unable to write to new_user file");
fwrite($new_user_file, $username.",".$newpassword);
fclose($new_user_file);
......
......@@ -25,12 +25,13 @@ if (isset($_POST['submitchangepassword'])) {
// Don't rely on php PRNG
$newpassword = exec("openssl rand -base64 32 | tr -dc A-Za-z0-9 | head -c 10 ; echo -n ''");
if ((preg_match('/[^A-Za-z0-9]/', $newpassword)) && (strlen($newpassword)>9)) {
exec('cp password_confirm_template.html password_confirm.html');
exec('sed -i "s|USERNAME|'.$username.'|g" password_confirm.html');
exec('sed -i "s|NEWPASSWORD|'.$newpassword.'|g" password_confirm.html');
exec('cp password_confirm_template.html password_confirm.html');
exec('sed -i "s|USERNAME|'.$username.'|g" password_confirm.html');
exec('sed -i "s|NEWPASSWORD|'.$newpassword.'|g" password_confirm.html');
$output_filename = "password_confirm.html";
$output_filename = "password_confirm.html";
}
}
$htmlfile = fopen("$output_filename", "r") or die("Unable to open $output_filename");
......
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