serverinfo cleanup, fix cache, query optimizations

This commit is contained in:
Znote
2021-07-24 02:35:26 +02:00
parent 8f5487db2b
commit 0e941b2c1e
3 changed files with 38 additions and 84 deletions

View File

@@ -1,34 +1,27 @@
<?php
$cache = new Cache('engine/cache/asideServerInfo');
if ($cache->hasExpired()) {
$asideServerInfo = mysql_select_single("
SELECT
(SELECT COUNT(`id`) FROM `accounts`) as `accounts`,
(SELECT COUNT(`id`) FROM `players`) as `players`,
(SELECT COUNT(`player_id`) FROM `players_online`) as `online`
");
$cache->setContent($asideServerInfo);
$cache->save();
} else {
$asideServerInfo = $cache->load();
}
?>
<div class="well widget">
<div class="header">
Server Information
</div>
<div class="body">
<ul>
<?php
$status = true;
if ($config['status']['status_check']) {
@$sock = fsockopen ($config['status']['status_ip'], $config['status']['status_port'], $errno, $errstr, 1);
if(!$sock) {
echo "<span style='color:red;font-weight:bold;'><center>Server Offline!</center></span><br/>";
$status = false;
}
else {
$info = chr(6).chr(0).chr(255).chr(255).'info';
fwrite($sock, $info);
$data='';
while (!feof($sock))$data .= fgets($sock, 1024);
fclose($sock);
echo "<span style='color:green;font-weight:bold;'><center>Server Online!</center></span><br />";
}
}
if ($status) {
?>
<li><a href="onlinelist.php">Players online:
<?php echo user_count_online(); ?></a></li>
<?php
}
?>
<li>Registered accounts: <?php echo user_count_accounts();?></li>
<li><a href="onlinelist.php">Players online: <?php echo $asideServerInfo['online']; ?></a></li>
<li>Registered accounts: <?php echo $asideServerInfo['accounts'];?></li>
<li>Registered players: <?php echo $asideServerInfo['players'];?></li>
</ul>
</div>
</div>