• 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!

AAC Looking for working MYACC ban page TFS 1.2

henkas

Well-Known Member
Joined
Jul 8, 2015
Messages
993
Solutions
5
Reaction score
55
Looking for ban table like this

Banned PlayerCommentBanned ByAddedExpires
PLAYER NAMEBeing a degenerate [GM]DICK18/10/2020, 7:20:4615/11/2020, 7:20:46

ban.php
Completely empty deleted entire code because it just wasnt working so there was no point to have it

ban.lua
Lua:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    local split = param:split(",")
   
    local name = split[1]
    local reason = tostring(split[2])
    local bandays = tonumber(split[3])
   
    local accountId = getAccountNumberByPlayerName(name)
    if accountId == 0 then
        player:sendCancelMessage("Usage: /Ban PlayerName, Reason, Days")
        return false
    end

    local resultId = db.storeQuery("SELECT 1 FROM `account_bans` WHERE `account_id` = " .. accountId)
    if resultId ~= false then
        result.free(resultId)
        return false
    end

    local timeNow = os.time()
    db.query("INSERT INTO `account_bans` (`account_id`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES (" ..
            accountId .. ", " .. db.escapeString(reason) .. ", " .. timeNow .. ", " .. timeNow + (bandays * 86400) .. ", " .. player:getGuid() .. ")")

    local target = Player(name)
    if target ~= nil then
        broadcastMessage("" .. split[1] .. " has been banned for" .. split[3] .. " days. Reason:" .. split[2] .. ".",MESSAGE_STATUS_WARNING)
        target:remove()
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, name .. " has been banned.")
    end
end

ban table in phpmyadmin
0de62ff35d190fd32eec0470a6112406.png
 
The problem is, as you can see, that player_name is not saved in database. Only account_id is saved. So you can't show who is really banned because showing account_id is dangerous. That's why I disabled that bans page on MyAAC for TFS 1.x.

There are, however some solutions to this. Maybe we can show all player names from that account? Or what would be your suggestion then I can fix this?
 
The problem is, as you can see, that player_name is not saved in database. Only account_id is saved. So you can't show who is really banned because showing account_id is dangerous. That's why I disabled that bans page on MyAAC for TFS 1.x.

