1 | <?php |
---|
2 | require_once("config.php"); |
---|
3 | require_once("class.killboard.php"); |
---|
4 | require_once("class.session.php"); |
---|
5 | |
---|
6 | class Page |
---|
7 | { |
---|
8 | function Page($title = "", $cachable = true) |
---|
9 | { |
---|
10 | $this->title_ = $title; |
---|
11 | $this->admin_ = false; |
---|
12 | |
---|
13 | if (substr($_SERVER['HTTP_USER_AGENT'], 0, 15) == "EVE-minibrowser") |
---|
14 | { |
---|
15 | $this->igb_ = true; |
---|
16 | } |
---|
17 | else |
---|
18 | { |
---|
19 | $this->igb_ = false; |
---|
20 | } |
---|
21 | |
---|
22 | $this->timestart_ = strtok(microtime(), ' ') + strtok(''); |
---|
23 | |
---|
24 | $this->killboard_ = new Killboard(KB_SITE); |
---|
25 | |
---|
26 | $this->session_ = new Session(); |
---|
27 | |
---|
28 | $this->cachable_ = $cachable; |
---|
29 | $this->cachetime_ = 5; |
---|
30 | } |
---|
31 | |
---|
32 | function setContent($html) |
---|
33 | { |
---|
34 | $this->contenthtml_ = $html; |
---|
35 | } |
---|
36 | |
---|
37 | function addContext($html) |
---|
38 | { |
---|
39 | $this->contexthtml_ .= $html; |
---|
40 | } |
---|
41 | |
---|
42 | function error($message) |
---|
43 | { |
---|
44 | global $smarty; |
---|
45 | |
---|
46 | $smarty->assign('error', $message); |
---|
47 | $this->setContent($smarty->fetch(get_tpl('error'))); |
---|
48 | $this->generate(); |
---|
49 | } |
---|
50 | |
---|
51 | function generate() |
---|
52 | { |
---|
53 | global $smarty; |
---|
54 | |
---|
55 | $smarty->assign('kb_title', KB_TITLE.' Killboard - '.$this->title_); |
---|
56 | |
---|
57 | $style = config::get('style_name'); |
---|
58 | $smarty->assign('style', $style); |
---|
59 | |
---|
60 | $smarty->assign('common_url', COMMON_URL); |
---|
61 | if ($this->onload_) |
---|
62 | { |
---|
63 | $smarty->assign('on_load', ' onload="'.$this->onload_.'"'); |
---|
64 | } |
---|
65 | // header |
---|
66 | |
---|
67 | if (!$this->igb_) |
---|
68 | { |
---|
69 | if (strpos(config::get('mods_active'), 'rss_feed') !== false) |
---|
70 | { |
---|
71 | $smarty->assign('rss_feed', 1); |
---|
72 | } |
---|
73 | if (MAIN_SITE) |
---|
74 | { |
---|
75 | $smarty->assign('banner_link', MAIN_SITE); |
---|
76 | } |
---|
77 | $banner = config::get('style_banner'); |
---|
78 | if ($banner == 'custom') |
---|
79 | { |
---|
80 | $banner = 'kb-banner.jpg'; |
---|
81 | } |
---|
82 | $smarty->assign('banner', $banner); |
---|
83 | |
---|
84 | $menu = new Menu(); |
---|
85 | $menu->add('home', 'Home'); |
---|
86 | |
---|
87 | $contracts = $this->killboard_->hasContracts(); |
---|
88 | $campaigns = $this->killboard_->hasCampaigns(); |
---|
89 | if ($contracts) |
---|
90 | { |
---|
91 | $menu->add('contracts', 'Contracts'); |
---|
92 | } |
---|
93 | if ($campaigns) |
---|
94 | { |
---|
95 | $menu->add('campaigns', 'Campaigns'); |
---|
96 | } |
---|
97 | $w = 10; |
---|
98 | if ($campaigns) |
---|
99 | { |
---|
100 | $w--; |
---|
101 | } |
---|
102 | if ($contracts) |
---|
103 | { |
---|
104 | $w--; |
---|
105 | } |
---|
106 | if (config::get('show_standing')) |
---|
107 | { |
---|
108 | $w--; |
---|
109 | $menu->add('standings', 'Standings'); |
---|
110 | } |
---|
111 | $menu->add('kills', 'Kills'); |
---|
112 | $menu->add('losses', 'Losses'); |
---|
113 | $menu->add('post', 'Post Mail'); |
---|
114 | |
---|
115 | if (CORP_ID) |
---|
116 | { |
---|
117 | $link = 'corp_detail&crp_id='.CORP_ID; |
---|
118 | } |
---|
119 | elseif (ALLIANCE_ID) |
---|
120 | { |
---|
121 | $link = 'alliance_detail&all_id='.ALLIANCE_ID; |
---|
122 | } |
---|
123 | $menu->add($link, 'Stats'); |
---|
124 | $menu->add('awards', 'Awards'); |
---|
125 | $menu->add('search', 'Search'); |
---|
126 | $menu->add('admin', 'Admin'); |
---|
127 | $menu->add('about', 'About'); |
---|
128 | |
---|
129 | $smarty->assign('menu_w', $w.'%'); |
---|
130 | $smarty->assign('menu', $menu->get()); |
---|
131 | } |
---|
132 | $smarty->assign('page_title', $this->title_); |
---|
133 | |
---|
134 | $this->timeend_ = strtok(microtime(), ' ') + strtok(''); |
---|
135 | $this->processingtime_ = $this->timeend_ - $this->timestart_; |
---|
136 | |
---|
137 | $smarty->assign('profile_time', $this->processingtime_); |
---|
138 | $smarty->assign('profile', KB_PROFILE); |
---|
139 | $smarty->assign('content_html', $this->contenthtml_); |
---|
140 | if (config::get('user_showmenu')) |
---|
141 | { |
---|
142 | $this->contexthtml_ = user::menu().$this->contexthtml_; |
---|
143 | } |
---|
144 | $smarty->assign('context_html', $this->contexthtml_); |
---|
145 | $smarty->display(get_tpl('index')); |
---|
146 | } |
---|
147 | |
---|
148 | function igb() |
---|
149 | { |
---|
150 | return $this->igb_; |
---|
151 | } |
---|
152 | |
---|
153 | function setOnLoad($onload) |
---|
154 | { |
---|
155 | $this->onload_ = $onload; |
---|
156 | } |
---|
157 | |
---|
158 | function setTitle($title) |
---|
159 | { |
---|
160 | $this->title_ = $title; |
---|
161 | } |
---|
162 | |
---|
163 | function setAdmin() |
---|
164 | { |
---|
165 | if (!$this->session_->isAdmin()) |
---|
166 | { |
---|
167 | header("Location: ?a=login"); |
---|
168 | echo '<a href="?a=login">Login</a>'; |
---|
169 | exit; |
---|
170 | } |
---|
171 | } |
---|
172 | |
---|
173 | function isAdmin() |
---|
174 | { |
---|
175 | return $this->session_->isAdmin(); |
---|
176 | } |
---|
177 | |
---|
178 | function isSuperAdmin() |
---|
179 | { |
---|
180 | return $this->session_->isSuperAdmin(); |
---|
181 | } |
---|
182 | |
---|
183 | function setSuperAdmin() |
---|
184 | { |
---|
185 | if (!$this->session_->isSuperAdmin()) |
---|
186 | Header("Location: ?a=login"); |
---|
187 | } |
---|
188 | |
---|
189 | function setCachable($cachable) |
---|
190 | { |
---|
191 | $this->cachable_ = $cachable; |
---|
192 | } |
---|
193 | |
---|
194 | function setCacheTime($cachetime) |
---|
195 | { |
---|
196 | $this->cachetime_ = $cachetime; |
---|
197 | } |
---|
198 | } |
---|
199 | |
---|
200 | class Menu |
---|
201 | { |
---|
202 | function Menu() |
---|
203 | { |
---|
204 | $this->menu_ = array(); |
---|
205 | } |
---|
206 | |
---|
207 | function get() |
---|
208 | { |
---|
209 | return $this->menu_; |
---|
210 | } |
---|
211 | |
---|
212 | function add($link, $text) |
---|
213 | { |
---|
214 | $this->menu_[] = array('link' => $link, 'text' => $text); |
---|
215 | } |
---|
216 | } |
---|
217 | ?> |
---|