source: trunk/pages/online-hraci.php

Last change on this file was 701, checked in by george, 15 years ago
  • Opraveno: Řazení společného výpisu online hráčů.
File size: 5.8 KB
Line 
1<?php
2
3$order_by = (isset($_GET['order'])) ? $db->real_escape_string($_GET['order']) : 'name';
4$dir = (isset($_GET['dir'])) ? $db->real_escape_string($_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="vzestupně" />' : '<img src="'.$html->Link('/imgs/inc/down.gif').'" alt="sestupně"/>';
8
9function MakeLink($show, $sort)
10{
11 global $dir, $dir_img, $html;
12
13 if(isset($_GET['order']) and $_GET['order'] == $sort)
14 {
15 $arrow = $dir_img;
16 }
17 else
18 {
19 $arrow = '';
20 }
21 return($arrow.'<a href="'.$html->Link('/online-hraci/?order='.$sort.'&amp;dir='.$dir).'">'.$show.'</a>');
22}
23
24echo('<h3 class="PageTitle">Online hráči</h3>');
25
26if(array_key_exists('RealmIndex', $_COOKIE))
27{
28 $Realm = new Realm($System, $_COOKIE['RealmIndex']);
29 echo('<div style="text-align: center">Celkem '.$Realm->OnlineCharactersCount().' hráčů.</div>'.
30 '<table class="BaseTable">
31 <tr>
32 <th align="center">Frakce</th>
33 <th align="center">'.MakeLink('Jméno', 'name').'</th>
34 <th align="center">'.MakeLink('Rasa', 'race').'</th>
35 <th align="center">'.MakeLink('Třída', 'class').'</th>
36 <th align="center">'.MakeLink('Úroveň', 'level').'</th>
37 <th align="center">'.MakeLink('Mapa', 'map').'</th>
38 <th align="center">'.MakeLink('Body cti', 'highest_rank').'<br />'.
39 MakeLink('Body arén', 'arena_points').'</th></tr>');
40
41 $sql = $Realm->CharactersDatabase->query('SELECT guid, name, race, class, zone, map, '.
42 'CAST( SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, " ", '.$Config['Mangos']['CharacterDataOffset']['HonorPoints'].'+1), " ", -1) AS UNSIGNED) AS highest_rank, '.
43 'CAST( SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, " ", '.$Config['Mangos']['CharacterDataOffset']['Level'].' + 1), " ", -1) AS UNSIGNED) AS level, '.
44 'CAST( SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, " ", '.$Config['Mangos']['CharacterDataOffset']['ArenaPoints'].' + 1), " ", -1) AS UNSIGNED) AS arena_points, '.
45 'mid(lpad( hex( CAST(substring_index(substring_index(data, " ", '.$Config['Mangos']['CharacterDataOffset']['Gender'].' + 1), " ", -1) as unsigned) ), 8, 0), 4, 1) AS gender '.
46 'FROM `characters` WHERE `online`= 1 ORDER BY `'.$order_by.'` '.$order_dir);
47 while($row = $sql->fetch_assoc())
48 {
49 $aliance = array(1, 3, 4, 7, 11);
50 $frakce = (in_array($row['race'], $aliance)) ? '<img src="'.$html->Link('/imgs/inc/a.gif').'" alt="aliance"/>' : '<img src="'.$html->Link('/imgs/inc/h.gif').'" alt="horda" />';
51 $gender = ($row['gender'] == 0) ? '0' : '1';
52 echo('<tr>
53 <td align="center">'.$frakce.'</td>
54 <td align="center">'.$row['name'].'</td>
55 <td align="center"><img src="'.$html->Link('/imgs/icons/'.$row['race'].'-'.$gender.'.gif').'" alt="rasa" /></td>
56 <td align="center"><img src="'.$html->Link('/imgs/icons/'.$row['class'].'.gif').'" alt="třída" /></td>
57 <td align="center">'.$row['level'].'</td>
58 <td align="center">'.$server->MapName($row['map']).'<br />('.$server->ZoneName($row['zone']).')</td>
59 <td align="center">'.$row['highest_rank'].'<br />'.$row['arena_points'].'</td></tr>');
60 }
61 echo('</table>');
62} else
63{
64 $PlayerList = array();
65 $DbResult2 = $System->Database->query('SELECT * FROM Realm WHERE Enabled =1');
66 while($DbRealm = $DbResult2->fetch_assoc())
67 {
68 $Realm = new Realm($System, $DbRealm['Id']);
69 $sql = $Realm->CharactersDatabase->query('SELECT guid, name, race, class, zone, map, '.
70 'CAST( SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, " ", '.$Config['Mangos']['CharacterDataOffset']['HonorPoints'].'+1), " ", -1) AS UNSIGNED) AS highest_rank, '.
71 'CAST( SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, " ", '.$Config['Mangos']['CharacterDataOffset']['Level'].' + 1), " ", -1) AS UNSIGNED) AS level, '.
72 'CAST( SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, " ", '.$Config['Mangos']['CharacterDataOffset']['ArenaPoints'].' + 1), " ", -1) AS UNSIGNED) AS arena_points, '.
73 'mid(lpad( hex( CAST(substring_index(substring_index(data, " ", '.$Config['Mangos']['CharacterDataOffset']['Gender'].' + 1), " ", -1) as unsigned) ), 8, 0), 4, 1) AS gender '.
74 'FROM `characters` WHERE `online`= 1');
75 $I = 0;
76 while($DbRow = $sql->fetch_assoc())
77 {
78 $DbRow['svet'] = $DbRealm['Name'];
79 $PlayerList[$DbRow[$order_by].$I] = $DbRow;
80 $I++;
81 }
82 }
83
84 echo('<div style="text-align: center">Celkem '.count($PlayerList).' hráčů ve všech světech.</div>'.
85 '<table class="BaseTable">
86 <tr>'.
87 '<th align="center">Frakce</th>'.
88 '<th align="center">'.MakeLink('Jméno', 'name').'</th>'.
89 '<th align="center">'.MakeLink('Rasa', 'race').'</th>'.
90 '<th align="center">'.MakeLink('Třída', 'class').'</th>'.
91 '<th align="center">'.MakeLink('Úroveň', 'level').'</th>'.
92 '<th align="center">'.MakeLink('Svět', 'svet').'</th>'.
93 '</tr>');
94
95 if($order_dir == 'ASC') ksort($PlayerList);
96 else krsort($PlayerList);
97
98 foreach($PlayerList as $row)
99 {
100 $aliance = array(1, 3, 4, 7, 11);
101 $frakce = (in_array($row['race'], $aliance)) ? '<img src="'.$html->Link('/imgs/inc/a.gif').'" alt="aliance"/>' : '<img src="'.$html->Link('/imgs/inc/h.gif').'" alt="horda" />';
102 $gender = ($row['gender'] == 0) ? '0' : '1';
103 echo('<tr>'.
104 '<td align="center">'.$frakce.'</td>'.
105 '<td align="center">'.$row['name'].'</td>'.
106 '<td align="center"><img src="'.$html->Link('/imgs/icons/'.$row['race'].'-'.$gender.'.gif').'" alt="rasa" /></td>'.
107 '<td align="center"><img src="'.$html->Link('/imgs/icons/'.$row['class'].'.gif').'" alt="třída" /></td>'.
108 '<td align="center">'.$row['level'].'</td>'.
109 '<td align="center">'.$row['svet'].'</td>'.
110 '</tr>');
111 }
112 echo('</table>');
113}
114
115?>
Note: See TracBrowser for help on using the repository browser.