root/dev/common/index.php @ 181

Revision 181, 3.2 KB (checked in by exi, 16 years ago)

Changed admin/options to show the actual page as page title.
admin_menu.php now also loads settings from mods.
Added event manager and the first 2 events (comment/killmail added).
Changed config to be in a separate file and modified it to be called static with config::get().
http_request now stores the socket status in $this->status.
Changed MapView? to store pictures based on KB_SITE so it doesnt show a map with wrong colors for the current killboard on a multi-site installation.
Changed options to handle element options (like 'edit:size:40').
Changed options to use the static calls to config.
Changed Page to use the static calls to config.
Changed Session to use session_name() to determine if it should start a session.
index.php now loads module-init-scripts.
Changed post.php to use config and it should now also use the mailserver configuration directive to send emails.
Added a mail_forward-mod to show how easy it can be to develop mods once there are enough events listed.
Fixed 2 typos in battle_overview.tpl.

Line 
1<?php
2require_once('db.php');
3require_once('class.killboard.php');
4require_once('smarty/Smarty.class.php');
5require_once('class.event.php');
6require_once('class.roles.php');
7// smarty doesnt like it (i either)
8@set_magic_quotes_runtime(0);
9
10$page = str_replace('.', '', $_GET['a']);
11$page = str_replace('/', '', $page);
12if ($page == '')
13{
14    $page = 'home';
15}
16
17// check for the igb
18if (substr($_SERVER['HTTP_USER_AGENT'], 0, 15) == 'EVE-minibrowser')
19{
20    define('IS_IGB', true);
21    if (!isset($_GET['a']))
22    {
23        $page = 'igb';
24    }
25}
26else
27{
28    define('IS_IGB', false);
29}
30
31$killboard = new Killboard(KB_SITE);
32$config = $killboard->getConfig();
33
34// setting up smarty
35$smarty = new Smarty();
36$smarty->template_dir = './templates';
37$smarty->compile_dir = './cache/templates_c';
38$smarty->cache_dir = './cache/data';
39$smarty->assign('style_url', STYLE_URL);
40$smarty->assign('img_url', IMG_URL);
41$smarty->assign_by_ref('config', $config);
42
43// this is to make sure that smarty is able to create output
44if (!is_dir('./cache/templates_c'))
45{
46    if (mkdir('./cache/templates_c'))
47    {
48        chmod('./cache/templates_c', 0777);
49    }
50    else
51    {
52        exit('please create cache/templates_c and chmod it 777');
53    }
54}
55
56if (substr($page, 0, 9) == 'settings_')
57{
58    $settingsPage = true;
59}
60else
61{
62    $settingsPage = false;
63}
64$mods_active = explode(',', $config->getConfig('mods_active'));
65$modOverrides = false;
66foreach ($mods_active as $mod)
67{
68    // load all modules which need initialization
69    if (file_exists('mods/'.$mod.'/init.php'))
70    {
71        include('mods/'.$mod.'/init.php');
72    }
73    if (file_exists('mods/'.$mod.'/'.$page.'.php'))
74    {
75        if ($modOverrides)
76        {
77            die('Error: Two or more of the mods you have activated are conflicting');
78        }
79        $modOverrides = true;
80        $modOverride = $mod;
81    }
82}
83if (!$settingsPage && !file_exists('common/'.$page.'.php') && !$modOverrides)
84{
85    $page = 'home';
86}
87
88if (KB_CACHE == 1 && count($_POST) == 0 && !in_array($page, $cacheignore))
89{
90    $docache = true;
91}
92else
93{
94    $docache = false;
95}
96
97if ($docache)
98{
99    if (!file_exists(KB_CACHEDIR . '/' . KB_SITE))
100    {
101        @mkdir(KB_CACHEDIR . '/' . KB_SITE);
102    }
103
104    if ($cachetimes[$page])
105    {
106        $cachetime = $cachetimes[$page];
107    }
108    else
109    {
110        $cachetime = 5;
111    }
112
113    $cachetime = $cachetime * 60;
114
115    $cachefile = KB_CACHEDIR . '/' . KB_SITE . '/' . md5($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']) . '.cache';
116    $timestamp = ((@file_exists($cachefile))) ? @filemtime($cachefile) : 0;
117
118    if (time() - $cachetime < $timestamp)
119    {
120        ob_start('ob_gzhandler');
121        @readfile($cachefile);
122        ob_end_flush();
123        exit();
124    }
125
126    ob_start();
127}
128
129if ($settingsPage)
130{
131    include ('mods/'.substr($page, 9, strlen($page)-9).'/settings.php');
132}
133elseif ($modOverrides)
134{
135    include('mods/'.$modOverride.'/'.$page.'.php');
136}
137else
138{
139    include('common/'.$page.'.php');
140}
141
142if ($docache)
143{
144    $fp = @fopen($cachefile, 'w');
145    @fwrite($fp, ob_get_contents());
146    @fwrite($fp, '<!-- Generated from cache -->');
147    @fclose($fp);
148    ob_end_flush();
149}
150?>
Note: See TracBrowser for help on using the browser.