Someone (probably you) has requested a new password for your account on $company_name's ITFlow Client Portal.

Please click here to reset your password.

Alternatively, copy and paste this URL into your browser:
$url

If you didn't request this change, you can safely ignore this email.

~
$company_name
Support Department
$config_mail_from_email"; $data = [ [ 'recipient' => $email, 'recipient_name' => $name, 'subject' => $subject, 'body' => $body ] ]; $mail = addToMailQueue($mysqli, $data); // Error handling if ($mail !== true) { mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Mail', notification = 'Failed to send email to $email'"); mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Mail', log_action = 'Error', log_description = 'Failed to send email to $email regarding $subject. $mail'"); } //End Mail IF } else { sleep(rand(2, 4)); // Mimic the e-mail send delay even if email is invalid to help prevent user enumeration } $_SESSION['login_message'] = "If your account exists, a reset link is on it's way!"; /* * Do password reset */ } elseif (isset($_POST['password_reset_set_password'])) { if (!isset($_POST['new_password']) || !isset($_POST['email']) || !isset($_POST['token']) || !isset($_POST['client'])) { $_SESSION['login_message'] = WORDING_ERROR; } $token = sanitizeInput($_POST['token']); $email = sanitizeInput($_POST['email']); $client = intval($_POST['client']); // Query user $sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_email = '$email' AND contact_password_reset_token = '$token' AND contact_client_id = $client AND contact_auth_method = 'local' LIMIT 1"); $contact_row = mysqli_fetch_array($sql); $contact_id = intval($contact_row['contact_id']); $name = $contact_row['contact_name']; // Ensure the token is correct if (sha1($contact_row['contact_password_reset_token']) == sha1($token)) { // Set password, invalidate token, logging $password = mysqli_real_escape_string($mysqli, password_hash($_POST['new_password'], PASSWORD_DEFAULT)); mysqli_query($mysqli, "UPDATE contacts SET contact_password_hash = '$password', contact_password_reset_token = NULL WHERE contact_id = $contact_id LIMIT 1"); mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Contact', log_action = 'Modify', log_description = 'Reset portal password for $email.', log_ip = '$ip', log_user_agent = '$user_agent', log_client_id = $client"); // Send confirmation email $subject = "Password reset confirmation for $company_name ITFlow Portal"; $body = "Hello, $name

Your password for your account on $company_name's ITFlow Client Portal was successfully reset. You should be all set!

If you didn't reset your password, please get in touch ASAP.

~
$company_name
Support Department
$config_mail_from_email"; $data = [ [ 'recipient' => $email, 'recipient_name' => $name, 'subject' => $subject, 'body' => $body ] ]; $mail = addToMailQueue($mysqli, $data); // Error handling if ($mail !== true) { mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Mail', notification = 'Failed to send email to $email'"); mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Mail', log_action = 'Error', log_description = 'Failed to send email to $email regarding $subject. $mail'"); } // Redirect to login page $_SESSION['login_message'] = "Password reset successfully!"; header("Location: login.php"); exit(); } else { $_SESSION['login_message'] = WORDING_ERROR; } } } ?> <?php echo $company_name; ?> | Password Reset