|
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 |
|
26 // Make sure no one attempts to run this script "directly" |
|
27 if (!defined('PUN')) |
|
28 exit; |
|
29 |
|
30 // Send no-cache headers |
|
31 header('Expires: Thu, 21 Jul 1977 07:30:00 GMT'); // When yours truly first set eyes on this world! :) |
|
32 header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
33 header('Cache-Control: post-check=0, pre-check=0', false); |
|
34 header('Pragma: no-cache'); // For HTTP/1.0 compability |
|
35 |
|
36 |
|
37 // Load the template |
|
38 if (defined('PUN_ADMIN_CONSOLE')) |
|
39 $tpl_main = file_get_contents(PUN_ROOT.'include/template/admin.tpl'); |
|
40 else if (defined('PUN_HELP')) |
|
41 $tpl_main = file_get_contents(PUN_ROOT.'include/template/help.tpl'); |
|
42 else |
|
43 $tpl_main = file_get_contents(PUN_ROOT.'include/template/main.tpl'); |
|
44 |
|
45 |
|
46 // START SUBST - <pun_include "*"> |
|
47 while (preg_match('#<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">#', $tpl_main, $cur_include)) |
|
48 { |
|
49 if (!file_exists(PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2])) |
|
50 error('Unable to process user include '.htmlspecialchars($cur_include[0]).' from template main.tpl. There is no such file in folder /include/user/'); |
|
51 |
|
52 ob_start(); |
|
53 include PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2]; |
|
54 $tpl_temp = ob_get_contents(); |
|
55 $tpl_main = str_replace($cur_include[0], $tpl_temp, $tpl_main); |
|
56 ob_end_clean(); |
|
57 } |
|
58 // END SUBST - <pun_include "*"> |
|
59 |
|
60 |
|
61 // START SUBST - <pun_content_direction> |
|
62 $tpl_main = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_main); |
|
63 // END SUBST - <pun_content_direction> |
|
64 |
|
65 |
|
66 // START SUBST - <pun_char_encoding> |
|
67 $tpl_main = str_replace('<pun_char_encoding>', $lang_common['lang_encoding'], $tpl_main); |
|
68 // END SUBST - <pun_char_encoding> |
|
69 |
|
70 |
|
71 // START SUBST - <pun_head> |
|
72 ob_start(); |
|
73 |
|
74 // Is this a page that we want search index spiders to index? |
|
75 if (!defined('PUN_ALLOW_INDEX')) |
|
76 echo '<meta name="ROBOTS" content="NOINDEX, FOLLOW" />'."\n"; |
|
77 |
|
78 ?> |
|
79 <title><?php echo $page_title ?></title> |
|
80 <link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" /> |
|
81 <?php |
|
82 |
|
83 if (defined('PUN_ADMIN_CONSOLE')) |
|
84 echo '<link rel="stylesheet" type="text/css" href="style/imports/base_admin.css" />'."\n"; |
|
85 |
|
86 if (isset($required_fields)) |
|
87 { |
|
88 // Output JavaScript to validate form (make sure required fields are filled out) |
|
89 |
|
90 ?> |
|
91 <script type="text/javascript"> |
|
92 <!-- |
|
93 function process_form(the_form) |
|
94 { |
|
95 var element_names = new Object() |
|
96 <?php |
|
97 |
|
98 // Output a JavaScript array with localised field names |
|
99 while (list($elem_orig, $elem_trans) = @each($required_fields)) |
|
100 echo "\t".'element_names["'.$elem_orig.'"] = "'.addslashes(str_replace(' ', ' ', $elem_trans)).'"'."\n"; |
|
101 |
|
102 ?> |
|
103 |
|
104 if (document.all || document.getElementById) |
|
105 { |
|
106 for (i = 0; i < the_form.length; ++i) |
|
107 { |
|
108 var elem = the_form.elements[i] |
|
109 if (elem.name && elem.name.substring(0, 4) == "req_") |
|
110 { |
|
111 if (elem.type && (elem.type=="text" || elem.type=="textarea" || elem.type=="password" || elem.type=="file") && elem.value=='') |
|
112 { |
|
113 alert("\"" + element_names[elem.name] + "\" <?php echo $lang_common['required field'] ?>") |
|
114 elem.focus() |
|
115 return false |
|
116 } |
|
117 } |
|
118 } |
|
119 } |
|
120 |
|
121 return true |
|
122 } |
|
123 // --> |
|
124 </script> |
|
125 <?php |
|
126 |
|
127 } |
|
128 |
|
129 $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : ''; |
|
130 if (strpos($user_agent, 'msie') !== false && strpos($user_agent, 'windows') !== false && strpos($user_agent, 'opera') === false) |
|
131 echo '<script type="text/javascript" src="style/imports/minmax.js"></script>'; |
|
132 |
|
133 $tpl_temp = trim(ob_get_contents()); |
|
134 $tpl_main = str_replace('<pun_head>', $tpl_temp, $tpl_main); |
|
135 ob_end_clean(); |
|
136 // END SUBST - <pun_head> |
|
137 |
|
138 |
|
139 // START SUBST - <body> |
|
140 if (isset($focus_element)) |
|
141 { |
|
142 $tpl_main = str_replace('<body onload="', '<body onload="document.getElementById(\''.$focus_element[0].'\').'.$focus_element[1].'.focus();', $tpl_main); |
|
143 $tpl_main = str_replace('<body>', '<body onload="document.getElementById(\''.$focus_element[0].'\').'.$focus_element[1].'.focus()">', $tpl_main); |
|
144 } |
|
145 // END SUBST - <body> |
|
146 |
|
147 |
|
148 // START SUBST - <pun_page> |
|
149 $tpl_main = str_replace('<pun_page>', htmlspecialchars(basename($_SERVER['PHP_SELF'], '.php')), $tpl_main); |
|
150 // END SUBST - <pun_title> |
|
151 |
|
152 |
|
153 // START SUBST - <pun_title> |
|
154 $tpl_main = str_replace('<pun_title>', '<h1><span>'.pun_htmlspecialchars($pun_config['o_board_title']).'</span></h1>', $tpl_main); |
|
155 // END SUBST - <pun_title> |
|
156 |
|
157 |
|
158 // START SUBST - <pun_desc> |
|
159 $tpl_main = str_replace('<pun_desc>', '<p><span>'.$pun_config['o_board_desc'].'</span></p>', $tpl_main); |
|
160 // END SUBST - <pun_desc> |
|
161 |
|
162 |
|
163 // START SUBST - <pun_navlinks> |
|
164 $tpl_main = str_replace('<pun_navlinks>','<div id="brdmenu" class="inbox">'."\n\t\t\t". generate_navlinks()."\n\t\t".'</div>', $tpl_main); |
|
165 // END SUBST - <pun_navlinks> |
|
166 |
|
167 |
|
168 // START SUBST - <pun_status> |
|
169 if ($pun_user['is_guest']) |
|
170 $tpl_temp = '<div id="brdwelcome" class="inbox">'."\n\t\t\t".'<p>'.$lang_common['Not logged in'].'</p>'."\n\t\t".'</div>'; |
|
171 else |
|
172 { |
|
173 $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>'; |
|
174 |
|
175 if ($pun_user['g_id'] < PUN_GUEST) |
|
176 { |
|
177 $result_header = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'reports WHERE zapped IS NULL') or error('Unable to fetch reports info', __FILE__, __LINE__, $db->error()); |
|
178 |
|
179 if ($db->result($result_header)) |
|
180 $tpl_temp .= "\n\t\t\t\t".'<li class="reportlink"><strong><a href="admin_reports.php">There are new reports</a></strong></li>'; |
|
181 |
|
182 if ($pun_config['o_maintenance'] == '1') |
|
183 $tpl_temp .= "\n\t\t\t\t".'<li class="maintenancelink"><strong><a href="admin_options.php#maintenance">Maintenance mode is enabled!</a></strong></li>'; |
|
184 } |
|
185 |
|
186 if (in_array(basename($_SERVER['PHP_SELF']), array('index.php', 'search.php'))) |
|
187 $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>'; |
|
188 else |
|
189 $tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>'; |
|
190 } |
|
191 |
|
192 $tpl_main = str_replace('<pun_status>', $tpl_temp, $tpl_main); |
|
193 // END SUBST - <pun_status> |
|
194 |
|
195 |
|
196 // START SUBST - <pun_announcement> |
|
197 if ($pun_config['o_announcement'] == '1') |
|
198 { |
|
199 ob_start(); |
|
200 |
|
201 ?> |
|
202 <div id="announce" class="block"> |
|
203 <h2><span><?php echo $lang_common['Announcement'] ?></span></h2> |
|
204 <div class="box"> |
|
205 <div class="inbox"> |
|
206 <div><?php echo $pun_config['o_announcement_message'] ?></div> |
|
207 </div> |
|
208 </div> |
|
209 </div> |
|
210 <?php |
|
211 |
|
212 $tpl_temp = trim(ob_get_contents()); |
|
213 $tpl_main = str_replace('<pun_announcement>', $tpl_temp, $tpl_main); |
|
214 ob_end_clean(); |
|
215 } |
|
216 else |
|
217 $tpl_main = str_replace('<pun_announcement>', '', $tpl_main); |
|
218 // END SUBST - <pun_announcement> |
|
219 |
|
220 |
|
221 // START SUBST - <pun_main> |
|
222 ob_start(); |
|
223 |
|
224 |
|
225 define('PUN_HEADER', 1); |