Skip to content

Commit

Permalink
improvement: serverinfo page (opentibiabr#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
elsongabriel authored Apr 3, 2024
1 parent 6409b80 commit f85b52f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
2 changes: 2 additions & 0 deletions common.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@
$basedir = str_replace(array('/admin', '/install', '/tools'), '', $basedir);
define('BASE_DIR', $basedir);

$TABLE_PREFIX = TABLE_PREFIX;

if (file_exists(BASE . 'config.local.php') && !defined('MYAAC_INSTALL')) {
require BASE . 'config.local.php';
}
Expand Down
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
global $db, $twig, $template_path, $account_logged, $logged, $template_name, $status;
/**
* Project: MyAAC
* Automatic Account Creator for Open Tibia Servers
Expand Down
21 changes: 12 additions & 9 deletions system/status.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
global $TABLE_PREFIX;
/**
* Server status
*
Expand Down Expand Up @@ -65,11 +66,9 @@
// get info from db
/** @var OTS_DB_MySQL $db */
$status_query = $db->query(
'SELECT `name`, `value` FROM `' .
TABLE_PREFIX .
'config` WHERE ' .
$db->fieldName('name') .
' LIKE "%status%"'
"SELECT `name`, `value` FROM `{$TABLE_PREFIX}config` WHERE {$db->fieldName(
'name'
)} LIKE '%status%'"
);
if ($status_query->rowCount() <= 0) {
// empty, just insert it
Expand Down Expand Up @@ -135,10 +134,14 @@ function updateStatus()
}
}

$status['uptime'] = $serverStatus->getUptime();
$h = floor($status['uptime'] / 3600);
$m = floor(($status['uptime'] - $h * 3600) / 60);
$status['uptimeReadable'] = $h . 'h ' . $m . 'm';
$uptime = $status['uptime'] = $serverStatus->getUptime();
$m = date('m', $uptime);
$m = $m > 1 ? "$m months, " : ($m == 1 ? 'month, ' : '');
$d = date('d', $uptime);
$d = $d > 1 ? "$d days, " : ($d == 1 ? 'day, ' : '');
$h = date('H', $uptime);
$min = date('i', $uptime);
$status['uptimeReadable'] = "{$m}{$d}{$h}h {$min}m";

$status['monsters'] = $serverStatus->getMonstersCount();
$status['motd'] = $serverStatus->getMOTD();
Expand Down
7 changes: 5 additions & 2 deletions system/templates/serverinfo.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
var serverSaveTime = new Date({{ serverSaveTime }});
var x = setInterval(function () {
var x = setInterval(function() {
var now = new Date().getTime();
var distance = serverSaveTime - now;
var hours = Math.floor(distance / (1000 * 60 * 60));
Expand Down Expand Up @@ -152,7 +152,10 @@
</td>
</tr>
<tr bgcolor="#F1E0C6">
<td><b>Level to create guild: </b> {{ config.guild_need_level }}</td>
<td>
<b>Level to create
guild:</b>{% if config.guild_need_level > 0 %} {{ config.guild_need_level }} {% else %} no level {% endif %}
</td>
</tr>
{% if houseLevel %}
<tr bgcolor="#D4C0A1">
Expand Down

0 comments on commit f85b52f

Please sign in to comment.