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