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