1 | <?php
|
---|
2 |
|
---|
3 | $order_by = (isset($_GET['order'])) ? $_GET['order'] : 'name';
|
---|
4 | $dir = (isset($_GET['dir'])) ? $_GET['dir'] : 'down';
|
---|
5 | $order_dir = ($dir == 'up') ? 'ASC' : 'DESC';
|
---|
6 | $dir = ($dir == 'down') ? 'up' : 'down';
|
---|
7 | $dir_img = ($dir == 'down') ? '<img src="'.$html->Link('/imgs/inc/up.gif').'" alt="nahoru">' : '<img src="'.$html->Link('/imgs/inc/down.gif').'" alt="dolu" />';
|
---|
8 |
|
---|
9 |
|
---|
10 | function MakeLink($show, $sort)
|
---|
11 | {
|
---|
12 | global $dir, $dir_img, $html;
|
---|
13 |
|
---|
14 | if (isset($_GET['order']) and $_GET['order'] == $sort) $arrow = $dir_img;
|
---|
15 | else $arrow = '';
|
---|
16 | return($arrow.'<a href="'.$html->Link('/spolky/?order='.$sort.'&dir='.$dir).'">'.$show.'</a>');
|
---|
17 | }
|
---|
18 |
|
---|
19 | function GuildPages($row, $name)
|
---|
20 | {
|
---|
21 | global $server;
|
---|
22 |
|
---|
23 | if($row != '') return('<a href="http://'.$row.'/">www</a>');
|
---|
24 | else return('');
|
---|
25 | }
|
---|
26 |
|
---|
27 | function FrakceImg($frakce)
|
---|
28 | {
|
---|
29 | global $html;
|
---|
30 |
|
---|
31 | if($frakce == 0) return('<img src="'.$html->Link('/imgs/inc/h.gif').'" alt="horda" />');
|
---|
32 | else return('<img src="'.$html->Link('/imgs/inc/a.gif').'" alt="aliance" />');
|
---|
33 | }
|
---|
34 |
|
---|
35 | if(isset($Realm))
|
---|
36 | {
|
---|
37 | $db2 = $Realm->CharactersDatabase;
|
---|
38 |
|
---|
39 | if(count($QueryItems) > 3)
|
---|
40 | {
|
---|
41 | $GuildName = $QueryItems[3];
|
---|
42 | $DbResult = $db2->query('SELECT guildid FROM guild WHERE '.$System->SQLURLName('Name').'="'.$GuildName.'"');
|
---|
43 | $DbRow = $DbResult->fetch_assoc();
|
---|
44 | $_GET['id'] = $DbRow['guildid'];
|
---|
45 | include('spolek.php');
|
---|
46 | } else
|
---|
47 | {
|
---|
48 | echo('<h2 class="PageTitle">Seznam spolků</h2>');
|
---|
49 | echo('<table class="BaseTable">'.
|
---|
50 | '<tr>'.
|
---|
51 | '<th>'.MakeLink('', 'fraction').'</th>'.
|
---|
52 | '<th>'.MakeLink('Jméno spolku', 'name').'</th>'.
|
---|
53 | '<th>'.MakeLink('Celkem členů', 'member_count').'</th>'.
|
---|
54 | '<th>Členů online</th>'.
|
---|
55 | '<th>Guild master</th>'.
|
---|
56 | '<th>'.MakeLink('Webové stránky', 'homepage').'</th>'.
|
---|
57 | '</tr>');
|
---|
58 |
|
---|
59 |
|
---|
60 | $sql = $db2->query('SELECT `guild`.name, '.$System->SQLURLName('`guild`.name').' AS URLName, `guild`.guildid, FROM_UNIXTIME(`guild`.`createdate`) AS `createdate`, COUNT(`guild_member`.`guildid`) AS member_count ,`leader`.`race` IN (1, 3, 4, 7, 11) AS fraction , `leader`.`guid` AS leader FROM `guild` JOIN `guild_member` ON `guild_member`.`guildid` = `guild`.`guildid` JOIN `characters` AS `memebers` ON `memebers`.`guid`= `guild_member`.`guid` JOIN `characters` AS `leader` ON `leader`.`guid`= `guild`.`leaderguid` GROUP BY guild.name ORDER BY '.$order_by.' '.$order_dir.';');
|
---|
61 | while($row = $sql->fetch_assoc())
|
---|
62 | {
|
---|
63 | $DbResult = $db2->query('SELECT COUNT(*) AS online_mem FROM `guild_member`, `characters`, `guild` WHERE guild.guildid = '.$row['guildid'].' AND guild_member.guildid = guild.guildid AND guild_member.guid = characters.guid AND characters.online = 1');
|
---|
64 | $online_mem = $DbResult->fetch_assoc();
|
---|
65 | $DbResult = $db->query('SELECT Homepage FROM GuildInfo WHERE Guild='.$row['guildid'].' AND Realm='.$Realm->Id);
|
---|
66 | $DbRow = $DbResult->fetch_assoc();
|
---|
67 | $Homepage = $DbRow['Homepage'];
|
---|
68 | $date_arr = explode(' ', $row['createdate']);
|
---|
69 | $date = explode('-', $date_arr[0]);
|
---|
70 | $time_stp = explode(':', $date_arr[1]);
|
---|
71 | $time = mktime($time_stp[0], $time_stp[1], $time_stp[2], $date[1], $date[2], $date[0]);
|
---|
72 | $human_date = date('d.m.Y H:i:s', $time);
|
---|
73 | echo('<tr>'.
|
---|
74 | '<td align="center">'.FrakceImg($row['fraction']).'</td>'.
|
---|
75 | '<td align="center"><a href="'.$html->Link($row['URLName'].'/').'">'.$row['name'].'</a></td>'.
|
---|
76 | '<td align="center">'.$row['member_count'].'</td>'.
|
---|
77 | '<td align="center">'.$online_mem['online_mem'].'</td>'.
|
---|
78 | '<td align="center">'.$Realm->GuidToCharName($row['leader']).'</td>'.
|
---|
79 | '<td align="center">'.GuildPages($Homepage, $row['name']).'</td>'.
|
---|
80 | '</tr>');
|
---|
81 | }
|
---|
82 | echo('</table>');
|
---|
83 | }
|
---|
84 | } else echo('Musíte vybrat svět');
|
---|
85 |
|
---|
86 | ?>
|
---|