Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. <?php
  2. //configuration
  3. $db_host = "host"; //your MySql Host
  4. $db_name = "db"; //your MySql Database Name
  5. $db_user = "username"; //your MySql username
  6. $db_pass = "password"; //your MySql password
  7. $db_tablename = "bans"; //your banlist table name
  8.  
  9. ?>
  10.  
  11. <!DOCTYPE html>
  12. <html lang="en">
  13. <head>
  14. <meta charset="utf-8">
  15. <meta name="viewport" content="width=device-width, initial-scale=1">
  16. <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  17. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  18. <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  19. <style type="text/css">
  20. .body
  21. {
  22. padding: 0;
  23. margin: 0;
  24. }
  25. .table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th
  26. {
  27. border-top: 1px solid !important;
  28. }
  29. th {
  30. background-color: #444444;
  31. color: white;
  32. }
  33. </style>
  34. </head>
  35. <body>
  36. <?php
  37.  
  38. $db = new mysqli($db_host, $db_user, $db_pass, $db_name);
  39.  
  40. if($db->connect_errno > 0){
  41. die('Unable to connect to database [' . $db->connect_error . ']');
  42. }
  43. $sql = "SELECT * FROM `".$db_tablename."` ORDER BY `banTime` DESC";
  44.  
  45.  
  46. if(!$result = $db->query($sql)){
  47. die('There was an error running the query [' . $db->error . ']');
  48. }
  49.  
  50. function convertToHumanReadableTime($seconds)
  51. {
  52. $ret = "";
  53.  
  54. /*** get the days ***/
  55. $days = intval(intval($seconds) / (3600*24));
  56. if($days> 0)
  57. {
  58. $ret .= "$days days ";
  59. }
  60.  
  61. /*** get the hours ***/
  62. $hours = (intval($seconds) / 3600) % 24;
  63. if($hours > 0)
  64. {
  65. $ret .= "$hours hours ";
  66. }
  67.  
  68. /*** get the minutes ***/
  69. $minutes = (intval($seconds) / 60) % 60;
  70. if($minutes > 0)
  71. {
  72. $ret .= "$minutes minutes ";
  73. }
  74.  
  75. /*** get the seconds ***/
  76. $seconds = intval($seconds) % 60;
  77. if ($seconds > 0) {
  78. $ret .= "$seconds seconds";
  79. }
  80.  
  81. return $ret;
  82. }
  83.  
  84. echo '<table class="table table-striped">
  85. <tr>
  86. <th>Character Name</th>
  87. <th>Ban Reason</th>
  88. <th>Ban Length</th>
  89. <th>Proof</th>
  90. <th>Banned On</th>
  91. </tr>';
  92.  
  93. while($row = $result->fetch_assoc()){
  94. echo '<tr>
  95. <td><a href="http://steamcommunity.com/profiles/'.$row['steamId'].'">'.$row['charactername'].'</a></td>
  96. <td>'.$row['banMessage'].'</td>
  97. <td>'.convertToHumanReadableTime($row['banDuration']).'</td>
  98. <td>'.$row['spy'].'</td>
  99. <td>'.date("m/d/Y", strtotime($row['banTime'])).'</td>
  100. </tr>';
  101. }
  102. echo '</table>';
  103. ?>
  104.  
  105. <hr />
  106. </body>
  107. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement