source: pages/server.php

Last change on this file was 8, checked in by george, 17 years ago

Přidáno: Zaznamenávání a zobrazování údaje o odezevně serverů.
Upraveno: Šablony stránek a použití jazykových proměnných ve větší míře.

File size: 5.6 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['server_reg_desc'] = $text['reg_desc'];
12$tpl->output['info_place'] = $text['info_place'];
13$tpl->output['info_avarage_players'] = $text['info_avarage_players'];
14$tpl->output['info_owner'] = $text['info_owner'];
15
16$id = (int)$_GET['str1'];
17$server_info = $db->strip($db->query_fetch_assoc('SELECT *, CAST(`online_players_sum`/`player_checks` AS UNSIGNED) as `online_players` FROM `servers` WHERE `id` = '.$id));
18
19if($server_info['wss_partner'] == 1)
20{
21 $tpl->output['server_name'] = '<img src="templates/img/hvezda.gif" alt="WSS Partner" title="WSS Partner">'.$server_info['name'];
22}
23else
24{
25 $tpl->output['server_name'] = $server_info['name'];
26}
27$tpl->output['title_name'] = $server_info['name'];
28$tpl->output['server_version'] = $server_info['version'];
29$tpl->output['server_typ'] = $server_info['type'];
30$tpl->output['server_limit'] = $server_info['limit'];
31$tpl->output['server_description'] = $server_info['desc'];
32$tpl->output['server_added'] = datum($server_info['created']);
33$tpl->output['info_added'] = $text['server_added_info'];
34if ((int)$server_info['player_checks']<>0)
35 {
36 $tpl->output['server_online_players'] = $server_info['online_players'];
37 }
38 else
39 {
40 $tpl->output['server_online_players']='0';
41 }
42$tpl->output['server_online'] = @round($server_info['online'], 2).'%';
43switch ($server_info['xp'])
44 {
45 case 1: $tpl->output['server_xp'] = 'Very low'; break;
46 case 2: $tpl->output['server_xp'] = 'Low'; break;
47 case 3: $tpl->output['server_xp'] = 'Normal'; break;
48 case 4: $tpl->output['server_xp'] = 'High'; break;
49 case 5: $tpl->output['server_xp'] = 'Very high'; break;
50 }
51$tpl->output['server_emu'] = $server_info['emu'];
52if ($server_info['place']==1)
53 {
54 $tpl->output['server_place'] = $text['reg_czech'];
55 }
56else
57 {
58 $tpl->output['server_place'] = $text['reg_abroad'];
59 }
60$tpl->output['server_web'] = '<a href="'.$server_info['web'].'" target="_blank">'.$server_info['web'].'</a>';
61$tpl->output['server_web_reg'] = '<a href="'.$server_info['web_reg'].'" target="_blank">'.$server_info['web_reg'].'</a>';
62$tpl->output['server_port'] = $server_info['port'];
63$tpl->output['server_owner'] = print_nick($server_info['owner']);
64if($server_info['latency'] == 0) $Latency = '?'; else $Latency = round($server_info['latency']).'ms';
65$tpl->output['server_latency'] = $Latency;
66
67if (empty($_SESSION['id']))
68 {
69 $vote = false;
70 }
71else
72 {
73 $c = $db->query_result('SELECT COUNT(*) as `pocet` FROM ratings WHERE (`server_id`= '.(int)$server_info['id'].' AND `user_id`='.(int)$_SESSION['id'].')');
74 if ($c == 1)
75 {
76 $vote = false;
77 }
78 else
79 {
80 $vote = true;
81 }
82 }
83
84if ($server_info['ratings']==0)
85 {
86 $rating = 0;
87 }
88else
89 {
90 $rating = round($server_info['rating_sum']/$server_info['ratings'], 2);
91 }
92$rating_width = 30*$rating;
93
94if ($vote)
95 {
96 $tpl->output['rating_stars'] = "<li class='current-rating' title='".$rating."/5' style='width:".$rating_width."px;'></li>";
97 $tpl->output['rating_stars'] .= "<li><a href='action.php?do=rate&amp;server=$id&amp;rating=1' title='1 hvězda z 5' class='jedna-hvezda'></a></li>";
98$tpl->output['rating_stars'] .= "<li><a href='action.php?do=rate&amp;server=$id&amp;rating=2' title='2 hvězdy z 5' class='dve-hvezdy'></a></li>";
99$tpl->output['rating_stars'] .= "<li><a href='action.php?do=rate&amp;server=$id&amp;rating=3' title='3 hvězdy z 5' class='tri-hvezdy'></a></li>";
100$tpl->output['rating_stars'] .= "<li><a href='action.php?do=rate&amp;server=$id&amp;rating=4' title='4 hvězdy z 5' class='ctyri-hvezdy'></a></li>";
101$tpl->output['rating_stars'] .= "<li><a href='action.php?do=rate&amp;server=$id&amp;rating=5' title='5 z 5 hvězd' class='pet-hvezd'></a></li>";
102 }
103else
104 {
105 $tpl->output['rating_stars'] = "<li class='current-rating' title='$rating/5 ".$text['vote_only']."' style='width:".$rating_width."px;'></li>
106<li><div title='1 hvězda z 5' class='jedna-hvezda'></div></li>
107<li><div title='2 hvězdy z 5' class='dve-hvezdy'></div></li>
108<li><div title='3 hvězdy z 5' class='tri-hvezdy'></div></li>
109<li><div title='4 hvězdy z 5' class='ctyri-hvezdy'></div></li>
110<li><div title='5 z 5 hvězd' class='pet-hvezd'></div></li>";
111 }
112
113if (($user['admin']==1) OR ($server_info['owner']==$_SESSION['id']))
114 {
115 $tpl->output['admin'] = '<tr classs="table"><td colspan="2" align="center">'.ulink('edit-server/'.$id, 'Edit').' | <a href="#" onclick="potvrd(\'action.php?do=delserver&amp;server='.$id.'\', \'Opravdu smazat?\'); return false;">Delete</a>';
116 }
117else
118 {
119 $tpl->output['admin']='';
120 }
121if ($user['admin']==1)
122 {
123 if ($server_info['wss_partner']==1)
124 {
125 $tpl->output['admin'] .= ' | <a href="action.php?do=delwss&amp;id='.$id.'">Odebrat WSS</a></td></tr>';
126 }
127 else
128 {
129 $tpl->output['admin'] .= ' | <a href="action.php?do=addwss&amp;id='.$id.'">Přidat WSS</a></td></tr>';
130 }
131 }
132else
133 {
134 $tpl->output['admin'].='</td></tr>';
135 }
136
137//comments
138$count_comment = $db->query_result('select count(*) as pocet from `comments` where server='.$id);
139$tpl->output['comments']='<a href="'.$config['base_url'].'index.php?page=comments&amp;server='.$id.'">Komentáře('.$count_comment.')';
140?>
141
Note: See TracBrowser for help on using the repository browser.