Skip to content

Commit

Permalink
Merge pull request msaad1999#4 from msaad1999/system-upgrade
Browse files Browse the repository at this point in the history
System upgrade -> documentation
  • Loading branch information
msaad1999 authored Jan 14, 2020
2 parents 5577e56 + 3767b8c commit 27a9d70
Show file tree
Hide file tree
Showing 9 changed files with 877 additions and 21 deletions.
30 changes: 24 additions & 6 deletions logout/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,34 @@
require '../assets/includes/auth_functions.php';
check_logged_in();

session_unset();
session_destroy();

if(isset($_COOKIE[session_name()])):

if(isset($_COOKIE[session_name()])){

setcookie(session_name(), '', time()-7000000, '/');
endif;
}

if(isset($_COOKIE['rememberme'])) {

if(isset($_COOKIE['rememberme'])):
setcookie('rememberme', '', time()-7000000, '/');
endif;

require '../assets/setup/db.inc.php';
$sql = "DELETE FROM auth_tokens WHERE user_email=? AND auth_type='remember_me';";
$stmt = mysqli_stmt_init($conn);
if (mysqli_stmt_prepare($stmt, $sql)){

mysqli_stmt_bind_param($stmt, "s", $_SESSION['email']);
mysqli_stmt_execute($stmt);

if (isset($_SESSION['auth'])){

$_SESSION['auth'] = 'verified';
}
}
}

session_unset();
session_destroy();

header("Location: ../login/");
exit();
Expand Down
5 changes: 4 additions & 1 deletion profile-edit/includes/password-edit.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
exit();
}

$pwdChange = true;
$passwordUpdated = true;

// script endpoint --------->>
}
}
}
Expand All @@ -58,3 +60,4 @@
header("Location: ../");
exit();
}

78 changes: 73 additions & 5 deletions profile-edit/includes/profile-edit.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
require '../../assets/includes/auth_functions.php';
check_verified();

require '../../assets/vendor/PHPMailer/src/Exception.php';
require '../../assets/vendor/PHPMailer/src/PHPMailer.php';
require '../../assets/vendor/PHPMailer/src/SMTP.php';

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

