-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgmaccount.php
More file actions
95 lines (76 loc) · 2.3 KB
/
gmaccount.php
File metadata and controls
95 lines (76 loc) · 2.3 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
$pagetitle = 'Account';
require 'common.php';
$_GET['name'] = substr($_GET['name'], 0, 16);
if (!$logged)
{
$tpl->message = 'You must be logged in to view this page.';
$tpl->Execute(null);
exit;
}
if (!$GM)
{
$tpl->message = 'You must be a Game Master to view this page.';
$tpl->Execute(null);
exit;
}
if (empty($_GET['name']))
{
$tpl->message = 'No character name specified.';
$tpl->Execute(null);
exit;
}
$account = webcp_db_fetchall("SELECT * FROM accounts WHERE username = ?", strtolower($_GET['name']));
if (empty($account[0]))
{
$tpl->message = 'Account does not exist.';
$tpl->Execute(null);
exit;
}
$account = $account[0];
$ip1 = $account['regip'];
$ip2 = $account['lastip'];
$account['computer_str'] = $account['computer'];
$account['hdid_str'] = sprintf("%08x", (double)$account['hdid']);
$account['hdid_str'] = strtoupper(substr($account['hdid_str'],0,4).'-'.substr($account['hdid_str'],4,4));
$account['created_str'] = date('r', $account['created']);
$account['lastused_str'] = date('r', $account['lastused']);
$account['city1'] = '';
$account['region1'] = '';
$account['city2'] = '';
$account['region2'] = '';
$lastlogin = time() - $account['lastused'];
function timesince($lastlogin)
{
$timearray = array (
31536000 => 'year',
2592000 => 'month',
604800 => 'week',
86400 => 'day',
3600 => 'hour',
60 => 'minute',
1 => 'second'
);
foreach ($timearray as $unit => $text) {
if ($lastlogin < $unit) continue;
$numberOfUnits = floor($lastlogin / $unit);
return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'').' ago';
}
}
$account['last_login'] = timesince($lastlogin);
$tpl->account = $account;
$characters = webcp_db_fetchall("SELECT * FROM characters WHERE account = ? ORDER BY exp DESC", strtolower($_GET['name']));
foreach ($characters as &$character)
{
$character['name'] = ucfirst($character['name']);
$character['gender'] = $character['gender']?'Male':'Female';
$character['title'] = empty($character['title'])?'-':ucfirst($character['title']);
$character['exp'] = number_format($character['exp']);
$character['gm'] = $character['admin'] > 0;
$character['admin_str'] = adminrank_str($character['admin']);
}
unset($character);
$tpl->characters = $characters;
$pagetitle .= ': '.htmlentities($_GET['name']);
$tpl->pagetitle = $pagetitle;
$tpl->Execute('account');