-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathguildmembers.php
70 lines (53 loc) · 1.75 KB
/
guildmembers.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
$pagetitle = 'Guild Members';
require 'common.php';
if (empty($_GET['tag']))
{
$tpl->message = 'No guild tag specified.';
$tpl->Execute(null);
exit;
}
$guild = webcp_db_fetchall("SELECT * FROM guilds WHERE tag = ?", strtoupper($_GET['tag']));
if (empty($guild[0]))
{
$tpl->message = 'Guild does not exist.';
$tpl->Execute(null);
exit;
}
$guild = $guild[0];
$guild['name'] = ucfirst($guild['name']);
$guild['ranks'] = explode(',', $guild['ranks']);
$tpl->guild = $guild;
$count = webcp_db_fetchall("SELECT COUNT(1) as count FROM characters WHERE guild = ?", $guild['tag']);
$count = $count[0]['count'];
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$pages = ceil($count / $perpage);
if ($page < 1 || $page > $pages)
{
$page = max(min($page, $pages), 1);
}
$start = ($page-1) * $perpage;
$members = webcp_db_fetchall("SELECT * FROM characters WHERE guild = ? ORDER BY guild_rank ASC, name ASC LIMIT ?,?", $guild['tag'], $start, $perpage);
foreach ($members as &$member)
{
$member['name'] = ucfirst($member['name']);
$member['gender'] = $member['gender']?'Male':'Female';
$member['title'] = empty($member['title'])?'-':ucfirst($member['title']);
$member['exp'] = number_format($member['exp']);
$member['gm'] = $member['admin'] > 0;
$member['rank'] = guildrank_str($guild['ranks'], $member['guild_rank']);
}
unset($member);
$pagination = generate_pagination($pages, $page, '?tag=' . $guild['tag']);
$tpl->page = $page;
$tpl->pages = $pages;
$tpl->pagination = $pagination;
$tpl->perpage = $perpage;
$tpl->showing = count($members);
$tpl->start = $start+1;
$tpl->end = min($start+$perpage, $count);
$tpl->count = $count;
$tpl->members = $members;
$pagetitle .= ': '.htmlentities($guild['tag']);
$tpl->pagetitle = $pagetitle;
$tpl->Execute('guildmembers');