1 |
|
---|
2 | <?php
|
---|
3 | $server = (int) $_GET['server'];
|
---|
4 | $server_name = $db->query_result('select `name` from `servers` where `id`='.$server);
|
---|
5 | $tpl->output['server_name']= $server_name;
|
---|
6 | $tpl->output['success_blok']='none';
|
---|
7 | if (isset($_SESSION['id']))
|
---|
8 | {
|
---|
9 | $tpl->output['add_comment_blok']='block';
|
---|
10 | $tpl->output['deny_adding_blok']='display: none';
|
---|
11 | }
|
---|
12 | else
|
---|
13 | {
|
---|
14 | $tpl->output['add_comment_blok']='none';
|
---|
15 | $tpl->output['deny_adding_blok']='';
|
---|
16 | $tpl->output['deny_adding_msg']= $text['deny_adding_comments'];
|
---|
17 | }
|
---|
18 | if ((isset($posted['text'])) AND (isset($_SESSION['id'])))
|
---|
19 | {
|
---|
20 | $db->insert('comments', array('server'=>$server, 'author'=>$_SESSION['id'], 'time'=>time('now'), 'text'=>$posted['text']));
|
---|
21 | $tpl->output['success_blok']='block';
|
---|
22 | $tpl->output['added_comment'] = $text['added_comment'];
|
---|
23 | }
|
---|
24 |
|
---|
25 | $tpl->output['comment_h3'] = $text['comment_h3'];
|
---|
26 | $tpl->output['add_comment'] = $text['add_comment'];
|
---|
27 | ob_start();
|
---|
28 | $num = $db->query_result('select count(*) as pocet from `comments` where `server`='.$server);
|
---|
29 | if ($num==0)
|
---|
30 | {
|
---|
31 | echo '<tr><td align="center">'.$text['no_comments'].'</td></tr>';
|
---|
32 | }
|
---|
33 | else
|
---|
34 | {
|
---|
35 | $p = new CleverPager('select * from `comments` where `server`='.$server.' order by `time` desc', 'str');
|
---|
36 | $p->PageSize=10;
|
---|
37 | $p->CountCommand = 'select count(*) as Count from `comments` where `server`='.$server;
|
---|
38 | $p->DataBind();
|
---|
39 |
|
---|
40 | while ($row = $p->GetOne())
|
---|
41 | {
|
---|
42 | echo '<tr class="table"><td align="center" style="width:100px">'.print_nick($row['author']).'<br />'.datum($row['time']).'</td>';
|
---|
43 | echo '<td align="justify" style="width:290px">'.nl2br(htmlspecialchars($db->strip($row['text']))).'</td>';
|
---|
44 | if ($user['admin']==1)
|
---|
45 | {
|
---|
46 | echo '<td style="text-align:right; width:10px;"><a href="action.php?do=delcom&id='.$row['id'].'" title="Smazat" class="del">X</a></td>';
|
---|
47 | }
|
---|
48 | echo '</tr>';
|
---|
49 | }
|
---|
50 | echo '<tr><td align="center" colspan="3" class="table">';
|
---|
51 | echo $p->DrawPager();
|
---|
52 | echo '</td></tr>';
|
---|
53 | }
|
---|
54 | $tpl->output['comments_data'] = ob_get_contents();
|
---|
55 | ob_clean();
|
---|
56 | $tpl->output['url_to_post']='index.php?page=comments&server='.$server;
|
---|
57 |
|
---|
58 | ?>
|
---|