• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[PHP] Bans table

Of course it is. You would have to do something like this, I am not sure how the ban table structure looks like, so you'd have to modify it.
PHP:
<?PHP
     $result = mysql_query ( "SELECT * FROM `bans` ORDER BY `id` DESC" );

     while ( $row = mysql_fetch_array ( $result )
     {
          echo $row['value'] . ' - ' . $row['reason'];
     }
?>
 
Hehe anytime, remember you would have to modify it a bit though as this is just a rough example of how it would work.
 
If you do not manage to fix it, I'll take a look at it.

Thanks man!

Edit: I couldn't make it.. :(

Copy from forgottenserver.sql:
Code:
    `type` INT NOT NULL COMMENT 'this field defines if its ip, accountban or namelock',
    `ip` INT UNSIGNED NOT NULL DEFAULT 0,
    `mask` INT UNSIGNED NOT NULL DEFAULT 4294967295,
    `player` INT UNSIGNED NOT NULL DEFAULT 0,
    `account` INT UNSIGNED NOT NULL DEFAULT 0,
    `time` INT UNSIGNED NOT NULL DEFAULT 0,
    `reason_id` INT NOT NULL DEFAULT 0,
    `action_id` INT NOT NULL DEFAULT 0,
    `comment` VARCHAR(60) NOT NULL DEFAULT '',
    `banned_by` INT UNSIGNED NOT NULL DEFAULT 0
 
Last edited:
I'll take a look at it as promised, but I'll have to do it later today as I'm going banuta soon.
 
PHP:
<style>
a { color: blue; text-decoration: none; font-weight: bold }
a:visited { color: blue; text-decoration: none; font-weight: bold }
a:hover { color: blue; text-decoration: underline; font-weight: bold }
.white { color: white; font-weight: bold }
body { background-color: #051122; font-family: Times New Roman; color: #5A2800 }
</style>
<?
mysql_connect("localhost", "root", "") or die ("noob");
mysql_select_db("tfs") or die ("noob");

function getPlayerNameById($id)
{
    $query = mysql_query("SELECT name FROM players WHERE id = $id");
    $row = mysql_fetch_array($query);
    mysql_free_result($query);
    return '<a href="index.php?subtopic=characters&name='.urlencode($row[0]).'">'.$row[0].'</a>';
}

function getPlayersByAccount($account, $limit)
{
    $query = mysql_query("SELECT name FROM players WHERE account_id = $account ORDER BY level DESC LIMIT $limit");
    $row = mysql_fetch_array($query);
    mysql_free_result($query);
    return '<a href="index.php?subtopic=characters&name='.urlencode($row[0]).'">'.$row[0].'</a> <i>(Account Ban)</i>';
}

$bans_count = 0;
$bans_types = array("", "IP banised", "namelocked", "banished", "warned", "deleted");
$bans_reasons = array(
"offensive name", "invalid name format", "unsuitable name", "name inciting rule violation", "offensive statement",
"spamming", "illegal advertising", "off-topic public statement", "non-english public statement", "inciting rule violation",
"bug abuse", "game weakness abuse", "using unofficial software to play", "hacking", "multi-clienting", "account trading or sharing",
"threatening gamemaster", "pretending to have influence on rule enforcers", "false report to gamemaster", "destructive behaviour",
"excessive unjustified player killing", "invalid payment", "spoiling auction"
);
$query = mysql_query("SELECT * FROM bans");
if(mysql_num_rows($query) != 0)
{
    echo '<table><tr bgcolor=#505050 class="WHITE"><td>Banishments:</td></tr>';
    while($row = mysql_fetch_array($query))
    {
        if($row[active] != 0) {
            if(is_int($bans_count / 2)) { $bgcolor = "#F1E0C6"; } else { $bgcolor = "#D4C0A1"; }
            $bans_count++;
            if($row[type] == 2) { $function = getPlayerNameById($row[value]); }
            if($row[type] == 3) { $function = getPlayersByAccount($row[value], 1); }
            if($row[expires] == "-1") { $until = "permamently";} else { $until = 'until '.date("d m Y, H:i:s", $row[expires]).''; }
            echo '<tr bgcolor='.$bgcolor.'><td>'.$function.' is '.$bans_types[$row[type]].' by '.getPlayerNameById($row[admin_id]).' '.$until.' because of '.$bans_reasons[$row[reason]].' with a comment '.$row[comment].'.</td>';
        }
    }
    echo '</table>';
}
else
{
    echo 'No one is banned.';
}
mysql_close();
?>
 
Last edited:
It is only showing comment and this time: '01 01 1970, 01:00:00', and I get this errors above the bans:

Code:
[B]Warning[/B]:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in [B]C:\xampp\htdocs\bans.php[/B] on line [B]8[/B]

[B]Warning[/B]:  mysql_free_result(): supplied argument is not a valid MySQL result resource in [B]C:\xampp\htdocs\bans.php[/B] on line [B]9

[/B]I get this errors on like 100 lines
Line 8, 9:
Code:
    $row = mysql_fetch_array($query);
    mysql_free_result($query);
 
Last edited:
Ive used wrong bans structure... :p

Fixing now.

@mpa;

I would like you to send me your bans table, with records of course, because I dont really know what it puts there.
BTW:
Temporarily fix:
PHP:
		echo '<tr><td>'.getPlayerNameById($row[value]).'</td><td>'.$bans_array[$row[reason]].'</td><td>'.$row[comment].'</td><td>'.date("d m Y, H:i:s", $row[expires]).'</td>';
 
Last edited:
It would be nice to have it with the tibia colors.
You know:
2drvwpi.png
 
Remove from <style> to </style> if you use gesiors aac and it should look fine.

PHP:
<style>
a { color: blue; text-decoration: none; font-weight: bold }
a:visited { color: blue; text-decoration: none; font-weight: bold }
a:hover { color: blue; text-decoration: underline; font-weight: bold }
.white { color: white; font-weight: bold }
body { background-color: #051122; font-family: Times New Roman; color: #5A2800 }
</style>
<?
mysql_connect("localhost", "root", "") or die ("noob");
mysql_select_db("tfs") or die ("noob");

function getPlayerNameById($id)
{
	$query = mysql_query("SELECT name FROM players WHERE id = $id");
	$row = mysql_fetch_array($query);
	mysql_free_result($query);
	return '<a href="index.php?subtopic=characters&name='.urlencode($row[0]).'">'.$row[0].'</a>';
}

function getPlayersByAccount($account, $limit)
{
	$query = mysql_query("SELECT name FROM players WHERE account_id = $account ORDER BY level DESC LIMIT $limit");
	$row = mysql_fetch_array($query);
	mysql_free_result($query);
	return '<a href="index.php?subtopic=characters&name='.urlencode($row[0]).'">'.$row[0].'</a> <i>(Account Ban)</i>';
}

$bans_count = 0;
$bans_types = array("", "IP banised", "namelocked", "banished", "warned", "deleted");
$bans_reasons = array(
"offensive name", "invalid name format", "unsuitable name", "name inciting rule violation", "offensive statement",
"spamming", "illegal advertising", "off-topic public statement", "non-english public statement", "inciting rule violation",
"bug abuse", "game weakness abuse", "using unofficial software to play", "hacking", "multi-clienting", "account trading or sharing",
"threatening gamemaster", "pretending to have influence on rule enforcers", "false report to gamemaster", "destructive behaviour",
"excessive unjustified player killing", "invalid payment", "spoiling auction"
);
$query = mysql_query("SELECT * FROM bans");
if(mysql_num_rows($query) != 0)
{
	echo '<table><tr bgcolor=#505050 class="WHITE"><td>Banishments:</td></tr>';
	while($row = mysql_fetch_array($query))
	{
		if($row[active] != 0) {
			if(is_int($bans_count / 2)) { $bgcolor = "#F1E0C6"; } else { $bgcolor = "#D4C0A1"; }
			$bans_count++;
			if($row[type] == 2) { $function = getPlayerNameById($row[value]); }
			if($row[type] == 3) { $function = getPlayersByAccount($row[value], 1); }
			if($row[expires] == "-1") { $until = "permamently";} else { $until = 'until '.date("d m Y, H:i:s", $row[expires]).''; }
			echo '<tr bgcolor='.$bgcolor.'><td>'.$function.' is '.$bans_types[$row[type]].' by '.getPlayerNameById($row[admin_id]).' '.$until.' because of '.$bans_reasons[$row[reason]].' with a comment '.$row[comment].'.</td>';
		}
	}
	echo '</table>';
}
else
{
	echo 'No one is banned.';
}
mysql_close();
?>
 
Back
Top