aboutsummaryrefslogtreecommitdiff
path: root/report/view.php
diff options
context:
space:
mode:
Diffstat (limited to 'report/view.php')
-rw-r--r--report/view.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/report/view.php b/report/view.php
new file mode 100644
index 0000000..479f90e
--- /dev/null
+++ b/report/view.php
@@ -0,0 +1,32 @@
+<?php
+require '../config.php';
+require_once(TEMPLATES_PATH . "/header.php");
+require_once(TEMPLATES_PATH . "/panel.php");
+require_once(LIBRARY_PATH . "/functions.php");
+require_once(LIBRARY_PATH . "/parsedown.php");
+
+if(!isset($_GET['id']) || $_GET['id'] == "") {
+ echo "<div id='error'>No report selected, redirecting to index...</div>";
+ header("Refresh: 2; URL=$_SERVER[HTTP_REFERER]");
+ goto footer;
+}
+
+$conn = new PDO($config['db']['dsn'], $config['db']['username'], $config['db']['password']);
+$query = $conn->prepare("SELECT title, description, users.username AS submitter FROM reports
+ JOIN users ON reports.author = users.id WHERE reports.id=:report_id");
+$query->bindParam(':report_id', $_GET['id']);
+$query->execute();
+$result = $query->fetch();
+
+$markdown = new Parsedown();
+
+echo "<p><b>$result[title]</b></p>";
+echo "<p>Submitted by $result[submitter]</p>";
+echo '<p>' . $markdown->text($result['description']) . '</p>';
+
+if(session_set()) {
+ echo "<p><a href=edit.php?id=$_GET[id]>Edit</a> | <a href=delete.php?id=$_GET[id]>Delete</a></p>";
+}
+
+footer: require_once(TEMPLATES_PATH . "/footer.php");
+?>