There are, however some solutions to this. Maybe we can show all player names from that account? Or what would be your suggestion then I can fix this?
Isnt it possible to get banned player name? With something like
Code:
getPlayerLink($player['name']
but like you mentioned even ban system bans account_id and not name.
 
Isnt it possible to get banned player name? With something like
Code:
getPlayerLink($player['name']
but like you mentioned even ban system bans account_id and not name.
Nope. Just account_id. And with account_id you can get list of players from that account. Maybe that would be a solution. I will think about it.
 
Nope. Just account_id. And with account_id you can get list of players from that account. Maybe that would be a solution. I will think about it.
Hmm at that time will try to post it here for few days if someone get the solution quicker :D
Nope. Just account_id. And with account_id you can get list of players from that account. Maybe that would be a solution. I will think about it.
Yea posted my ban talkaction in this thread above
 
Can you add me on discord? Itutorial#7874
Post automatically merged:

This is add the player name into the ban. You have to add a column in the database in the account_bans table named: player_banned

You can use that to create the page on the website.

Lua:
function addAccountBan(admin, player, accountId, days, reason)
    local currentTime = os.time()
    local banTime = currentTime + (days * 86400)
    db.query("INSERT INTO `account_bans` (`account_id`, `player_banned`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES ("..accountId..", '"..player.."', "..reason..", "..currentTime..", "..banTime..", "..admin:getName()..");")
    return true
end

function getOfflinePlayerGroupId(name)
    local query = db.storeQuery("SELECT `group_id` FROM `players` WHERE `name` = '"..name.."';")
    if query:getId() ~= -1 then
        local result = query.getDataInt('group_id')
        return result
    end
    return false
end

function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    local split = param:split(",")
   
    local name = split[1]
    local reason = tostring(split[2])
    local bandays = tonumber(split[3])
    
    if getOfflinePlayerGroupId(name) and getOfflinePlayerGroupId(name) >= player:getGroup():getId() then
        player:sendCancelMessage("You may not ban someone who is the same staff position as you.")
        return false
    end
    
    local accountId = getAccountNumberByPlayerName(name)
    if accountId == 0 then
        player:sendCancelMessage("Usage: /Ban PlayerName, Reason, Days")
        return false
    end

    local resultId = db.storeQuery("SELECT * FROM `account_bans` WHERE `account_id` = " .. accountId)
    if resultId ~= false then
        result.free(resultId)
        player:sendCancelMessage("Player is already banned.")
        return false
    end

   if addAccountBan(player, name, accountId, banDays, reason) then
        local target = Player(name)
        if target ~= nil then
            broadcastMessage("" .. split[1] .. " has been banned for" .. split[3] .. " days. Reason:" .. split[2] .. ".",MESSAGE_STATUS_WARNING)
            target:remove()
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, name .. " has been banned.")
        end
    else
        player:sendCancelMessage("Unable to ban player.")
    end
    return false
end
 
Last edited:
Can you add me on discord? Itutorial#7874
Post automatically merged:

This is add the player name into the ban. You have to add a column in the database in the account_bans table named: player_banned

You can use that to create the page on the website.

Lua:
function addAccountBan(admin, player, accountId, days, reason)
    local currentTime = os.time()
    local banTime = currentTime + (days * 86400)
    db.query("INSERT INTO `account_bans` (`account_id`, `player_banned`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES ("..accountId..", '"..player.."', "..reason..", "..currentTime..", "..banTime..", "..admin:getName()..");")
    return true
end

function getOfflinePlayerGroupId(name)
    local query = db.storeQuery("SELECT `group_id` FROM `players` WHERE `name` = '"..name.."';")
    if query:getId() ~= -1 then
        local result = query.getDataInt('group_id')
        return result
    end
    return false
end

function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    local split = param:split(",")
 
    local name = split[1]
    local reason = tostring(split[2])
    local bandays = tonumber(split[3])
  
    if getOfflinePlayerGroupId(name) and getOfflinePlayerGroupId(name) >= player:getGroup():getId() then
        player:sendCancelMessage("You may not ban someone who is the same staff position as you.")
        return false
    end
  
    local accountId = getAccountNumberByPlayerName(name)
    if accountId == 0 then
        player:sendCancelMessage("Usage: /Ban PlayerName, Reason, Days")
        return false
    end

    local resultId = db.storeQuery("SELECT * FROM `account_bans` WHERE `account_id` = " .. accountId)
    if resultId ~= false then
        result.free(resultId)
        player:sendCancelMessage("Player is already banned.")
        return false
    end

   if addAccountBan(player, name, accountId, banDays, reason) then
        local target = Player(name)
        if target ~= nil then
            broadcastMessage("" .. split[1] .. " has been banned for" .. split[3] .. " days. Reason:" .. split[2] .. ".",MESSAGE_STATUS_WARNING)
            target:remove()
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, name .. " has been banned.")
        end
    else
        player:sendCancelMessage("Unable to ban player.")
    end
    return false
end
Damn thanks :eek: i dont use discord to be honest. And how the website php part should be?
 
Last edited:
Solution
Hey,

I've just created the bans page for TFS 1.x.

It's available here:

Please test & review.
Fatal error: Uncaught Error: Call to undefined function config() in /var/www/html/system/pages/bans.php:14 Stack trace: #0 /var/www/html/index.php(425): require() #1 {main} thrown in /var/www/html/system/pages/bans.php on line 14

Even when added everything from github it says undefined function in config which is
// bans page
'bans_per_page' => 20,
not sure why it gives error like this
 
Fatal error: Uncaught Error: Call to undefined function config() in /var/www/html/system/pages/bans.php:14 Stack trace: #0 /var/www/html/index.php(425): require() #1 {main} thrown in /var/www/html/system/pages/bans.php on line 14

Even when added everything from github it says undefined function in config which is
// bans page
'bans_per_page' => 20,
not sure why it gives error like this

Ah, looks like you using outdated 0.7.

Copy this function (function config) into your system/functions.php:
 
Ah, looks like you using outdated 0.7.

