ULX

Author Topic: Simple, Configurable, Uban multi-page php viewer  (Read 7244 times)

0 Members and 1 Guest are viewing this topic.

Offline DJWolf

  • Newbie
  • *
  • Posts: 8
  • Karma: 3
Simple, Configurable, Uban multi-page php viewer
« on: August 11, 2011, 09:49:15 AM »
I got tired of looking for a php page that would let me list our server bans, so i made this with a bit of help from a guy named Corporate Bastard
It "makes" multiple pages so you wont have a big long list on 1 page.
You can set how wide the table is, how many bans to show per page, and if you want to, you can change the the names of the Columns.
When the ban is a perma ban, the unban time says never
Be sure to set the db address, user and pass at the top, as well as the database and table
If you must you can remove the part at the bottom that says "By DJ Wolf(technowolf248)"

Code: [Select]
<html>
<body>
<?php
//CONFIG
$db_address "127.0.0.1";
$db_user "root";
$db_pass "";
$database "test";
$table "gbans";
$bpp "50"//how many bans per page
$width "925"//how wide the table is
?>


<?php
$con 
mysql_connect($db_address,$db_user,$db_pass);
if (!
$con)
  {
  die(
'Could not connect: ' mysql_error());
  }

mysql_select_db("$database"$con);
if (isset(
$_GET["page"])) { $page  $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * $bpp;
$result mysql_query("SELECT * FROM $table ORDER BY id DESC LIMIT $start_from$bpp");

//EDIT THE NAMES, DO NOT CHANGE THE ORDER
echo "<table border='1'>
<table width='
$width'>
<tr>
<th>Name</th>
<th>Steam ID</th>
<th>Ban Time</th>
<th>Unban Time</th>
<th>Reason</th>
<th>Admin</th>

</tr>"
;

while(
$row mysql_fetch_array($result)){
if( 
$row['unban_time'] == "0000-00-00 00:00:00" ){$ubtime =  "Never";
}else{
$ubtime =  $row['unban_time'];
}

  echo 
"<tr>";
  echo 
"<td>" .htmlentities($row['name']) . "</td>";
  echo 
"<td>" $row['steamid']."</td>";
  echo 
"<td>" $row['time']."</td>";
  echo 
"<td>" $ubtime."</td>";
  echo 
"<td>" .htmlentities($row['comment']) . "</td>";
  echo 
"<td>" .htmlentities($row['adminname']) . "</td>";
  echo 
"</tr>";
  }
echo 
"</table>";

$result = ("SELECT COUNT(Name) FROM $table");
$rs_result mysql_query($result,$con);
$row mysql_fetch_row($rs_result);
$total_records $row[0];
$total_pages ceil($total_records $bpp);

for (
$i=1$i<=$total_pages$i++) {
            echo 
"<a href='bans?page=".$i."'>".$i."</a> ";
};

mysql_close($con);
?>

</body>
<footer>
By DJ Wolf(technowolf248)
</footer>
</html>

OH, forgot, make sure you save the page as bans.php or change the line at the bottom of the page to say 
Code: [Select]
echo "<a href='YOUR PAGE NAME ?page=".$i."'>".$i."</a> ";
« Last Edit: August 11, 2011, 08:08:28 PM by DJWolf »
In the event of an emergency, all power will be diverted away from security...  ^_^

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Simple, Configurable, Uban multi-page php viewer
« Reply #1 on: August 11, 2011, 06:13:50 PM »
Nice and simple, just the way we like things around here. Good job! :)
Experiencing God's grace one day at a time.

Offline Aero

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
  • AeroWolf Community Leader
Re: Simple, Configurable, Uban multi-page php viewer
« Reply #2 on: August 11, 2011, 07:43:05 PM »
Great work bro!
« Last Edit: August 11, 2011, 07:58:07 PM by Aero »

Offline pikkip

  • Newbie
  • *
  • Posts: 27
  • Karma: 1
Re: Simple, Configurable, Uban multi-page php viewer
« Reply #3 on: February 24, 2012, 06:50:08 AM »
I know this is a old thread, but it really gets me on my nerves,

what kinda scoureban does it request?

i found this http://www.sourcebans.net/ but dono if that can work? please help D=

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Simple, Configurable, Uban multi-page php viewer
« Reply #4 on: February 24, 2012, 04:08:44 PM »
Nikki, as the subject of the topic says, the code was meant to show UBan bans.
UBan has nothing to do with SourceBans.
The only similarity is that it would allow one SQL ban library for multiple ULib servers.
Search the Releases forum area to learn about UBan.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline pikkip

  • Newbie
  • *
  • Posts: 27
  • Karma: 1
Re: Simple, Configurable, Uban multi-page php viewer
« Reply #5 on: February 25, 2012, 08:47:31 AM »
Nikki, as the subject of the topic says, the code was meant to show UBan bans.
UBan has nothing to do with SourceBans.
The only similarity is that it would allow one SQL ban library for multiple ULib servers.
Search the Releases forum area to learn about UBan.

Thanks, i was just a bit confused cause i never used mysql / database for a global banning system