Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Ban list</title>
- <style type="text/css">
- body {
- font-family: Verdana;
- }
- table thead {
- background-color:#006633;
- color:#FFFFFF;
- cursor: default;
- }
- .r0 {
- background-color: #FFFFFF;
- text-align: left;
- font-size: small;
- }
- .r1 {
- background-color: #EBFADC;
- text-align: left;
- font-size: small;
- }
- </style>
- </head>
- <body>
- <font size=2>
- <?php
- if($_GET['page']) // Is page defined?
- {
- $page = $_GET['page']; // Set to the page defined
- }
- else
- {
- $page = 1; // Set to default page 1
- }
- $items = 50; //items oer page to show.
- $start =(($page * $items) - $items); // Work out what results to show
- //Database details
- $username = "your_username";
- $password = "your_password";
- $database = "your_database";
- $ip = "your_host";
- //Connect to MySQL database server and select database
- $con = mysql_connect("$ip","$username","$password") or die(mysql_error());
- if (!$con)
- {
- die('Could not connect: ' . mysql_error());
- }
- mysql_select_db("$database", $con);
- //determine what the current time is
- $timenow = date("o-m-d H:i:s");
- $timenow_unix = time();
- //select all permabans to show the "x mingebags have got themselves permanently banned"
- $sql = "SELECT * FROM gbans WHERE unban_time = '0000-00-00 00:00:00'";
- $result = mysql_query($sql);
- $num_permabans = mysql_num_rows($result);
- echo "In total, <b>{$num_permabans}</b> mingebags have got themselves <b><font color=red>permabanned</font></b>.<br /><br />";
- // select all bans to work out how many there are - this is required for pagenation
- $sql = "SELECT * FROM gbans";
- $result = mysql_query($sql);
- $counttotal = mysql_num_rows($result); // work out how many bans there are
- //select data to display in table
- $sql = "SELECT steamid, name, time, unban_time, comment, adminname FROM gbans ORDER BY time DESC LIMIT $start, $items";
- $result = mysql_query($sql);
- ?>
- <table width=100%>
- <thead>
- <tr><th>SteamID</th><th>Time</th><th>Name</th><th>Reason</th><th>Banned by</th><th>Time left</th></tr>
- </thead>
- <tbody>
- <?php
- //initialise the row number counter
- $rownum = 1;
- //perform loop for each row
- while($row = mysql_fetch_array( $result ))
- {
- $steamid = $row['steamid'];
- $time = $row['time'];
- $name = $row['name'];
- $reason = $row['comment'];
- $banlift = $row['unban_time'];
- $bannedby = $row['adminname'];
- //Check if name is Null
- if(trim($name)=='<Unknown>' || trim($name)=='')
- {
- $name = "<i><font color=purple>Unknown</color></i>";
- }
- //Check if banned via console
- if (trim($bannedby)=='' || trim($bannedby)=='<Console>')
- {
- $bannedby = "<i><font color=purple>Console</color></i>";
- }
- //Determine time left, and display info accordingly
- if ($banlift == "0000-00-00 00:00:00")
- {
- $timeleft = "<b><font color=red>Forever</font><b>";
- }
- else
- {
- $banlift_unix = strtotime($banlift);
- $secondsleft = round($banlift_unix - $timenow_unix);
- if ($secondsleft > 0)
- {
- $minutesleft = floor(($secondsleft % 3600)/60);
- $hoursleft = floor($secondsleft / 3600);
- $timeleft = "<b>{$hoursleft} hrs, {$minutesleft} mins</b>";
- }
- else
- {
- $timeleft = "<font color=green><b>Ban is over!</b></font>";
- }
- }
- //Check if row is odd or even - this allows teh sexy alternating colours
- if (($rownum % 2) == 0) // if the modulus is 0, then the row number is even,.
- {
- echo "<tr class=r0>";
- }
- else
- {
- echo "<tr class=r1>";
- }
- //Display table elements
- echo "<td><font size=1>{$steamid}</td>";
- echo "<td><div align=center><font size=1>{$time}</div></td>";
- echo "<td width=75>{$name}</td>";
- echo "<td>{$reason}</td>";
- echo "<td>{$bannedby}</td>";
- echo "<td>{$timeleft}</td>";
- $rownum=$rownum + 1; // Increment row counter.
- echo "</tr>";
- ?>
- <?php
- }
- ?>
- </tbody>
- </table>
- <?php
- echo "<br /><br /><div align=right><font size=1>";
- $total_pages = ceil($counttotal / $items); // dive the total, by the maximum results to show
- if($page > 1)
- { // is the page number more than 1?
- $prev = ($page - 1); // if so, do the following. take 1 away from the current page number
- echo '<a href="?page=' . $prev . '"><< Previous</a> '; // echo a previous page link
- }
- for($i = 1; $i <= $total_pages; $i++){// for each page number
- if($page == $i) // if this page were about to echo = the current page
- {
- echo '<b>' . $i . '</b> '; // echo the page number bold
- } else {
- echo "<a href=\"?page=\"" . $i. "\">{$i}</a> "; // echo a link to the page
- }
- }
- if($page < $total_pages)
- { // is there a next page?
- $next = ($page + 1); // if so, add 1 to the current
- echo '<a href="?page=' . $next . '">Next >></a>'; // echo the next page link
- }
- echo "</font></div>";
- mysql_close($con);
- ?>
- </font>
- <br /><br />
- <div align=center><font size=1>Ban list page written by Lt. Smith, based upon an original idea by Ninjadude101.</font></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement