Browse code

add MD5 password check and warning in Edit Personal Information page

Clarissa Walker authored on 2026/09/16 16:51:10
Showing 2 changed files
... ...
@@ -294,6 +294,7 @@ define ("_BIO", "Bio");
294 294
 define ("_EDITPERSONAL", "Edit Personal Information");
295 295
 define ("_EMAILINUSE", "This email address has already been used to sign up for an account. If you've lost your password, please generate a new one by using the <a href=\"user.php?action=lostpassword\">lost password</a> feature.");
296 296
 define ("_ICQ", "ICQ");
297
+define ("_INSECUREPWD", "Your password is hashed using unsalted MD5, a known insecure hashing algorithm. Please update your password so it can be converted to the more secure bcrypt.");
297 298
 define ("_INVALIDEMAIL", "The e-mail address you supplied is an invalid format.");
298 299
 define ("_LOGINAGAIN", "However, if you have changed your password, you will have to <a href=\"login.php\">login again</a>.");
299 300
 define ("_NEWACCOUNT", "New Account");
... ...
@@ -49,6 +49,16 @@ function random_string ($charset_string, $length)
49 49
 	if((!isADMIN || uLEVEL > 2) && $uid != USERUID && $action == "editbio") $output .= write_error(_NOTAUTHORIZED);
50 50
 	if(isMEMBER) $output .= "<div id=\"pagetitle\">"._EDITPERSONAL."</div>";
51 51
 	else $output .= "<div id=\"pagetitle\">"._NEWACCOUNT."</div>";
52
+
53
+	// check for MD5 password hashes after a user logs in to edit their bio and warn them if their password is insecure
54
+	// all MD5 hashes are 32 exact characters long, hexadecimal, 0-9 and a-f random
55
+	// this set is a bit cursed... but it works
56
+	$pwdcharlengthquery = dbquery("SELECT CHAR_LENGTH(password) FROM ".TABLEPREFIX."fanfiction_authors WHERE uid = ".USERUID.";");
57
+	$pwdlengthfetch = mysqli_fetch_row($pwdcharlengthquery);
58
+	$pwdlengthstring = end($pwdlengthfetch);
59
+	$pwdcheck = (int) $pwdlengthstring;
60
+	if ($pwdcheck == 32) $output .= "<center>"._INSECUREPWD."</center><br>";
61
+
52 62
 	if(!empty($_POST['submit'])) {
53 63
 		$penname = isset($_POST['newpenname']) ? escapestring($_POST['newpenname']) : false;
54 64
 		$email = escapestring($_POST['email']);