Advertisement
Script47

breport.php

Jan 11th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.95 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <title>Bug Report</title>
  4.     </head>
  5.     <style>
  6.         textarea {
  7.             resize: none;
  8.         }
  9.         table {
  10.             border-collapse: collapse;
  11.         }
  12.     </style>
  13. </html>
  14.  
  15. <?php
  16.  
  17. /*
  18.  * Developer: Script47
  19.  * Module Name: Bug Reports Centre Re-Coded
  20.  * Description: Allows users to report bugs.
  21.  * Price: Free
  22.  * Support: Script47@hotmail.com
  23.  * MWG Contact: http://www.makewebgames.com/member.php/69670-Script47
  24.  * Thread: http://www.makewebgames.com/showthread.php/43393-Bug-Reports-Centre-Mod
  25. */
  26.  
  27. include 'globals.php';
  28.  
  29. echo '<h3>Bug Reports</h3>';
  30.  
  31. if($ir['userid'] == 1) {
  32.     echo '[<a href="breport.php?truncate=true"><font color="blue">Truncate Table</font></a>]';
  33. }
  34.  
  35. if(isset($_GET['truncate'])) {
  36.     if($ir['userid'] != 1) {
  37.         header("Location: breport.php");
  38.         exit();
  39.     } else {
  40.         $truncate = $db->query("TRUNCATE TABLE `bug_reports`");
  41.        
  42.         if($truncate) {
  43.             header("Location: breport.php");
  44.             exit();
  45.         } else {
  46.             echo 'Something went wrong.';
  47.             header("Refresh:1; URL=breport.php");
  48.             exit();
  49.         }
  50.     }
  51. }
  52.  
  53. echo '<br/>';
  54. echo '<br/>';
  55.  
  56. echo 'Spotted a bug? Report it <a href="breport.php?report=true"><font color="blue">here</font></a>.';
  57.  
  58. if(isset($_GET['report'])) {
  59.     echo '<br/>';
  60.    
  61.     echo '<form method="post">
  62.             <input type="text" name="Title" placeholder="Title" title="Title" spellcheck="true" required autofocus>
  63.             <br/>
  64.             <textarea rows="10" cols="45" name="Description" placeholder="Detailed explanation of error, page and code if possible." title="Description" spellcheck="true" required></textarea>
  65.             <br/>
  66.             <input type="submit" name="report" value="Report">
  67.          </form>';
  68.    
  69.     if(isset($_POST['report'])) {
  70.         if(!isset($_POST['Title']) || empty($_POST['Title'])) {
  71.             echo 'Title field empty!';
  72.             exit();
  73.         } else if(!isset($_POST['Description']) || empty($_POST['Description'])) {
  74.             echo 'Description field empty!';
  75.             exit();
  76.         } else {
  77.             $title = htmlspecialchars(trim($db->escape($_POST['Title'])));
  78.             $description = htmlspecialchars(trim($db->escape($_POST['Description'])));
  79.             $user = $db->escape($ir['username']);
  80.                        
  81.             $insertReport = $db->query("INSERT INTO `bug_reports` (Title, Description, Reporter) VALUES ('$title', '$description', '$user')");
  82.            
  83.             if($insertReport) {
  84.                 header("Location: breport.php");
  85.                 exit();
  86.             } else {
  87.                 echo 'Something went wrong.';
  88.                 header("Refresh:1; URL=breport.php");
  89.                 exit();
  90.             }
  91.         }
  92.     }
  93. }
  94.  
  95. echo '<br/>';
  96. echo '<br/>';
  97.  
  98. $getReports = $db->query("SELECT * FROM `bug_reports`");
  99.  
  100. echo '<table align="center" cellpadding="10" border="1">';
  101.  
  102. echo '<th>ID</th>';
  103. echo '<th>Title</th>';
  104. echo '<th>Description</th>';
  105. echo '<th>Reporter</th>';
  106. echo '<th>Status</th>';
  107. echo '<th>Date</th>';
  108.  
  109. if($ir['user_level'] == 2) {
  110.     echo '<th>Actions</th>';
  111. }
  112.  
  113. $status = array(
  114.     '1' => '<font color="red">Queued</font>',
  115.     '2' => '<font color="orange">Pending</font>',
  116.     '3' => '<font color="green">Fixed</font>',
  117.     '4' => '<font color="#A9A9A9">Not a Bug</font>'
  118. );
  119.  
  120. while ($results = $db->fetch_row($getReports)) {
  121.     echo '<tr><td>';
  122.     echo $results['ID'];
  123.     echo '</td><td>';
  124.     echo $results['Title'];
  125.     echo '</td><td>';
  126.     echo $results['Description'];
  127.     echo '</td><td>';
  128.     echo $results['Reporter'];
  129.     echo '</td><td>';
  130.     echo $status[$results['Status']];
  131.     echo '</td><td>';
  132.     echo date('d/m/Y g:i:s A',  strtotime($results['Created']));
  133.     echo '</td><td>';
  134.     if($ir['user_level'] == 2) {
  135.         echo "[<a href='breport.php?delete=true&rID={$results['ID']}'><font color='blue'>Delete Report</font></a>] <br/>";
  136.         echo "<br/>[<a href='breport.php?edit=true&rID={$results['ID']}'><font color='blue'>Edit Report Status</font></a>]";
  137.     }
  138. }
  139. echo '</table>';
  140.  
  141. if(isset($_GET['delete'])) {
  142.     if(!ctype_digit($_GET['rID'])) {
  143.         header("Location: breport.php");
  144.         exit();
  145.     } else {
  146.         $ID = htmlspecialchars($_GET['rID'])+0;
  147.    
  148.         $deleteReport = $db->query("DELETE FROM `bug_reports` WHERE ID=$ID");
  149.    
  150.         if($deleteReport) {
  151.             header("Location: breport.php");
  152.             exit();
  153.         } else {
  154.             echo 'Something went wrong.';
  155.             header("Refresh:1; URL=breport.php");
  156.             exit();
  157.         }
  158.     }
  159. }
  160.  
  161. if(isset($_GET['edit'])) {
  162.     if(!ctype_digit($_GET['rID'])) {
  163.         header("Location: breport.php");
  164.         exit();
  165.     } else {
  166.         echo '<br/>';
  167.        
  168.         $ID = htmlspecialchars($_GET['rID'])+0;
  169.    
  170.         echo '<form method="post">
  171.                 <select name="status">
  172.                     <option value="1">Queued</option>
  173.                     <option value="2">Pending</option>
  174.                     <option value="3">Fixed</option>
  175.                     <option value="4">Not a Bug</option>
  176.                 </select>
  177.                 <br/>
  178.                 <input type="submit" name="editReport" value="Edit">
  179.              </form>';
  180.    
  181.         if(isset($_POST['editReport'])) {
  182.             $newStatus = htmlspecialchars($_POST['status'])+0;
  183.  
  184.             $changeStatus = $db->query("UPDATE `bug_reports` SET Status=$newStatus WHERE ID=$ID");
  185.            
  186.             if($changeStatus) {
  187.                 header("Location: breport.php");
  188.                 exit();
  189.             } else {
  190.                 echo 'Something went wrong.';
  191.                 header("Refresh:1; URL=breport.php");
  192.                 exit();
  193.             }
  194.         }
  195.     }
  196. }
  197.  
  198. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement