1 <?php |
|
2 /*********************************************************************** |
|
3 |
|
4 Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org) |
|
5 |
|
6 This file is part of PunBB. |
|
7 |
|
8 PunBB is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published |
|
10 by the Free Software Foundation; either version 2 of the License, |
|
11 or (at your option) any later version. |
|
12 |
|
13 PunBB is distributed in the hope that it will be useful, but |
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 GNU General Public License for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with this program; if not, write to the Free Software |
|
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
|
21 MA 02111-1307 USA |
|
22 |
|
23 ************************************************************************/ |
|
24 |
|
25 // Import the Enano API |
|
26 global $db, $session, $paths, $template, $plugins; // Common objects |
|
27 |
|
28 // Make sure no one attempts to run this script "directly" |
|
29 if (!defined('PUN')) |
|
30 exit; |
|
31 |
|
32 $template->tpl_strings['PAGE_NAME'] = $page_title; |
|
33 $template->add_header('<pun_head>'); |
|
34 |
|
35 // Special case - many Enano themes have indented paragraphs |
|
36 $template->add_header('<style type="text/css"> |
|
37 div.pun p { |
|
38 margin-left: 0; |
|
39 } |
|
40 div.pun a[href ^="http://"] { |
|
41 background-image: none; |
|
42 padding-right: 0; |
|
43 } |
|
44 div.inbox li { |
|
45 list-style-type: none !important; |
|
46 } |
|
47 div.pun h2 { |
|
48 border-bottom-width: 0; |
|
49 } |
|
50 </style>'); |
|
51 |
|
52 // Send no-cache headers |
|
53 header('Expires: Thu, 21 Jul 1977 07:30:00 GMT'); // When yours truly first set eyes on this world! :) |
|
54 header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
55 header('Cache-Control: post-check=0, pre-check=0', false); |
|
56 header('Pragma: no-cache'); // For HTTP/1.0 compability |
|
57 |
|
58 // Load the template |
|
59 if (defined('PUN_ADMIN_CONSOLE')) |
|
60 { |
|
61 $inner = '<div id="punwrap"> |
|
62 <div id="punadmin" class="pun"> |
|
63 |
|
64 <div id="brdheader" class="block"> |
|
65 <div class="box"> |
|
66 <div id="brdtitle" class="inbox"> |
|
67 <pun_title> |
|
68 <pun_desc> |
|
69 </div> |
|
70 <pun_navlinks> |
|
71 <pun_status> |
|
72 </div> |
|
73 </div> |
|
74 |
|
75 <pun_announcement> |
|
76 |
|
77 <pun_main> |
|
78 |
|
79 <pun_footer> |
|
80 |
|
81 </div> |
|
82 </div>'; |
|
83 |
|
84 $tpl_main = $template->getHeader() . $inner . $template->getFooter(); |
|
85 } |
|
86 else if (defined('PUN_HELP')) |
|
87 { |
|
88 $tpl_main = file_get_contents(PUN_ROOT.'include/template/help.tpl'); |
|
89 } |
|
90 else |
|
91 { |
|
92 // $tpl_main = file_get_contents(PUN_ROOT.'include/template/main.tpl'); |
|
93 $inner = '<div id="punwrap"> |
|
94 <div id="pun<pun_page>" class="pun"> |
|
95 |
|
96 <div id="brdheader" class="block"> |
|
97 <div class="box"> |
|
98 <div id="brdtitle" class="inbox"> |
|
99 <pun_title> |
|
100 <pun_desc> |
|
101 </div> |
|
102 <pun_navlinks> |
|
103 <pun_status> |
|
104 </div> |
|
105 </div> |
|
106 |
|
107 <pun_announcement> |
|
108 |
|
109 <pun_main> |
|
110 |
|
111 <pun_footer> |
|
112 |
|
113 </div> |
|
114 </div>'; |
|
115 |
|
116 $tpl_main = $template->getHeader() . $inner . $template->getFooter(); |
|
117 |
|
118 } |
|
119 |
|
120 |
|
121 // START SUBST - <pun_include "*"> |
|
122 while (preg_match('#<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">#', $tpl_main, $cur_include)) |
|
123 { |
|
124 if (!file_exists(PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2])) |
|
125 error('Unable to process user include '.htmlspecialchars($cur_include[0]).' from template main.tpl. There is no such file in folder /include/user/'); |
|
126 |
|
127 ob_start(); |
|
128 include PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2]; |
|
129 $tpl_temp = ob_get_contents(); |
|
130 $tpl_main = str_replace($cur_include[0], $tpl_temp, $tpl_main); |
|
131 ob_end_clean(); |
|
132 } |
|
133 // END SUBST - <pun_include "*"> |
|
134 |
|
135 // START SUBST - <pun_content_direction> |
|
136 $tpl_main = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_main); |
|
137 // END SUBST - <pun_content_direction> |
|
138 |
|
139 |
|
140 // START SUBST - <pun_char_encoding> |
|
141 $tpl_main = str_replace('<pun_char_encoding>', $lang_common['lang_encoding'], $tpl_main); |
|
142 // END SUBST - <pun_char_encoding> |
|
143 |
|
144 // START SUBST - <pun_head> |
|
145 ob_start(); |
|
146 |
|
147 // Is this a page that we want search index spiders to index? |
|
148 if (!defined('PUN_ALLOW_INDEX')) |
|
149 echo '<meta name="ROBOTS" content="NOINDEX, FOLLOW" />'."\n"; |
|
150 |
|
151 ?> |
|
152 <link rel="stylesheet" type="text/css" href="<?php echo scriptPath; ?>/punbb/style/<?php echo $pun_user['style'].'.css' ?>" /> |
|
153 <?php |
|
154 |
|
155 if (defined('PUN_ADMIN_CONSOLE')) |
|
156 echo '<link rel="stylesheet" type="text/css" href="style/imports/base_admin.css" />'."\n"; |
|
157 |
|
158 if (isset($required_fields)) |
|
159 { |
|
160 // Output JavaScript to validate form (make sure required fields are filled out) |
|
161 |
|
162 ?> |
|
163 <script type="text/javascript"> |
|
164 <!-- |
|
165 function process_form(the_form) |
|
166 { |
|
167 var element_names = new Object() |
|
168 <?php |
|
169 |
|
170 // Output a JavaScript array with localised field names |
|
171 while (list($elem_orig, $elem_trans) = @each($required_fields)) |
|
172 echo "\t".'element_names["'.$elem_orig.'"] = "'.addslashes(str_replace(' ', ' ', $elem_trans)).'"'."\n"; |
|
173 |
|
174 ?> |
|
175 |
|
176 if (document.all || document.getElementById) |
|
177 { |
|
178 for (i = 0; i < the_form.length; ++i) |
|
179 { |
|
180 var elem = the_form.elements[i] |
|
181 if (elem.name && elem.name.substring(0, 4) == "req_") |
|
182 { |
|
183 if (elem.type && (elem.type=="text" || elem.type=="textarea" || elem.type=="password" || elem.type=="file") && elem.value=='') |
|
184 { |
|
185 alert("\"" + element_names[elem.name] + "\" <?php echo $lang_common['required field'] ?>") |
|
186 elem.focus() |
|
187 return false |
|
188 } |
|
189 } |
|
190 } |
|
191 } |
|
192 |
|
193 return true |
|
194 } |
|
195 // --> |
|
196 </script> |
|
197 <?php |
|
198 |
|
199 } |
|
200 |
|
201 $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : ''; |
|
202 if (strpos($user_agent, 'msie') !== false && strpos($user_agent, 'windows') !== false && strpos($user_agent, 'opera') === false) |
|
203 echo '<script type="text/javascript" src="style/imports/minmax.js"></script>'; |
|
204 |
|
205 $tpl_temp = trim(ob_get_contents()); |
|
206 $tpl_main = str_replace('<pun_head>', $tpl_temp, $tpl_main); |
|
207 ob_end_clean(); |
|
208 // END SUBST - <pun_head> |
|
209 |
|
210 |
|
211 // START SUBST - <body> |
|
212 if (isset($focus_element)) |
|
213 { |
|
214 $tpl_main = str_replace('<body onload="', '<body onload="document.getElementById(\''.$focus_element[0].'\').'.$focus_element[1].'.focus();', $tpl_main); |
|
215 $tpl_main = str_replace('<body>', '<body onload="document.getElementById(\''.$focus_element[0].'\').'.$focus_element[1].'.focus()">', $tpl_main); |
|
216 } |
|
217 // END SUBST - <body> |
|
218 |
|
219 |
|
220 // START SUBST - <pun_page> |
|
221 $tpl_main = str_replace('<pun_page>', htmlspecialchars(basename($_SERVER['PHP_SELF'], '.php')), $tpl_main); |
|
222 // END SUBST - <pun_page> |
|
223 |
|
224 |
|
225 // START SUBST - <pun_title> |
|
226 $tpl_main = str_replace('<pun_title>', '<h1><span>'.pun_htmlspecialchars($pun_config['o_board_title']).'</span></h1>', $tpl_main); |
|
227 // END SUBST - <pun_title> |
|
228 |
|
229 |
|
230 // START SUBST - <pun_desc> |
|
231 $tpl_main = str_replace('<pun_desc>', '<p><span>'.$pun_config['o_board_desc'].'</span></p>', $tpl_main); |
|
232 // END SUBST - <pun_desc> |
|
233 |
|
234 |
|
235 // START SUBST - <pun_navlinks> |
|
236 $tpl_main = str_replace('<pun_navlinks>','<div id="brdmenu" class="inbox">'."\n\t\t\t". generate_navlinks()."\n\t\t".'</div>', $tpl_main); |
|
237 // END SUBST - <pun_navlinks> |
|
238 |
|
239 |
|
240 // START SUBST - <pun_status> |
|
241 if ($pun_user['is_guest']) |
|
242 $tpl_temp = '<div id="brdwelcome" class="inbox">'."\n\t\t\t".'<p>'.$lang_common['Not logged in'].'</p>'."\n\t\t".'</div>'; |
|
243 else |
|
244 { |
|
245 $tpl_temp = '<div id="brdwelcome" class="inbox">'."\n\t\t\t".'<ul class="conl">'."\n\t\t\t\t".'<li>'.$lang_common['Logged in as'].' <strong>'.pun_htmlspecialchars($pun_user['username']).'</strong></li>'."\n\t\t\t\t".'<li>'.$lang_common['Last visit'].': '.format_time($pun_user['last_visit']).'</li>'; |
|
246 |
|
247 if ($pun_user['g_id'] >= USER_LEVEL_MEMBER) |
|
248 { |
|
249 $result_header = $pun_db->query('SELECT COUNT(id) FROM '.$pun_db->prefix.'reports WHERE zapped IS NULL') or error('Unable to fetch reports info', __FILE__, __LINE__, $pun_db->error()); |
|
250 |
|
251 if ($pun_db->result($result_header)) |
|
252 $tpl_temp .= "\n\t\t\t\t".'<li class="reportlink"><strong><a href="admin_reports.php">There are new reports</a></strong></li>'; |
|
253 |
|
254 if ($pun_config['o_maintenance'] == '1') |
|
255 $tpl_temp .= "\n\t\t\t\t".'<li class="maintenancelink"><strong><a href="admin_options.php#maintenance">Maintenance mode is enabled!</a></strong></li>'; |
|
256 } |
|
257 |
|
258 if (in_array(basename($_SERVER['PHP_SELF']), array('index.php', 'search.php'))) |
|
259 $tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<ul class="conr">'."\n\t\t\t\t".'<li><a href="search.php?action=show_new">'.$lang_common['Show new posts'].'</a></li>'."\n\t\t\t\t".'<li><a href="misc.php?action=markread">'.$lang_common['Mark all as read'].'</a></li>'."\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>'; |
|
260 else |
|
261 $tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>'; |
|
262 } |
|
263 |
|
264 $tpl_main = str_replace('<pun_status>', $tpl_temp, $tpl_main); |
|
265 // END SUBST - <pun_status> |
|
266 |
|
267 // START SUBST - <pun_announcement> |
|
268 if ($pun_config['o_announcement'] == '1') |
|
269 { |
|
270 ob_start(); |
|
271 |
|
272 ?> |
|
273 <div id="announce" class="block"> |
|
274 <h2><span><?php echo $lang_common['Announcement'] ?></span></h2> |
|
275 <div class="box"> |
|
276 <div class="inbox"> |
|
277 <div><?php echo $pun_config['o_announcement_message'] ?></div> |
|
278 </div> |
|
279 </div> |
|
280 </div> |
|
281 <?php |
|
282 |
|
283 $tpl_temp = trim(ob_get_contents()); |
|
284 $tpl_main = str_replace('<pun_announcement>', $tpl_temp, $tpl_main); |
|
285 ob_end_clean(); |
|
286 } |
|
287 else |
|
288 $tpl_main = str_replace('<pun_announcement>', '', $tpl_main); |
|
289 // END SUBST - <pun_announcement> |
|
290 |
|
291 // START SUBST - <pun_main> |
|
292 ob_start(); |
|
293 |
|
294 |
|
295 define('PUN_HEADER', 1); |
|