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