aboutsummaryrefslogtreecommitdiff
path: root/bug
diff options
context:
space:
mode:
Diffstat (limited to 'bug')
-rw-r--r--bug/delete.php0
-rw-r--r--bug/edit.php33
-rw-r--r--bug/update.php35
-rw-r--r--bug/view.php28
4 files changed, 96 insertions, 0 deletions
diff --git a/bug/delete.php b/bug/delete.php
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/bug/delete.php
diff --git a/bug/edit.php b/bug/edit.php
new file mode 100644
index 0000000..7eba339
--- /dev/null
+++ b/bug/edit.php
@@ -0,0 +1,33 @@
+<?php
+require 'config.php';
+require_once(TEMPLATES_PATH . "/header.php");
+require_once(TEMPLATES_PATH . "/panel.php");
+require_once(LIBRARY_PATH . "/functions.php");
+
+if(!isset($_GET['id']) || $_GET['id'] == "") {
+ echo "<div id='error'>No bug selected, redirecting to index...</div>";
+ header('Refresh: 2; URL=index.php');
+
+} else if(!isset($_SESSION['user_id']) || $_SESSION['user_id'] == "") {
+ echo "<div id='error'>Not logged in, redirecting to index...</div>";
+ header('Refresh: 2; URL=index.php');
+
+} else {
+ $conn = new PDO($config['db']['dsn'], $config['db']['username'], $config['db']['password']);
+
+ $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();
+?>
+
+<form action="update.php?id=<?php echo $_GET['id']; ?>" method="post">
+<p>Title: <input name="title" type="text" value="<?php echo $result['title']; ?>"></p>
+<p>Submitted by: <?php echo $result['submitter']; ?></p>
+<p>Description: <br><textarea name="description" rows=25 cols=80><?php echo $result['description']; ?></textarea></p>
+<input type="submit" value="update" >
+</form>
+
+<?php
+}
+
+require_once(TEMPLATES_PATH . "/footer.php");
+?>
diff --git a/bug/update.php b/bug/update.php
new file mode 100644
index 0000000..f27cdd4
--- /dev/null
+++ b/bug/update.php
@@ -0,0 +1,35 @@
+<?php
+require 'config.php';
+require_once(TEMPLATES_PATH . "/header.php");
+require_once(TEMPLATES_PATH . "/panel.php");
+require_once(LIBRARY_PATH . "/functions.php");
+
+if(!isset($_GET['id']) || $_GET['id'] == "") {
+ echo "<div id='error'>No bug selected, redirecting to index...</div>";
+ header('Refresh: 2; URL=index.php');
+
+} else if(!isset($_SESSION['user_id']) || $_SESSION['user_id'] == "") {
+ echo "<div id='error'>Not logged in, redirecting to index...</div>";
+ header('Refresh: 2; URL=index.php');
+
+} else {
+ $conn = new PDO($config['db']['dsn'], $config['db']['username'], $config['db']['password']);
+
+ $query = $conn->prepare("UPDATE bugs SET title=:title, description=:description WHERE id=:id");
+ $query->bindParam(':title', $_POST['title']);
+ $query->bindParam(':description', $_POST['description']);
+ $query->bindParam(':id', $_GET['id']);
+
+ if ($query->execute()) {
+ echo "Data is updated\n";
+ } else {
+ echo "User must have sent wrong inputs\n";
+ }
+
+ header("Refresh: 2; URL=view.php?id=$_GET[id]");
+
+}
+
+require_once(TEMPLATES_PATH . "/footer.php");
+?>
+
diff --git a/bug/view.php b/bug/view.php
new file mode 100644
index 0000000..2468abb
--- /dev/null
+++ b/bug/view.php
@@ -0,0 +1,28 @@
+<?php
+require 'config.php';
+require_once(TEMPLATES_PATH . "/header.php");
+require_once(TEMPLATES_PATH . "/panel.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');
+
+} 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']);
+ $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>';
+}
+
+require_once(TEMPLATES_PATH . "/footer.php");
+?>