-
Notifications
You must be signed in to change notification settings - Fork 13
/
server.php
51 lines (39 loc) · 1.14 KB
/
server.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
require_once('includes/header.php');
$user = user_isonline();
if ($user === false) {
if (!isset($_GET['json'])) {
$smarty->assign('tip_title', _('Login Required'));
$smarty->assign('tip_msg', _('You have to login to access Server List'));
$smarty->display('tip.html');
}
else {
echo json_encode(array('error' => _('You have to login to access Server List')));
}
die();
}
$servers = db_quick_fetch('server', 'WHERE enabled=1');
for ($i = 0; $i < count($servers); $i++) {
if ($user === false) {
$servers[$i]['address'] = _("*HIDDEN*");
}
$servers[$i]['uptimestr'] = time2readable($servers[$i]['uptime'], 3);
/// 处理在线信息及流量信息
if (time() - $servers[$i]['heartbeat'] > SERVER_ALIVE_THRESHOLD) {
$servers[$i]['isonline'] = 0;
$servers[$i]['rtratestr'] = _('Unknown');
}
else {
$servers[$i]['isonline'] = 1;
$servers[$i]['rtrate'] = $servers[$i]['rxrate'] + $servers[$i]['txrate'];
$servers[$i]['rtratestr'] = bps2readable($servers[$i]['rtrate']);
}
}
if (isset($_GET['json'])) {
die(json_encode($servers));
}
else {
$smarty->assign('servers', $servers);
$smarty->display('server.html');
}
?>