Copy this function (function config) into your system/functions.php:

Fatal error: Uncaught Error: Call to undefined method OTS_DB_MySQL::hasTable() in /var/www/html/system/pages/bans.php:36 Stack trace: #0 /var/www/html/index.php(425): require() #1 {main} thrown in /var/www/html/system/pages/bans.php on line 36
 
Fatal error: Uncaught Error: Call to undefined method OTS_DB_MySQL::hasTable() in /var/www/html/system/pages/bans.php:36 Stack trace: #0 /var/www/html/index.php(425): require() #1 {main} thrown in /var/www/html/system/pages/bans.php on line 36

Replace all $db->hasTable with

tableExist

so when its like this:

PHP:
$db->hasTable('bans')
it should be:
PHP:
tableExist('bans')

Same with, $db->hasColumn

Change to fieldExist
 
Replace all $db->hasTable with

tableExist

so when its like this:

PHP:
$db->hasTable('bans')
it should be:
PHP:
tableExist('bans')

Same with, $db->hasColumn

Change to fieldExist
Fatal error: Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'forgottenserver.value' doesn't exist in /var/www/html/system/libs/pot/OTS_Base_DB.php:101 Stack trace: #0 /var/www/html/system/libs/pot/OTS_Base_DB.php(101): PDO->query('SHOW COLUMNS FR...') #1 /var/www/html/system/functions.php(369): OTS_Base_DB->query('SHOW COLUMNS FR...') #2 /var/www/html/system/pages/bans.php(69): fieldExist('bans', 'value') #3 /var/www/html/index.php(425): require('/var/www/html/s...') #4 {main} thrown in /var/www/html/system/libs/pot/OTS_Base_DB.php on line 101
 
Try this:
PHP:
<?php
/**
 * Bans
 *
 * @package   MyAAC
 * @author    Gesior <[email protected]>
 * @author    Slawkens <[email protected]>
 * @copyright 2019 MyAAC
 * @link      https://my-aac.org
 */
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Bans list';

$configBansPerPage = config('bans_per_page');
$_page = isset($_GET['page']) ? $_GET['page'] : 1;

if(!is_numeric($_page) || $_page > PHP_INT_MAX) {
   $_page = 1;
}

if ($_page > 1) {
   $offset = ($_page - 1) * $configBansPerPage;
}
else {
   $offset = 0;
}

/**
 * @var OTS_DB_MySQL $db
 */
$configBans = [];
$configBans['hasType'] = false;
$configBans['hasReason'] = false;

$limit = 'LIMIT ' . ($configBansPerPage + 1) . (isset($offset) ? ' OFFSET ' . $offset : '');
if (tableExist('account_bans')) {
   $bansQuery = $db->query('SELECT * FROM `account_bans` ORDER BY `banned_at` DESC ' . $limit);
}
else if (tableExist('bans') && fieldExist('active', 'bans')
   && fieldExist('type', 'bans') && fieldExist('reason', 'bans')) {
   $bansQuery = $db->query('SELECT * FROM `bans` WHERE `active` = 1 ORDER BY `added` DESC ' . $limit);
   $configBans['hasType'] = true;
   $configBans['hasReason'] = true;
}
else {
   echo 'Bans list is not supported in your distribution.';
   return;
}

if(!$bansQuery->rowCount())
{
   echo 'There are no banishments yet.';
   return;
}

