Misc tidying code spacing & formatting in accordance with SonarCloud/PSR
This commit is contained in:
20
ajax.php
20
ajax.php
@@ -6,9 +6,9 @@
|
||||
* Always returns data in JSON format, unless otherwise specified
|
||||
*/
|
||||
|
||||
include("config.php");
|
||||
include("functions.php");
|
||||
include("check_login.php");
|
||||
require_once("config.php");
|
||||
require_once("functions.php");
|
||||
require_once("check_login.php");
|
||||
require_once("rfc6238.php");
|
||||
|
||||
/*
|
||||
@@ -46,8 +46,7 @@ if(isset($_GET['certificate_fetch_parse_json_details'])){
|
||||
$response['expire'] = date('Y-m-d', $cert_public_key_obj['validTo_time_t']);
|
||||
$response['issued_by'] = strip_tags($cert_public_key_obj['issuer']['O']);
|
||||
$response['public_key'] = $export; //nl2br
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$response['success'] = "FALSE";
|
||||
}
|
||||
|
||||
@@ -118,8 +117,7 @@ if(isset($_GET['merge_ticket_get_json_details'])){
|
||||
|
||||
if (mysqli_num_rows($sql) == 0) {
|
||||
//Do nothing.
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//Return ticket, client and contact details for the given ticket number
|
||||
$response = mysqli_fetch_array($sql);
|
||||
echo json_encode($response);
|
||||
@@ -187,21 +185,21 @@ if(isset($_GET['ticket_query_views'])){
|
||||
while ($row = mysqli_fetch_array($query)) {
|
||||
$users[] = $row['user_name'];
|
||||
}
|
||||
|
||||
if (!empty($users)) {
|
||||
$users = array_unique($users);
|
||||
if (count($users) > 1) {
|
||||
// Multiple viewers
|
||||
$response['message'] = implode(", ", $users) . " are viewing this ticket.";
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
// Single viewer
|
||||
$response['message'] = implode("", $users) . " is viewing this ticket.";
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
// No viewers
|
||||
$response['message'] = "";
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
// Headers to allow extensions access (CORS)
|
||||
$chrome_id = "chrome-extension://afgpakhonllnmnomchjhidealcpmnegc";
|
||||
//$firefox_id = "moz-extension://857479e9-3992-4e99-9a5e-b514d2ad0a82"; // Firefox rejected the extension. They are still using manifest v2 so will just focus on Chrome/Edge with v3 for now until Mozilla catches up
|
||||
|
||||
if (isset($_SERVER['HTTP_ORIGIN'])) {
|
||||
if ($_SERVER['HTTP_ORIGIN'] == $chrome_id) {
|
||||
@@ -27,8 +26,8 @@ if (isset($_SERVER['HTTP_ORIGIN'])) {
|
||||
}
|
||||
}
|
||||
|
||||
include("config.php");
|
||||
include("functions.php");
|
||||
include_once("config.php");
|
||||
include_once("functions.php");
|
||||
|
||||
// IP & User Agent for logging
|
||||
$ip = strip_tags(mysqli_real_escape_string($mysqli,get_ip()));
|
||||
@@ -44,7 +43,7 @@ DEFINE("WORDING_BAD_EXT_COOKIE_KEY", "ITFlow - You are not logged into ITFlow, d
|
||||
if (!isset($_COOKIE['user_extension_key'])) {
|
||||
$data['found'] = "FALSE";
|
||||
$data['message'] = WORDING_BAD_EXT_COOKIE_KEY;
|
||||
echo(json_encode($data));
|
||||
echo json_encode($data);
|
||||
|
||||
// Logging
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Login', log_action = 'Extension Failed', log_description = 'Failed login attempt using extension (get_credential.php)', log_ip = '$ip', log_user_agent = '$user_agent'");
|
||||
@@ -59,7 +58,7 @@ $user_extension_key = $_COOKIE['user_extension_key'];
|
||||
if (empty($user_extension_key) || strlen($user_extension_key) < 16 || strtolower($user_extension_key) == "disabled") {
|
||||
$data['found'] = "FALSE";
|
||||
$data['message'] = WORDING_BAD_EXT_COOKIE_KEY;
|
||||
echo(json_encode($data));
|
||||
echo json_encode($data);
|
||||
|
||||
// Logging
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Login', log_action = 'Extension Failed', log_description = 'Failed login attempt using extension (get_credential.php)', log_ip = '$ip', log_user_agent = '$user_agent'");
|
||||
@@ -77,7 +76,7 @@ $row = mysqli_fetch_array($auth_user);
|
||||
if (mysqli_num_rows($auth_user) < 1 || !$auth_user) {
|
||||
$data['found'] = "FALSE";
|
||||
$data['message'] = WORDING_BAD_EXT_COOKIE_KEY;
|
||||
echo(json_encode($data));
|
||||
echo json_encode($data);
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Login', log_action = 'Extension Failed', log_description = 'Failed login attempt using extension (get_credential.php)', log_ip = '$ip', log_user_agent = '$user_agent'");
|
||||
@@ -89,7 +88,7 @@ if(mysqli_num_rows($auth_user) < 1 || !$auth_user){
|
||||
if (hash('sha256', $row['user_extension_key']) !== hash('sha256', $_COOKIE['user_extension_key'])) {
|
||||
$data['found'] = "FALSE";
|
||||
$data['message'] = WORDING_BAD_EXT_COOKIE_KEY;
|
||||
echo(json_encode($data));
|
||||
echo json_encode($data);
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Login', log_action = 'Extension Failed', log_description = 'Failed login attempt using extension (get_credential.php)', log_ip = '$ip', log_user_agent = '$user_agent'");
|
||||
@@ -113,7 +112,7 @@ $session_user_role = $row['user_role'];
|
||||
if ($session_user_role < 1) {
|
||||
$data['found'] = "FALSE";
|
||||
$data['message'] = WORDING_ROLECHECK_FAILED;
|
||||
echo(json_encode($data));
|
||||
echo json_encode($data);
|
||||
|
||||
//Logging
|
||||
$user_name = mysqli_real_escape_string($mysqli, $session_name);
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
* OAuth Login via Microsoft IDP
|
||||
*/
|
||||
|
||||
include('../config.php');
|
||||
include('../functions.php');
|
||||
require_once('../config.php');
|
||||
require_once('../functions.php');
|
||||
|
||||
if (!isset($_SESSION)) {
|
||||
// HTTP Only cookies
|
||||
ini_set("session.cookie_httponly", True);
|
||||
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);
|
||||
ini_set("session.cookie_secure", true);
|
||||
}
|
||||
session_start();
|
||||
}
|
||||
@@ -86,9 +86,8 @@ if (isset($_POST['code']) && $_POST['state'] == session_id()){
|
||||
echo "Error with MS Graph API. Details:";
|
||||
var_dump($msgraph_response['error']);
|
||||
exit();
|
||||
}
|
||||
|
||||
elseif(isset($msgraph_response['id'])){
|
||||
} elseif (isset($msgraph_response['id'])) {
|
||||
|
||||
$upn = mysqli_real_escape_string($mysqli, $msgraph_response["userPrincipalName"]);
|
||||
|
||||
@@ -106,15 +105,13 @@ if (isset($_POST['code']) && $_POST['state'] == session_id()){
|
||||
|
||||
header("Location: index.php");
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$_SESSION['login_message'] = 'Something went wrong with login. Ensure you are setup for SSO.';
|
||||
header("Location: index.php");
|
||||
}
|
||||
}
|
||||
header('Location: index.php');
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
echo "Error getting access_token";
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@ if (empty($config_smtp_host)) {
|
||||
|
||||
if (!isset($_SESSION)) {
|
||||
// HTTP Only cookies
|
||||
ini_set("session.cookie_httponly", True);
|
||||
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);
|
||||
ini_set("session.cookie_secure", true);
|
||||
}
|
||||
session_start();
|
||||
}
|
||||
@@ -82,8 +82,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
/*
|
||||
* Do password reset
|
||||
*/
|
||||
}
|
||||
elseif(isset($_POST['password_reset_set_password'])){
|
||||
} 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;
|
||||
|
||||
@@ -15,7 +15,7 @@ if(isset($_POST['add_ticket'])){
|
||||
$config_ticket_next_number = $row['config_ticket_next_number'];
|
||||
|
||||
// HTML Purifier
|
||||
require("../plugins/htmlpurifier/HTMLPurifier.standalone.php");
|
||||
require_once("../plugins/htmlpurifier/HTMLPurifier.standalone.php");
|
||||
$purifier_config = HTMLPurifier_Config::createDefault();
|
||||
$purifier_config->set('URI.AllowedSchemes', ['data' => true, 'src' => true, 'http' => true, 'https' => true]);
|
||||
$purifier = new HTMLPurifier($purifier_config);
|
||||
@@ -28,8 +28,7 @@ if(isset($_POST['add_ticket'])){
|
||||
// Ensure priority is low/med/high (as can be user defined)
|
||||
if ($_POST['priority'] !== "Low" && $_POST['priority'] !== "Medium" && $_POST['priority'] !== "High") {
|
||||
$priority = "Low";
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$priority = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['priority'])));
|
||||
}
|
||||
|
||||
@@ -50,7 +49,7 @@ if(isset($_POST['add_ticket'])){
|
||||
|
||||
if (isset($_POST['add_ticket_comment'])) {
|
||||
// HTML Purifier
|
||||
require("../plugins/htmlpurifier/HTMLPurifier.standalone.php");
|
||||
require_once("../plugins/htmlpurifier/HTMLPurifier.standalone.php");
|
||||
$purifier_config = HTMLPurifier_Config::createDefault();
|
||||
$purifier_config->set('URI.AllowedSchemes', ['data' => true, 'src' => true, 'http' => true, 'https' => true]);
|
||||
$purifier = new HTMLPurifier($purifier_config);
|
||||
@@ -79,8 +78,7 @@ if(isset($_POST['add_ticket_comment'])){
|
||||
|
||||
// Redirect
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// The client does not have access to this ticket
|
||||
header("Location: portal_post.php?logout");
|
||||
exit();
|
||||
@@ -104,8 +102,7 @@ if(isset($_POST['add_ticket_feedback'])){
|
||||
|
||||
// Redirect
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// The client does not have access to this ticket
|
||||
header("Location: portal_post.php?logout");
|
||||
exit();
|
||||
@@ -129,10 +126,8 @@ if(isset($_GET['close_ticket'])){
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Closed', log_description = '$ticket_id Closed by client', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_created_at = NOW(), company_id = $session_company_id");
|
||||
|
||||
header("Location: ticket.php?id=" . $ticket_id);
|
||||
}
|
||||
else {
|
||||
// The client does not have access to this ticket
|
||||
// This is only a GET request, might just be a mistake
|
||||
} else {
|
||||
// The client does not have access to this ticket - send them home
|
||||
header("Location: index.php");
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -11,8 +11,7 @@ if(isset($_GET['id']) && intval($_GET['id'])) {
|
||||
|
||||
if ($session_contact_id == $session_client_primary_contact_id) {
|
||||
$ticket_sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_id = '$ticket_id' AND ticket_client_id = '$session_client_id'");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$ticket_sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_id = '$ticket_id' AND ticket_client_id = '$session_client_id' AND ticket_contact_id = '$session_contact_id'");
|
||||
}
|
||||
|
||||
@@ -107,8 +106,7 @@ if(isset($_GET['id']) && intval($_GET['id'])) {
|
||||
$user_initials = initials($row['contact_name']);
|
||||
$user_avatar = $row['contact_photo'];
|
||||
$avatar_link = "../uploads/clients/$session_company_id/$session_client_id/$user_avatar";
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$ticket_reply_by_display = $row['user_name'];
|
||||
$user_id = $row['user_id'];
|
||||
$user_avatar = $row['user_avatar'];
|
||||
@@ -153,12 +151,11 @@ if(isset($_GET['id']) && intval($_GET['id'])) {
|
||||
?>
|
||||
|
||||
<?php
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
echo "Ticket ID not found!";
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
} else {
|
||||
header("Location: index.php");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
Reference in New Issue
Block a user