aboutsummaryrefslogtreecommitdiff
path: root/bug/view.php
diff options
context:
space:
mode:
Diffstat (limited to 'bug/view.php')
-rw-r--r--bug/view.php34
1 files changed, 19 insertions, 15 deletions
diff --git a/bug/view.php b/bug/view.php
index 2468abb..d1e4335 100644
--- a/bug/view.php
+++ b/bug/view.php
@@ -1,28 +1,32 @@
<?php
-require 'config.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 bug selected, redirecting to index...</div>";
- header('Refresh: 2; URL=index.php');
+ echo "<div id='error'>No bug selected...</div>";
+ header("Refresh: 2; URL=$_SERVER[HTTP_REFERER]");
+ goto footer;
+}
-} else {
- if(isset($_SESSION['user_id']) && $_SESSION['user_id'] != "") {
- echo "<p><a href=edit.php?id=$_GET[id]>Edit</a></p>";
- }
+$conn = new PDO($config['db']['dsn'], $config['db']['username'], $config['db']['password']);
+$query = $conn->prepare("SELECT title, description, users.username AS submitter FROM bugs
+ JOIN users ON bugs.author = users.id WHERE bugs.id=:bug_id");
+$query->bindParam(':bug_id', $_GET['id']);
+$query->execute();
+$result = $query->fetch();
- $conn = new PDO($config['db']['dsn'], $config['db']['username'], $config['db']['password']);
- $markdown = new Parsedown();
+$markdown = new Parsedown();
- $query = "SELECT title, description, users.username AS submitter FROM bugs JOIN users ON bugs.author = users.id WHERE bugs.id=$_GET[id]";
- $result = $conn->query($query)->fetch();
+echo "<p><b>$result[title]</b></p>";
+echo "<p>Submitted by $result[submitter]</p>";
+echo '<p>' . $markdown->text($result['description']) . '</p>';
- 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>";
}
-require_once(TEMPLATES_PATH . "/footer.php");
+footer: require_once(TEMPLATES_PATH . "/footer.php");
?>