root/dev/common/index.php @ 188

Revision 188, 3.3 KB (checked in by exi, 14 years ago)

Changed default td width for options to 160px.
Added the appropiate timeframe to the fast contractlisttable.
Events now can also return a reference to a variable containing additional information.
Killlists now return a non formatted isk-value for losses/kills, please report any errors on other pages.
Added a custom user menu, able to be shownon every page.
Added some code for user logins, please ignore it for now.
Added a small battle statistics frame to the battle overview.
To login as admin now just leave user blank and use the admin password.

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