$nextPage = false;
$i = 0;
$bans = $bansQuery->fetchAll();
foreach ($bans as $id => &$ban)
{
   if(++$i > $configBansPerPage)
   {
      unset($bans[$id]);
      $nextPage = true;
      break;
   }

   $ban['i'] = $i;
   if (fieldExist('value', 'bans')) {
      $accountId = $ban['value'];
   }
   else {
      // TFS 1.x
      $accountId = $ban['account_id'];
   }

   $ban['player'] = getPlayerLink(getPlayerNameByAccount($accountId));

   if ($configBans['hasType']) {
      $ban['type'] = getBanType($ban['type']);
   }

   $expiresColumn = 'expires_at';
   if (fieldExist('expires', 'bans')) {
      $expiresColumn = 'expires';
   }

   if ((int)$ban[$expiresColumn] === -1) {
      $ban['expires'] = 'Never';
   }
   else {
      $ban['expires'] = date('H:i:s', $ban[$expiresColumn]) . '<br/>' . date('d.M.Y', $ban[$expiresColumn]);
   }

   if ($configBans['hasReason']) {
      $ban['reason'] = getBanReason($ban['reason']);
   }
   else {
      $ban['comment'] = $ban['reason'];
   }

   $addedBy = '';
   if (fieldExist('admin_id', 'bans')) {
      if ((int)$ban['admin_id'] === 0) {
         $addedBy = 'Autoban';
      }
      else {
         $addedBy = getPlayerLink(getPlayerNameByAccount($ban['admin_id']));
      }
   }
   else {
      $addedBy = getPlayerLink(getPlayerNameByAccount($ban['banned_by']));
   }

   if (fieldExist('added', 'bans')) {
      $addedTime = $ban['added'];
   }
   else {
      $addedTime = $ban['banned_at'];
   }

   $ban['addedTime'] = date('H:i:s', $addedTime) . '<br/>' . date('d.M.Y', $addedTime);
   $ban['addedBy'] = $addedBy;
}

$twig->display('bans.html.twig', [
   'bans' => $bans,
   'configBans' => $configBans,
   'page' => $_page,
   'nextPage' => $nextPage,
]);
 
Try this:
PHP:
<?php
/**
* Bans
*
* @package   MyAAC
* @author    Gesior <[email protected]>
* @author    Slawkens <[email protected]>
* @copyright 2019 MyAAC
* @link      https://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Bans list';

$configBansPerPage = config('bans_per_page');
$_page = isset($_GET['page']) ? $_GET['page'] : 1;

if(!is_numeric($_page) || $_page > PHP_INT_MAX) {
   $_page = 1;
}

if ($_page > 1) {
   $offset = ($_page - 1) * $configBansPerPage;
}
else {
   $offset = 0;
}

/**
* @var OTS_DB_MySQL $db
*/
$configBans = [];
$configBans['hasType'] = false;
$configBans['hasReason'] = false;

$limit = 'LIMIT ' . ($configBansPerPage + 1) . (isset($offset) ? ' OFFSET ' . $offset : '');
if (tableExist('account_bans')) {
   $bansQuery = $db->query('SELECT * FROM `account_bans` ORDER BY `banned_at` DESC ' . $limit);
}
else if (tableExist('bans') && fieldExist('active', 'bans')
   && fieldExist('type', 'bans') && fieldExist('reason', 'bans')) {
   $bansQuery = $db->query('SELECT * FROM `bans` WHERE `active` = 1 ORDER BY `added` DESC ' . $limit);
   $configBans['hasType'] = true;
   $configBans['hasReason'] = true;
}
else {
   echo 'Bans list is not supported in your distribution.';
   return;
}

if(!$bansQuery->rowCount())
{
   echo 'There are no banishments yet.';
   return;
}

$nextPage = false;
$i = 0;
$bans = $bansQuery->fetchAll();
foreach ($bans as $id => &$ban)
{
   if(++$i > $configBansPerPage)
   {
      unset($bans[$id]);
      $nextPage = true;
      break;
   }

   $ban['i'] = $i;
   if (fieldExist('value', 'bans')) {
      $accountId = $ban['value'];
   }
   else {
      // TFS 1.x
      $accountId = $ban['account_id'];
   }

   $ban['player'] = getPlayerLink(getPlayerNameByAccount($accountId));

   if ($configBans['hasType']) {
      $ban['type'] = getBanType($ban['type']);
   }

   $expiresColumn = 'expires_at';
   if (fieldExist('expires', 'bans')) {
      $expiresColumn = 'expires';
   }

   if ((int)$ban[$expiresColumn] === -1) {
      $ban['expires'] = 'Never';
   }
   else {
      $ban['expires'] = date('H:i:s', $ban[$expiresColumn]) . '<br/>' . date('d.M.Y', $ban[$expiresColumn]);
   }

   if ($configBans['hasReason']) {
      $ban['reason'] = getBanReason($ban['reason']);
   }
   else {
      $ban['comment'] = $ban['reason'];
   }

   $addedBy = '';
   if (fieldExist('admin_id', 'bans')) {
      if ((int)$ban['admin_id'] === 0) {
         $addedBy = 'Autoban';
      }
      else {
         $addedBy = getPlayerLink(getPlayerNameByAccount($ban['admin_id']));
      }
   }
   else {
      $addedBy = getPlayerLink(getPlayerNameByAccount($ban['banned_by']));
   }

   if (fieldExist('added', 'bans')) {
      $addedTime = $ban['added'];
   }
   else {
      $addedTime = $ban['banned_at'];
   }

   $ban['addedTime'] = date('H:i:s', $addedTime) . '<br/>' . date('d.M.Y', $addedTime);
   $ban['addedBy'] = $addedBy;
}

