From d105cefe617921223959fdea47ef6f02d657e5c9 Mon Sep 17 00:00:00 2001
From: Luke Tainton
Date: Tue, 4 Aug 2020 18:29:23 +0100
Subject: [PATCH] :art: Don't use header() to redirect to /login
Signed-off-by: Luke Tainton
---
app/includes/header.php | 5 ++
app/public/index.php | 173 ++++++++++++++++++----------------------
app/public/new.php | 6 +-
app/public/open.php | 4 -
app/public/view.php | 74 ++++++++---------
5 files changed, 118 insertions(+), 144 deletions(-)
diff --git a/app/includes/header.php b/app/includes/header.php
index 8a7d372..521b451 100644
--- a/app/includes/header.php
+++ b/app/includes/header.php
@@ -8,6 +8,11 @@
+ ");
+ }
+ ?>
diff --git a/app/public/index.php b/app/public/index.php
index 89b1008..e6950a0 100644
--- a/app/public/index.php
+++ b/app/public/index.php
@@ -3,32 +3,28 @@
require_once __DIR__ . "/../includes/prereqs.php";
require_once __DIR__ . "/../includes/header.php";
- if (is_signed_in()) {
- // Get user's own tickets
- try {
- $user_tickets_stmt = "SELECT uuid, id, title, description, status FROM tickets WHERE created_by=:uuid";
- $user_tickets_sql = $db->prepare($user_tickets_stmt);
- $user_tickets_sql->bindParam(':uuid', $_SESSION['uuid']);
- $user_tickets_sql->execute();
- $user_tickets_sql->setFetchMode(PDO::FETCH_ASSOC);
- $user_tickets_result = $user_tickets_sql->fetchAll();
- } catch (PDOException $e) {
- echo("Error: " . $e->getMessage());
- }
+ // Get user's own tickets
+ try {
+ $user_tickets_stmt = "SELECT uuid, id, title, description, status FROM tickets WHERE created_by=:uuid";
+ $user_tickets_sql = $db->prepare($user_tickets_stmt);
+ $user_tickets_sql->bindParam(':uuid', $_SESSION['uuid']);
+ $user_tickets_sql->execute();
+ $user_tickets_sql->setFetchMode(PDO::FETCH_ASSOC);
+ $user_tickets_result = $user_tickets_sql->fetchAll();
+ } catch (PDOException $e) {
+ echo("Error: " . $e->getMessage());
+ }
- // Get tickets user has subscribed to
- try {
- $sub_tickets_stmt = "SELECT ticket_uuid FROM ticket_subscribers WHERE user_uuid=:uuid";
- $sub_tickets_sql = $db->prepare($sub_tickets_stmt);
- $sub_tickets_sql->bindParam(':uuid', $_SESSION['uuid']);
- $sub_tickets_sql->execute();
- $sub_tickets_sql->setFetchMode(PDO::FETCH_ASSOC);
- $sub_tickets_result = $sub_tickets_sql->fetchAll();
- } catch (PDOException $e) {
- echo("Error: " . $e->getMessage());
- }
-
- $user_tickets_sub = 0; // Force 'no subbed tickets' msg until the code works
+ // Get tickets user has subscribed to
+ try {
+ $sub_tickets_stmt = "SELECT ticket_uuid FROM ticket_subscribers WHERE user_uuid=:uuid";
+ $sub_tickets_sql = $db->prepare($sub_tickets_stmt);
+ $sub_tickets_sql->bindParam(':uuid', $_SESSION['uuid']);
+ $sub_tickets_sql->execute();
+ $sub_tickets_sql->setFetchMode(PDO::FETCH_ASSOC);
+ $sub_tickets_result = $sub_tickets_sql->fetchAll();
+ } catch (PDOException $e) {
+ echo("Error: " . $e->getMessage());
}
function get_sub_ticket($db, $ticket_uuid) {
@@ -77,84 +73,73 @@
is the one-stop shop for all of your IT-related needs. Let us know how we can help you by opening a request.
- Create a request
- View existing requests
- ");
- } else {
- echo("Please log in to create or view tickets.");
- }
- ?>
+ Create a request
+ View existing requests
-
-
-
-
-
- No open tickets");
- } else {
- foreach($user_tickets_result as $tkt) {
- ?>
- -
-
-
-
-
+
+
+
+
+ No open tickets");
+ } else {
+ foreach($user_tickets_result as $tkt) {
+ ?>
+ -
+
-
+
+
+
+
+
+
-
-
-
-
- No subscribed tickets");
- } else {
- foreach($sub_tickets_result as $sub) {
- $tkt = get_sub_ticket($db, $sub['ticket_uuid']);
- $tkt_creator = get_user_name($db, $tkt['created_by']);
- ?>
- -
-
-
-
-
+
+
+
+
+ No subscribed tickets");
+ } else {
+ foreach($sub_tickets_result as $sub) {
+ $tkt = get_sub_ticket($db, $sub['ticket_uuid']);
+ $tkt_creator = get_user_name($db, $tkt['created_by']);
+ ?>
+ -
+
-
-
+
+
+
+
+
+
diff --git a/app/public/new.php b/app/public/new.php
index 892dba3..0686777 100644
--- a/app/public/new.php
+++ b/app/public/new.php
@@ -3,10 +3,6 @@
require_once __DIR__ . "/../includes/prereqs.php";
require_once __DIR__ . "/../includes/header.php";
- if (!is_signed_in()) {
- header('Location: /login');
- }
-
// If form submitted, save to database
if($_SERVER['REQUEST_METHOD'] == 'POST') {
try {
@@ -69,7 +65,7 @@