root/dev/common/index.php @ 282

Revision 282, 5.5 KB (checked in by exi, 15 years ago)

Removed autoupgrade code, all databases should be up to date.
Fixed 2 parser bugs with trinity mails.
Added event call after all mods have been loaded.
Added an option to include the dropped item value to total loss.

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('kbconfig.php');
25require_once('common/includes/globals.php');
26require_once('common/includes/php_compat.php');
27require_once('common/includes/db.php');
28require_once('common/includes/class.config.php');
29require_once('common/includes/class.killboard.php');
30require_once('common/includes/class.page.php');
31require_once('common/includes/class.event.php');
32require_once('common/includes/class.roles.php');
33#require_once('common/includes/class.titles.php');
34require_once('common/includes/class.user.php');
35require_once('common/includes/class.session.php');
36require_once('common/includes/class.cache.php');
37require_once('common/includes/class.involvedloader.php');
38require_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);
46if ($page == '' || $page == 'index')
47{
48    $page = 'home';
49}
50
51// check for the igb
52if (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}
60else
61{
62    define('IS_IGB', false);
63}
64
65// load the config from the database
66$config = new Config(KB_SITE);
67define('DB_USE_CCP', true);
68define('KB_HOST', config::get('cfg_kbhost'));
69define('MAIN_SITE', config::get('cfg_mainsite'));
70define('STYLE_URL', config::get('cfg_style'));
71define('COMMON_URL', config::get('cfg_common'));
72define('IMG_URL', config::get('cfg_img'));
73define('DB_HALTONERROR', (bool)config::get('cfg_sqlhalt'));
74define('DB_USE_QCACHE', (bool)config::get('cfg_qcache'));
75if (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}
80define('KB_TITLE', config::get('cfg_kbtitle'));
81
82// corporation OR alliance id
83if (config::get('cfg_corpid'))
84{
85    define('CORP_ID', config::get('cfg_corpid'));
86    define('ALLIANCE_ID', 0);
87}
88else
89{
90    define('CORP_ID', 0);
91    define('ALLIANCE_ID', config::get('cfg_allianceid'));
92}
93if (!$dir = config::get('cache_dir'))
94{
95    $dir = 'cache/data';
96}
97define('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_by_ref('config', $config);
107
108// set up titles/roles
109role::init();
110#title::init();
111
112// start session management
113session::init();
114
115// reinforced management
116if (config::get('auto_reinforced'))
117{
118    // first check if we are in reinforced
119    if (config::get('is_reinforced'))
120    {
121        // every 1/x request we check for disabling RF
122        if (rand(1, config::get('reinforced_rf_prob')) == 1)
123        {
124            cache::checkLoad();
125        }
126    }
127    else
128    {
129        // reinforced not active
130        // check for load and activate reinforced if needed
131        if (rand(1, config::get('reinforced_prob')) == 1)
132        {
133            cache::checkLoad();
134        }
135    }
136}
137
138// all admin files are now in the admin directory and preload the menu
139if (substr($page, 0, 5) == 'admin')
140{
141    require_once('common/admin/admin_menu.php');
142    $page = 'admin/'.$page;
143}
144
145// old modcode for loading settings
146if (substr($page, 0, 9) == 'settings_')
147{
148    $settingsPage = true;
149}
150else
151{
152    $settingsPage = false;
153}
154$mods_active = explode(',', config::get('mods_active'));
155$modOverrides = false;
156foreach ($mods_active as $mod)
157{
158    // load all active modules which need initialization
159    if (file_exists('mods/'.$mod.'/init.php'))
160    {
161        include('mods/'.$mod.'/init.php');
162    }
163    if (file_exists('mods/'.$mod.'/'.$page.'.php'))
164    {
165        if ($modOverrides)
166        {
167            die('Error: Two or more of the mods you have activated are conflicting');
168        }
169        $modOverrides = true;
170        $modOverride = $mod;
171    }
172}
173$none = '';
174event::call('mods_initialised', $none);
175if (!$settingsPage && !file_exists('common/'.$page.'.php') && !$modOverrides)
176{
177    $page = 'home';
178}
179
180cache::check($page);
181if ($settingsPage)
182{
183    if (!session::isAdmin())
184    {
185        header('Location: ?a=login');
186        echo '<a href="?a=login">Login</a>';
187        exit;
188    }
189
190    include('mods/'.substr($page, 9, strlen($page)-9).'/settings.php');
191}
192elseif ($modOverrides)
193{
194    include('mods/'.$modOverride.'/'.$page.'.php');
195}
196else
197{
198    include('common/'.$page.'.php');
199}
200
201cache::generate();
202?>
Note: See TracBrowser for help on using the browser.