1<?php
2require_once 'engine/init.php';
3theme_open();
4if (!$config['toponline']['enabled']) {
5echo 'This page has been disabled at config.php.';
6theme_close();
7 exit();
8}
9$limit = $config['toponline']['limit'];
10$type = (isset($_GET['type'])) ? getValue($_GET['type'] ?? null) : false;
11
12function onlineTimeTotal($value)
13{
14 $hours = floor($value / 3600);
15 $value = $value - $hours * 3600;
16 $minutes = floor($value / 60);
17 return '<font color="black">'.$hours.'h '.$minutes.'m</font>';
18}
19function hours_and_minutes($value, $color = 1)
20{
21 $hours = floor($value / 3600);
22 $value = $value - $hours * 3600;
23 $minutes = floor($value / 60);
24 if($color != 1)
25 return '<font color="black">'.$hours.'h '.$minutes.'m</font>';
26 else
27 if($hours >= 12)
28 return '<font color="red">'.$hours.'h '.$minutes.'m</font>';
29 elseif($hours >= 6)
30 return '<font color="black">'.$hours.'h '.$minutes.'m</font>';
31 else
32 return '<font color="green">'.$hours.'h '.$minutes.'m</font>';
33}
34if(empty($type))
35 $znotePlayers = db()->fetchAll('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 ?', [(int)$limit]);
36elseif($type == "sum")
37 $znotePlayers = db()->fetchAll('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 ?', [(int)$limit]);
38elseif($type >= 1 && $type <= 4)
39 $znotePlayers = db()->fetchAll('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 ?', [(int)$limit]);
40
41view('toponline');
42
43theme_close();
44