* fixed when ban expires is unlimited

* moved Banished code to twig
This commit is contained in:
slawkens 2017-10-19 10:41:39 +02:00
parent cde42ec3fa
commit 23c1df72aa
2 changed files with 13 additions and 7 deletions

View File

@ -351,16 +351,16 @@ WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, kil
// check if account has been banned // check if account has been banned
$bannedUntil = ''; $bannedUntil = '';
$banned = array(); $banned = array();
if (tableExist('account_bans')) if(tableExist('account_bans'))
$banned = $db->query('SELECT `expires_at` as `expires` FROM `account_bans` WHERE `account_id` = ' . $account->getId() . ' and `expires_at` > ' . time()); $banned = $db->query('SELECT `expires_at` as `expires` FROM `account_bans` WHERE `account_id` = ' . $account->getId() . ' and (`expires_at` > ' . time() . ' OR `expires_at` = -1);');
else if (tableExist('bans')) { else if (tableExist('bans')) {
if (fieldExist('expires', 'bans')) if (fieldExist('expires', 'bans'))
$banned = $db->query('SELECT `expires` FROM `bans` WHERE (`value` = ' . $account->getId() . ' or `value` = ' . $player->getId() . ') and `active` = 1 and `type` != 2 and `type` != 4 and `expires` > ' . time()); $banned = $db->query('SELECT `expires` FROM `bans` WHERE (`value` = ' . $account->getId() . ' or `value` = ' . $player->getId() . ') and `active` = 1 and `type` != 2 and `type` != 4 and (`expires` > ' . time() . ' OR `expires` = -1);');
else else
$banned = $db->query('SELECT `time` as `time` FROM `bans` WHERE (`account` = ' . $account->getId() . ' or `player` = ' . $player->getId() . ') and `type` != 2 and `type` != 4 and `time` > ' . time()); $banned = $db->query('SELECT `time` as `time` FROM `bans` WHERE (`account` = ' . $account->getId() . ' or `player` = ' . $player->getId() . ') and `type` != 2 and `type` != 4 and (`time` > ' . time() . ' OR `time` = -1);');
} }
foreach ($banned as $ban) { foreach($banned as $ban) {
$bannedUntil = ' <font color="red">[Banished ' . ($ban['expires'] == "-1" ? 'forever' : 'until ' . date("d F Y, h:s", $ban['expires'])) . ']</font>'; $bannedUntil = $ban['expires'];
} }
$account_players = $account->getPlayersList(); $account_players = $account->getPlayersList();

View File

@ -329,7 +329,13 @@
{% set rows = rows + 1 %} {% set rows = rows + 1 %}
<tr bgcolor="{{ getStyle(rows) }}"> <tr bgcolor="{{ getStyle(rows) }}">
<td width="20%">Created:</td> <td width="20%">Created:</td>
<td>{{ account.getCustomField("created")|date("j F Y, g:i a") ~ bannedUntil|raw }}</td> <td>{{ account.getCustomField("created")|date("j F Y, g:i a") }}
{% if bannedUntil matches '/^\\d+$/' or bannedUntil == '-1' %}
<font color="red">[Banished {% if bannedUntil == '-1' %}forever{% else %}until {{ bannedUntil|date('d F Y, h:s') }}{% endif %}]</font>
{% else %}
{{ bannedUntil|raw }}
{% endif %}
</td>
</tr> </tr>
</table> </table>
{{ hook(constant('HOOK_CHARACTERS_AFTER_ACCOUNT')) }} {{ hook(constant('HOOK_CHARACTERS_AFTER_ACCOUNT')) }}