Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.92 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4. <title>Ban list</title>
  5.  
  6. <style type="text/css">
  7. body {
  8. font-family: Verdana;
  9. }
  10.  
  11. table thead {
  12. background-color:#006633;
  13. color:#FFFFFF;
  14. cursor: default;
  15. }
  16. .r0 {
  17. background-color: #FFFFFF;
  18. text-align: left;
  19. font-size: small;
  20. }
  21. .r1 {
  22. background-color: #EBFADC;
  23. text-align: left;
  24. font-size: small;
  25. }
  26.  
  27. </style>
  28.  
  29. </head>
  30.  
  31. <body>
  32. <font size=2>
  33.  
  34. <?php
  35.  
  36. if($_GET['page']) // Is page defined?
  37. {
  38. $page = $_GET['page']; // Set to the page defined
  39. }
  40. else
  41. {
  42. $page = 1; // Set to default page 1
  43. }
  44.  
  45. $items = 50; //items oer page to show.
  46. $start =(($page * $items) - $items); // Work out what results to show
  47.  
  48.  
  49.  
  50. //Database details
  51. $username = "your_username";
  52. $password = "your_password";
  53. $database = "your_database";
  54. $ip = "your_host";
  55.  
  56. //Connect to MySQL database server and select database
  57. $con = mysql_connect("$ip","$username","$password") or die(mysql_error());
  58. if (!$con)
  59. {
  60. die('Could not connect: ' . mysql_error());
  61. }
  62. mysql_select_db("$database", $con);
  63.  
  64. //determine what the current time is
  65. $timenow = date("o-m-d H:i:s");
  66. $timenow_unix = time();
  67.  
  68. //select all permabans to show the "x mingebags have got themselves permanently banned"
  69. $sql = "SELECT * FROM gbans WHERE unban_time = '0000-00-00 00:00:00'";
  70. $result = mysql_query($sql);
  71.  
  72. $num_permabans = mysql_num_rows($result);
  73. echo "In total, <b>{$num_permabans}</b> mingebags have got themselves <b><font color=red>permabanned</font></b>.<br /><br />";
  74.  
  75. // select all bans to work out how many there are - this is required for pagenation
  76. $sql = "SELECT * FROM gbans";
  77. $result = mysql_query($sql);
  78. $counttotal = mysql_num_rows($result); // work out how many bans there are
  79.  
  80. //select data to display in table
  81. $sql = "SELECT steamid, name, time, unban_time, comment, adminname FROM gbans ORDER BY time DESC LIMIT $start, $items";
  82. $result = mysql_query($sql);
  83.  
  84. ?>
  85.  
  86. <table width=100%>
  87.  
  88. <thead>
  89. <tr><th>SteamID</th><th>Time</th><th>Name</th><th>Reason</th><th>Banned by</th><th>Time left</th></tr>
  90. </thead>
  91.  
  92. <tbody>
  93.  
  94. <?php
  95.  
  96. //initialise the row number counter
  97. $rownum = 1;
  98.  
  99. //perform loop for each row
  100. while($row = mysql_fetch_array( $result ))
  101. {
  102. $steamid = $row['steamid'];
  103. $time = $row['time'];
  104. $name = $row['name'];
  105. $reason = $row['comment'];
  106. $banlift = $row['unban_time'];
  107. $bannedby = $row['adminname'];
  108.  
  109. //Check if name is Null
  110. if(trim($name)=='<Unknown>' || trim($name)=='')
  111. {
  112. $name = "<i><font color=purple>Unknown</color></i>";
  113. }
  114.  
  115. //Check if banned via console
  116. if (trim($bannedby)=='' || trim($bannedby)=='<Console>')
  117. {
  118. $bannedby = "<i><font color=purple>Console</color></i>";
  119. }
  120.  
  121. //Determine time left, and display info accordingly
  122. if ($banlift == "0000-00-00 00:00:00")
  123. {
  124. $timeleft = "<b><font color=red>Forever</font><b>";
  125. }
  126. else
  127. {
  128. $banlift_unix = strtotime($banlift);
  129. $secondsleft = round($banlift_unix - $timenow_unix);
  130. if ($secondsleft > 0)
  131. {
  132. $minutesleft = floor(($secondsleft % 3600)/60);
  133. $hoursleft = floor($secondsleft / 3600);
  134. $timeleft = "<b>{$hoursleft} hrs, {$minutesleft} mins</b>";
  135. }
  136. else
  137. {
  138. $timeleft = "<font color=green><b>Ban is over!</b></font>";
  139. }
  140. }
  141.  
  142. //Check if row is odd or even - this allows teh sexy alternating colours
  143. if (($rownum % 2) == 0) // if the modulus is 0, then the row number is even,.
  144. {
  145. echo "<tr class=r0>";
  146. }
  147. else
  148. {
  149. echo "<tr class=r1>";
  150. }
  151.  
  152. //Display table elements
  153. echo "<td><font size=1>{$steamid}</td>";
  154. echo "<td><div align=center><font size=1>{$time}</div></td>";
  155. echo "<td width=75>{$name}</td>";
  156. echo "<td>{$reason}</td>";
  157. echo "<td>{$bannedby}</td>";
  158. echo "<td>{$timeleft}</td>";
  159.  
  160. $rownum=$rownum + 1; // Increment row counter.
  161.  
  162. echo "</tr>";
  163.  
  164. ?>
  165.  
  166. <?php
  167. }
  168. ?>
  169. </tbody>
  170. </table>
  171. <?php
  172.  
  173.  
  174. echo "<br /><br /><div align=right><font size=1>";
  175. $total_pages = ceil($counttotal / $items); // dive the total, by the maximum results to show
  176.  
  177. if($page > 1)
  178. { // is the page number more than 1?
  179. $prev = ($page - 1); // if so, do the following. take 1 away from the current page number
  180. echo '<a href="?page=' . $prev . '"><< Previous</a> '; // echo a previous page link
  181. }
  182.  
  183. for($i = 1; $i <= $total_pages; $i++){// for each page number
  184. if($page == $i) // if this page were about to echo = the current page
  185. {
  186. echo '<b>' . $i . '</b> '; // echo the page number bold
  187. } else {
  188. echo "<a href=\"?page=\"" . $i. "\">{$i}</a> "; // echo a link to the page
  189. }
  190. }
  191.  
  192. if($page < $total_pages)
  193. { // is there a next page?
  194. $next = ($page + 1); // if so, add 1 to the current
  195. echo '<a href="?page=' . $next . '">Next >></a>'; // echo the next page link
  196. }
  197. echo "</font></div>";
  198.  
  199.  
  200. mysql_close($con);
  201. ?>
  202.  
  203. </font>
  204. <br /><br />
  205. <div align=center><font size=1>Ban list page written by Lt. Smith, based upon an original idea by Ninjadude101.</font></div>
  206. </body>
  207. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement