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

Revision 245, 5.5 KB (checked in by exi, 13 years ago)

Fixed SQL Query caching.
Changed userportraits to use img/portraits.
Added JS code for IE/PNG-fix.

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'));
71if (DB_USE_QCACHE)
72{
73    require_once('common/includes/class.db_cache.php');
74}
75define('KB_TITLE', config::get('cfg_kbtitle'));
76
77// corporation OR alliance id
78if (config::get('cfg_corpid'))
79{
80    define('CORP_ID', config::get('cfg_corpid'));
81    define('ALLIANCE_ID', 0);
82}
83else
84{
85    define('CORP_ID', 0);
86    define('ALLIANCE_ID', config::get('cfg_allianceid'));
87}
88if (!$dir = config::get('cache_dir'))
89{
90    $dir = 'cache/data';
91}
92define('KB_CACHEDIR', $dir);
93
94// setting up smarty and feed it with some config
95$smarty = new Smarty();
96$smarty->template_dir = './templates';
97$smarty->compile_dir = './cache/templates_c';
98$smarty->cache_dir = './cache/data';
99$smarty->assign('style_url', STYLE_URL);
100$smarty->assign('img_url', IMG_URL);
101$smarty->assign_by_ref('config', $config);
102
103// set up titles/roles
104role::init();
105#title::init();
106
107// start session management
108session::init();
109
110// reinforced management
111if (config::get('auto_reinforced'))
112{
113    // first check if we are in reinforced
114    if (config::get('is_reinforced'))
115    {
116        // every 1/x request we check for disabling RF
117        if (rand(1, config::get('reinforced_rf_prob')) == 1)
118        {
119            cache::checkLoad();
120        }
121    }
122    else
123    {
124        // reinforced not active
125        // check for load and activate reinforced if needed
126        if (rand(1, config::get('reinforced_prob')) == 1)
127        {
128            cache::checkLoad();
129        }
130    }
131}
132
133// this is to make sure that smarty is able to create output
134if (!is_dir('./cache/templates_c'))
135{
136    if (mkdir('./cache/templates_c'))
137    {
138        chmod('./cache/templates_c', 0777);
139    }
140    else
141    {
142        exit('please create cache/templates_c and chmod it 777');
143    }
144}
145
146// all admin files are now in the admin directory and preload the menu
147if (substr($page, 0, 5) == 'admin')
148{
149    require_once('common/admin/admin_menu.php');
150    $page = 'admin/'.$page;
151}
152
153// old modcode for loading settings
154if (substr($page, 0, 9) == 'settings_')
155{
156    $settingsPage = true;
157}
158else
159{
160    $settingsPage = false;
161}
162$mods_active = explode(',', config::get('mods_active'));
163$modOverrides = false;
164foreach ($mods_active as $mod)
165{
166    // load all active modules which need initialization
167    if (file_exists('mods/'.$mod.'/init.php'))
168    {
169        include('mods/'.$mod.'/init.php');
170    }
171    if (file_exists('mods/'.$mod.'/'.$page.'.php'))
172    {
173        if ($modOverrides)
174        {
175            die('Error: Two or more of the mods you have activated are conflicting');
176        }
177        $modOverrides = true;
178        $modOverride = $mod;
179    }
180}
181if (!$settingsPage && !file_exists('common/'.$page.'.php') && !$modOverrides)
182{
183    $page = 'home';
184}
185
186cache::check($page);
187if ($settingsPage)
188{
189    if (!session::isAdmin())
190    {
191        header('Location: ?a=login');
192        echo '<a href="?a=login">Login</a>';
193        exit;
194    }
195
196    include('mods/'.substr($page, 9, strlen($page)-9).'/settings.php');
197}
198elseif ($modOverrides)
199{
200    include('mods/'.$modOverride.'/'.$page.'.php');
201}
202else
203{
204    include('common/'.$page.'.php');
205}
206
207cache::generate();
208?>
Note: See TracBrowser for help on using the browser.