root/dev/common/index.php @ 400

Revision 400, 6.1 KB (checked in by kovell, 13 years ago)

Fixes: install is locked after first run, private cache files made inaccesible, initial summary caching removed from kill posting, board will not attempt to run on MySQL < 4.1, PILOT_ID cannot be set, legacy option removed from admin panel, pos values added to installation defaults

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');
29//require_once('common/includes/class.apicache.php');
30require_once('common/includes/class.killboard.php');
31require_once('common/includes/class.page.php');
32require_once('common/includes/class.event.php');
33require_once('common/includes/class.roles.php');
34#require_once('common/includes/class.titles.php');
35require_once('common/includes/class.user.php');
36require_once('common/includes/class.session.php');
37require_once('common/includes/class.cache.php');
38require_once('common/includes/class.involvedloader.php');
39require_once('common/smarty/Smarty.class.php');
40
41// smarty doesnt like it
42@set_magic_quotes_runtime(0);
43
44// remove some chars from the request string to avoid 'hacking'-attempts
45$page = str_replace('.', '', $_GET['a']);
46$page = str_replace('/', '', $page);
47if ($page == '' || $page == 'index')
48{
49    $page = 'home';
50}
51
52// check for the igb
53if (substr($_SERVER['HTTP_USER_AGENT'], 0, 15) == 'EVE-minibrowser')
54{
55    define('IS_IGB', true);
56    if (!isset($_GET['a']))
57    {
58        $page = 'igb';
59    }
60}
61else
62{
63    define('IS_IGB', false);
64}
65
66// load the config from the database
67$config = new Config(KB_SITE);
68//$ApiCache = new ApiCache(KB_SITE);
69define('KB_HOST', config::get('cfg_kbhost'));
70define('MAIN_SITE', config::get('cfg_mainsite'));
71define('STYLE_URL', config::get('cfg_style'));
72define('COMMON_URL', config::get('cfg_common'));
73define('IMG_URL', config::get('cfg_img'));
74define('KB_TITLE', config::get('cfg_kbtitle'));
75
76// pilot id not fully implemented yet.
77if (0 && config::get('cfg_pilotid'))
78{
79        define('PILOT_ID', intval(config::get('cfg_pilotid')) );
80        define('CORP_ID', 0);
81        define('ALLIANCE_ID', 0);
82}
83elseif (config::get('cfg_corpid'))
84{
85        define('PILOT_ID', 0);
86        define('CORP_ID', intval(config::get('cfg_corpid')));
87        define('ALLIANCE_ID', 0);
88}
89else
90{
91        define('PILOT_ID', 0);
92        define('CORP_ID', 0);
93        define('ALLIANCE_ID', intval(config::get('cfg_allianceid')));
94}
95
96// setting up smarty and feed it with some config
97$smarty = new Smarty();
98$smarty->template_dir = './templates';
99$smarty->compile_dir = './cache/templates_c';
100$smarty->cache_dir = './cache/data';
101$smarty->assign('style_url', STYLE_URL);
102$smarty->assign('img_url', IMG_URL);
103$smarty->assign('kb_host', KB_HOST);
104$smarty->assign_by_ref('config', $config);
105
106// set up titles/roles
107role::init();
108#title::init();
109
110// start session management
111session::init();
112
113// reinforced management
114if (config::get('auto_reinforced'))
115{
116    // first check if we are in reinforced
117    if (config::get('is_reinforced'))
118    {
119        // every 1/x request we check for disabling RF
120        if (rand(1, config::get('reinforced_rf_prob')) == 1)
121        {
122            cache::checkLoad();
123        }
124    }
125    else
126    {
127        // reinforced not active
128        // check for load and activate reinforced if needed
129        if (rand(1, config::get('reinforced_prob')) == 1)
130        {
131            cache::checkLoad();
132        }
133    }
134}
135// Enable page caching if set.
136if(config::get('cache_enabled')) define('KB_CACHE', 1);
137else define('KB_CACHE', 0);
138
139// Hardcode the DBUpdate
140define(LASTEST_DB_UPDATE,"010");
141
142if(config::get('DBUpdate') < LASTEST_DB_UPDATE) $page = 'admin';
143
144// all admin files are now in the admin directory and preload the menu
145if (substr($page, 0, 5) == 'admin')
146{
147    require_once('common/admin/admin_menu.php');
148        // Check DB is up to date.
149        require_once("common/includes/autoupgrade.php");
150        updateDB();
151    $page = 'admin/'.$page;
152}
153
154// old modcode for loading settings
155if (substr($page, 0, 9) == 'settings_')
156{
157    $settingsPage = true;
158}
159else
160{
161    $settingsPage = false;
162}
163$mods_active = explode(',', config::get('mods_active'));
164$modOverrides = false;
165$modconflicts = array();
166foreach ($mods_active as $mod)
167{
168    // load all active modules which need initialization
169    if (file_exists('mods/'.$mod.'/init.php'))
170    {
171        include('mods/'.$mod.'/init.php');
172    }
173    if (file_exists('mods/'.$mod.'/'.$page.'.php'))
174    {
175                $modconflicts[] = $mod;
176                /*
177                if ($modOverrides)
178        {
179            die('Error: Two or more of the mods you have activated are conflicting');
180        }
181                 *
182                 */
183        $modOverrides = true;
184        $modOverride = $mod;
185    }
186        if(count($modconflicts)>1)
187        {
188                echo "<html><head></head><body>There are multiple active mods ".
189                        "for this page. Only one may be active at a time. All others ".
190                        "must be deactivated in the admin panel.<br>";
191                foreach($modconflicts as $modname) echo $modname." <br> ";
192                echo "</body>";
193                die();
194        }
195}
196$none = '';
197event::call('mods_initialised', $none);
198if (!$settingsPage && !file_exists('common/'.$page.'.php') && !$modOverrides)
199{
200    $page = 'home';
201}
202// Serve feeds to feed fetchers.
203if(strpos($_SERVER['HTTP_USER_AGENT'], 'EDK Feedfetcher') !== false) $page = 'feed';
204cache::check($page);
205if ($settingsPage)
206{
207    if (!session::isAdmin())
208    {
209        header('Location: ?a=login');
210        echo '<a href="?a=login">Login</a>';
211        exit;
212    }
213
214    include('mods/'.substr($page, 9, strlen($page)-9).'/settings.php');
215}
216elseif ($modOverrides)
217{
218    include('mods/'.$modOverride.'/'.$page.'.php');
219}
220else
221{
222    include('common/'.$page.'.php');
223}
224
225cache::generate();
226?>
Note: See TracBrowser for help on using the browser.