SA-MP Forums Archive
[Tool/Web/Other] Ban List v1 - View an active ban list [PHP] [MYSQL] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Tools and Files (https://sampforum.blast.hk/forumdisplay.php?fid=82)
+---- Thread: [Tool/Web/Other] Ban List v1 - View an active ban list [PHP] [MYSQL] (/showthread.php?tid=549803)



Ban List v1 - View an active ban list [PHP] [MYSQL] - MD5 - 08.12.2014

MD5's PHP/MYSQL Ban List
Quote:
Ban List v1.0

I made this Ban List for my server originally. But, I've decided to release it as I haven't seen it in this section yet. Nothing is advanced here, and should be quite easy to get going.

- Minor PHP/MYSQL knowledge required to use this.

Quote:
Installation Procedure(s)

1. Download the file from the archive link below.
2. Extract it to your desktop, or a preferred folder.
3. Open up "index.php", and find the MySQL connection settings at the top. And change them to your own settings.
4. Then, find the "mysql_query" and edit the path variables to your own.
5. Now finally, goto the bottom and where you see "echo" find "playerbanned" etc, and change them to your own variables.

Quote:
License

There's not a strict license on it, but if you could. Leave "author=md5" in the script.

Quote:
Downloads

- http://sampcnrsf.com/banlist-rgba1.rar
- https://swagapi.net/downloads/banlist-rgba1.rar

Mirrors are allowed.
Quote:
DEMO

- http://sampcnrsf.com/banlist




Re: Ban List v1 - View an active ban list [PHP] [MYSQL] - awsomedude - 08.12.2014

Your code kind of looks like this gamemodes bans page https://sampforum.blast.hk/showthread.php?tid=527966

At least give credits.


Re: Ban List v1 - View an active ban list [PHP] [MYSQL] - MD5 - 08.12.2014

Quote:
Originally Posted by awsomedude
View Post
Your code kind of looks like this gamemodes bans page https://sampforum.blast.hk/showthread.php?tid=527966

At least give credits.
Didn't even know that existed until you've shared the link.


Re: Ban List v1 - View an active ban list [PHP] [MYSQL] - GWMPT - 08.12.2014

MD5, why are you using
Code:
<!--
-->
to comment your code inside the PHP "space", when PHP doesn't even support that type of comments?


Re: Ban List v1 - View an active ban list [PHP] [MYSQL] - MD5 - 08.12.2014

Ah, I forgot about those. I will remove them.

Edit: Updated the links with the fixed files.


Re: Ban List v1 - View an active ban list [PHP] [MYSQL] - Kaperstone - 08.12.2014

PHP Code:
<!--Edit these variables to your own!--> 
Well, I think you forgot a line then.
PHP Code:
//KILLS THE MYSQL CONNECTION AFTER EXITED 
It doesn't kill the connection after the user exited the page but when the PHP reached that line.
PHP Code:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> 
Why ISO-8859-1 ?
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
As of HTML 5 you don't need everything after the PUBLIC
PHP Code:
<!DOCTYPE html
PHP Code:
if (mysqli_num_rows($result) > 0) { 
Eh, another one :v
why not simply
PHP Code:
if(mysqli_num_rows($result)) { 
PHP Code:
while($row mysqli_fetch_assoc($result)) {
        
//HTML codes inside of "echo" represent the actual *html* code.
        
echo "<div class='tablestuff2 table'>"
        echo 
"<table border='1'>";
        echo 
"<thead>";
        echo 
"<tr>";
        echo 
"<th id='th1' style='width: 150px'><font color = 'red'>Banned Player</font></th>";
        echo 
"<th id='th2' style='width: 150px'><font color = 'red'>Banned By</font></th>";
        echo 
"<th id='th3' style='width: 150px'><font color = 'red'>Banned Reason</font></th>";
        echo 
"</tr>";
        echo 
"</thead>";
        echo 
"</table>";
        echo 
"</div>";
    while(
$row mysqli_fetch_assoc($result)) 
    {
        echo 
"<div class='tablestuff2 table'>";
        echo 
"<table border='1'>";
        echo 
"<tbody>";
        echo 
"<tr>";
        echo 
"<td headers='th1' style='width: 150px'>".$row['player_banned']."</td>";
        echo 
"<td headers='th2' style='width: 150px'>".$row['banned_by']."</td>";
        echo 
"<td headers='th3' style='width: 150px'>".$row['banned_for']."</td>";
        echo 
"</tr>";
        echo 
"</tbody>";
        echo 
"</table>";
        echo 
"</div>";
        }
    } 
Why you made two while loops and used so many "echo" ?
You can sum it into one "echo"
PHP Code:
$sql "SELECT ban_id, bannedby, bannedfor, playerbanned FROM users"
You selected these columns, yet
PHP Code:
echo "<td headers='th1' style='width: 150px'>".$row['player_banned']."</td>";
        echo 
"<td headers='th2' style='width: 150px'>".$row['banned_by']."</td>";
        echo 
"<td headers='th3' style='width: 150px'>".$row['banned_for']."</td>"
You're outputing them with underscore _

EDIT: Tested, the first while loop deletes the first ban.


Re: Ban List v1 - View an active ban list [PHP] [MYSQL] - MD5 - 09.12.2014

Quote:
Originally Posted by Kaperstone
View Post
PHP Code:
<!--Edit these variables to your own!--> 
Well, I think you forgot a line then.
PHP Code:
//KILLS THE MYSQL CONNECTION AFTER EXITED 
It doesn't kill the connection after the user exited the page but when the PHP reached that line.
PHP Code:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> 
Why ISO-8859-1 ?
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
As of HTML 5 you don't need everything after the PUBLIC
PHP Code:
<!DOCTYPE html
PHP Code:
if (mysqli_num_rows($result) > 0) { 
Eh, another one :v
why not simply
PHP Code:
if(mysqli_num_rows($result)) { 
PHP Code:
while($row mysqli_fetch_assoc($result)) {
        
//HTML codes inside of "echo" represent the actual *html* code.
        
echo "<div class='tablestuff2 table'>"
        echo 
"<table border='1'>";
        echo 
"<thead>";
        echo 
"<tr>";
        echo 
"<th id='th1' style='width: 150px'><font color = 'red'>Banned Player</font></th>";
        echo 
"<th id='th2' style='width: 150px'><font color = 'red'>Banned By</font></th>";
        echo 
"<th id='th3' style='width: 150px'><font color = 'red'>Banned Reason</font></th>";
        echo 
"</tr>";
        echo 
"</thead>";
        echo 
"</table>";
        echo 
"</div>";
    while(
$row mysqli_fetch_assoc($result)) 
    {
        echo 
"<div class='tablestuff2 table'>";
        echo 
"<table border='1'>";
        echo 
"<tbody>";
        echo 
"<tr>";
        echo 
"<td headers='th1' style='width: 150px'>".$row['player_banned']."</td>";
        echo 
"<td headers='th2' style='width: 150px'>".$row['banned_by']."</td>";
        echo 
"<td headers='th3' style='width: 150px'>".$row['banned_for']."</td>";
        echo 
"</tr>";
        echo 
"</tbody>";
        echo 
"</table>";
        echo 
"</div>";
        }
    } 
Why you made two while loops and used so many "echo" ?
You can sum it into one "echo"
PHP Code:
$sql "SELECT ban_id, bannedby, bannedfor, playerbanned FROM users"
You selected these columns, yet
PHP Code:
echo "<td headers='th1' style='width: 150px'>".$row['player_banned']."</td>";
        echo 
"<td headers='th2' style='width: 150px'>".$row['banned_by']."</td>";
        echo 
"<td headers='th3' style='width: 150px'>".$row['banned_for']."</td>"
You're outputing them with underscore _

EDIT: Tested, the first while loop deletes the first ban.
This is my 2nd release, and I'm still learning PHP. But, thanks for the TIPs.

+Repped.


Re: Ban List v1 - View an active ban list [PHP] [MYSQL] - MD5 - 14.12.2014

I just updated the links and removed "if (mysqli_num_rows($result) > 0) {" as it was useless, and also removed the first ban on the list.


Re: Ban List v1 - View an active ban list [PHP] [MYSQL] - HaterSamp - 30.06.2015

Links does not works anymore, please fix it.


Re: Ban List v1 - View an active ban list [PHP] [MYSQL] - SpikY_ - 30.06.2015

Ah! nice work.