1 | <?php
|
---|
2 | //db
|
---|
3 | session_start();
|
---|
4 | require ('./includes/config.php');
|
---|
5 | $db = new tMySql;
|
---|
6 | $db->dbServer = $db_config['host'];
|
---|
7 | $db->dbUser = $db_config['user'];
|
---|
8 | $db->dbPassword = $db_config['pass'];
|
---|
9 | $db->dbName = $db_config['name'];
|
---|
10 | $db->connect();
|
---|
11 | $db->query(0, "SET NAMES UTF8");
|
---|
12 | $geted = $db->escape($_GET);
|
---|
13 | $posted = $db->escape($_POST);
|
---|
14 |
|
---|
15 | //language
|
---|
16 | if (isset($_COOKIE['lang']))
|
---|
17 | {
|
---|
18 | $lang = $_COOKIE['lang'];
|
---|
19 | }
|
---|
20 | else $lang = 'cs';
|
---|
21 | require('./lang/'.$lang.'.php');
|
---|
22 |
|
---|
23 | $tpl = new Html_template;
|
---|
24 | $tpl->global_template = './templates/index.html';
|
---|
25 | if(!array_key_exists('page', $geted)) $geted['page'] = 'servers';
|
---|
26 | $page_info = $db->query_fetch_assoc('SELECT * FROM `pages` WHERE `page` LIKE "'.$geted['page'].'"');
|
---|
27 | if(empty($page_info))
|
---|
28 | {
|
---|
29 | $page_info = $db->query_fetch_assoc('SELECT * FROM `pages` WHERE `page` LIKE "servers"');
|
---|
30 | }
|
---|
31 | $page_info['tpl'] = eregi_replace("\-", "_", $page_info['page']);
|
---|
32 | $tpl->template = './templates/'.$page_info['tpl'].'.html';
|
---|
33 | $p = $page_info['url'];
|
---|
34 | $tpl->output['top_online_data'] = '';
|
---|
35 | $tpl->output['top_rating_data'] = '';
|
---|
36 | if($page_info['menu'] == 1)
|
---|
37 | {
|
---|
38 | $tpl->menu_template = './templates/menu.html';
|
---|
39 | $tpl->output['bg_color'] = '#ffffff';
|
---|
40 |
|
---|
41 | // Filter top servers
|
---|
42 | $Filter = '';
|
---|
43 | if(array_key_exists('page', $_GET))
|
---|
44 | {
|
---|
45 | if($_GET['page'] == 'servers') $Filter = 'WHERE place=1';
|
---|
46 | if($_GET['page'] == 'a-servers') $Filter = 'WHERE place=2';
|
---|
47 | if($_GET['page'] == 'wss-partners') $Filter = 'WHERE wss_partner=1';
|
---|
48 | }
|
---|
49 |
|
---|
50 | // Show top player count servers
|
---|
51 | $db->query('top_online', 'SELECT `id`, LEFT(`name`, 25) as `name`, CAST(`online_players_sum`/`player_checks` AS UNSIGNED) as online FROM `servers` '.$Filter.' ORDER BY `online` DESC LIMIT '.$Config['TopServersCount']);
|
---|
52 | $tpl->output['top_online'] = '';
|
---|
53 | while($row = $db->strip($db->fetch_assoc('top_online')))
|
---|
54 | {
|
---|
55 | if($row['online'] == 0) $row['online'] = 0;
|
---|
56 | $tpl->output['top_online_data'] .= '<li>'.ulink('server/'.$row['id'], $row['name']).' - '.$row['online'].' '.$text['players'].'</li>';
|
---|
57 | }
|
---|
58 |
|
---|
59 | // Show top rating servers
|
---|
60 | $db->query('top_rating','SELECT `id`, LEFT(`name`, 25) as `name`, `rating_sum`/`ratings` as rating FROM `servers` '.$Filter.' ORDER BY `rating` DESC LIMIT '.$Config['TopServersCount']);
|
---|
61 | $tpl->output['top_rating_data'] = '';
|
---|
62 | while($row = $db->strip($db->fetch_assoc('top_rating')))
|
---|
63 | {
|
---|
64 | $row['rating'] = round($row['rating'], 2);
|
---|
65 | $tpl->output['top_rating_data'] .= '<li>'.ulink('server/'.$row['id'], $row['name']).' - '.$row['rating'].'</li>';
|
---|
66 | }
|
---|
67 | $tpl->output['mm6'] = menuitem('home', $menu['mm1']);
|
---|
68 | $tpl->output['mm1'] = menuitem('index.php?page=wss-partners', $menu['mm2']);
|
---|
69 | $tpl->output['mm2'] = menuitem('index.php?page=servers', $menu['mm3']);
|
---|
70 | $tpl->output['mm3'] = menuitem('index.php?page=a-servers', $menu['mm4']);
|
---|
71 | $tpl->output['mm4'] = menuitem('index.php?page=users', $menu['mm5']);
|
---|
72 | $tpl->output['mm5'] = menuitem('add-server/', $menu['mm6']);
|
---|
73 | }
|
---|
74 | else $tpl->output['bg_color'] = '#e6e6e6';
|
---|
75 |
|
---|
76 | $tpl->output['title'] = 'WSS - '.$page_info['title'];
|
---|
77 | $tpl->output['url'] = $config['base_url'];
|
---|
78 | $tpl->output['lang'] = $lang;
|
---|
79 | $tpl->output['footer'] = 'Vytvořeno členy komunity.';
|
---|
80 | if(isset($_SESSION['id']))
|
---|
81 | {
|
---|
82 | $tpl->output['acc'] = ulink('action.php?do=logout', 'Logout');
|
---|
83 | }
|
---|
84 | else
|
---|
85 | {
|
---|
86 | $tpl->output['acc'] = window_open($config['base_url'].'index.php?page=register', 'Registrace', 400, 350, 400, 250).' | '.window_open($config['base_url'].'index.php?page=login', 'Login', 200, 140, 500, 300);
|
---|
87 | }
|
---|
88 |
|
---|
89 | $tpl->output['top_online'] = $text['top_online'];
|
---|
90 | $tpl->output['top_rating'] = $text['top_rating'];
|
---|
91 |
|
---|
92 | if(isset($_SESSION['id']))
|
---|
93 | {
|
---|
94 | $user = $db->strip($db->query_fetch_assoc('SELECT * from `users` WHERE id ='.(int)$_SESSION['id']));
|
---|
95 | }
|
---|
96 | if(($page_info['admin'] == 1) AND $user['admin'] <> 1)
|
---|
97 | {
|
---|
98 | die('Hacking attemp');
|
---|
99 | }
|
---|
100 |
|
---|
101 | include $p;
|
---|
102 | $tpl->flush();
|
---|
103 |
|
---|
104 | ?>
|
---|