if (isset($_POST['update-profile'])) {

require '../../assets/setup/db.inc.php';
Expand All @@ -13,10 +20,15 @@
$email = $_POST['email'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$gender = $_POST['gender'];
$headline = $_POST['headline'];
$bio = $_POST['bio'];

if (isset($_POST['gender']))
$gender = $_POST['gender'];
else
$gender = NULL;


$oldPassword = $_POST['password'];
$newpassword = $_POST['newpassword'];
$passwordrepeat = $_POST['confirmpassword'];
Expand Down Expand Up @@ -116,8 +128,64 @@

if( !empty($oldPassword) || !empty($newpassword) || !empty($passwordRepeat)){

require 'password-edit.inc.php';
}
include 'password-edit.inc.php';
}

if ($passwordUpdated) {

/*
* -------------------------------------------------------------------------------
* Sending notification email on password update
* -------------------------------------------------------------------------------
*/

$to = $_SESSION['email'];
$subject = 'Password Updated';

/*
* -------------------------------------------------------------------------------
* Using email template
* -------------------------------------------------------------------------------
*/

$mail_variables = array();

$mail_variables['APP_NAME'] = APP_NAME;
$mail_variables['email'] = $_SESSION['email'];

$message = file_get_contents("./template_notificationemail.php");

foreach($mail_variables as $key => $value) {

$message = str_replace('{{ '.$key.' }}', $value, $message);
}

$mail = new PHPMailer(true);

try {

$mail->isSMTP();
$mail->Host = MAIL_HOST;
$mail->SMTPAuth = true;
$mail->Username = MAIL_USERNAME;
$mail->Password = MAIL_PASSWORD;
$mail->SMTPSecure = MAIL_ENCRYPTION;
$mail->Port = MAIL_PORT;

$mail->setFrom(MAIL_USERNAME, APP_NAME);
$mail->addAddress($to, APP_NAME);

$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;

$mail->send();
}
catch (Exception $e) {


}
}


/*
Expand All @@ -136,7 +204,7 @@
bio=?,
profile_image=?";

if ($pwdChange){
if ($passwordUpdated){

$sql .= ", password=?
WHERE id=?;";
Expand All @@ -156,7 +224,7 @@
}
else {

if ($pwdChange){
if ($passwordUpdated){

$hashedPwd = password_hash($newpassword, PASSWORD_DEFAULT);
mysqli_stmt_bind_param($stmt, "ssssssssss",
Expand Down
202 changes: 202 additions & 0 deletions profile-edit/includes/template_notificationemail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Verify Your Email</title>
<style type="text/css">
body {
width: 100%;
background-color: #ffffff;
margin: 0;
margin-top: 70px;
padding: 0;
-webkit-font-smoothing: antialiased;
}
p,
h1,
h2,
h3,
h4 {
margin-top: 0;
margin-bottom: 0;
padding-top: 0;
padding-bottom: 0;
}
span.preheader {
display: none;
font-size: 1px;
}
html {
width: 100%;
}
table {
font-size: 14px;
border: 0;
}
/* ----------- responsivity ----------- */
@media only screen and (max-width: 640px) {
/*------ top header ------ */
.main-header {
font-size: 20px !important;
}
.main-section-header {
font-size: 28px !important;
}
.show {
display: block !important;
}
.hide {
display: none !important;
}
.align-center {
text-align: center !important;
}
.no-bg {
background: none !important;
}
/*----- main image -------*/
.main-image img {
width: 440px !important;
height: auto !important;
}
/* ====== divider ====== */
.divider img {
width: 440px !important;
}
/*-------- container --------*/
.container590 {
width: 440px !important;
}
.container580 {
width: 400px !important;
}
.main-button {
width: 220px !important;
}
/*-------- secions ----------*/
.section-img img {
width: 320px !important;
height: auto !important;
}
.team-img img {
width: 100% !important;
height: auto !important;
}
}
@media only screen and (max-width: 479px) {
/*------ top header ------ */
.main-header {
font-size: 18px !important;
}
.main-section-header {
font-size: 26px !important;
}
/* ====== divider ====== */
.divider img {
width: 280px !important;
}
/*-------- container --------*/
.container590 {
width: 280px !important;
}
.container590 {
width: 280px !important;
}
.container580 {
width: 260px !important;
}
/*-------- secions ----------*/
.section-img img {
width: 280px !important;
height: auto !important;
}
}
</style>
</head>
<body class="respond" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table border="0" width="100%" cellpadding="0" cellspacing="0" bgcolor="ffffff" class="bg_color">
<tr>
<td align="center">
<table border="0" align="center" width="590" cellpadding="0" cellspacing="0" class="container590">
<tr>
<td height="20" style="font-size: 20px; line-height: 20px;">&nbsp;</td>
</tr>
<tr>
<td align="center" style="color: #343434; font-size: 24px; font-family: Quicksand, Calibri, sans-serif; font-weight:700;letter-spacing: 3px; line-height: 35px;"
class="main-header">
<div style="line-height: 35px">
PASSWORD UPDATED</span>
</div>
</td>
</tr>
<tr>
<td height="10" style="font-size: 10px; line-height: 10px;">&nbsp;</td>
</tr>
<tr>
<td align="center">
<table border="0" width="40" align="center" cellpadding="0" cellspacing="0" bgcolor="eeeeee">
<tr>
<td height="2" style="font-size: 2px; line-height: 2px;">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="20" style="font-size: 20px; line-height: 20px;">&nbsp;</td>
</tr>
<tr>
<td align="center">
<table border="0" width="400" align="center" cellpadding="0" cellspacing="0" class="container590">
<tr>
<td align="center" style="color: #888888; font-size: 16px; font-family: 'Work Sans', Calibri, sans-serif; line-height: 24px;">
<div style="line-height: 24px">
Your account associated with the email [{{ email }}] just had its password updated.
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="25" style="font-size: 25px; line-height: 25px;">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr class="hide">
<td height="25" style="font-size: 25px; line-height: 25px;">&nbsp;</td>
</tr>
<tr>
<td height="40" style="font-size: 40px; line-height: 40px;">&nbsp;</td>
</tr>
</table>
</body>
</html>
Loading

0 comments on commit 27a9d70

Please sign in to comment.