-
@@ -158,7 +158,7 @@ if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['login'])){
diff --git a/portal/login_microsoft.php b/portal/login_microsoft.php
index e6ff7286..6e7703e7 100644
--- a/portal/login_microsoft.php
+++ b/portal/login_microsoft.php
@@ -31,7 +31,7 @@ $token_grant_url = "https://login.microsoftonline.com/organizations/oauth2/v2.0/
// Initial Login Request, via Microsoft
// Returns a authorization code if login was successful
-if ($_SERVER['REQUEST_METHOD'] == "GET"){
+if ($_SERVER['REQUEST_METHOD'] == "GET") {
$params = array (
'client_id' => $client_id,
@@ -47,7 +47,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET"){
// Login was successful, Microsoft has returned us a authorization code via POST
// Request an access token using authorization code (& client secret) (server side)
-if (isset($_POST['code']) && $_POST['state'] == session_id()){
+if (isset($_POST['code']) && $_POST['state'] == session_id()) {
$params = array (
'client_id' =>$client_id,
@@ -70,7 +70,7 @@ if (isset($_POST['code']) && $_POST['state'] == session_id()){
// Check if we have an access token
// If we do, send a request to Microsoft Graph API to get user info
- if (isset($access_token_response['access_token'])){
+ if (isset($access_token_response['access_token'])) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Authorization: Bearer '.$access_token_response['access_token'],
@@ -81,7 +81,7 @@ if (isset($_POST['code']) && $_POST['state'] == session_id()){
$msgraph_response = json_decode(curl_exec($ch), 1);
- if (isset($msgraph_response['error'])){
+ if (isset($msgraph_response['error'])) {
// Something went wrong verifying the token/using the Graph API - quit
echo "Error with MS Graph API. Details:";
var_dump($msgraph_response['error']);
@@ -119,5 +119,5 @@ if (isset($_POST['code']) && $_POST['state'] == session_id()){
// If the user is just sat on the page, redirect them to login to try again
if (empty($_GET)) {
- echo "";
+ echo "";
}
\ No newline at end of file
diff --git a/portal/login_reset.php b/portal/login_reset.php
index 6b9716fd..d78cdec3 100644
--- a/portal/login_reset.php
+++ b/portal/login_reset.php
@@ -10,22 +10,22 @@ require_once('../functions.php');
require_once('../get_settings.php');
if (empty($config_smtp_host)) {
- header("Location: login.php");
- exit();
+ header("Location: login.php");
+ exit();
}
if (!isset($_SESSION)) {
- // HTTP Only cookies
- ini_set("session.cookie_httponly", true);
- if ($config_https_only) {
- // Tell client to only send cookie(s) over HTTPS
- ini_set("session.cookie_secure", true);
- }
- session_start();
+ // HTTP Only cookies
+ ini_set("session.cookie_httponly", true);
+ if ($config_https_only) {
+ // Tell client to only send cookie(s) over HTTPS
+ ini_set("session.cookie_secure", true);
+ }
+ session_start();
}
$ip = strip_tags(mysqli_real_escape_string($mysqli,get_ip()));
-$user_agent = strip_tags(mysqli_real_escape_string($mysqli,$_SERVER['HTTP_USER_AGENT']));
+$user_agent = strip_tags(mysqli_real_escape_string($mysqli, $_SERVER['HTTP_USER_AGENT']));
$company_sql = mysqli_query($mysqli, "SELECT company_name FROM companies WHERE company_id = '1'");
$company_results = mysqli_fetch_array($company_sql);
@@ -35,106 +35,106 @@ DEFINE("WORDING_ERROR", "Something went wrong! Your link may have expired. Pleas
if ($_SERVER['REQUEST_METHOD'] == "POST") {
- /*
- * Send password reset email
- */
- if (isset($_POST['password_reset_email_request'])) {
-
- $email = strip_tags(mysqli_real_escape_string($mysqli, $_POST['email']));
-
- $sql = mysqli_query($mysqli, "SELECT contact_id, contact_name, contact_email, contact_client_id, company_id FROM contacts WHERE contact_email = '$email' AND contact_auth_method = 'local' LIMIT 1");
- $row = mysqli_fetch_assoc($sql);
-
- $id = $row['contact_id'];
- $name = $row['contact_name'];
- $client = $row['contact_client_id'];
- $company = $row['company_id'];
-
- if ($row['contact_email'] == $email) {
- $token = key32gen();
- $url = "https://$config_base_url/portal/login_reset.php?email=$email&token=$token&client=$client";
- mysqli_query($mysqli, "UPDATE contacts SET contact_password_reset_token = '$token' WHERE contact_id = $id LIMIT 1");
- mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Contact', log_action = 'Modify', log_description = 'Sent a portal password reset e-mail for $email.', log_ip = '$ip', log_user_agent = '$user_agent', log_created_at = NOW(), log_client_id = $client, company_id = $company");
-
-
- // Send reset email
- $subject = "Password reset for $company_name ITFlow Portal";
- $body = "Hello, $name
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";
-
- $mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port,
- $config_mail_from_email, $config_mail_from_name,
- $email, $name,
- $subject, $body);
-
- // Error handling
- if ($mail !== true) {
- mysqli_query($mysqli,"INSERT INTO notifications SET notification_type = 'Mail', notification = 'Failed to send email to $email', notification_timestamp = NOW(), company_id = $company");
- mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Mail', log_action = 'Error', log_description = 'Failed to send email to $email regarding $subject. $mail', company_id = $company");
- }
-
- //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
+ * Send password reset email
*/
- } elseif (isset($_POST['password_reset_set_password'])) {
+ if (isset($_POST['password_reset_email_request'])) {
+
+ $email = strip_tags(mysqli_real_escape_string($mysqli, $_POST['email']));
+
+ $sql = mysqli_query($mysqli, "SELECT contact_id, contact_name, contact_email, contact_client_id, company_id FROM contacts WHERE contact_email = '$email' AND contact_auth_method = 'local' LIMIT 1");
+ $row = mysqli_fetch_assoc($sql);
+
+ $id = $row['contact_id'];
+ $name = $row['contact_name'];
+ $client = $row['contact_client_id'];
+ $company = $row['company_id'];
+
+ if ($row['contact_email'] == $email) {
+ $token = key32gen();
+ $url = "https://$config_base_url/portal/login_reset.php?email=$email&token=$token&client=$client";
+ mysqli_query($mysqli, "UPDATE contacts SET contact_password_reset_token = '$token' WHERE contact_id = $id LIMIT 1");
+ mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Contact', log_action = 'Modify', log_description = 'Sent a portal password reset e-mail for $email.', log_ip = '$ip', log_user_agent = '$user_agent', log_created_at = NOW(), log_client_id = $client, company_id = $company");
+
+
+ // Send reset email
+ $subject = "Password reset for $company_name ITFlow Portal";
+ $body = "Hello, $name
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";
+
+ $mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port,
+ $config_mail_from_email, $config_mail_from_name,
+ $email, $name,
+ $subject, $body);
+
+ // Error handling
+ if ($mail !== true) {
+ mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Mail', notification = 'Failed to send email to $email', notification_timestamp = NOW(), company_id = $company");
+ mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Mail', log_action = 'Error', log_description = 'Failed to send email to $email regarding $subject. $mail', company_id = $company");
+ }
+
+ //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 = strip_tags(mysqli_real_escape_string($mysqli, $_POST['token']));
+ $email = strip_tags(mysqli_real_escape_string($mysqli, $_POST['email']));
+ $client = intval(strip_tags(mysqli_real_escape_string($mysqli, $_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 = $contact_row['contact_id'];
+ $name = $contact_row['contact_name'];
+ $company = $contact_row['company_id'];
+
+ // 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_created_at = NOW(), log_client_id = $client, company_id = $company");
+
+ // 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";
+
+
+ $mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port,
+ $config_mail_from_email, $config_mail_from_name,
+ $email, $name,
+ $subject, $body);
+
+ // Error handling
+ if ($mail !== true) {
+ mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Mail', notification = 'Failed to send email to $email', notification_timestamp = NOW(), company_id = $company");
+ mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Mail', log_action = 'Error', log_description = 'Failed to send email to $email regarding $subject. $mail', company_id = $company");
+ }
+
+ // Redirect to login page
+ $_SESSION['login_message'] = "Password reset successfully!";
+ header("Location: login.php");
+ exit();
+
+ } else {
+ $_SESSION['login_message'] = WORDING_ERROR;
+ }
+
- if (!isset($_POST['new_password']) || !isset($_POST['email']) || !isset($_POST['token']) || !isset($_POST['client'])) {
- $_SESSION['login_message'] = WORDING_ERROR;
}
- $token = strip_tags(mysqli_real_escape_string($mysqli, $_POST['token']));
- $email = strip_tags(mysqli_real_escape_string($mysqli, $_POST['email']));
- $client = intval(strip_tags(mysqli_real_escape_string($mysqli, $_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 = $contact_row['contact_id'];
- $name = $contact_row['contact_name'];
- $company = $contact_row['company_id'];
-
- // 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_created_at = NOW(), log_client_id = $client, company_id = $company");
-
- // 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";
-
-
- $mail = sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_password, $config_smtp_encryption, $config_smtp_port,
- $config_mail_from_email, $config_mail_from_name,
- $email, $name,
- $subject, $body);
-
- // Error handling
- if ($mail !== true) {
- mysqli_query($mysqli,"INSERT INTO notifications SET notification_type = 'Mail', notification = 'Failed to send email to $email', notification_timestamp = NOW(), company_id = $company");
- mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Mail', log_action = 'Error', log_description = 'Failed to send email to $email regarding $subject. $mail', company_id = $company");
- }
-
- // Redirect to login page
- $_SESSION['login_message'] = "Password reset successfully!";
- header("Location: login.php");
- exit();
-
- } else {
- $_SESSION['login_message'] = WORDING_ERROR;
- }
-
-
- }
-
}
@@ -142,110 +142,110 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
-
-
-
| Password Reset
+
+
+
| Password Reset
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
=$company_name?>
Password Reset
-
-
+
=$company_name?>
Password Reset
+
+
-
+
-
-
-
+
+
+
-
Back to login
+
Back to login
+
+
+
-
-
-
-
+
@@ -261,7 +261,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
diff --git a/portal/portal_functions.php b/portal/portal_functions.php
index 56fcbbf7..f4b8cca4 100644
--- a/portal/portal_functions.php
+++ b/portal/portal_functions.php
@@ -7,32 +7,32 @@
/*
* Verifies a contact has access to a particular ticket ID, and that the ticket is in the correct state (open/closed) to perform an action
*/
-function verifyContactTicketAccess($requested_ticket_id, $expected_ticket_state){
+function verifyContactTicketAccess($requested_ticket_id, $expected_ticket_state) {
- // Access the global variables
- global $mysqli, $session_contact_id, $session_client_primary_contact_id, $session_client_id;
+ // Access the global variables
+ global $mysqli, $session_contact_id, $session_client_primary_contact_id, $session_client_id;
- // Setup
- if($expected_ticket_state == "Closed"){
- // Closed tickets
- $ticket_state_snippet = "ticket_status = 'Closed'";
- }
- else{
- // Open (working/hold) tickets
- $ticket_state_snippet = "ticket_status != 'Closed'";
- }
+ // Setup
+ if ($expected_ticket_state == "Closed") {
+ // Closed tickets
+ $ticket_state_snippet = "ticket_status = 'Closed'";
+ }
+ else {
+ // Open (working/hold) tickets
+ $ticket_state_snippet = "ticket_status != 'Closed'";
+ }
- // Verify the contact has access to the provided ticket ID
- $sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_id = '$requested_ticket_id' AND $ticket_state_snippet AND ticket_client_id = '$session_client_id' LIMIT 1");
- $row = mysqli_fetch_array($sql);
- $ticket_id = $row['ticket_id'];
+ // Verify the contact has access to the provided ticket ID
+ $sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_id = '$requested_ticket_id' AND $ticket_state_snippet AND ticket_client_id = '$session_client_id' LIMIT 1");
+ $row = mysqli_fetch_array($sql);
+ $ticket_id = $row['ticket_id'];
- if(intval($ticket_id) && ($session_contact_id == $row['ticket_contact_id'] || $session_contact_id == $session_client_primary_contact_id)) {
- // Client is ticket owner, or primary contact
- return TRUE;
- }
+ if (intval($ticket_id) && ($session_contact_id == $row['ticket_contact_id'] || $session_contact_id == $session_client_primary_contact_id)) {
+ // Client is ticket owner, or primary contact
+ return TRUE;
+ }
- // Client is NOT ticket owner or primary contact
- return FALSE;
+ // Client is NOT ticket owner or primary contact
+ return FALSE;
}
\ No newline at end of file
diff --git a/portal/portal_header.php b/portal/portal_header.php
index a45efa6a..ede24c9f 100644
--- a/portal/portal_header.php
+++ b/portal/portal_header.php
@@ -8,61 +8,61 @@
-
-
-
| Client Portal - Tickets
+
+
+
| Client Portal - Tickets
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/portal/ticket_add.php b/portal/ticket_add.php
index 902115e9..9f7d5e10 100644
--- a/portal/ticket_add.php
+++ b/portal/ticket_add.php
@@ -7,44 +7,44 @@
require('inc_portal.php');
?>
-
Raise a new ticket
+
Raise a new ticket
-
-