Advertisement
Guest User

Untitled

a guest
Apr 13th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.54 KB | None | 0 0
  1. <?php
  2. require('database.php');
  3.  
  4. if(isset($_GET['p']) && is_numeric($_GET['p'])) {
  5. $page = array(
  6. 'max'=>$_GET['p']*25, //The multiple is the maximum amount of results on a single page.
  7. 'min'=>($_GET['p'] - 1)*25,
  8. 'number'=>$_GET['p'],
  9. 'posts'=>0,
  10. 'count'=>0);
  11. }else{
  12. $page = array(
  13. 'max'=>'25', //The maximum amount of results on a single page.
  14. 'min'=>'0',
  15. 'number'=>'1',
  16. 'posts'=>0,
  17. 'count'=>0);
  18. }
  19.  
  20. $types = array('all','ban','temp_ban','mute','temp_mute','warning','temp_warning','kick'); //List the types of punishments.
  21. ?>
  22. <html lang="en">
  23. <head>
  24. <title><?php echo $info['title']; ?></title>
  25. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  26. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
  27. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  28. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  29. <link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/<?php echo $info['theme']; ?>/bootstrap.min.css" rel="stylesheet">
  30. <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
  31. </head>
  32. <body>
  33. <nav class="navbar navbar-default navbar-fixed-top">
  34. <div class="container">
  35. <div class="navbar-header">
  36. <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
  37. <span class="sr-only">Toggle navigation</span>
  38. <span class="icon-bar"></span>
  39. <span class="icon-bar"></span>
  40. <span class="icon-bar"></span>
  41. </button>
  42. <a class="navbar-brand" href=""><?php echo $info['title']; ?></a>
  43. </div>
  44.  
  45. <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  46. <ul class="nav navbar-nav">
  47. <li class="active"><a href="">Punishments</a></li>
  48. <li><a href="admin">Dashboard</a></li>
  49. </ul>
  50. <ul class="nav navbar-nav navbar-right">
  51. <li class="dropdown">
  52. <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Credits <span class="caret"></span></a>
  53. <ul class="dropdown-menu" role="menu">
  54. <li><a href="https://github.com/mathhulk/ab-web-addon">GitHub</a></li>
  55. <li><a href="https://www.spigotmc.org/resources/advancedban.8695/">AdvancedBan</a></li>
  56. <li><a href="https://theartex.net">mathhulk</a></li>
  57. </ul>
  58. </li>
  59. </ul>
  60. </div>
  61. </div>
  62. </nav>
  63.  
  64. <div class="container">
  65. <div class="jumbotron">
  66. <h1><br><?php echo $info['title']; ?></h1>
  67. <p><?php echo $info['description']; ?></p>
  68. <p>
  69. <?php
  70. foreach($types as $type) { //Loop through the types of punishments.
  71. $result = mysqli_query($con,"SELECT * FROM `".$info['table']."` WHERE punishmentType='".strtoupper($type)."'"); $rows = mysqli_num_rows($result); //Grab the number of rows per punishment type.
  72. $url = "index.php?type=".$type; //Grab the URL for each type.
  73. if($type == 'all') { //If the type is all...
  74. $url = "index.php"; //...set the URL to the same page.
  75. $result = mysqli_query($con,"SELECT * FROM `".$info['table']."` WHERE punishmentType!='IP_BAN'"); $rows = mysqli_num_rows($result); //Grab the number of rows per punishment type.
  76. }
  77. echo '<a href="'.$url.'" class="btn btn-primary btn-md">'.ucwords(str_replace('_','-',$type)).($type != "all" ? "s" : "").' <span class="badge">'.$rows.'</span></a></a>'; //Print the resulting punishment type on the page.
  78. }
  79. ?>
  80. </p>
  81. </div>
  82.  
  83. <div class="jumbotron">
  84. <form method="post" action="user.php">
  85. <div class="input-group">
  86. <input type="text" maxlength="50" name="user" class="form-control" placeholder="Search for...">
  87. <span class="input-group-btn">
  88. <button class="btn btn-default" type="submit">Submit</button>
  89. </span>
  90. </div>
  91. </form>
  92. </div>
  93.  
  94. <div class="jumbotron">
  95. <table class="table table-striped table-hover">
  96. <thead>
  97. <tr>
  98. <th>Username</th>
  99. <th>Reason</th>
  100. <th>Operator</th>
  101. <th>Date</th>
  102. <th>End</th>
  103. <th>Type</th>
  104. </tr>
  105. </thead>
  106. <tbody>
  107. <?php
  108. if(isset($_GET['type']) && $_GET['type'] != 'all' && in_array(strtolower($_GET['type']),$types)) { //Check to see if the type is in the list of types.
  109. $punishment = stripslashes($_GET['type']); $punishment = mysqli_real_escape_string($con,$punishment); //Prevent SQL injection by sanitising and escaping the string.
  110. $result = mysqli_query($con,"SELECT * FROM `".$info['table']."` WHERE punishmentType='".$punishment."' ORDER BY id DESC"); //Grab data from the MYSQL database if a specific type is specified.
  111. } else {
  112. $result = mysqli_query($con,"SELECT * FROM `".$info['table']."` WHERE punishmentType!='IP_BAN' ORDER BY id DESC"); //Grab data from the MYSQL database.
  113. }
  114.  
  115. $rows = mysqli_num_rows($result); //Grab the amount of results to be used in pagination.
  116. while($row = mysqli_fetch_array($result)) { //Fetch colums from each row of the MYSQL database.
  117. if($page['count'] < $page['max'] && $page['count'] >= $page['min']) {
  118. $page['count'] = $page['count'] + 1; //For some reason, $page['count']++ won't work. *shrugs*
  119.  
  120. //Start timezone API.
  121. $time_zone = file_get_contents('http://freegeoip.net/json/'.$_SERVER['REMOTE_ADDR']); //Get the timezone of the visitor.
  122. $time_zone = json_decode($time_zone, true);
  123. $time_zone = $time_zone['time_zone'];
  124.  
  125. $end_date = new DateTime(gmdate('F jS, Y g:i A', $row['end'] / 1000));
  126. $end_date->setTimezone(new DateTimeZone($time_zone)); //Set the timezone of the date to that of the visitor.
  127.  
  128. $start_date = new DateTime(gmdate('F jS, Y g:i A', $row['start'] / 1000));
  129. $start_date->setTimezone(new DateTimeZone($time_zone)); //Set the timezone of the date to that of the visitor.
  130. //End timezone API.
  131.  
  132. $end = $end_date->format("F jS, Y")."<br><span class='badge'>".$end_date->format("g:i A")."</span>"; //Grab the end time as a data.
  133. if($row['end'] == '-1') { //If the end time isn't set...
  134. $end = 'Not Evaluated'; //...set the end time to N/A.
  135. }
  136. echo "<tr><td><img src='https://crafatar.com/renders/head/".$row['uuid']."?scale=2&default=MHF_Steve&overlay' alt='".$row['name']."'>".$row['name']."</td><td>".$row['reason']."</td><td>".$row['operator']."</td><td>".$start_date->format("F jS, Y")."<br><span class='badge'>".$start_date->format("g:i A")."</span></td><td>".$end."</td><td>".ucwords(strtolower(str_replace('_','-',$row['punishmentType'])))."</td></tr>";
  137. $page['posts'] = $page['posts'] + 1;
  138. } else {
  139. $page['count'] = $page['count'] + 1;
  140. if($page['count'] >= $page['max']) {
  141. break;
  142. }
  143. }
  144. }
  145.  
  146. if($page['posts'] == 0) { //Display an error if no punishments could be found.
  147. echo "<tr><td>---</td><td>No punishments could be listed on this page.</td><td>---</td><td>---</td><td>---</td><td>---</td></tr>";
  148. }
  149. ?>
  150. </tbody>
  151. </table>
  152. <div class="text-center">
  153. <ul class='pagination'>
  154. <?php
  155. if($page['number'] != 1) { //Display a previous page button if the current page is not 1.
  156. echo "<li><a href='index.php?p=".($page['number'] - 1).(isset($punishment) ? "&type=".$punishment : '')."'>&laquo; Previous Page</a></li>";
  157. }
  158. $pages = floor($rows / 25); $pagination = 1; //Fetch the number of regular pages.
  159. if($rows % 25 != 0) {
  160. $pages = $pages + 1; //Add one more page if the content will not fit on the number of regular pages.
  161. }
  162. $pages_ = $pages; //Quick fix to get the number of pages for the next page button.
  163. while($pages != 0) {
  164. echo "<li ".($pagination == $page['number'] ? 'class="active"' : '')."><a href='index.php?p=".$pagination.(isset($punishment) ? "&type=".$punishment : '')."'>".$pagination."</a></li>"; //Display the pagination.
  165. $pagination = $pagination + 1; $pages = $pages - 1;
  166. }
  167. if($page['number'] < $pages_) { //Display a next page button if the total punishments is more than that of the current page.
  168. echo "<li><a href='index.php?p=".($page['number'] + 1).(isset($punishment) ? "&type=".$punishment : '')."'>Next Page &raquo;</a></li>";
  169. }
  170. ?>
  171. </ul>
  172. </div>
  173. </div>
  174. </div>
  175. </body>
  176. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement