source: branches/old/guildy.php

Last change on this file was 448, checked in by george, 16 years ago
  • Přesunuto: Obsah kořenové složky byl přesunut do složky trunk a beta web přesunut do branches/beta.
File size: 6.0 KB
Line 
1<?php
2
3include('global.php');
4ShowHeader();
5
6require_once("minimanager/scripts/defines.php");
7
8$RanksEN = array('Guildmaster', 'Veteran', 'Intendant', 'Support Officer', 'PR Officer', 'Officer', 'Famed Member',
9'Member', 'Rokie', 'Newbie');
10$RanksCZ = array('Pán cechu', 'Veterán', 'Vrchní správce', 'Pomocný důstojník', 'PR důstojník', 'Důstojník', 'Proslavený člen', 'Člen', 'Zelenáč', 'Nováček');
11
12$order_by = (isset($_GET['order_by'])) ? $Database->real_escape_string($_GET['order_by']) : "name";
13
14$dir = (isset($_GET['dir'])) ? $Database->real_escape_string($_GET['dir']) : 1;
15$order_dir = ($dir) ? "ASC" : "DESC";
16$dir = ($dir) ? 0 : 1;
17
18function HeaderText($Text, $Column)
19{
20 global $dir, $order_by, $GuildId;
21 echo('<th><a href="?order_by='.$Column.'&amp;dir='.$dir.'">'.($order_by==$Column ? '<img src="images/online_player/arr_'.($dir ? 'up' : 'dw').'.gif" /> ' : '').$Text.'</a></th>');
22}
23
24function HeaderTextGuild($Text, $Column)
25{
26 global $dir, $order_by, $GuildId;
27 echo('<th><a href="?guild='.$GuildId.'&amp;order_by='.$Column.'&amp;dir='.$dir.'">'.($order_by==$Column ? '<img src="images/online_player/arr_'.($dir ? 'up' : 'dw').'.gif" /> ' : '').$Text.'</a></th>');
28}
29
30$Database->select_db($Config['Mangos']['DatabaseCharacters']);
31if(!array_key_exists('guild', $_GET))
32{
33 echo('<h3>Seznam spolků:</h3><div align="center">');
34 echo('<table class="TableGuilda" border="1" cellpadding="3" cellspacing="0"><tr>');
35 HeaderText('F', 'fraction');
36 HeaderText('Název', 'name');
37 HeaderText('Počet členů', 'member_count');
38 HeaderText('Součet levelů', 'guild_level');
39 HeaderText('Součet bodů cti', 'guild_honor');
40 HeaderText('Webové stránky', '');
41 echo('</tr>');
42// DB_Query(' COUNT(guild_member.guildid) as member_count FROM guild JOIN guild_member ON guild_member.guildid = guild.guildid GROUP BY guild.name ORDER BY member_count DESC');
43 $Result = $Database->query('SELECT `guild`.homepage, `guild`.name, guild.guildid, COUNT(`guild_member`.`guildid`) as member_count, SUM(SUBSTRING_INDEX(SUBSTRING_INDEX(`memebers`.`data`, " ", 35), " ", -1)) as guild_level, SUM(SUBSTRING_INDEX(SUBSTRING_INDEX(`memebers`.`data`, " ", '.(CHAR_DATA_OFFSET_HONOR_POINTS+1).'), " ", -1)) as guild_honor, `leader`.`race` IN (1, 3, 4, 7, 11) as fraction 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);
44 while($Guild = $Result->fetch_array())
45 {
46 if($Guild['fraction'] == 1) $Fraction = 'aliance'; else $Fraction = 'horda';
47 if($Guild['homepage'] == '') $Guild['homepage'] = '&nbsp;';
48 else $Guild['homepage'] = '<a href="http://'.$Guild['homepage'].'/">'.$Guild['homepage'].'</a>';
49 echo('<tr><td><img src="images/online_player/'.$Fraction.'.gif" alt="'.$Fraction.'"></td><td><a href="?guild='.$Guild['guildid'].'">'.$Guild['name'].'</a></td><td>'.$Guild['member_count'].'</td><td>'.$Guild['guild_level'].'</td><td>'.$Guild['guild_honor'].'</td><td>'.$Guild['homepage'].'</td></tr>');
50 }
51 echo('</table></div>');
52} else {
53 $GuildId = addslashes($_GET['guild']);
54 $Result = $Database->query('SELECT `guild`.name, guild.guildid, guild.leaderguid, COUNT(`guild_member`.`guildid`) as member_count, SUM(SUBSTRING_INDEX(SUBSTRING_INDEX(`characters`.`data`, " ", '.(CHAR_DATA_OFFSET_LEVEL+1).'), " ", -1)) as guild_level, SUM(SUBSTRING_INDEX(SUBSTRING_INDEX(`characters`.`data`, " ", '.(CHAR_DATA_OFFSET_HONOR_POINTS+1).'), " ", -1)) as guild_honor FROM `guild` JOIN `guild_member` ON `guild_member`.`guildid` = `guild`.`guildid` JOIN `characters` ON `characters`.`guid`= `guild_member`.`guid` WHERE guild.guildid='.$GuildId.' GROUP BY guild.name');
55 if($Result->num_rows > 0)
56 {
57 $Guild = $Result->fetch_array();
58 // if($Guild['homepage'] != '') $Guild['name'] = $Guild['name'].' <a href="'.$Guild['homepage'].'">WWW</a>';
59 //if($Guild['info'] != '') $Guild['info'] = ''.$Guild['info'].'</i>';
60 echo('<h3>Seznam členů spolku '.$Guild['name'].'</h3><div align="center">');
61 $Result = $Database->select('characters', 'name', $Guild['leaderguid'].'=guid');
62 $GuildMaster = $Result->fetch_array();
63 echo('Vedoucí spolku: '.$GuildMaster['name'].'<br>');
64 echo('<table class="TableGuilda" border="1" cellpadding="1" cellspacing="0">');
65 echo('<tr>');
66 HeaderTextGuild('Jméno', 'name');
67 HeaderTextGuild('Úroveň', 'level');
68 HeaderTextGuild('Hodnost', 'rank');
69 HeaderTextGuild('Body cti', 'honor');
70 echo('</tr>');
71 //echo('<tr><td colspan="2" Class="TdGuilda">Informace: '.$Guild['public_info'].'</td></tr>');
72
73 $GuildRanks = array();
74 $Result = $Database->select('guild_rank', '*', 'guildid='.$Guild['guildid']);
75 while($GuildRank = $Result->fetch_array()) $GuildRanks[$GuildRank['rid']] = $GuildRank;
76
77 $Result = $Database->query('SELECT guild_member.rank, guild_member.guid, SUBSTRING_INDEX(SUBSTRING_INDEX(characters.data," ", '.(CHAR_DATA_OFFSET_LEVEL+1).'), " ", -1)*1 as level, SUBSTRING_INDEX(SUBSTRING_INDEX(characters.data," ", '.(CHAR_DATA_OFFSET_HONOR_POINTS+1).'), " ", -1)*1 as honor, characters.name FROM guild_member JOIN `characters` ON guild_member.guid = characters.guid AND guild_member.guildid='.$Guild['guildid'].' ORDER BY '.$order_by.' '.$order_dir);
78 while($Member = $Result->fetch_array())
79 {
80 if(array_key_exists($Member['rank'] + 1, $GuildRanks))
81 $GuildRank = $GuildRanks[$Member['rank'] + 1]['rname'];
82 else $GuildRank = '&nbsp;';
83// $DataParts = explode(' ', $Member['data']);
84// $Member['level'] .= ','.$DataParts[34];
85 echo('<tr><td width="30%">'.$Member['name'].'</td><td>'.$Member['level'].'</td><td>'.$GuildRank.'</td><td>'.$Member['honor'].'</td></tr>');
86 }
87 echo('</table>');
88 echo('<a href="guildy.php">Zpět na seznam spolků</a></div>');
89 } else echo('Spolek nenalezen!');
90}
91
92ShowFooter();
93?>
Note: See TracBrowser for help on using the repository browser.