$twig->display('bans.html.twig', [
   'bans' => $bans,
   'configBans' => $configBans,
   'page' => $_page,
   'nextPage' => $nextPage,
]);
Fatal error: Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'forgottenserver.bans' doesn't exist in /var/www/html/system/libs/pot/OTS_Base_DB.php:101 Stack trace: #0 /var/www/html/system/libs/pot/OTS_Base_DB.php(101): PDO->query('SHOW COLUMNS FR...') #1 /var/www/html/system/functions.php(369): OTS_Base_DB->query('SHOW COLUMNS FR...') #2 /var/www/html/system/pages/bans.php(69): fieldExist('value', 'bans') #3 /var/www/html/index.php(425): require('/var/www/html/s...') #4 {main} thrown in /var/www/html/system/libs/pot/OTS_Base_DB.php on line 101
 
Try this:
PHP:
<?php
/**
* Bans
*
* @package   MyAAC
* @author    Gesior <[email protected]>
* @author    Slawkens <[email protected]>
* @copyright 2019 MyAAC
* @link      https://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Bans list';

$configBansPerPage = config('bans_per_page');
$_page = isset($_GET['page']) ? $_GET['page'] : 1;

if(!is_numeric($_page) || $_page > PHP_INT_MAX) {
   $_page = 1;
}

if ($_page > 1) {
   $offset = ($_page - 1) * $configBansPerPage;
}
else {
   $offset = 0;
}

/**
* @var OTS_DB_MySQL $db
*/
$configBans = [];
$configBans['hasType'] = false;
$configBans['hasReason'] = false;

$limit = 'LIMIT ' . ($configBansPerPage + 1) . (isset($offset) ? ' OFFSET ' . $offset : '');
if (tableExist('account_bans')) {
   $bansQuery = $db->query('SELECT * FROM `account_bans` ORDER BY `banned_at` DESC ' . $limit);
}
else if (tableExist('bans') && fieldExist('active', 'bans')
   && fieldExist('type', 'bans') && fieldExist('reason', 'bans')) {
   $bansQuery = $db->query('SELECT * FROM `bans` WHERE `active` = 1 ORDER BY `added` DESC ' . $limit);
   $configBans['hasType'] = true;
   $configBans['hasReason'] = true;
}
else {
   echo 'Bans list is not supported in your distribution.';
   return;
}

if(!$bansQuery->rowCount())
{
   echo 'There are no banishments yet.';
   return;
}

