Account fix (#63)

* Admin Panel

* fixes

-Code Clean Up
-Remove dist folder and merged into tools.

* Use Acc Name

Use Acc Name fix for login.

* Pull fix

* Dashboard fix

- Fix coins table
- Fix points table
This commit is contained in:
Lee 2018-11-26 05:40:39 +00:00 committed by slawkens
parent d1e6061541
commit 82fed8abfe
5 changed files with 109 additions and 223 deletions

View File

@ -11,42 +11,40 @@ defined('MYAAC') or die('Direct access not allowed!');
$title = 'Dashboard';
$cache = Cache::getInstance();
if($cache->enabled()) {
if(isset($_GET['clear_cache'])) {
if(clearCache())
success('Cache cleared.');
else
error('Error while clearing cache.');
}
if ($cache->enabled()) {
if (isset($_GET['clear_cache'])) {
if (clearCache())
success('Cache cleared.');
else
error('Error while clearing cache.');
}
}
if(isset($_GET['maintenance'])) {
$_status = (int)$_POST['status'];
$message = $_POST['message'];
if(empty($message)) {
error('Message cannot be empty.');
}
else if(strlen($message) > 255) {
error('Message is too long. Maximum length allowed is 255 chars.');
}
else {
$tmp = '';
if(fetchDatabaseConfig('site_closed', $tmp))
updateDatabaseConfig('site_closed', $_status);
else
registerDatabaseConfig('site_closed', $_status);
if (isset($_GET['maintenance'])) {
$_status = (int)$_POST['status'];
$message = $_POST['message'];
if (empty($message)) {
error('Message cannot be empty.');
} else if (strlen($message) > 255) {
error('Message is too long. Maximum length allowed is 255 chars.');
} else {
$tmp = '';
if (fetchDatabaseConfig('site_closed', $tmp))
updateDatabaseConfig('site_closed', $_status);
else
registerDatabaseConfig('site_closed', $_status);
if(fetchDatabaseConfig('site_closed_message', $tmp))
updateDatabaseConfig('site_closed_message', $message);
else
registerDatabaseConfig('site_closed_message', $message);
}
if (fetchDatabaseConfig('site_closed_message', $tmp))
updateDatabaseConfig('site_closed_message', $message);
else
registerDatabaseConfig('site_closed_message', $message);
}
}
$is_closed = getDatabaseConfig('site_closed') == '1';
$closed_message = 'Server is under maintenance, please visit later.';
$tmp = '';
if(fetchDatabaseConfig('site_closed_message', $tmp))
$closed_message = $tmp;
if (fetchDatabaseConfig('site_closed_message', $tmp))
$closed_message = $tmp;
$query = $db->query('SELECT count(*) as `how_much` FROM `accounts`;');
$query = $query->fetch();
@ -64,64 +62,74 @@ $query = $db->query('SELECT count(*) as `how_much` FROM `houses`;');
$query = $query->fetch();
$total_houses = $query['how_much'];
$points = $db->query('SELECT `premium_points`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `premium_points` DESC LIMIT 10;');
if ($db->hasColumn('accounts', 'premium_points')) {
$points = $db->query('SELECT `premium_points`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `premium_points` DESC LIMIT 10;');
} else {
$points = 0;
}
if ($db->hasColumn('accounts', 'coins')) {
$coins = $db->query('SELECT `coins`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `coins` DESC LIMIT 10;');
} else {
$coins = 0;
}
$twig->display('admin.statistics.html.twig', array(
'total_accounts' => $total_accounts,
'total_players' => $total_players,
'total_guilds' => $total_guilds,
'total_houses' => $total_houses
'total_accounts' => $total_accounts,
'total_players' => $total_players,
'total_guilds' => $total_guilds,
'total_houses' => $total_houses
));
$twig->display('admin.dashboard.html.twig', array(
'is_closed' => $is_closed,
'closed_message' => $closed_message,
'status' => $status,
'account_type' => (USE_ACCOUNT_NAME ? 'name' : 'number'),
'points' => $points
'account_type' => (USE_ACCOUNT_NAME ? 'name' : 'number'),
'points' => $points,
'coins' => $coins,
));
function clearCache()
{
global $template_name;
$cache = Cache::getInstance();
global $template_name;
$cache = Cache::getInstance();
$tmp = '';
if($cache->fetch('status', $tmp))
$cache->delete('status');
$tmp = '';
if ($cache->fetch('status', $tmp))
$cache->delete('status');
if($cache->fetch('templates', $tmp))
$cache->delete('templates');
if ($cache->fetch('templates', $tmp))
$cache->delete('templates');
if($cache->fetch('config_lua', $tmp))
$cache->delete('config_lua');
if ($cache->fetch('config_lua', $tmp))
$cache->delete('config_lua');
if($cache->fetch('vocations', $tmp))
$cache->delete('vocations');
if ($cache->fetch('vocations', $tmp))
$cache->delete('vocations');
if($cache->fetch('towns', $tmp))
$cache->delete('towns');
if ($cache->fetch('towns', $tmp))
$cache->delete('towns');
if($cache->fetch('groups', $tmp))
$cache->delete('groups');
if ($cache->fetch('groups', $tmp))
$cache->delete('groups');
if($cache->fetch('visitors', $tmp))
$cache->delete('visitors');
if ($cache->fetch('visitors', $tmp))
$cache->delete('visitors');
if($cache->fetch('views_counter', $tmp))
$cache->delete('views_counter');
if ($cache->fetch('views_counter', $tmp))
$cache->delete('views_counter');
if($cache->fetch('failed_logins', $tmp))
$cache->delete('failed_logins');
if ($cache->fetch('failed_logins', $tmp))
$cache->delete('failed_logins');
if($cache->fetch('news' . $template_name . '_' . NEWS, $tmp))
$cache->delete('news' . $template_name . '_' . NEWS);
if ($cache->fetch('news' . $template_name . '_' . NEWS, $tmp))
$cache->delete('news' . $template_name . '_' . NEWS);
if($cache->fetch('news' . $template_name . '_' . TICKER, $tmp))
$cache->delete('news' . $template_name . '_' . TICKER);
if ($cache->fetch('news' . $template_name . '_' . TICKER, $tmp))
$cache->delete('news' . $template_name . '_' . TICKER);
if($cache->fetch('template_ini' . $template_name, $tmp))
$cache->delete('template_ini' . $template_name);
if ($cache->fetch('template_ini' . $template_name, $tmp))
$cache->delete('template_ini' . $template_name);
return true;
return true;
}

View File

@ -24,7 +24,9 @@ if(isset($errors)) {
}
}
$twig->display('admin.login.html.twig', array(
'errors' => $search_errors,
'logout' => $logout
'logout' => $logout,
'account' => USE_ACCOUNT_NAME ? 'Name' : 'Number',
));

View File

@ -41,39 +41,11 @@
</div>
</div>
</div>
{% if points is iterable %}
<div class="col-md-3">
<div class="box">
<div class="box-header">
<h3 class="box-title">Top 10 - Most wealthly accounts</h3>
</div>
<div class="box-body no-padding">
<table class="table table-condensed">
<tbody>
<tr>
<th>#</th>
<th>Account {{ account_type }}</th>
<th>Tibia coins</th>
</tr>
{% set i = 0 %}
{% for result in coins %}
{% set i = i + 1 %}
<tr>
<td>{{ i }}</td>
<td>{{ result.name }}</td>
<td>{{ result.coins }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<div class="col-md-3">
<div class="box">
<div class="box-header">
<h3 class="box-title">Top 10 - Most wealthly accounts</h3>
<h3 class="box-title">Top 10 - Most premium points</h3>
</div>
<div class="box-body no-padding">
<table class="table table-condensed">
@ -97,4 +69,34 @@
</div>
</div>
</div>
{% endif %}
{% if coins is iterable %}
<div class="col-md-3">
<div class="box">
<div class="box-header">
<h3 class="box-title">Top 10 - Most coins</h3>
</div>
<div class="box-body no-padding">
<table class="table table-condensed">
<tbody>
<tr>
<th>#</th>
<th>Account {{ account_type }}</th>
<th>Tibia coins</th>
</tr>
{% set i = 0 %}
{% for result in coins %}
{% set i = i + 1 %}
<tr>
<td>{{ i }}</td>
<td>{{ result.name }}</td>
<td>{{ result.coins }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endif %}
</div>

View File

@ -1,126 +0,0 @@
<div class="row">
<div class="col-md-6">
<div class="box box-warning">
<div class="box-header with-border">
<h3 class="box-title">Maintenance</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
</button>
</div>
</div>
<div class="box-body">
<form action="?p=dashboard&maintenance" method="post" class="form-horizontal">
<div class="box-body">
<div class="form-group">
<label for="status" class="col-sm-2 control-label">Website:</label>
<div class="col-sm-10">
<select class="form-control" id="status" name="status">
<option value="0"{% if not is_closed %} selected{% endif %}>Open</option>
<option value="1"{% if is_closed %} selected{% endif %}>Closed</option>
</select>
</div>
</div>
<div class="form-group">
<label for="message" class="col-sm-2 control-label">Message:<br>
<small>(only if closed)</small>
</label>
<div class="col-sm-10">
<textarea name="message" cols="40" class="form-control" rows="5" maxlength="255"
placeholder="Enter ...">{{ closed_message }}</textarea>
</div>
</div>
</div>
<div class="box-footer">
<a href="?p=dashboard&clear_cache" onclick="return confirm('Are you sure?');"><span
class="btn btn-danger">Clear cache</span></a>
<div class="pull-right">
<input type="submit" class="btn btn-primary" value="Update"/>
</div>
</div>
</form>
</div>
</div>
</div>
{% if status.online %}
<div class="col-md-6">
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Server Online</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i
class="fa fa-minus"></i>
</button>
</div>
</div>
<div class="box-body">
<table class="table table-hover">
<tbody>
<tr>
<td>Status</td>
<td>{{ status.uptimeReadable }}, {{ status.players }}/{{ status.playersMax }}</td>
</tr>
<tr>
<td>Connection</td>
<td>{{ config.lua.ip }} : {{ config.lua.loginPort }}</td>
</tr>
<tr>
<td>Server</td>
<td>{{ status.server }} {{ status.serverVersion }}</td>
</tr>
<tr>
<td>Version</td>
<td> {{ status.clientVersion }}</td>
</tr>
<tr>
<td>Monsters</td>
<td>{{ status.monsters }}</td>
</tr>
<tr>
<td>Map</td>
<td>{{ status.mapName }}, <b>author</b>: {{ status.mapAuthor }},
<b>size</b>: {{ status.mapWidth }} x {{ status.mapHeight }}</td>
</tr>
<tr>
<td>MOTD</td>
<td>{{ status.motd }}</td>
</tr>
<tr>
<td>Last updated</td>
<td>{{ status.lastCheck|date("H:i:s") }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
{% endif %}
<div class="col-md-3">
<div class="box">
<div class="box-header">
<h3 class="box-title">Top 10 - Most wealthly accounts</h3>
</div>
<div class="box-body no-padding">
<table class="table table-condensed">
<tbody>
<tr>
<th>#</th>
<th>Account {{ account_type }}</th>
<th>Premium points</th>
</tr>
{% set i = 0 %}
{% for result in points %}
{% set i = i + 1 %}
<tr>
<td>{{ i }}</td>
<td>{{ result.name }}</td>
<td>{{ result.premium_points }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>

View File

@ -17,7 +17,7 @@
<div class="form-group input-group">
<span class="input-group-addon"><i class="fa fa-lock"></i></span>
<input type="password" class="form-control" id="account-name-input" name="account_login"
placeholder="Account Name" required autofocus>
placeholder="Account {{ account }}" required autofocus>
</div>
<div class="form-group input-group">
<span class="input-group-addon"><i class="fa fa-key"></i></span>
@ -35,4 +35,4 @@
</div>
</div>
</form>
</div>
</div>