source: pages/a_servers.php

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