1 | <?php |
---|
2 | require_once('common/includes/class.navigation.php'); |
---|
3 | |
---|
4 | class Page |
---|
5 | { |
---|
6 | function Page($title = '', $cachable = true) |
---|
7 | { |
---|
8 | if (!config::get('public_stats')) |
---|
9 | { |
---|
10 | config::set('public_stats','do nothing'); |
---|
11 | } |
---|
12 | |
---|
13 | $this->title_ = $title; |
---|
14 | $this->admin_ = false; |
---|
15 | $this->headlines = array(); |
---|
16 | |
---|
17 | $this->igb_ = IS_IGB; |
---|
18 | |
---|
19 | $this->timestart_ = strtok(microtime(), ' ') + strtok(''); |
---|
20 | |
---|
21 | $this->killboard_ = new Killboard(KB_SITE); |
---|
22 | |
---|
23 | $this->cachable_ = $cachable; |
---|
24 | $this->cachetime_ = 5; |
---|
25 | |
---|
26 | // if you have probs with missing tables uncomment this and |
---|
27 | // require_once('common/includes/autoupgrade.php'); |
---|
28 | // check_navigationtable(); |
---|
29 | } |
---|
30 | |
---|
31 | function setContent($html) |
---|
32 | { |
---|
33 | $this->contenthtml_ = $html; |
---|
34 | } |
---|
35 | |
---|
36 | function addContext($html) |
---|
37 | { |
---|
38 | $this->contexthtml_ .= $html; |
---|
39 | } |
---|
40 | |
---|
41 | function error($message) |
---|
42 | { |
---|
43 | global $smarty; |
---|
44 | |
---|
45 | $smarty->assign('error', $message); |
---|
46 | $this->setContent($smarty->fetch(get_tpl('error'))); |
---|
47 | $this->generate(); |
---|
48 | } |
---|
49 | |
---|
50 | function addHeader($line) |
---|
51 | { |
---|
52 | $this->headlines[] = $line; |
---|
53 | } |
---|
54 | |
---|
55 | function generate() |
---|
56 | { |
---|
57 | global $smarty; |
---|
58 | |
---|
59 | $smarty->assign('kb_title', KB_TITLE.' Killboard - '.$this->title_); |
---|
60 | |
---|
61 | $style = config::get('style_name'); |
---|
62 | $smarty->assign('style', $style); |
---|
63 | |
---|
64 | $smarty->assign('common_url', COMMON_URL); |
---|
65 | if ($this->onload_) |
---|
66 | { |
---|
67 | $smarty->assign('on_load', ' onload="'.$this->onload_.'"'); |
---|
68 | } |
---|
69 | |
---|
70 | event::call('page_assembleheader', $this); |
---|
71 | // header |
---|
72 | $smarty->assign('page_headerlines', join("\n", $this->headlines)); |
---|
73 | |
---|
74 | if (!$this->igb_) |
---|
75 | { |
---|
76 | if (strpos(config::get('mods_active'), 'rss_feed') !== false) |
---|
77 | { |
---|
78 | $smarty->assign('rss_feed', 1); |
---|
79 | } |
---|
80 | if (MAIN_SITE) |
---|
81 | { |
---|
82 | $smarty->assign('banner_link', MAIN_SITE); |
---|
83 | } |
---|
84 | $banner = config::get('style_banner'); |
---|
85 | if ($banner == 'custom') |
---|
86 | { |
---|
87 | $banner = 'kb-banner.jpg'; |
---|
88 | } |
---|
89 | $smarty->assign('banner', $banner); |
---|
90 | |
---|
91 | $nav = new Navigation(); |
---|
92 | $nav->setSite($_GET['a']); |
---|
93 | $menu = $nav->generateMenu(); |
---|
94 | $w = floor(100 / count($menu->get())); |
---|
95 | |
---|
96 | $smarty->assign('menu_w',$w.'%'); |
---|
97 | $smarty->assign('menu', $menu->get()); |
---|
98 | } |
---|
99 | $smarty->assign('page_title', $this->title_); |
---|
100 | |
---|
101 | $this->timeend_ = strtok(microtime(), ' ') + strtok(''); |
---|
102 | $this->processingtime_ = $this->timeend_ - $this->timestart_; |
---|
103 | |
---|
104 | $qry = new DBQuery(); |
---|
105 | if (method_exists($qry, 'queryCachedCount')) |
---|
106 | { |
---|
107 | $smarty->assign('profile_sql_cached', $qry->queryCachedCount()); |
---|
108 | } |
---|
109 | $smarty->assign('profile_sql', $qry->queryCount()); |
---|
110 | $smarty->assign('profile_time', $this->processingtime_); |
---|
111 | $smarty->assign('profile', KB_PROFILE); |
---|
112 | $smarty->assign('content_html', $this->contenthtml_); |
---|
113 | if (config::get('user_showmenu')) |
---|
114 | { |
---|
115 | $this->contexthtml_ = user::menu().$this->contexthtml_; |
---|
116 | } |
---|
117 | $smarty->assign('context_html', $this->contexthtml_); |
---|
118 | event::call('smarty_displayindex', $smarty); |
---|
119 | $smarty->display(get_tpl('index')); |
---|
120 | } |
---|
121 | |
---|
122 | function igb() |
---|
123 | { |
---|
124 | return $this->igb_; |
---|
125 | } |
---|
126 | |
---|
127 | function setOnLoad($onload) |
---|
128 | { |
---|
129 | $this->onload_ = $onload; |
---|
130 | } |
---|
131 | |
---|
132 | function setTitle($title) |
---|
133 | { |
---|
134 | $this->title_ = $title; |
---|
135 | } |
---|
136 | |
---|
137 | function setAdmin() |
---|
138 | { |
---|
139 | if (!Session::isAdmin()) |
---|
140 | { |
---|
141 | header("Location: ?a=login"); |
---|
142 | echo '<a href="?a=login">Login</a>'; |
---|
143 | exit; |
---|
144 | } |
---|
145 | } |
---|
146 | |
---|
147 | function isAdmin() |
---|
148 | { |
---|
149 | return Session::isAdmin(); |
---|
150 | } |
---|
151 | |
---|
152 | function isSuperAdmin() |
---|
153 | { |
---|
154 | return Session::isSuperAdmin(); |
---|
155 | } |
---|
156 | |
---|
157 | function setSuperAdmin() |
---|
158 | { |
---|
159 | if (!Session::isSuperAdmin()) |
---|
160 | Header("Location: ?a=login"); |
---|
161 | } |
---|
162 | |
---|
163 | function setCachable($cachable) |
---|
164 | { |
---|
165 | $this->cachable_ = $cachable; |
---|
166 | } |
---|
167 | |
---|
168 | function setCacheTime($cachetime) |
---|
169 | { |
---|
170 | $this->cachetime_ = $cachetime; |
---|
171 | } |
---|
172 | |
---|
173 | } |
---|
174 | |
---|
175 | class Menu |
---|
176 | { |
---|
177 | function Menu() |
---|
178 | { |
---|
179 | $this->menu_ = array(); |
---|
180 | } |
---|
181 | |
---|
182 | function get() |
---|
183 | { |
---|
184 | return $this->menu_; |
---|
185 | } |
---|
186 | |
---|
187 | function add($link, $text) |
---|
188 | { |
---|
189 | $this->menu_[] = array('link' => $link, 'text' => $text); |
---|
190 | } |
---|
191 | } |
---|
192 | ?> |
---|