$nextPage = false;
$i = 0;
$bans = $bansQuery->fetchAll();
foreach ($bans as $id => &$ban)
{
   if(++$i > $configBansPerPage)
   {
      unset($bans[$id]);
      $nextPage = true;
      break;
   }

   $ban['i'] = $i;
   if (tableExist('bans') && fieldExist('value', 'bans')) {
      $accountId = $ban['value'];
   }
   else {
      // TFS 1.x
      $accountId = $ban['account_id'];
   }

   $ban['player'] = getPlayerLink(getPlayerNameByAccount($accountId));

   if ($configBans['hasType']) {
      $ban['type'] = getBanType($ban['type']);
   }

   $expiresColumn = 'expires_at';
   if (tableExist('bans') && fieldExist('expires', 'bans')) {
      $expiresColumn = 'expires';
   }

   if ((int)$ban[$expiresColumn] === -1) {
      $ban['expires'] = 'Never';
   }
   else {
      $ban['expires'] = date('H:i:s', $ban[$expiresColumn]) . '<br/>' . date('d.M.Y', $ban[$expiresColumn]);
   }

   if ($configBans['hasReason']) {
      $ban['reason'] = getBanReason($ban['reason']);
   }
   else {
      $ban['comment'] = $ban['reason'];
   }

   $addedBy = '';
   if (tableExist('bans') && fieldExist('admin_id', 'bans')) {
      if ((int)$ban['admin_id'] === 0) {
         $addedBy = 'Autoban';
      }
      else {
         $addedBy = getPlayerLink(getPlayerNameByAccount($ban['admin_id']));
      }
   }
   else {
      $addedBy = getPlayerLink(getPlayerNameByAccount($ban['banned_by']));
   }

   if (tableExist('bans') && fieldExist('added', 'bans')) {
      $addedTime = $ban['added'];
   }
   else {
      $addedTime = $ban['banned_at'];
   }

   $ban['addedTime'] = date('H:i:s', $addedTime) . '<br/>' . date('d.M.Y', $addedTime);
   $ban['addedBy'] = $addedBy;
}

$twig->display('bans.html.twig', [
   'bans' => $bans,
   'configBans' => $configBans,
   'page' => $_page,
   'nextPage' => $nextPage,
]);

