Update toponline.php

This commit is contained in:
Atte 2014-09-10 10:57:44 +03:00
parent cb5316d958
commit 4b97c12edb

View File

@ -1,23 +1,25 @@
<?php <?php
require_once 'engine/init.php'; require_once 'engine/init.php';
include 'layout/overall/header.php'; include 'layout/overall/header.php';
$powergamers = $config['powergamers']; $toponline = $config['toponline'];
$limit = $powergamers['limit']; $limit = $toponline['limit'];
if ($config['powergamers_enabled'] === false) { if ($config['toponline_enabled'] === false) {
echo 'Powergamers page has been disabled at config.php.'; echo 'This page has been disabled at config.php.';
include 'layout/overall/footer.php'; include 'layout/overall/footer.php';
exit(); exit();
} }
?>
<style>
#selectedP {
text-decoration: underline
}
</style>
<?php
$type = $_GET['type']; $type = $_GET['type'];
function onlineTimeTotal($value)
{
$hours = floor($value / 3600);
$value = $value - $hours * 3600;
$minutes = floor($value / 60);
return '<font color="black">'.$hours.'h '.$minutes.'m</font>';
}
function hours_and_minutes($value, $color = 1) function hours_and_minutes($value, $color = 1)
{ {
$hours = floor($value / 3600); $hours = floor($value / 3600);
@ -37,35 +39,37 @@ function hours_and_minutes($value, $color = 1)
if(empty($type)) if(empty($type))
$znotePlayers = mysql_select_multi('SELECT * FROM `znote_players` AS `z` JOIN `players` AS `p` WHERE `p`.`id`=`z`.`player_id` and `p`.`group_id` < 3 ORDER BY `onlinetimetoday` DESC LIMIT '.$limit); $znotePlayers = mysql_select_multi('SELECT * FROM `znote_players` AS `z` JOIN `players` AS `p` WHERE `p`.`id`=`z`.`player_id` and `p`.`group_id` < 3 ORDER BY `onlinetimetoday` DESC LIMIT '.$limit);
elseif($type == "sum") elseif($type == "sum")
$znotePlayers = mysql_select_multi('SELECT * FROM `znote_players` AS `z` JOIN `players` AS `p` WHERE `p`.`id`=`z`.`player_id` and `p`.`group_id` < 3 ORDER BY `onlinetime1`+`onlinetime2`+`onlinetime3`+`onlinetime4`+`onlinetime5`+`onlinetime6`+`onlinetime7`+`onlinetimetoday` DESC LIMIT ' . $limit); $znotePlayers = mysql_select_multi('SELECT * FROM `znote_players` AS `z` JOIN `players` AS `p` WHERE `p`.`id`=`z`.`player_id` and `p`.`group_id` < 3 ORDER BY `z`.`onlinetimeall` DESC LIMIT '. $limit);
elseif($type >= 1 && $type <= 7) elseif($type >= 1 && $type <= 4)
$znotePlayers = mysql_select_multi('SELECT * FROM `znote_players` AS `z` JOIN `players` AS `p` WHERE `p`.`id`=`z`.`player_id` and `p`.`group_id` < 3 ORDER BY `onlinetime' . (int) $type . '` DESC LIMIT '.$limit); $znotePlayers = mysql_select_multi('SELECT * FROM `znote_players` AS `z` JOIN `players` AS `p` WHERE `p`.`id`=`z`.`player_id` and `p`.`group_id` < 3 ORDER BY `onlinetime' . (int) $type . '` DESC LIMIT '.$limit);
echo '<CENTER><H2>Ranking of powergamers</H2></CENTER> echo '<CENTER><H2>Most online on server name</H2></CENTER>
<BR> <BR>
<table class="table table-striped"> <table class="table table-striped">
<td><center><b>#</b></center></td> <td><center><b>#</b></center></td>
<td width="10%"><b>Name</b></td>'; <td width="10%"><b>Name</b></td>';
if($type == "sum") if($type == "sum")
echo '<TD bgcolor="red"><b><center><a href="?subtopic=onlinetime&type=sum">Total</a></center></B></TD>'; echo '<td ><center><b><center><a href="?subtopic=onlinetime&type=sum">Total</a></center></B></TD>';
else else
echo '<TD bgcolor="yellow"><b><center><a href="?subtopic=onlinetime&type=sum">Total</a></center></B></TD>'; echo '<td ><center><b><center><a href="?subtopic=onlinetime&type=sum">Total</a></center></B></TD>';
for($i = 3; $i >= 2; $i--) for($i = 3; $i >= 2; $i--)
{ {
if($type == $i) if($type == $i)
echo '<TD bgcolor="red"><b><center><a href="?subtopic=onlinetime&type='.$i.'">'.$i.' Days Ago</a></center></B></TD>'; echo '<TD ><b><center><a href="?subtopic=onlinetime&type='.$i.'">'.$i.' Days Ago</a></center></B></TD>';
else else
echo '<TD bgcolor="yellow"><b><center><a href="?subtopic=onlinetime&type='.$i.'">'.$i.' Days Ago</a></center></B></TD>'; echo '<TD ><b><center><a href="?subtopic=onlinetime&type='.$i.'">'.$i.' Days Ago</a></center></B></TD>';
} }
if($type == 1) if($type == 1)
echo '<TD bgcolor="red"><b><center><a href="?subtopic=onlinetime&type=1">1 Day Ago</a></center></B></TD>'; echo '<TD ><b><center><a href="?subtopic=onlinetime&type=1">1 Day Ago</a></center></B></TD>';
else else
echo '<TD bgcolor="yellow"><b><center><a href="?subtopic=onlinetime&type=1">1 Day Ago</a></center></B></TD>'; echo '<TD ><b><center><a href="?subtopic=onlinetime&type=1">1 Day Ago</a></center></B></TD>';
if(empty($type)) if(empty($type))
echo '<TD bgcolor="red"><b><center><a href="?subtopic=onlinetime">Today</a></center></B></TD>'; echo '<TD><b><center><a href="?subtopic=onlinetime">Today</a></center></B></TD>';
else else
echo '<TD bgcolor="yellow"><b><center><a href="?subtopic=onlinetime">Today</a></center></B></TD></tr>'; echo '<TD ><b><center><a href="?subtopic=onlinetime">Today</a></center></B></TD>';
echo '</TR>';
$number_of_rows = 1; $number_of_rows = 1;
if($znotePlayers) if($znotePlayers)
@ -74,8 +78,9 @@ foreach($znotePlayers as $player)
echo '<td><center>'. $number_of_rows . '.</center></td>'; echo '<td><center>'. $number_of_rows . '.</center></td>';
echo '<td><a href="characterprofile.php?name=' .$player['name']. '">' .$player['name']. '</a>'; echo '<td><a href="characterprofile.php?name=' .$player['name']. '">' .$player['name']. '</a>';
echo '<br> ' .$player['level']. ' '.htmlspecialchars(vocation_id_to_name($player['vocation'])).' '; echo '<br> ' .$player['level']. ' '.htmlspecialchars(vocation_id_to_name($player['vocation'])).' ';
echo '<td align="right">'.hours_and_minutes($player['onlinetime1'] + $player['onlinetime2'] + $player['onlinetime3'] + $player['onlinetimetoday'], 0).'</td>'; echo '<td ><center>' .onlineTimeTotal($player['onlinetimeall']).'</td>';
echo '<td align="right">'.hours_and_minutes($player['onlinetime3']).'</td><td align="right">'.hours_and_minutes($player['onlinetime2']).'</td><td align="right">'.hours_and_minutes($player['onlinetime1']).'</td><td align="right">'.hours_and_minutes($player['onlinetimetoday']).'</td></tr>'; $number_of_rows++;
echo '<td ><center>'.hours_and_minutes($player['onlinetime3']).'</center></td><td ><center>'.hours_and_minutes($player['onlinetime2']).'</center></td><td ><center>'.hours_and_minutes($player['onlinetime1']).'</center></td><td ><center>'.hours_and_minutes($player['onlinetimetoday']).'</center></td></tr>';
} }
echo '</TABLE></div>'; echo '</TABLE></div>';
?> ?>