source: pages/servers.php

Last change on this file was 9, checked in by george, 16 years ago

Přidáno: Řazení podle času přidání serveru.
Opraveno: Řazení podle odezvy.

File size: 3.4 KB
Line 
1<?php
2$tpl->output['th_players'] = $text['th_players'];
3$tpl->output['th_name'] = $text['name'];
4$tpl->output['th_latency'] = $text['th_latency'];
5$tpl->output['th_version'] = $text['th_version'];
6$tpl->output['th_xp'] = $text['th_xp'];
7$tpl->output['th_online_state'] = $text['th_online_state'];
8$tpl->output['th_type'] = $text['th_type'];
9$tpl->output['th_rating'] = $text['th_rating'];
10$tpl->output['th_recommend'] = $text['th_recommend'];
11$tpl->output['th_created'] = $text['th_created'];
12$tpl->output['order_by'] = $text['order_by'];
13$tpl->output['place'] = $text['info_place'];
14
15if(!array_key_exists('order', $_GET)) $_GET['order'] = 0;
16$order_index = (int) $_GET['order'];
17switch ($order_index)
18{
19 case 0: $order = ' order by `name`'; break;
20 case 1: $order = ' order by `rating` desc '; break;
21 case 2: $order = ' order by `version` desc '; break;
22 case 3: $order = ' order by `type` desc '; break;
23 case 4: $order = ' order by `xp` desc '; break;
24 case 5: $order = ' order by `players` desc '; break;
25 case 6: $order = ' order by `online` desc '; break;
26 case 7: $order = ' order by ceil(`online` / 100) desc, `latency`'; break;
27 case 8: $order = ' order by `created` desc'; break;
28}
29$tpl->output['s0'] = '';
30$tpl->output['s1'] = '';
31$tpl->output['s2'] = '';
32$tpl->output['s3'] = '';
33$tpl->output['s4'] = '';
34$tpl->output['s5'] = '';
35$tpl->output['s6'] = '';
36$tpl->output['s7'] = '';
37$tpl->output['s8'] = '';
38if (empty($order_index))
39{
40 $tpl->output['s0'] = 'SELECTED';
41}
42else
43{
44 $tpl->output['s'.$order_index] = 'SELECTED';
45}
46
47$pa = new CleverPager('select `id`,`wss_partner`, LEFT(`name`, 25) as `name`, `place`, `rating_sum`/`ratings` as `rating`, `version`, `type`, `xp`, `online`, `online_players_sum`/`player_checks` as `players`,`latency` from `servers` where `place`=1 '.$order, 'p');
48$pa->PageSize = $Config['DisplayServerCountPerPage'];
49$pa->PageLinksDisplayed = 5;
50$pa->CountCommand = 'select count(*) as Count from `servers` where `place` =1';
51$pa->DataBind();
52$tpl->output['servers_data'] = '';
53while ($row = $pa->GetOne())
54{
55 switch ($row['xp'])
56 {
57 case 1: $xp = 'Very low'; break;
58 case 2: $xp = 'Low'; break;
59 case 3: $xp = 'Normal'; break;
60 case 4: $xp = 'High'; break;
61 case 5: $xp = 'Very high'; break;
62 }
63 if ($row['place'] == 1)
64 {
65 $place = $text['reg_czech'];
66 }
67 else
68 {
69 $place = $text['reg_abroad'];
70 }
71 $tpl->output['servers_data'] .= '<tr>';
72 $tpl->output['servers_data'] .= ($row['wss_partner'] == 1)?'<td><img src="templates/img/hvezda.gif" alt="Doporučujeme" title="Doporučujeme"></td>':'<td></td>';
73 $tpl->output['servers_data'] .='<td align="left">'.ulink('server/'.$row['id'], $row['name']).'</td>';
74 $tpl->output['servers_data'] .='<td>'.round($row['rating'], 2).'</td>';
75 $tpl->output['servers_data'] .='<td>'.$row['version'].'</td>';
76 $tpl->output['servers_data'] .='<td>'.$row['type'].'</td>';
77 $tpl->output['servers_data'] .='<td>'.$xp.'</td>';
78 $tpl->output['servers_data'] .='<td>'.(int)$row['players'].'</td>';
79 $tpl->output['servers_data'] .='<td>'.$row['online'].'%</td>';
80 if($row['latency'] == 0) $Latency = '?'; else $Latency = round($row['latency']).'ms';
81 $tpl->output['servers_data'] .='<td>'.$Latency.'</td>';
82 $tpl->output['servers_data'] .='</tr>';
83 }
84ob_start();
85$pa->DrawPager();
86$tpl->output['pager'] = ob_get_contents();
87ob_clean();
88?>
Note: See TracBrowser for help on using the repository browser.