Update accounts.php

-Bans table error
-Fix for #114
This commit is contained in:
Lee 2020-04-02 14:52:38 +01:00
parent 7c208b38ed
commit a0afeb2a7a

View File

@ -47,9 +47,6 @@ else if (isset($_REQUEST['search'])) {
if (strlen($search_account) < 3 && !Validator::number($search_account)) { if (strlen($search_account) < 3 && !Validator::number($search_account)) {
echo_error('Player name is too short.'); echo_error('Player name is too short.');
} else { } else {
if (Validator::number($search_account))
$id = (int)$search_account;
else {
$query = $db->query('SELECT `id` FROM `accounts` WHERE `name` = ' . $db->quote($search_account)); $query = $db->query('SELECT `id` FROM `accounts` WHERE `name` = ' . $db->quote($search_account));
if ($query->rowCount() == 1) { if ($query->rowCount() == 1) {
$query = $query->fetch(); $query = $query->fetch();
@ -68,7 +65,6 @@ else if (isset($_REQUEST['search'])) {
echo_error('No entries found.'); echo_error('No entries found.');
} }
} }
}
} }
?> ?>
<div class="row"> <div class="row">
@ -255,18 +251,17 @@ else if (isset($_REQUEST['search'])) {
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" id="accounts-chars-tab" data-toggle="pill" href="#accounts-chars">Characters</a> <a class="nav-link" id="accounts-chars-tab" data-toggle="pill" href="#accounts-chars">Characters</a>
</li> </li>
<?php <?php if ($db->hasTable('bans')) : ?>
if (!$config['otserv_version'] != TFS_02) { ?>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" id="accounts-bans-tab" data-toggle="pill" href="#accounts-bans">Bans</a> <a class="nav-link" id="accounts-bans-tab" data-toggle="pill" href="#accounts-bans">Bans</a>
</li> </li>
<?php } <?php endif;
if ($db->hasTable('store_history')) { ?> if ($db->hasTable('store_history')) : ?>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" id="accounts-store-tab" data-toggle="pill" href="#accounts-store">Store History</a> <a class="nav-link" id="accounts-store-tab" data-toggle="pill" href="#accounts-store">Store History</a>
</li> </li>
<?php } ?> <?php endif; ?>
</ul> </ul>
</div> </div>
<div class="card-body"> <div class="card-body">
@ -449,8 +444,7 @@ else if (isset($_REQUEST['search'])) {
} ?> } ?>
</div> </div>
</div> </div>
<?php <?php if ($db->hasTable('bans')) : ?>
if (!$config['otserv_version'] != TFS_02) { ?>
<div class="tab-pane fade" id="accounts-bans"> <div class="tab-pane fade" id="accounts-bans">
<?php <?php
$bans = $db->query('SELECT * FROM ' . $db->tableName('bans') . ' WHERE ' . $db->fieldName('active') . ' = 1 AND ' . $db->fieldName('id') . ' = ' . $account->getId() . ' ORDER BY ' . $db->fieldName('added') . ' DESC'); $bans = $db->query('SELECT * FROM ' . $db->tableName('bans') . ' WHERE ' . $db->fieldName('active') . ' = 1 AND ' . $db->fieldName('id') . ' = ' . $account->getId() . ' ORDER BY ' . $db->fieldName('added') . ' DESC');
@ -510,7 +504,7 @@ else if (isset($_REQUEST['search'])) {
echo 'No Account bans.'; echo 'No Account bans.';
} ?> } ?>
</div> </div>
<?php } <?php endif;
if ($db->hasTable('store_history')) { ?> if ($db->hasTable('store_history')) { ?>
<div class="tab-pane fade" id="accounts-store"> <div class="tab-pane fade" id="accounts-store">
<?php $store_history = $db->query('SELECT * FROM `store_history` WHERE `account_id` = "' . $account->getId() . '" ORDER BY `time` DESC')->fetchAll(); ?> <?php $store_history = $db->query('SELECT * FROM `store_history` WHERE `account_id` = "' . $account->getId() . '" ORDER BY `time` DESC')->fetchAll(); ?>
@ -546,13 +540,27 @@ else if (isset($_REQUEST['search'])) {
<h5 class="m-0">Search Accounts</h5> <h5 class="m-0">Search Accounts</h5>
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="row">
<div class="col-6 col-lg-12">
<form action="<?php echo $admin_base; ?>" method="post"> <form action="<?php echo $admin_base; ?>" method="post">
<label for="name">Account Name:</label>
<div class="input-group input-group-sm"> <div class="input-group input-group-sm">
<input type="text" class="form-control" name="search" value="<?php echo $search_account; ?>" maxlength="32" size="32"> <input type="text" class="form-control" name="search" value="<?php echo $search_account; ?>" maxlength="32" size="32">
<span class="input-group-append"><button type="submit" class="btn btn-info btn-flat">Search</button></span> <span class="input-group-append"><button type="submit" class="btn btn-info btn-flat">Search</button></span>
</div> </div>
</form> </form>
</div> </div>
<div class="col-6 col-lg-12">
<form action="<?php echo $admin_base; ?>" method="post">
<label for="name">Account ID:</label>
<div class="input-group input-group-sm">
<input type="text" class="form-control" name="id" value="" maxlength="32" size="32">
<span class="input-group-append"><button type="submit" class="btn btn-info btn-flat">Search</button></span>
</div>
</form>
</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>