mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-04-29 18:59:21 +02:00
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:
parent
ac8da54d78
commit
2fad7a3efb
@ -29,7 +29,6 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false)
|
||||
}
|
||||
|
||||
$profile_znote_data = user_znote_character_data($user_id, 'created', 'hide_char', 'comment');
|
||||
$account_data = user_znote_account_data($profile_data['account_id'], 'flag');
|
||||
|
||||
$guild_exist = false;
|
||||
|
||||
@ -47,12 +46,18 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false)
|
||||
<!-- Profile name -->
|
||||
<h1><font class="profile_font" name="profile_font_header">Profile: <?php echo $profile_data['name']; ?></font></h1>
|
||||
<ul class="unstyled">
|
||||
<?php
|
||||
if ($config['country_flags'])
|
||||
{ ?>
|
||||
<!-- Player country data -->
|
||||
<li><font class="profile_font" name="profile_font_country">Country: <?php echo '<img src="flags/' . $account_data['flag'] . '.png">'; ?></font></li><?php
|
||||
} ?>
|
||||
<?php
|
||||
$flags = $config['country_flags'];
|
||||
if ($flags['enabled'] && $flags['characterprofile']) {
|
||||
$account_data = user_znote_account_data($profile_data['account_id'], 'flag');
|
||||
|
||||
if (strlen($account_data['flag']) > 0):
|
||||
?><!-- Player country data -->
|
||||
<li><font class="profile_font" name="profile_font_country">Country: <?php echo '<img src="' . $flags['server'] . '/' . $account_data['flag'] . '.png">'; ?></font></li>
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Player Position -->
|
||||
<?php if ($profile_data['group_id'] > 1) { ?>
|
||||
|
@ -560,7 +560,13 @@
|
||||
$config['use_guild_logos'] = true;
|
||||
|
||||
// Use country flags
|
||||
$config['country_flags'] = false;
|
||||
$config['country_flags'] = array(
|
||||
'enabled' => true,
|
||||
'highscores' => true,
|
||||
'onlinelist' => true,
|
||||
'characterprofile' => true,
|
||||
'server' => 'http://flag.znote.eu'
|
||||
);
|
||||
|
||||
// Level requirement to create guild? (Just set it to 1 to allow all levels).
|
||||
$config['create_guild_level'] = 8;
|
||||
|
@ -277,13 +277,6 @@ function format_character_name($name) {
|
||||
return ucwords(strtolower($name));
|
||||
}
|
||||
|
||||
// Returns a list of players online
|
||||
function online_list() {
|
||||
if (config('TFSVersion') == 'TFS_10') return mysql_select_multi("SELECT `o`.`player_id` AS `id`, `p`.`name` as `name`, `p`.`level` as `level`, `p`.`vocation` as `vocation`, `g`.`name` as `gname` FROM `players_online` as `o` INNER JOIN `players` as `p` ON `o`.`player_id` = `p`.`id` LEFT JOIN `guild_membership` gm ON `o`.`player_id` = `gm`.`player_id` LEFT JOIN `guilds` g ON `gm`.`guild_id` = `g`.`id`");
|
||||
else return mysql_select_multi("SELECT `p`.`name` as `name`, `p`.`level` as `level`, `p`.`vocation` as `vocation`, `g`.`name` as `gname` FROM `players` p LEFT JOIN `guild_ranks` gr ON `gr`.`id` = `p`.`rank_id` LEFT JOIN `guilds` g ON `gr`.`guild_id` = `g`.`id` WHERE `p`.`online` = '1' ORDER BY `p`.`name` DESC;");
|
||||
}
|
||||
|
||||
|
||||
// Gets you the actual IP address even from users behind ISP proxies and so on.
|
||||
function getIP() {
|
||||
/*
|
||||
|
@ -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>
|
||||
|
@ -2,8 +2,30 @@
|
||||
|
||||
<h1>Who is online?</h1>
|
||||
<?php
|
||||
$array = online_list();
|
||||
if ($array) {
|
||||
|
||||
// Returns a list of players online
|
||||
$array = false;
|
||||
$loadFlags = ($config['country_flags']['enabled'] && $config['country_flags']['onlinelist']) ? true : false;
|
||||
|
||||
// Small 30 seconds players_online cache.
|
||||
$cache = new Cache('engine/cache/onlinelist');
|
||||
$cache->setExpiration(30);
|
||||
if ($cache->hasExpired()) {
|
||||
// Load online list data from SQL
|
||||
if ($config['TFSVersion'] == 'TFS_10') {
|
||||
$array = ($loadFlags === true) ? mysql_select_multi("SELECT `p`.`name` AS `name`, `p`.`level` AS `level`, `p`.`vocation` AS `vocation`, `g`.`name` AS `gname`, `za`.`flag` AS `flag` FROM `players_online` AS `o` INNER JOIN `players` AS `p` ON `o`.`player_id` = `p`.`id` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id` = `za`.`account_id` LEFT JOIN `guild_membership` AS `gm` ON `o`.`player_id` = `gm`.`player_id` LEFT JOIN `guilds` AS `g` ON `gm`.`guild_id` = `g`.`id`;") : mysql_select_multi("SELECT `p`.`name` AS `name`, `p`.`level` AS `level`, `p`.`vocation` AS `vocation`, `g`.`name` AS `gname` FROM `players_online` AS `o` INNER JOIN `players` AS `p` ON `o`.`player_id` = `p`.`id` LEFT JOIN `guild_membership` AS `gm` ON `o`.`player_id` = `gm`.`player_id` LEFT JOIN `guilds` AS `g` ON `gm`.`guild_id` = `g`.`id`;");
|
||||
} else {
|
||||
$array = ($loadFlags === true) ? mysql_select_multi("SELECT `p`.`name` as `name`, `p`.`level` as `level`, `p`.`vocation` as `vocation`, `g`.`name` as `gname`, `za`.`flag` as `flag` FROM `players` as `p` INNER JOIN `znote_accounts` as `za` ON `za`.`account_id` = `p`.`account_id` LEFT JOIN `guild_ranks` as `gr` ON `gr`.`id` = `p`.`rank_id` LEFT JOIN `guilds` as `g` ON `gr`.`guild_id` = `g`.`id` WHERE `p`.`online` = '1' ORDER BY `p`.`name` DESC;") : mysql_select_multi("SELECT `p`.`name` as `name`, `p`.`level` as `level`, `p`.`vocation` as `vocation`, `g`.`name` as `gname` FROM `players` as `p` LEFT JOIN `guild_ranks` as `gr` ON `gr`.`id` = `p`.`rank_id` LEFT JOIN `guilds` as `g` ON `gr`.`guild_id` = `g`.`id` WHERE `p`.`online` = '1' ORDER BY `p`.`name` DESC;");
|
||||
}
|
||||
// End loading data from SQL
|
||||
$cache->setContent($array);
|
||||
$cache->save();
|
||||
} else {
|
||||
$array = $cache->load();
|
||||
}
|
||||
// End cache
|
||||
|
||||
if ($array !== false) {
|
||||
?>
|
||||
|
||||
<table id="onlinelistTable" class="table table-striped table-hover">
|
||||
@ -13,17 +35,21 @@ if ($array) {
|
||||
<th>Level:</th>
|
||||
<th>Vocation:</th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($array as $value) {
|
||||
<?php
|
||||
foreach ($array as $value) {
|
||||
$url = url("characterprofile.php?name=". $value['name']);
|
||||
echo '<tr class="special" onclick="javascript:window.location.href=\'' . $url . '\'">';
|
||||
echo '<td><a href="characterprofile.php?name='. $value['name'] .'">'. $value['name'] .'</a></td>';
|
||||
if (!empty($value['gname'])) echo '<td><a href="guilds.php?name='. $value['gname'] .'">'. $value['gname'] .'</a></td>'; else echo '<td></td>';
|
||||
echo '<td>'. $value['level'] .'</td>';
|
||||
echo '<td>'. vocation_id_to_name($value['vocation']) .'</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
$flag = ($loadFlags === true && strlen($value['flag']) > 1) ? '<img src="' . $config['country_flags']['server'] . '/' . $value['flag'] . '.png"> ' : '';
|
||||
$guildname = (!empty($value['gname'])) ? '<a href="guilds.php?name='. $value['gname'] .'">'. $value['gname'] .'</a>' : '';
|
||||
?>
|
||||
<tr class="special" onclick="javascript:window.location.href='<?php echo $url; ?>'">
|
||||
<td><?php echo $flag; ?><a href="characterprofile.php?name=<?php echo $value['name']; ?>"><?php echo $value['name']; ?></a></td>
|
||||
<td><?php echo $guildname; ?></td>
|
||||
<td><?php echo $value['level']; ?></td>
|
||||
<td><?php echo vocation_id_to_name($value['vocation']); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
|
Loading…
x
Reference in New Issue
Block a user