forked from greensea/seavpn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccount.php
More file actions
63 lines (46 loc) · 1.65 KB
/
account.php
File metadata and controls
63 lines (46 loc) · 1.65 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
<?php
require_once('includes/header.php');
require_once('includes/vpn.php');
$smarty->assign('title', _('My Account'));
if (user_isonline() == false) {
account_login();
}
else {
account_main();
}
die();
function account_login() {
global $smarty;
$smarty->assign('tip_title', _('Please login'));
$smarty->assign('tip_msg', _('You have to login before access My Account page'));
$smarty->assign('redirect_url', 'login.php');
$smarty->display('tip.html');
}
function account_main() {
global $smarty;
$user = user_isonline();
$vpn = vpn_list($user['id']);
foreach ($vpn as $key => $value) {
$arr = vpn_accountstat_monthly($value['username']);
$arr['inbandstr'] = size2readable($arr['in']);
$arr['outbandstr'] = size2readable($arr['out']);
$arr['usedbandstr'] = size2readable($arr['in'] + $arr['out']);
$arr['availbandstr'] = size2readable($value['trafficquota'] - $arr['in'] - $arr['out']);
if ($value['trafficquota'] > 0) {
$arr['percentused'] = sprintf('%.0f', round(($arr['in'] + $arr['out']) * 100 / $value['trafficquota']));
}
else {
$arr['percentused'] = '100+';
}
$arr['onlinetimestr'] = time2readable($arr['sessiontime']);
$vpn[$key]['totalbandstr'] = size2readable($value['trafficquota']);
$vpn[$key]['validfromstr'] = strftime('%Y-%m-%d %H:%M', $vpn[$key]['validfrom']);
$vpn[$key]['validtostr'] = strftime('%Y-%m-%d %H:%M', $vpn[$key]['validto']);
$vpn[$key]['daysleft'] = ceil(($vpn[$key]['validto'] - time()) / 86400);
$vpn[$key]['stat_monthly'] = $arr;
$vpn[$key]['password'] = htmlspecialchars($vpn[$key]['password']);
}
$smarty->assign('vpns', $vpn);
$smarty->display('account.html');
}
?>