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('kbconfig.php'); |
---|
25 | require_once('common/includes/globals.php'); |
---|
26 | require_once('common/includes/php_compat.php'); |
---|
27 | require_once('common/includes/db.php'); |
---|
28 | require_once('common/includes/class.config.php'); |
---|
29 | require_once('common/includes/class.killboard.php'); |
---|
30 | require_once('common/includes/class.page.php'); |
---|
31 | require_once('common/includes/class.event.php'); |
---|
32 | require_once('common/includes/class.roles.php'); |
---|
33 | #require_once('common/includes/class.titles.php'); |
---|
34 | require_once('common/includes/class.user.php'); |
---|
35 | require_once('common/includes/class.session.php'); |
---|
36 | require_once('common/includes/class.cache.php'); |
---|
37 | require_once('common/includes/class.involvedloader.php'); |
---|
38 | require_once('common/smarty/Smarty.class.php'); |
---|
39 | |
---|
40 | // smarty doesnt like it |
---|
41 | @set_magic_quotes_runtime(0); |
---|
42 | |
---|
43 | // remove some chars from the request string to avoid 'hacking'-attempts |
---|
44 | $page = str_replace('.', '', $_GET['a']); |
---|
45 | $page = str_replace('/', '', $page); |
---|
46 | if ($page == '' || $page == 'index') |
---|
47 | { |
---|
48 | $page = 'home'; |
---|
49 | } |
---|
50 | |
---|
51 | // check for the igb |
---|
52 | if (substr($_SERVER['HTTP_USER_AGENT'], 0, 15) == 'EVE-minibrowser') |
---|
53 | { |
---|
54 | define('IS_IGB', true); |
---|
55 | if (!isset($_GET['a'])) |
---|
56 | { |
---|
57 | $page = 'igb'; |
---|
58 | } |
---|
59 | } |
---|
60 | else |
---|
61 | { |
---|
62 | define('IS_IGB', false); |
---|
63 | } |
---|
64 | |
---|
65 | // load the config from the database |
---|
66 | $config = new Config(KB_SITE); |
---|
67 | define('DB_USE_CCP', true); |
---|
68 | define('KB_HOST', config::get('cfg_kbhost')); |
---|
69 | define('MAIN_SITE', config::get('cfg_mainsite')); |
---|
70 | define('STYLE_URL', config::get('cfg_style')); |
---|
71 | define('COMMON_URL', config::get('cfg_common')); |
---|
72 | define('IMG_URL', config::get('cfg_img')); |
---|
73 | define('DB_HALTONERROR', (bool)config::get('cfg_sqlhalt')); |
---|
74 | define('DB_USE_QCACHE', (bool)config::get('cfg_qcache')); |
---|
75 | if (DB_USE_QCACHE) |
---|
76 | { |
---|
77 | // the object overloading system will switch to cached queries now |
---|
78 | require_once('common/includes/class.db_cache.php'); |
---|
79 | } |
---|
80 | define('KB_TITLE', config::get('cfg_kbtitle')); |
---|
81 | |
---|
82 | // corporation OR alliance id |
---|
83 | if (config::get('cfg_corpid')) |
---|
84 | { |
---|
85 | define('CORP_ID', config::get('cfg_corpid')); |
---|
86 | define('ALLIANCE_ID', 0); |
---|
87 | } |
---|
88 | else |
---|
89 | { |
---|
90 | define('CORP_ID', 0); |
---|
91 | define('ALLIANCE_ID', config::get('cfg_allianceid')); |
---|
92 | } |
---|
93 | if (!$dir = config::get('cache_dir')) |
---|
94 | { |
---|
95 | $dir = 'cache/data'; |
---|
96 | } |
---|
97 | define('KB_CACHEDIR', $dir); |
---|
98 | |
---|
99 | // setting up smarty and feed it with some config |
---|
100 | $smarty = new Smarty(); |
---|
101 | $smarty->template_dir = './templates'; |
---|
102 | $smarty->compile_dir = './cache/templates_c'; |
---|
103 | $smarty->cache_dir = './cache/data'; |
---|
104 | $smarty->assign('style_url', STYLE_URL); |
---|
105 | $smarty->assign('img_url', IMG_URL); |
---|
106 | $smarty->assign('kb_host', KB_HOST); |
---|
107 | $smarty->assign_by_ref('config', $config); |
---|
108 | |
---|
109 | // set up titles/roles |
---|
110 | role::init(); |
---|
111 | #title::init(); |
---|
112 | |
---|
113 | // start session management |
---|
114 | session::init(); |
---|
115 | |
---|
116 | // reinforced management |
---|
117 | if (config::get('auto_reinforced')) |
---|
118 | { |
---|
119 | // first check if we are in reinforced |
---|
120 | if (config::get('is_reinforced')) |
---|
121 | { |
---|
122 | // every 1/x request we check for disabling RF |
---|
123 | if (rand(1, config::get('reinforced_rf_prob')) == 1) |
---|
124 | { |
---|
125 | cache::checkLoad(); |
---|
126 | } |
---|
127 | } |
---|
128 | else |
---|
129 | { |
---|
130 | // reinforced not active |
---|
131 | // check for load and activate reinforced if needed |
---|
132 | if (rand(1, config::get('reinforced_prob')) == 1) |
---|
133 | { |
---|
134 | cache::checkLoad(); |
---|
135 | } |
---|
136 | } |
---|
137 | } |
---|
138 | |
---|
139 | // all admin files are now in the admin directory and preload the menu |
---|
140 | if (substr($page, 0, 5) == 'admin') |
---|
141 | { |
---|
142 | require_once('common/admin/admin_menu.php'); |
---|
143 | $page = 'admin/'.$page; |
---|
144 | } |
---|
145 | |
---|
146 | // old modcode for loading settings |
---|
147 | if (substr($page, 0, 9) == 'settings_') |
---|
148 | { |
---|
149 | $settingsPage = true; |
---|
150 | } |
---|
151 | else |
---|
152 | { |
---|
153 | $settingsPage = false; |
---|
154 | } |
---|
155 | $mods_active = explode(',', config::get('mods_active')); |
---|
156 | $modOverrides = false; |
---|
157 | foreach ($mods_active as $mod) |
---|
158 | { |
---|
159 | // load all active modules which need initialization |
---|
160 | if (file_exists('mods/'.$mod.'/init.php')) |
---|
161 | { |
---|
162 | include('mods/'.$mod.'/init.php'); |
---|
163 | } |
---|
164 | if (file_exists('mods/'.$mod.'/'.$page.'.php')) |
---|
165 | { |
---|
166 | if ($modOverrides) |
---|
167 | { |
---|
168 | die('Error: Two or more of the mods you have activated are conflicting'); |
---|
169 | } |
---|
170 | $modOverrides = true; |
---|
171 | $modOverride = $mod; |
---|
172 | } |
---|
173 | } |
---|
174 | $none = ''; |
---|
175 | event::call('mods_initialised', $none); |
---|
176 | if (!$settingsPage && !file_exists('common/'.$page.'.php') && !$modOverrides) |
---|
177 | { |
---|
178 | $page = 'home'; |
---|
179 | } |
---|
180 | |
---|
181 | cache::check($page); |
---|
182 | if ($settingsPage) |
---|
183 | { |
---|
184 | if (!session::isAdmin()) |
---|
185 | { |
---|
186 | header('Location: ?a=login'); |
---|
187 | echo '<a href="?a=login">Login</a>'; |
---|
188 | exit; |
---|
189 | } |
---|
190 | |
---|
191 | include('mods/'.substr($page, 9, strlen($page)-9).'/settings.php'); |
---|
192 | } |
---|
193 | elseif ($modOverrides) |
---|
194 | { |
---|
195 | include('mods/'.$modOverride.'/'.$page.'.php'); |
---|
196 | } |
---|
197 | else |
---|
198 | { |
---|
199 | include('common/'.$page.'.php'); |
---|
200 | } |
---|
201 | |
---|
202 | cache::generate(); |
---|
203 | ?> |
---|