Would be easier if you use 0.8 :(
 
Try this:
PHP:
<?php
/**
* Bans
*
* @package   MyAAC
* @author    Gesior <[email protected]>
* @author    Slawkens <[email protected]>
* @copyright 2019 MyAAC
* @link      https://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Bans list';

$configBansPerPage = config('bans_per_page');
$_page = isset($_GET['page']) ? $_GET['page'] : 1;

if(!is_numeric($_page) || $_page > PHP_INT_MAX) {
   $_page = 1;
}

if ($_page > 1) {
   $offset = ($_page - 1) * $configBansPerPage;
}
else {
   $offset = 0;
}

/**
* @var OTS_DB_MySQL $db
*/
$configBans = [];
$configBans['hasType'] = false;
$configBans['hasReason'] = false;

$limit = 'LIMIT ' . ($configBansPerPage + 1) . (isset($offset) ? ' OFFSET ' . $offset : '');
if (tableExist('account_bans')) {
   $bansQuery = $db->query('SELECT * FROM `account_bans` ORDER BY `banned_at` DESC ' . $limit);
}
else if (tableExist('bans') && fieldExist('active', 'bans')
   && fieldExist('type', 'bans') && fieldExist('reason', 'bans')) {
   $bansQuery = $db->query('SELECT * FROM `bans` WHERE `active` = 1 ORDER BY `added` DESC ' . $limit);
   $configBans['hasType'] = true;
   $configBans['hasReason'] = true;
}
else {
   echo 'Bans list is not supported in your distribution.';
   return;
}

if(!$bansQuery->rowCount())
{
   echo 'There are no banishments yet.';
   return;
}

$nextPage = false;
$i = 0;
$bans = $bansQuery->fetchAll();
foreach ($bans as $id => &$ban)
{
   if(++$i > $configBansPerPage)
   {
      unset($bans[$id]);
      $nextPage = true;
      break;
   }

   $ban['i'] = $i;
   if (tableExist('bans') && fieldExist('value', 'bans')) {
      $accountId = $ban['value'];
   }
   else {
      // TFS 1.x
      $accountId = $ban['account_id'];
   }

   $ban['player'] = getPlayerLink(getPlayerNameByAccount($accountId));

   if ($configBans['hasType']) {
      $ban['type'] = getBanType($ban['type']);
   }

   $expiresColumn = 'expires_at';
   if (tableExist('bans') && fieldExist('expires', 'bans')) {
      $expiresColumn = 'expires';
   }

   if ((int)$ban[$expiresColumn] === -1) {
      $ban['expires'] = 'Never';
   }
   else {
      $ban['expires'] = date('H:i:s', $ban[$expiresColumn]) . '<br/>' . date('d.M.Y', $ban[$expiresColumn]);
   }

   if ($configBans['hasReason']) {
      $ban['reason'] = getBanReason($ban['reason']);
   }
   else {
      $ban['comment'] = $ban['reason'];
   }

   $addedBy = '';
   if (tableExist('bans') && fieldExist('admin_id', 'bans')) {
      if ((int)$ban['admin_id'] === 0) {
         $addedBy = 'Autoban';
      }
      else {
         $addedBy = getPlayerLink(getPlayerNameByAccount($ban['admin_id']));
      }
   }
   else {
      $addedBy = getPlayerLink(getPlayerNameByAccount($ban['banned_by']));
   }

   if (tableExist('bans') && fieldExist('added', 'bans')) {
      $addedTime = $ban['added'];
   }
   else {
      $addedTime = $ban['banned_at'];
   }

   $ban['addedTime'] = date('H:i:s', $addedTime) . '<br/>' . date('d.M.Y', $addedTime);
   $ban['addedBy'] = $addedBy;
}

$twig->display('bans.html.twig', [
   'bans' => $bans,
   'configBans' => $configBans,
   'page' => $_page,
   'nextPage' => $nextPage,
]);

Would be easier if you use 0.8 :(
It would but i cant move to newer version to many changes made :D would be pain in the ass to move everything to latest version

Fatal error: Uncaught Error: Call to undefined function getPlayerNameByAccount() in /var/www/html/system/pages/bans.php:77 Stack trace: #0 /var/www/html/index.php(425): require() #1 {main} thrown in /var/www/html/system/pages/bans.php on line 77
 
Copy this to your system/functions.php
PHP:
function getBanReason($reasonId)
{
   switch($reasonId)
   {
      case 0:
         return "Offensive Name";
      case 1:
         return "Invalid Name Format";
      case 2:
         return "Unsuitable Name";
      case 3:
         return "Name Inciting Rule Violation";
      case 4:
         return "Offensive Statement";
      case 5:
         return "Spamming";
      case 6:
         return "Illegal Advertising";
      case 7:
         return "Off-Topic Public Statement";
      case 8:
         return "Non-English Public Statement";
      case 9:
         return "Inciting Rule Violation";
      case 10:
         return "Bug Abuse";
      case 11:
         return "Game Weakness Abuse";
      case 12:
         return "Using Unofficial Software to Play";
      case 13:
         return "Hacking";
      case 14:
         return "Multi-Clienting";
      case 15:
         return "Account Trading or Sharing";
      case 16:
         return "Threatening Gamemaster";
      case 17:
         return "Pretending to Have Influence on Rule Enforcement";
      case 18:
         return "False Report to Gamemaster";
      case 19:
         return "Destructive Behaviour";
      case 20:
         return "Excessive Unjustified Player Killing";
      case 21:
         return "Invalid Payment";
      case 22:
         return "Spoiling Auction";
   }

   return "Unknown Reason";
}

function getBanType($typeId)
{
   switch($typeId)
   {
      case 1:
         return "IP Banishment";
      case 2:
         return "Namelock";
      case 3:
         return "Banishment";
      case 4:
         return "Notation";
      case 5:
         return "Deletion";
   }

   return "Unknown Type";
}

function getPlayerNameByAccount($id)
{
   global $vowels, $ots, $db;
   if(is_numeric($id))
   {
      $player = new OTS_Player();
      $player->load($id);
      if($player->isLoaded())
         return $player->getName();
      else
      {
         $playerQuery = $db->query('SELECT `id` FROM `players` WHERE `account_id` = ' . $id . ' ORDER BY `lastlogin` DESC LIMIT 1;')->fetch();

         $tmp = "*Error*";
         /*
         $acco = new OTS_Account();
         $acco->load($id);
         if(!$acco->isLoaded())
            return "Unknown name";

         foreach($acco->getPlayersList() as $p)
         {
            $player= new OTS_Player();
            $player->find($p);*/
            $player->load($playerQuery['id']);
            //echo 'id gracza = ' . $p . '<br/>';
            if($player->isLoaded())
               $tmp = $player->getName();
         // break;
         //}

         return $tmp;
      }
   }

   return '';
}
 
Back
Top