1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * The EVE-Development Network Killboard |
---|
5 | * based on eve-killboard.net created by rig0r |
---|
6 | * |
---|
7 | * This program is free software; you can redistribute it and/or modify |
---|
8 | * it under the terms of the GNU General Public License as published by |
---|
9 | * the Free Software Foundation; either version 2 of the License, or |
---|
10 | * any later version. |
---|
11 | * |
---|
12 | * This program is distributed in the hope that it will be useful, but |
---|
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
15 | * General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU General Public License |
---|
18 | * along with this program; if not, write to the Free Software |
---|
19 | * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
---|
20 | * |
---|
21 | */ |
---|
22 | |
---|
23 | // many ppl had issues with pear and relative paths |
---|
24 | require_once('common/includes/db.php'); |
---|
25 | require_once('common/includes/class.config.php'); |
---|
26 | require_once('common/includes/class.killboard.php'); |
---|
27 | require_once('common/includes/class.page.php'); |
---|
28 | require_once('common/includes/class.event.php'); |
---|
29 | require_once('common/includes/class.roles.php'); |
---|
30 | #require_once('common/includes/class.titles.php'); |
---|
31 | require_once('common/includes/class.user.php'); |
---|
32 | require_once('common/includes/class.session.php'); |
---|
33 | require_once('common/smarty/Smarty.class.php'); |
---|
34 | |
---|
35 | // smarty doesnt like it |
---|
36 | @set_magic_quotes_runtime(0); |
---|
37 | |
---|
38 | // remove some chars from the request string to avoid 'hacking'-attempts |
---|
39 | $page = str_replace('.', '', $_GET['a']); |
---|
40 | $page = str_replace('/', '', $page); |
---|
41 | if ($page == '' || $page == 'index') |
---|
42 | { |
---|
43 | $page = 'home'; |
---|
44 | } |
---|
45 | |
---|
46 | // check for the igb |
---|
47 | if (substr($_SERVER['HTTP_USER_AGENT'], 0, 15) == 'EVE-minibrowser') |
---|
48 | { |
---|
49 | define('IS_IGB', true); |
---|
50 | if (!isset($_GET['a'])) |
---|
51 | { |
---|
52 | $page = 'igb'; |
---|
53 | } |
---|
54 | } |
---|
55 | else |
---|
56 | { |
---|
57 | define('IS_IGB', false); |
---|
58 | } |
---|
59 | |
---|
60 | // killboard is instantiated by class::Page |
---|
61 | //$killboard = new Killboard(KB_SITE); |
---|
62 | |
---|
63 | // load the config from the database |
---|
64 | $config = new Config(KB_SITE); |
---|
65 | |
---|
66 | // setting up smarty and feed it with some config |
---|
67 | $smarty = new Smarty(); |
---|
68 | $smarty->template_dir = './templates'; |
---|
69 | $smarty->compile_dir = './cache/templates_c'; |
---|
70 | $smarty->cache_dir = './cache/data'; |
---|
71 | $smarty->assign('style_url', STYLE_URL); |
---|
72 | $smarty->assign('img_url', IMG_URL); |
---|
73 | $smarty->assign_by_ref('config', $config); |
---|
74 | |
---|
75 | // set up titles/roles |
---|
76 | role::init(); |
---|
77 | #title::init(); |
---|
78 | |
---|
79 | // start session management |
---|
80 | Session::init(); |
---|
81 | |
---|
82 | // this is to make sure that smarty is able to create output |
---|
83 | if (!is_dir('./cache/templates_c')) |
---|
84 | { |
---|
85 | if (mkdir('./cache/templates_c')) |
---|
86 | { |
---|
87 | chmod('./cache/templates_c', 0777); |
---|
88 | } |
---|
89 | else |
---|
90 | { |
---|
91 | exit('please create cache/templates_c and chmod it 777'); |
---|
92 | } |
---|
93 | } |
---|
94 | |
---|
95 | // all admin files are now in the admin directory and preload the menu |
---|
96 | if (substr($page, 0, 5) == 'admin') |
---|
97 | { |
---|
98 | require_once('common/admin/admin_menu.php'); |
---|
99 | $page = 'admin/'.$page; |
---|
100 | } |
---|
101 | |
---|
102 | // old modcode for loading settings |
---|
103 | if (substr($page, 0, 9) == 'settings_') |
---|
104 | { |
---|
105 | $settingsPage = true; |
---|
106 | } |
---|
107 | else |
---|
108 | { |
---|
109 | $settingsPage = false; |
---|
110 | } |
---|
111 | $mods_active = explode(',', config::get('mods_active')); |
---|
112 | $modOverrides = false; |
---|
113 | foreach ($mods_active as $mod) |
---|
114 | { |
---|
115 | // load all active modules which need initialization |
---|
116 | if (file_exists('mods/'.$mod.'/init.php')) |
---|
117 | { |
---|
118 | include('mods/'.$mod.'/init.php'); |
---|
119 | } |
---|
120 | if (file_exists('mods/'.$mod.'/'.$page.'.php')) |
---|
121 | { |
---|
122 | if ($modOverrides) |
---|
123 | { |
---|
124 | die('Error: Two or more of the mods you have activated are conflicting'); |
---|
125 | } |
---|
126 | $modOverrides = true; |
---|
127 | $modOverride = $mod; |
---|
128 | } |
---|
129 | } |
---|
130 | if (!$settingsPage && !file_exists('common/'.$page.'.php') && !$modOverrides) |
---|
131 | { |
---|
132 | $page = 'home'; |
---|
133 | } |
---|
134 | |
---|
135 | if (KB_CACHE == 1 && count($_POST) == 0 && !in_array($page, $cacheignore)) |
---|
136 | { |
---|
137 | $docache = true; |
---|
138 | } |
---|
139 | else |
---|
140 | { |
---|
141 | $docache = false; |
---|
142 | } |
---|
143 | |
---|
144 | if ($docache) |
---|
145 | { |
---|
146 | if (!file_exists(KB_CACHEDIR.'/'.KB_SITE)) |
---|
147 | { |
---|
148 | @mkdir(KB_CACHEDIR.'/'.KB_SITE); |
---|
149 | } |
---|
150 | |
---|
151 | if ($cachetimes[$page]) |
---|
152 | { |
---|
153 | $cachetime = $cachetimes[$page]; |
---|
154 | } |
---|
155 | else |
---|
156 | { |
---|
157 | $cachetime = 5; |
---|
158 | } |
---|
159 | |
---|
160 | $cachetime = $cachetime * 60; |
---|
161 | |
---|
162 | $cachefile = KB_CACHEDIR.'/'.KB_SITE.'/'.md5($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']).'.cache'; |
---|
163 | $timestamp = ((@file_exists($cachefile))) ? @filemtime($cachefile) : 0; |
---|
164 | |
---|
165 | if (time() - $cachetime < $timestamp) |
---|
166 | { |
---|
167 | ob_start('ob_gzhandler'); |
---|
168 | @readfile($cachefile); |
---|
169 | ob_end_flush(); |
---|
170 | exit(); |
---|
171 | } |
---|
172 | |
---|
173 | ob_start(); |
---|
174 | } |
---|
175 | |
---|
176 | if ($settingsPage) |
---|
177 | { |
---|
178 | if (!Session::isAdmin()) |
---|
179 | { |
---|
180 | header('Location: ?a=login'); |
---|
181 | echo '<a href="?a=login">Login</a>'; |
---|
182 | exit; |
---|
183 | } |
---|
184 | |
---|
185 | include('mods/'.substr($page, 9, strlen($page)-9).'/settings.php'); |
---|
186 | } |
---|
187 | elseif ($modOverrides) |
---|
188 | { |
---|
189 | include('mods/'.$modOverride.'/'.$page.'.php'); |
---|
190 | } |
---|
191 | else |
---|
192 | { |
---|
193 | include('common/'.$page.'.php'); |
---|
194 | } |
---|
195 | |
---|
196 | if ($docache) |
---|
197 | { |
---|
198 | $fp = @fopen($cachefile, 'w'); |
---|
199 | @fwrite($fp, ob_get_contents()); |
---|
200 | @fwrite($fp, '<!-- Generated from cache -->'); |
---|
201 | @fclose($fp); |
---|
202 | ob_end_flush(); |
---|
203 | } |
---|
204 | ?> |
---|