Improved flags system & reduce query usage in online list

Using http://flag.znote.eu as an external image server for flags.
Online list is now stored in a 30 seconds quick cache.
Reduced query usage in online list to 1 instead of 1 + players online amounts of queries.
This commit is contained in:
Znote
2017-01-26 22:09:53 +01:00
parent ac8da54d78
commit 2fad7a3efb
5 changed files with 59 additions and 28 deletions

View File

@@ -28,6 +28,7 @@ if (!$page || $page == 0) $page = 1;
else $page = (int)$page;
$highscore = $config['highscore'];
$loadFlags = ($config['country_flags']['enabled'] && $config['country_flags']['highscores']) ? true : false;
$rows = $highscore['rows'];
$rowsPerPage = $highscore['rowsPerPage'];
@@ -53,7 +54,7 @@ function pageCheck($index, $page, $rowPerPage) {
$cache = new Cache('engine/cache/highscores');
if ($cache->hasExpired()) {
$vocGroups = fetchAllScores($rows, $config['TFSVersion'], $highscore['ignoreGroupId'], $configVocations, $vocation, $config['country_flags']);
$vocGroups = fetchAllScores($rows, $config['TFSVersion'], $highscore['ignoreGroupId'], $configVocations, $vocation, $loadFlags);
$cache->setContent($vocGroups);
$cache->save();
@@ -128,7 +129,7 @@ if ($vocGroups) {
<?php
} else {
if (pageCheck($i, $page, $rowsPerPage)) {
$flag = ($config['country_flags'] === true && strlen($vocGroup[$type][$i]['flag']) > 1) ? '<img src="flags/' . $vocGroup[$type][$i]['flag'] . '.png"> ' : '';
$flag = ($loadFlags === true && strlen($vocGroup[$type][$i]['flag']) > 1) ? '<img src="' . $config['country_flags']['server'] . '/' . $vocGroup[$type][$i]['flag'] . '.png"> ' : '';
?>
<tr>
<td><?php echo $i+1; ?></td>