| ... | ... |
@@ -87,7 +87,7 @@ $confirm = isset($_GET['confirm']) ? $_GET['confirm'] : false; |
| 87 | 87 |
mt_srand((double)microtime() * 1000000); |
| 88 | 88 |
$charset = '23456789' . 'abcdefghijkmnpqrstuvwxyz' . 'ABCDEFGHJKLMNPQRSTUVWXYZ'; |
| 89 | 89 |
$pass = random_string($charset, 10); |
| 90 |
- $encryppass = md5($pass); |
|
| 90 |
+ $encryppass = password_hash($pass, PASSWORD_BCRYPT, ['cost' => 12]); |
|
| 91 | 91 |
//$headers = "From: $sitename\n"; |
| 92 | 92 |
dbquery("UPDATE "._AUTHORTABLE." SET "._PASSWORDFIELD." = '$encryppass' WHERE uid = '".$_GET['release']."'");
|
| 93 | 93 |
|
| ... | ... |
@@ -192,7 +192,7 @@ switch ($_GET['step']) |
| 192 | 192 |
if ((!$_POST['email']) && !isADMIN) $fail .= "<div style='text-align: center;'>" . _EMAILREQUIRED . " " . _TRYAGAIN . "</div>"; |
| 193 | 193 |
if ($penname && !preg_match("!^[a-z0-9_ ]{3,30}$!i", $penname)) $fail = "<div style='text-align: center;'>" . _BADUSERNAME . " " . _TRYAGAIN . "</div>";
|
| 194 | 194 |
if (!preg_match("/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/", $_POST['email'])) $fail = "<div style='text-align: center;'>" . _INVALIDEMAIL . " " . _TRYAGAIN . "</div>";
|
| 195 |
- if ($_POST['password'] == $_POST['password2']) $encryptpassword = md5($_POST['password']); |
|
| 195 |
+ if ($_POST['password'] == $_POST['password2']) $encryptpassword = password_hash($_POST['password'], PASSWORD_BCRYPT, ['cost' => 12]); |
|
| 196 | 196 |
else $fail = write_message(_PASSWORDTWICE); |
| 197 | 197 |
if (!isset($fail)) |
| 198 | 198 |
{
|
| ... | ... |
@@ -531,7 +531,7 @@ CREATE TABLE IF NOT EXISTS `" . $tableprefix . "fanfiction_authorprefs` ( |
| 531 | 531 |
`image` varchar(200) NOT NULL default '', |
| 532 | 532 |
`date`int(10) unsigned NOT NULL default '0', |
| 533 | 533 |
`admincreated` char(1) NOT NULL default '0', |
| 534 |
- `password` varchar(40) NOT NULL default '0', |
|
| 534 |
+ `password` varchar(255) NOT NULL default '0', |
|
| 535 | 535 |
PRIMARY KEY (`uid`), |
| 536 | 536 |
KEY `penname` (`penname`), |
| 537 | 537 |
KEY `admincreated` (`admincreated`) |
| ... | ... |
@@ -65,6 +65,7 @@ define ("_JAVASCRIPTOFF", "You must have javascript enabled for this form to wor
|
| 65 | 65 |
define ("_LIKE", "like");
|
| 66 | 66 |
define ("_LIKES_NUMBER", "Number of Likes");
|
| 67 | 67 |
define ("_LOGIN", "Log In");
|
| 68 |
+define ("_LOGINAGAIN", "<br>However, if you have changed your password, you will have to <a href=\"login.php\">login again</a>.");
|
|
| 68 | 69 |
define ("_PLEASELOGIN", "Please login to access this feature.");
|
| 69 | 70 |
define ("_MEMBER", "Member");
|
| 70 | 71 |
define ("_MEMBERS", "Members");
|
| ... | ... |
@@ -68,7 +68,7 @@ function random_string ($charset_string, $length) |
| 68 | 68 |
if(!$pwdsetting) {
|
| 69 | 69 |
$charset = '23456789' . 'abcdefghijkmnpqrstuvwxyz' . 'ABCDEFGHJKLMNPQRSTUVWXYZ'; |
| 70 | 70 |
$pass = random_string($charset, 10); |
| 71 |
- $encryppass = md5($pass); |
|
| 71 |
+ $encryppass = password_hash($pass, PASSWORD_BCRYPT, ['cost' => 12]); |
|
| 72 | 72 |
} |
| 73 | 73 |
else {
|
| 74 | 74 |
if($_POST['password'] != $_POST['password2']) {
|
| ... | ... |
@@ -79,7 +79,7 @@ function random_string ($charset_string, $length) |
| 79 | 79 |
exit( ); |
| 80 | 80 |
} |
| 81 | 81 |
$pass = $_POST['password2']; |
| 82 |
- $encryppass = md5($pass); |
|
| 82 |
+ $encryppass = password_hash($pass, PASSWORD_BCRYPT, ['cost' => 12]); |
|
| 83 | 83 |
} |
| 84 | 84 |
dbquery("INSERT INTO ".substr(_AUTHORTABLE, 0, strpos(_AUTHORTABLE, "as author"))." (penname, realname, bio, email, date, password) VALUES ('".escapestring($penname)."', '".escapestring(strip_tags($_POST['realname']))."', '".strip_tags(escapestring($_POST['bio']), $allowed_tags)."', '$email'," . time() . ", '$encryppass')");
|
| 85 | 85 |
$useruid = dbinsertid(); |
| ... | ... |
@@ -153,7 +153,7 @@ function random_string ($charset_string, $length) |
| 153 | 153 |
else{
|
| 154 | 154 |
if(($_POST['password']) && ($_POST['password2'])) {
|
| 155 | 155 |
if($_POST['password'] == $_POST['password2']) {
|
| 156 |
- $encryppassword = md5($_POST['password']); |
|
| 156 |
+ $encryppassword = password_hash($_POST['password'], PASSWORD_BCRYPT, ['cost' => 12]); |
|
| 157 | 157 |
dbquery("UPDATE "._AUTHORTABLE." SET password='$encryppassword' WHERE uid = '$uid'");
|
| 158 | 158 |
} |
| 159 | 159 |
else $output .= write_error(_PASSWORDTWICE); |
| ... | ... |
@@ -183,7 +183,7 @@ function random_string ($charset_string, $length) |
| 183 | 183 |
} |
| 184 | 184 |
/* End dynamic fields */ |
| 185 | 185 |
dbquery("UPDATE "._AUTHORTABLE." SET realname='".descript(strip_tags(escapestring($_POST['realname'])), $allowed_tags)."', email='$email', bio='".descript(strip_tags(escapestring($_POST['bio']), $allowed_tags))."', image='".($imageupload && !empty($_POST['image']) ? escapestring($_POST['image']) : "")."' WHERE uid = '$uid'");
|
| 186 |
- $output .= write_message(_ACTIONSUCCESSFUL." ".(isset($_GET['uid']) ? _BACK2ADMIN : _BACK2ACCT)); |
|
| 186 |
+ $output .= write_message(_ACTIONSUCCESSFUL." ".(isset($_GET['uid']) ? _BACK2ADMIN : _BACK2ACCT." "._LOGINAGAIN)); |
|
| 187 | 187 |
} |
| 188 | 188 |
} |
| 189 | 189 |
else {
|
| ... | ... |
@@ -52,7 +52,8 @@ |
| 52 | 52 |
header("Location: maintenance.php");
|
| 53 | 53 |
exit( ); |
| 54 | 54 |
} |
| 55 |
- $encryptedpassword = md5($_POST['password']); |
|
| 55 |
+ $encryptedpasswordb = $passwd['password']; |
|
| 56 |
+ $encryptedpasswordm = md5($_POST['password']); |
|
| 56 | 57 |
if($passwd['level'] == -1) {
|
| 57 | 58 |
require_once("header.php");
|
| 58 | 59 |
//make a new TemplatePower object |
| ... | ... |
@@ -65,14 +66,28 @@ |
| 65 | 66 |
dbclose( ); |
| 66 | 67 |
exit( ); |
| 67 | 68 |
} |
| 68 |
- if($passwd['password'] == $encryptedpassword) {
|
|
| 69 |
+ if(password_verify($_POST['password'], $encryptedpasswordb) == $encryptedpasswordb) {
|
|
| 69 | 70 |
if(isset($_POST['cookiecheck'])) {
|
| 70 | 71 |
setcookie($sitekey."_useruid",$passwd['uid'], time()+60*60*24*30, "/"); |
| 71 |
- setcookie($sitekey."_salt", md5($passwd['email'] . $encryptedpassword), time()+60*60*24*30, "/"); |
|
| 72 |
+ setcookie($sitekey."_salt", md5($passwd['email'] . $encryptedpasswordb), time()+60*60*24*30, "/"); |
|
| 72 | 73 |
} |
| 73 | 74 |
if(!isset($_SESSION)) session_start( ); |
| 74 | 75 |
$_SESSION[$sitekey."_useruid"] = $passwd['uid']; |
| 75 |
- $_SESSION[$sitekey."_salt"] = md5($passwd['email'] . $encryptedpassword); |
|
| 76 |
+ $_SESSION[$sitekey."_salt"] = md5($passwd['email'] . $encryptedpasswordb); |
|
| 77 |
+ $logincode = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'login'");
|
|
| 78 |
+ while($code = dbassoc($logincode)) {
|
|
| 79 |
+ eval($code['code_text']); |
|
| 80 |
+ } |
|
| 81 |
+ } |
|
| 82 |
+ |
|
| 83 |
+ else if($passwd['password'] == $encryptedpasswordm) {
|
|
| 84 |
+ if(isset($_POST['cookiecheck'])) {
|
|
| 85 |
+ setcookie($sitekey."_useruid",$passwd['uid'], time()+60*60*24*30, "/"); |
|
| 86 |
+ setcookie($sitekey."_salt", md5($passwd['email'] . $encryptedpasswordm), time()+60*60*24*30, "/"); |
|
| 87 |
+ } |
|
| 88 |
+ if(!isset($_SESSION)) session_start( ); |
|
| 89 |
+ $_SESSION[$sitekey."_useruid"] = $passwd['uid']; |
|
| 90 |
+ $_SESSION[$sitekey."_salt"] = md5($passwd['email'] . $encryptedpasswordm); |
|
| 76 | 91 |
$logincode = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'login'");
|
| 77 | 92 |
while($code = dbassoc($logincode)) {
|
| 78 | 93 |
eval($code['code_text']); |
| ... | ... |
@@ -54,7 +54,7 @@ if(isMEMBER) accessDenied( ); |
| 54 | 54 |
mt_srand((double)microtime() * 1000000); |
| 55 | 55 |
$charset = '23456789' . 'abcdefghijkmnpqrstuvwxyz' . 'ABCDEFGHJKLMNPQRSTUVWXYZ'; |
| 56 | 56 |
$pass = random_string($charset, 10); |
| 57 |
- $encryppass = md5($pass); |
|
| 57 |
+ $encryppass = password_hash($_POST['password'], PASSWORD_BCRYPT, ['cost' => 12]); |
|
| 58 | 58 |
$subject = _NEWPWDSUB; |
| 59 | 59 |
$mailtext = sprintf(_NEWPWDMSG, $pass); |
| 60 | 60 |
|