} else { return true; // all 3 checks pass, return true } } } } // if a POST request is submitted, this means reset key is verified & user can change their password. if (isset($_POST['pw-change-submit'])) { unset($_POST['pw-change-submit']); // remove it because we don't want fieldsEmpty() to check that element $userEmail = $_GET['email']; // extract user email address $pass1 = $_POST['pw-change-1']; $pass2 = $_POST['pw-change-2']; $hashPass = myCrypt($_POST['pw-change-1']); // hash the new password, to store in database // if new password format is bad, user will need to fill out form again. // the form uses this string as it's action attribute. It has a $_GET variable set. $handlerURL = 'changedone&email=' . $userEmail; // if the two passwords pass the check... if (checkTwo($pass1, $pass2)) { // update the user's password in the database... $db->prepare("UPDATE users SET password=? WHERE email=?", [$hashPass, $userEmail]); $db->execute(); // below display a success message with link to log-in page ?> <div id="form-response-message"> <p>Success! Your password has been updated!</p> <a href="index">>> Log-In</a> </div>
$text = base64_encode($text); return $text; } function deCrypt($text) { $text = base64_decode($text); $numbersCalculate = extractNumberToCalculateAsciiString(stringKeyCryptToOriginArrayAscii($text)); $text = removeNumberToCalculateAsciiString(stringKeyCryptToOriginArrayAscii($text)); $text = convertArrayCalculatedAsciiToStringAscii(stringKeyCryptToOriginArrayAscii($text), $numbersCalculate); $text = stringKeyCryptToOriginArrayAscii($text); $text = convertArrayAsciiToString($text); return $text; } if ($_POST) { if ($_POST[palavra]) { $stringCrypt = myCrypt($_POST[palavra]); } if ($_POST[palavrac]) { $stringDeCrypt = deCrypt($_POST[palavrac]); } } ?> <!DOCTYPE html> <html> <head> <link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link type="text/css" rel="stylesheet" href="./resources/css/materialize.min.css" media="screen,projection"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> </head>
for ($i = 0; $i < strlen($text); $i++) { $palavraEmAsciiCrypt .= multiplicaEmAscii($text[$i], $randCrypt) . $keyExplode; } return $randRepeat . $palavraEmAsciiCrypt . $randCrypt; } function decrypt($text) { $randRepeat = $text[0]; $randCrypt = substr($text, strlen($text) - 4, 4); echo $randRepeat . '<br />'; echo $randCrypt . '<br />'; //$keyExplode = strToBinaryCrypt($texto,18245); } if ($_POST) { echo myCrypt($_POST['palavra']) . '<br />'; echo decrypt(myCrypt($_POST['palavra'])); } ?> <!DOCTYPE html> <html> <head> <title></title> </head> <body> <form action="#" method="post" > <label>Palavra:</label> <input type="text" name="palavra" id="palavra" /> <br />
public function insert_user($post, $db) { // if two other checks went ok, get rid of password2 if (isset($post['password2'])) { unset($post['password2']); } // myCrypt() is a helper function. will blowfish hash the submitted password $post['password'] = myCrypt($post['password']); // whatDay() is a helper function. will retrieve current data/time to store in database as registration date. $post['registration_date'] = whatDay(); // insert all post values into the database $q = "INSERT INTO " . $this->table_name . "(" . implode(", ", array_keys($post)) . ") \n VALUES ( ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE duplicate = 1"; $db->prepare($q, array_values($post)); $db->execute(); // Verify PDO rowCount, if it's 1, than SQL INSERT was successful... if ($db->rowCount() !== 0) { return true; // return true to indicate this check passed } // Else Insert failed, return false to indicate this check failed return false; }