root/dev/common/index.php @ 325

Revision 316, 5.6 KB (checked in by ralle030583, 14 years ago)

Tickets #72 , #73
- assign kb_host to smarty
- type and reformot in portrait_grab

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('kb_host', KB_HOST);
107$smarty->assign_by_ref('config', $config);
108
109// set up titles/roles
110role::init();
111#title::init();
112
113// start session management
114session::init();
115
116// reinforced management
117if (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
140if (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
147if (substr($page, 0, 9) == 'settings_')
148{
149    $settingsPage = true;
150}
151else
152{
153    $settingsPage = false;
154}
155$mods_active = explode(',', config::get('mods_active'));
156$modOverrides = false;
157foreach ($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 = '';
175event::call('mods_initialised', $none);
176if (!$settingsPage && !file_exists('common/'.$page.'.php') && !$modOverrides)
177{
178    $page = 'home';
179}
180
181cache::check($page);
182if ($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}
193elseif ($modOverrides)
194{
195    include('mods/'.$modOverride.'/'.$page.'.php');
196}
197else
198{
199    include('common/'.$page.'.php');
200}
201
202cache::generate();
203?>
Note: See TracBrowser for help on using the browser.