root/branch/rev3/common/index.php @ 243

Revision 243, 5.4 KB (checked in by exi, 13 years ago)

Moving config to runtime
Added reinforced management
New icon set with alpha, fixed missing/wrong icons
Changed version to 1.4.0
Added code for handling the new dogma codebase

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