forked from minimanager/minimanager
/
top100.php
436 lines (399 loc) · 21.4 KB
/
top100.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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
<?php
require_once 'header.php';
require_once 'libs/char_lib.php';
valid_login($action_permission['read']);
function top100($realmid, &$sqlr, &$sqlc)
{
global $output, $lang_top,
$realm_db, $characters_db, $server,
$itemperpage, $developer_test_mode, $multi_realm_mode;
$realm_id = $realmid;
$sqlc->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
//==========================$_GET and SECURE========================
$type = (isset($_GET['type'])) ? $sqlc->quote_smart($_GET['type']) : 'level';
if (preg_match('/^[_[:lower:]]{1,10}$/', $type)); else $type = 'level';
$start = (isset($_GET['start'])) ? $sqlc->quote_smart($_GET['start']) : 0;
if (is_numeric($start)); else $start=0;
$order_by = (isset($_GET['order_by'])) ? $sqlc->quote_smart($_GET['order_by']) : 'level';
if (preg_match('/^[_[:lower:]]{1,14}$/', $order_by)); else $order_by = 'level';
$dir = (isset($_GET['dir'])) ? $sqlc->quote_smart($_GET['dir']) : 1;
if (preg_match('/^[01]{1}$/', $dir)); else $dir=1;
$order_dir = ($dir) ? 'DESC' : 'DESC';
$dir = ($dir) ? 0 : 1;
//==========================$_GET and SECURE end========================
$type_list = array('level', 'stat', 'defense', 'attack', 'resist', 'crit_hit', 'pvp');
if (in_array($type, $type_list));
else $type = 'level';
$result = $sqlc->query('SELECT count(*) FROM characters');
$all_record = $sqlc->result($result, 0);
$all_record = (($all_record < 100) ? $all_record : 100);
$result = $sqlc->query('SELECT characters.guid, characters.name, race, class, gender, level, totaltime, online, money, health,
power1,
arenaPoints as arena, totalHonorPoints as honor, totalKills as kills,
guildid as gname,
strength AS str,
agility AS agi,
stamina AS sta,
intellect AS intel,
spirit AS spi,
armor AS armor,
blockPct AS block,
dodgePct AS dodge,
parryPct AS parry,
attackPower AS ap,
rangedAttackPower AS ranged_ap,
power2 AS min_dmg,
power3 AS max_dmg,
power4 AS min_ranged_dmg,
power5 AS max_ranged_dmg,
power6 AS expertise,
power7 AS off_expertise,
resHoly AS holy,
resFire AS fire,
resNature AS nature,
resFrost AS frost,
resShadow AS shadow,
resArcane AS arcane,
critPct AS melee_crit,
rangedCritPct AS range_crit,
power1 AS melee_hit,
power2 AS range_hit,
power3 AS spell_hit
FROM characters, character_stats, guild_member WHERE guild_member.guid = characters.guid ORDER BY '.$order_by.' '.$order_dir.' LIMIT '.$start.', '.$itemperpage.'');
//==========================top tage navigaion starts here========================
$output .= '
<center>
<div id="tab">
<ul>
<li'.(($type === 'level') ? ' id="selected"' : '' ).'>
<a href="top100.php?start='.$start.'">
'.$lang_top['general'].'
</a>
</li>
<li'.(($type === 'stat') ? ' id="selected"' : '' ).'>
<a href="top100.php?start='.$start.'&type=stat&order_by=health">
'.$lang_top['stats'].'
</a>
</li>
<li'.(($type === 'defense') ? ' id="selected"' : '' ).'>
<a href="top100.php?start='.$start.'&type=defense&order_by=armor">
'.$lang_top['defense'].'
</a>
</li>
<li'.(($type === 'resist') ? ' id="selected"' : '' ).'>
<a href="top100.php?start='.$start.'&type=resist&order_by=holy">
'.$lang_top['resist'].'
</a>
</li>
<li'.(($type === 'attack') ? ' id="selected"' : '' ).'>
<a href="top100.php?start='.$start.'&type=attack&order_by=ap">
'.$lang_top['melee'].'
</a>
</li>
<li'.(($type === 'crit_hit') ? ' id="selected"' : '' ).'>
<a href="top100.php?start='.$start.'&type=crit_hit&order_by=ranged_ap">
'.$lang_top['ranged'].'
</a>
</li>
<li'.(($type === 'pvp') ? ' id="selected"' : '' ).'>
<a href="top100.php?start='.$start.'&type=pvp&order_by=honor">
'.$lang_top['pvp'].'
</a>
</li>
</ul>
</div>
<div id="tab_content">
<table class="top_hidden" style="width: 720px">';
if($developer_test_mode && $multi_realm_mode)
{
$realms = $sqlr->query('SELECT count(*) FROM realmlist');
$tot_realms = $sqlr->result($realms, 0);
if (1 < $tot_realms && 1 < count($server))
{
$output .= '
<tr>
<td colspan="2" align="left">';
makebutton('View', 'javascript:do_submit(\'form'.$realm_id.'\',0)', 130);
$output .= '
<form action="top100.php?type='.$type.'" method="post" name="form'.$realm_id.'">
Number of Realms :
<input type="hidden" name="action" value="realms" />
<select name="n_realms">';
for($i=1;$i<=$tot_realms;++$i)
$output .= '
<option value="'.$i.'">'.htmlentities($i).'</option>';
$output .= '
</select>
</form>
</td>
</tr>';
}
}
$output .= '
<tr>
<td align="right">Total: '.$all_record.'</td>
<td align="right" width="25%">';
$output .= generate_pagination('top100.php?type='.$type.'&order_by='.$order_by.'&dir='.(($dir) ? 0 : 1).'', $all_record, $itemperpage, $start);
$output .= '
</td>
</tr>
</table>';
//==========================top tage navigaion ENDS here ========================
$output .= '
<table class="lined" style="width: 720px">
<tr>
<th width="5%">#</th>
<th width="14%">'.$lang_top['name'].'</th>
<th width="11%">'.$lang_top['race'].' '.$lang_top['class'].'</th>
<th width="8%"><a href="top100.php?type='.$type.'&order_by=level&start='.$start.'&dir='.$dir.'"'.($order_by==='level' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['level'].'</a></th>';
if ($type === 'level')
{
$output .= '
<th width="22%">'.$lang_top['guild'].'</th>
<th width="20%"><a href="top100.php?type='.$type.'&order_by=money&start='.$start.'&dir='.$dir.'"'.($order_by==='money' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['money'].'</a></th>
<th width="20%"><a href="top100.php?type='.$type.'&order_by=totaltime&start='.$start.'&dir='.$dir.'"'.($order_by==='totaltime' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['time_played'].'</a></th>';
}
elseif ($type === 'stat')
{
$output .= '
<th width="11%"><a href="top100.php?type='.$type.'&order_by=health&start='.$start.'&dir='.$dir.'"'.($order_by==='health' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['health'].'</a></th>
<th width="10%"><a href="top100.php?type='.$type.'&order_by=power1&start='.$start.'&dir='.$dir.'"'.($order_by==='power1' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['mana'].'</a></th>
<th width="9%"><a href="top100.php?type='.$type.'&order_by=str&start='.$start.'&dir='.$dir.'"'.($order_by==='str' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['str'].'</a></th>
<th width="8%"><a href="top100.php?type='.$type.'&order_by=agi&start='.$start.'&dir='.$dir.'"'.($order_by==='agi' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['agi'].'</a></th>
<th width="8%"><a href="top100.php?type='.$type.'&order_by=sta&start='.$start.'&dir='.$dir.'"'.($order_by==='sta' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['sta'].'</a></th>
<th width="8%"><a href="top100.php?type='.$type.'&order_by=intel&start='.$start.'&dir='.$dir.'"'.($order_by==='intel' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['intel'].'</a></th>
<th width="8%"><a href="top100.php?type='.$type.'&order_by=spi&start='.$start.'&dir='.$dir.'"'.($order_by==='spi' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['spi'].'</a></th>';
}
elseif ($type === 'defense')
{
$output .= '
<th width="16%"><a href="top100.php?type='.$type.'&order_by=armor&start='.$start.'&dir='.$dir.'"'.($order_by==='armor' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['armor'].'</a></th>
<th width="16%"><a href="top100.php?type='.$type.'&order_by=block&start='.$start.'&dir='.$dir.'"'.($order_by==='block' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['block'].'</a></th>
<th width="15%"><a href="top100.php?type='.$type.'&order_by=dodge&start='.$start.'&dir='.$dir.'"'.($order_by==='dodge' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['dodge'].'</a></th>
<th width="15%"><a href="top100.php?type='.$type.'&order_by=parry&start='.$start.'&dir='.$dir.'"'.($order_by==='parry' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['parry'].'</a></th>';
}
elseif ($type === 'resist')
{
$output .= '
<th width="10%"><a href="top100.php?type='.$type.'&order_by=holy&start='.$start.'&dir='.$dir.'"'.($order_by==='holy' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['holy'].'</a></th>
<th width="10%"><a href="top100.php?type='.$type.'&order_by=fire&start='.$start.'&dir='.$dir.'"'.($order_by==='fire' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['fire'].'</a></th>
<th width="10%"><a href="top100.php?type='.$type.'&order_by=nature&start='.$start.'&dir='.$dir.'"'.($order_by==='nature' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['nature'].'</a></th>
<th width="10%"><a href="top100.php?type='.$type.'&order_by=frost&start='.$start.'&dir='.$dir.'"'.($order_by==='frost' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['frost'].'</a></th>
<th width="11%"><a href="top100.php?type='.$type.'&order_by=shadow&start='.$start.'&dir='.$dir.'"'.($order_by==='shadow' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['shadow'].'</a></th>
<th width="11%"><a href="top100.php?type='.$type.'&order_by=arcane&start='.$start.'&dir='.$dir.'"'.($order_by==='arcane' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['arcane'].'</a></th>';
}
elseif ($type === 'attack')
{
$output .= '
<th width="20%"><a href="top100.php?type='.$type.'&order_by=ap&start='.$start.'&dir='.$dir.'"'.($order_by==='ap' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['ap'].'</a></th>
<th width="6%"><a href="top100.php?type='.$type.'&order_by=min_dmg&start='.$start.'&dir='.$dir.'"'.($order_by==='min_dmg' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['min_dmg'].'</a></th>
<th width="6%"><a href="top100.php?type='.$type.'&order_by=max_dmg&start='.$start.'&dir='.$dir.'"'.($order_by==='max_dmg' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['max_dmg'].'</a></th>
<th width="10%"><a href="top100.php?type='.$type.'&order_by=melee_crit&start='.$start.'&dir='.$dir.'"'.($order_by==='melee_crit' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['crit'].'</a></th>
<th width="5%"><a href="top100.php?type='.$type.'&order_by=melee_hit&start='.$start.'&dir='.$dir.'"'.($order_by==='melee_hit' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['hit'].'</a></th>
<th width="5%"><a href="top100.php?type='.$type.'&order_by=expertise&start='.$start.'&dir='.$dir.'"'.($order_by==='expertise' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['expertise'].'</a></th>
<th width="9%"><a href="top100.php?type='.$type.'&order_by=off_expertise&start='.$start.'&dir='.$dir.'"'.($order_by==='off_expertise' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['off_expertise'].'</a></th>
</tr>';
}
elseif ($type === 'crit_hit')
{
$output .= '
<th width="18%"><a href="top100.php?type='.$type.'&order_by=ranged_ap&start='.$start.'&dir='.$dir.'"'.($order_by==='ranged_ap' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['ap'].'</a></th>
<th width="12%"><a href="top100.php?type='.$type.'&order_by=min_ranged_dmg&start='.$start.'&dir='.$dir.'"'.($order_by==='min_ranged_dmg' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['min_dmg'].'</a></th>
<th width="12%"><a href="top100.php?type='.$type.'&order_by=max_ranged_dmg&start='.$start.'&dir='.$dir.'"'.($order_by==='max_ranged_dmg' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['max_dmg'].'</a></th>
<th width="10%"><a href="top100.php?type='.$type.'&order_by=range_crit&start='.$start.'&dir='.$dir.'"'.($order_by==='range_crit' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['crit'].'</a></th>
<th width="10%"><a href="top100.php?type='.$type.'&order_by=range_hit&start='.$start.'&dir='.$dir.'"'.($order_by==='range_hit' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['hit'].'</a></th>';
}
elseif ($type === 'pvp')
{
$output .= '
<th width="20%"><a href="top100.php?type='.$type.'&order_by=honor&start='.$start.'&dir='.$dir.'"'.($order_by==='honor' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['rank'].'</a></th>
<th width="14%">'.$lang_top['honor_points'].'</th>
<th width="14%"><a href="top100.php?type='.$type.'&order_by=kills&start='.$start.'&dir='.$dir.'"'.($order_by==='kills' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['kills'].'</a></th>
<th width="14%"><a href="top100.php?type='.$type.'&order_by=arena&start='.$start.'&dir='.$dir.'"'.($order_by==='arena' ? ' class="'.$order_dir.'"' : '').'>'.$lang_top['arena_points'].'</a></th>';
}
$output .= '
</tr>';
$i=0;
while($char = $sqlc->fetch_assoc($result))
{
$output .= '
<tr valign="top">
<td>'.(++$i+$start).'</td>
<td><a href="char.php?id='.$char['guid'].'&realm='.$realm_id.'">'.htmlentities($char['name']).'</a></td>
<td>
<img src="img/c_icons/'.$char['race'].'-'.$char['gender'].'.gif" alt="'.char_get_race_name($char['race']).'" onmousemove="toolTip(\''.char_get_race_name($char['race']).'\', \'item_tooltip\')" onmouseout="toolTip()" />
<img src="img/c_icons/'.$char['class'].'.gif" alt="'.char_get_class_name($char['class']).'" onmousemove="toolTip(\''.char_get_class_name($char['class']).'\', \'item_tooltip\')" onmouseout="toolTip()" />
</td>
<td>'.char_get_level_color($char['level']).'</td>';
if ($type === 'level')
{
$guild_name = $sqlc->result($sqlc->query('SELECT name FROM guild WHERE guildid = '.$char['gname'].''), 0);
$days = floor(round($char['totaltime'] / 3600)/24);
$hours = round($char['totaltime'] / 3600) - ($days * 24);
$time = '';
if ($days)
$time .= $days.' days ';
if ($hours)
$time .= $hours.' hours';
$output .= '
<td><a href="guild.php?action=view_guild&realm='.$realm_id.'&error=3&id='.$char['gname'].'">'.htmlentities($guild_name).'</a></td>
<td align="right">
'.substr($char['money'], 0, -4).'<img src="img/gold.gif" alt="" align="middle" />
'.substr($char['money'], -4, 2).'<img src="img/silver.gif" alt="" align="middle" />
'.substr($char['money'], -2).'<img src="img/copper.gif" alt="" align="middle" />
</td>
<td align="right">'.$time.'</td>';
}
elseif ($type === 'stat')
{
$output .= '
<td>'.$char['health'].'</td>
<td>'.$char['power1'].'</td>
<td>'.$char['str'].'</td>
<td>'.$char['agi'].'</td>
<td>'.$char['sta'].'</td>
<td>'.$char['intel'].'</td>
<td>'.$char['spi'].'</td>';
}
elseif ($type === 'defense')
{
$block = unpack('f', pack('L', $char['block']));
$block = round($block[1],2);
$dodge = unpack('f', pack('L', $char['dodge']));
$dodge = round($dodge[1],2);
$parry = unpack('f', pack('L', $char['parry']));
$parry = round($parry[1],2);
$output .= '
<td>'.$char['armor'].'</td>
<td>'.$block.'%</td>
<td>'.$dodge.'%</td>
<td>'.$parry.'%</td>';
}
elseif ($type === 'resist')
{
$output .= '
<td>'.$char['holy'].'</td>
<td>'.$char['fire'].'</td>
<td>'.$char['nature'].'</td>
<td>'.$char['frost'].'</td>
<td>'.$char['shadow'].'</td>
<td>'.$char['arcane'].'</td>';
}
elseif ($type === 'attack')
{
$melee = unpack('f', pack('L', $char['melee_crit']));
$melee = round($melee[1],2);
$mindamage = unpack('f', pack('L', $char['min_dmg']));
$mindamage = round($mindamage[1],0);
$maxdamage = unpack('f', pack('L', $char['max_dmg']));
$maxdamage = round($maxdamage[1],0);
$output .= '
<td>'.$char['ap'].'</td>
<td>'.$mindamage.'</td>
<td>'.$maxdamage.'</td>
<td>'.$melee.'%</td>
<td>'.$char['melee_hit'].'</td>
<td>'.$char['expertise'].'</td>
<td>'.$char['off_expertise'].'</td>';
}
elseif ($type === 'crit_hit')
{
$range = unpack('f', pack('L', $char['range_crit']));
$range = round($range[1],2);
$minrangeddamage = unpack('f', pack('L', $char['min_ranged_dmg']));
$minrangeddamage = round($minrangeddamage[1],0);
$maxrangeddamage = unpack('f', pack('L', $char['max_ranged_dmg']));
$maxrangeddamage = round($maxrangeddamage[1],0);
$output .= '
<td>'.$char['ranged_ap'].'</td>
<td>'.$minrangeddamage.'</td>
<td>'.$maxrangeddamage.'</td>
<td>'.$range.'%</td>
<td>'.$char['range_hit'].'</td>';
}
elseif ($type === 'pvp')
{
$output .= '
<td align="left"><img src="img/ranks/rank'.char_get_pvp_rank_id($char['honor'], char_get_side_id($char['race'])).'.gif" alt=""></img> '.char_get_pvp_rank_name($char['honor'], char_get_side_id($char['race'])).'</td>
<td>'.$char['honor'].'</td>
<td>'.$char['kills'].'</td>
<td>'.$char['arena'].'</td>';
}
$output .= '
</tr>';
}
$output .= '
</table>
<table class="top_hidden" style="width: 720px">
<tr>
<td align="right">Total: '.$all_record.'</td>
<td align="right" width="25%">';
$output .= generate_pagination('top100.php?type='.$type.'&order_by='.$order_by.'&dir='.(($dir) ? 0 : 1).'', $all_record, $itemperpage, $start);
unset($all_record);
$output .= '
</td>
</tr>
</table>
</div>
<br />
</center>';
}
//#############################################################################
// MAIN
//#############################################################################
//$err = (isset($_GET['error'])) ? $_GET['error'] : NULL;
//$output .= '
// <div class="top">';
$lang_top = lang_top();
//if(1 == $err);
//else
// $output .= "
// <h1>'.$lang_top['top100'].'</h1>;
//unset($err);
//$output .= '
// </div>';
$action = (isset($_POST['action'])) ? $_POST['action'] : NULL;
if ('realms' === $action)
{
if (isset($_POST['n_realms']))
{
$n_realms = $_POST['n_realms'];
$realms = $sqlr->query('SELECT id, name FROM realmlist LIMIT 10');
if (1 < $sqlr->num_rows($realms) && 1 < (count($server)))
{
for($i=1;$i<=$n_realms;++$i)
{
$realm = $sqlr->fetch_assoc($realms);
if(isset($server[$realm['id']]))
{
$output .= '
<div class="top"><h1>Top 100 of '.$realm['name'].'</h1></div>';
top100($realm['id'], $sqlr, $sqlc);
}
}
}
else
{
$output .= '
<div class="top"><h1>'.$lang_top['top100'].'</h1></div>';
top100($realm_id, $sqlr, $sqlc);
}
}
else
{
$output .= '
<div class="top"><h1>'.$lang_top['top100'].'</h1></div>';
top100($realm_id, $sqlr, $sqlc);
}
}
else
{
$output .= '
<div class="top"><h1>'.$lang_top['top100'].'</h1></div>';
top100($realm_id, $sqlr, $sqlc);
}
unset($action);
unset($action_permission);
unset($lang_top);
require_once 'footer.php';
?>