Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Bug Report</title>
- </head>
- <style>
- textarea {
- resize: none;
- }
- table {
- border-collapse: collapse;
- }
- </style>
- </html>
- <?php
- /*
- * Developer: Script47
- * Module Name: Bug Reports Centre Re-Coded
- * Description: Allows users to report bugs.
- * Price: Free
- * Support: Script47@hotmail.com
- * MWG Contact: http://www.makewebgames.com/member.php/69670-Script47
- * Thread: http://www.makewebgames.com/showthread.php/43393-Bug-Reports-Centre-Mod
- */
- include 'globals.php';
- echo '<h3>Bug Reports</h3>';
- if($ir['userid'] == 1) {
- echo '[<a href="breport.php?truncate=true"><font color="blue">Truncate Table</font></a>]';
- }
- if(isset($_GET['truncate'])) {
- if($ir['userid'] != 1) {
- header("Location: breport.php");
- exit();
- } else {
- $truncate = $db->query("TRUNCATE TABLE `bug_reports`");
- if($truncate) {
- header("Location: breport.php");
- exit();
- } else {
- echo 'Something went wrong.';
- header("Refresh:1; URL=breport.php");
- exit();
- }
- }
- }
- echo '<br/>';
- echo '<br/>';
- echo 'Spotted a bug? Report it <a href="breport.php?report=true"><font color="blue">here</font></a>.';
- if(isset($_GET['report'])) {
- echo '<br/>';
- echo '<form method="post">
- <input type="text" name="Title" placeholder="Title" title="Title" spellcheck="true" required autofocus>
- <br/>
- <textarea rows="10" cols="45" name="Description" placeholder="Detailed explanation of error, page and code if possible." title="Description" spellcheck="true" required></textarea>
- <br/>
- <input type="submit" name="report" value="Report">
- </form>';
- if(isset($_POST['report'])) {
- if(!isset($_POST['Title']) || empty($_POST['Title'])) {
- echo 'Title field empty!';
- exit();
- } else if(!isset($_POST['Description']) || empty($_POST['Description'])) {
- echo 'Description field empty!';
- exit();
- } else {
- $title = htmlspecialchars(trim($db->escape($_POST['Title'])));
- $description = htmlspecialchars(trim($db->escape($_POST['Description'])));
- $user = $db->escape($ir['username']);
- $insertReport = $db->query("INSERT INTO `bug_reports` (Title, Description, Reporter) VALUES ('$title', '$description', '$user')");
- if($insertReport) {
- header("Location: breport.php");
- exit();
- } else {
- echo 'Something went wrong.';
- header("Refresh:1; URL=breport.php");
- exit();
- }
- }
- }
- }
- echo '<br/>';
- echo '<br/>';
- $getReports = $db->query("SELECT * FROM `bug_reports`");
- echo '<table align="center" cellpadding="10" border="1">';
- echo '<th>ID</th>';
- echo '<th>Title</th>';
- echo '<th>Description</th>';
- echo '<th>Reporter</th>';
- echo '<th>Status</th>';
- echo '<th>Date</th>';
- if($ir['user_level'] == 2) {
- echo '<th>Actions</th>';
- }
- $status = array(
- '1' => '<font color="red">Queued</font>',
- '2' => '<font color="orange">Pending</font>',
- '3' => '<font color="green">Fixed</font>',
- '4' => '<font color="#A9A9A9">Not a Bug</font>'
- );
- while ($results = $db->fetch_row($getReports)) {
- echo '<tr><td>';
- echo $results['ID'];
- echo '</td><td>';
- echo $results['Title'];
- echo '</td><td>';
- echo $results['Description'];
- echo '</td><td>';
- echo $results['Reporter'];
- echo '</td><td>';
- echo $status[$results['Status']];
- echo '</td><td>';
- echo date('d/m/Y g:i:s A', strtotime($results['Created']));
- echo '</td><td>';
- if($ir['user_level'] == 2) {
- echo "[<a href='breport.php?delete=true&rID={$results['ID']}'><font color='blue'>Delete Report</font></a>] <br/>";
- echo "<br/>[<a href='breport.php?edit=true&rID={$results['ID']}'><font color='blue'>Edit Report Status</font></a>]";
- }
- }
- echo '</table>';
- if(isset($_GET['delete'])) {
- if(!ctype_digit($_GET['rID'])) {
- header("Location: breport.php");
- exit();
- } else {
- $ID = htmlspecialchars($_GET['rID'])+0;
- $deleteReport = $db->query("DELETE FROM `bug_reports` WHERE ID=$ID");
- if($deleteReport) {
- header("Location: breport.php");
- exit();
- } else {
- echo 'Something went wrong.';
- header("Refresh:1; URL=breport.php");
- exit();
- }
- }
- }
- if(isset($_GET['edit'])) {
- if(!ctype_digit($_GET['rID'])) {
- header("Location: breport.php");
- exit();
- } else {
- echo '<br/>';
- $ID = htmlspecialchars($_GET['rID'])+0;
- echo '<form method="post">
- <select name="status">
- <option value="1">Queued</option>
- <option value="2">Pending</option>
- <option value="3">Fixed</option>
- <option value="4">Not a Bug</option>
- </select>
- <br/>
- <input type="submit" name="editReport" value="Edit">
- </form>';
- if(isset($_POST['editReport'])) {
- $newStatus = htmlspecialchars($_POST['status'])+0;
- $changeStatus = $db->query("UPDATE `bug_reports` SET Status=$newStatus WHERE ID=$ID");
- if($changeStatus) {
- header("Location: breport.php");
- exit();
- } else {
- echo 'Something went wrong.';
- header("Refresh:1; URL=breport.php");
- exit();
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement