Changeset 3 for branches/rsr.v5.1.dev/web/punbb/header.php
- Timestamp:
- Nov 14, 2011, 11:17:15 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/rsr.v5.1.dev/web/punbb/header.php
r1 r3 1 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 2 3 /** 4 * Copyright (C) 2008-2011 FluxBB 5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB 6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher 7 */ 25 8 26 9 // Make sure no one attempts to run this script "directly" … … 29 12 30 13 // Send no-cache headers 31 header('Expires: Thu, 21 Jul 1977 07:30:00 GMT'); 14 header('Expires: Thu, 21 Jul 1977 07:30:00 GMT'); // When yours truly first set eyes on this world! :) 32 15 header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); 33 16 header('Cache-Control: post-check=0, pre-check=0', false); 34 header('Pragma: no-cache'); // For HTTP/1.0 compability 35 17 header('Pragma: no-cache'); // For HTTP/1.0 compatibility 18 19 // Send the Content-type header in case the web server is setup to send something else 20 header('Content-type: text/html; charset=utf-8'); 36 21 37 22 // Load the template 38 23 if (defined('PUN_ADMIN_CONSOLE')) 39 $tpl_ main = file_get_contents(PUN_ROOT.'include/template/admin.tpl');24 $tpl_file = 'admin.tpl'; 40 25 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'); 26 $tpl_file = 'help.tpl'; 27 else 28 $tpl_file = 'main.tpl'; 29 30 if (file_exists(PUN_ROOT.'style/'.$pun_user['style'].'/'.$tpl_file)) 31 { 32 $tpl_file = PUN_ROOT.'style/'.$pun_user['style'].'/'.$tpl_file; 33 $tpl_inc_dir = PUN_ROOT.'style/'.$pun_user['style'].'/'; 34 } 35 else 36 { 37 $tpl_file = PUN_ROOT.'include/template/'.$tpl_file; 38 $tpl_inc_dir = PUN_ROOT.'include/user/'; 39 } 40 41 $tpl_main = file_get_contents($tpl_file); 42 43 // START SUBST - <pun_include "*"> 44 preg_match_all('%<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">%i', $tpl_main, $pun_includes, PREG_SET_ORDER); 45 46 foreach ($pun_includes as $cur_include) 47 { 48 ob_start(); 49 50 // Allow for overriding user includes, too. 51 if (file_exists($tpl_inc_dir.$cur_include[1].'.'.$cur_include[2])) 52 require $tpl_inc_dir.$cur_include[1].'.'.$cur_include[2]; 53 else if (file_exists(PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2])) 54 require PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2]; 55 else 56 error(sprintf($lang_common['Pun include error'], htmlspecialchars($cur_include[0]), basename($tpl_file))); 57 58 $tpl_temp = ob_get_contents(); 59 $tpl_main = str_replace($cur_include[0], $tpl_temp, $tpl_main); 60 ob_end_clean(); 61 } 62 // END SUBST - <pun_include "*"> 63 64 65 // START SUBST - <pun_language> 66 $tpl_main = str_replace('<pun_language>', $lang_common['lang_identifier'], $tpl_main); 67 // END SUBST - <pun_language> 44 68 45 69 … … 49 73 50 74 51 // START SUBST - <pun_char_encoding>52 $tpl_main = str_replace('<pun_char_encoding>', $lang_common['lang_encoding'], $tpl_main);53 // END SUBST - <pun_char_encoding>54 55 56 75 // START SUBST - <pun_head> 57 76 ob_start(); 77 78 // Define $p if its not set to avoid a PHP notice 79 $p = isset($p) ? $p : null; 58 80 59 81 // Is this a page that we want search index spiders to index? … … 62 84 63 85 ?> 64 <title><?php echo $page_title?></title>86 <title><?php echo generate_page_title($page_title, $p) ?></title> 65 87 <link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" /> 66 88 <?php 67 89 68 90 if (defined('PUN_ADMIN_CONSOLE')) 69 echo '<link rel="stylesheet" type="text/css" href="style/imports/base_admin.css" />'."\n"; 91 { 92 if (file_exists(PUN_ROOT.'style/'.$pun_user['style'].'/base_admin.css')) 93 echo '<link rel="stylesheet" type="text/css" href="style/'.$pun_user['style'].'/base_admin.css" />'."\n"; 94 else 95 echo '<link rel="stylesheet" type="text/css" href="style/imports/base_admin.css" />'."\n"; 96 } 70 97 71 98 if (isset($required_fields)) … … 75 102 ?> 76 103 <script type="text/javascript"> 77 <!-- 104 /* <![CDATA[ */ 78 105 function process_form(the_form) 79 106 { 80 var element_names = new Object() 81 <?php 82 83 // Output a JavaScript array with localised field names 84 while (list($elem_orig, $elem_trans) = @each($required_fields)) 85 echo "\t".'element_names["'.$elem_orig.'"] = "'.addslashes(str_replace(' ', ' ', $elem_trans)).'"'."\n"; 86 107 var element_names = { 108 <?php 109 // Output a JavaScript object with localised field names 110 $tpl_temp = count($required_fields); 111 foreach ($required_fields as $elem_orig => $elem_trans) 112 { 113 echo "\t\t\"".$elem_orig.'": "'.addslashes(str_replace(' ', ' ', $elem_trans)); 114 if (--$tpl_temp) echo "\",\n"; 115 else echo "\"\n\t};\n"; 116 } 87 117 ?> 88 89 118 if (document.all || document.getElementById) 90 119 { 91 for ( i = 0; i < the_form.length; ++i)120 for (var i = 0; i < the_form.length; ++i) 92 121 { 93 var elem = the_form.elements[i] 94 if (elem.name && elem.name.substring(0, 4) == "req_")122 var elem = the_form.elements[i]; 123 if (elem.name && (/^req_/.test(elem.name))) 95 124 { 96 if ( elem.type && (elem.type=="text" || elem.type=="textarea" || elem.type=="password" || elem.type=="file") && elem.value=='')125 if (!elem.value && elem.type && (/^(?:text(?:area)?|password|file)$/i.test(elem.type))) 97 126 { 98 alert( "\"" + element_names[elem.name] + "\" <?php echo $lang_common['required field'] ?>")99 elem.focus() 100 return false 127 alert('"' + element_names[elem.name] + '" <?php echo $lang_common['required field'] ?>'); 128 elem.focus(); 129 return false; 101 130 } 102 131 } 103 132 } 104 133 } 105 106 return true 107 } 108 // --> 134 return true; 135 } 136 /* ]]> */ 109 137 </script> 110 138 <?php … … 112 140 } 113 141 114 $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : ''; 115 if (strpos($user_agent, 'msie') !== false && strpos($user_agent, 'windows') !== false && strpos($user_agent, 'opera') === false) 116 echo '<script type="text/javascript" src="style/imports/minmax.js"></script>'; 142 // JavaScript tricks for IE6 and older 143 echo '<!--[if lte IE 6]><script type="text/javascript" src="style/imports/minmax.js"></script><![endif]-->'."\n"; 144 145 if (isset($page_head)) 146 echo implode("\n", $page_head)."\n"; 117 147 118 148 $tpl_temp = trim(ob_get_contents()); … … 125 155 if (isset($focus_element)) 126 156 { 127 $tpl_main = str_replace('<body onload="', '<body onload="document.getElementById(\''.$focus_element[0].'\'). '.$focus_element[1].'.focus();', $tpl_main);128 $tpl_main = str_replace('<body>', '<body onload="document.getElementById(\''.$focus_element[0].'\'). '.$focus_element[1].'.focus()">', $tpl_main);157 $tpl_main = str_replace('<body onload="', '<body onload="document.getElementById(\''.$focus_element[0].'\').elements[\''.$focus_element[1].'\'].focus();', $tpl_main); 158 $tpl_main = str_replace('<body>', '<body onload="document.getElementById(\''.$focus_element[0].'\').elements[\''.$focus_element[1].'\'].focus()">', $tpl_main); 129 159 } 130 160 // END SUBST - <body> … … 132 162 133 163 // START SUBST - <pun_page> 134 $tpl_main = str_replace('<pun_page>', basename($_SERVER['PHP_SELF'], '.php'), $tpl_main); 164 $tpl_main = str_replace('<pun_page>', htmlspecialchars(basename($_SERVER['PHP_SELF'], '.php')), $tpl_main); 165 // END SUBST - <pun_page> 166 167 168 // START SUBST - <pun_title> 169 $tpl_main = str_replace('<pun_title>', '<h1><a href="index.php">'.pun_htmlspecialchars($pun_config['o_board_title']).'</a></h1>', $tpl_main); 135 170 // END SUBST - <pun_title> 136 171 137 172 138 // START SUBST - <pun_title>139 $tpl_main = str_replace('<pun_title>', '<h1><span>'.pun_htmlspecialchars($pun_config['o_board_title']).'</span></h1>', $tpl_main);140 // END SUBST - <pun_title>141 142 143 173 // START SUBST - <pun_desc> 144 $tpl_main = str_replace('<pun_desc>', '< p><span>'.$pun_config['o_board_desc'].'</span></p>', $tpl_main);174 $tpl_main = str_replace('<pun_desc>', '<div id="brddesc">'.$pun_config['o_board_desc'].'</div>', $tpl_main); 145 175 // END SUBST - <pun_desc> 146 176 147 177 148 178 // START SUBST - <pun_navlinks> 149 $tpl_main = str_replace('<pun_navlinks>','<div id="brdmenu" class="inbox">'."\n\t\t\t". generate_navlinks()."\n\t\t".'</div>', $tpl_main); 179 $links = array(); 180 181 // Index should always be displayed 182 $links[] = '<li id="navindex"'.((PUN_ACTIVE_PAGE == 'index') ? ' class="isactive"' : '').'><a href="index.php">'.$lang_common['Index'].'</a></li>'; 183 184 if ($pun_user['g_read_board'] == '1' && $pun_user['g_view_users'] == '1') 185 $links[] = '<li id="navuserlist"'.((PUN_ACTIVE_PAGE == 'userlist') ? ' class="isactive"' : '').'><a href="userlist.php">'.$lang_common['User list'].'</a></li>'; 186 187 if ($pun_config['o_rules'] == '1' && (!$pun_user['is_guest'] || $pun_user['g_read_board'] == '1' || $pun_config['o_regs_allow'] == '1')) 188 $links[] = '<li id="navrules"'.((PUN_ACTIVE_PAGE == 'rules') ? ' class="isactive"' : '').'><a href="misc.php?action=rules">'.$lang_common['Rules'].'</a></li>'; 189 190 if ($pun_user['g_read_board'] == '1' && $pun_user['g_search'] == '1') 191 $links[] = '<li id="navsearch"'.((PUN_ACTIVE_PAGE == 'search') ? ' class="isactive"' : '').'><a href="search.php">'.$lang_common['Search'].'</a></li>'; 192 193 if ($pun_user['is_guest']) 194 { 195 $links[] = '<li id="navregister"'.((PUN_ACTIVE_PAGE == 'register') ? ' class="isactive"' : '').'><a href="register.php">'.$lang_common['Register'].'</a></li>'; 196 $links[] = '<li id="navlogin"'.((PUN_ACTIVE_PAGE == 'login') ? ' class="isactive"' : '').'><a href="login.php">'.$lang_common['Login'].'</a></li>'; 197 } 198 else 199 { 200 $links[] = '<li id="navprofile"'.((PUN_ACTIVE_PAGE == 'profile') ? ' class="isactive"' : '').'><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a></li>'; 201 202 if ($pun_user['is_admmod']) 203 $links[] = '<li id="navadmin"'.((PUN_ACTIVE_PAGE == 'admin') ? ' class="isactive"' : '').'><a href="admin_index.php">'.$lang_common['Admin'].'</a></li>'; 204 205 $links[] = '<li id="navlogout"><a href="login.php?action=out&id='.$pun_user['id'].'&csrf_token='.pun_hash($pun_user['id'].pun_hash(get_remote_address())).'">'.$lang_common['Logout'].'</a></li>'; 206 } 207 208 // Are there any additional navlinks we should insert into the array before imploding it? 209 if ($pun_user['g_read_board'] == '1' && $pun_config['o_additional_navlinks'] != '') 210 { 211 if (preg_match_all('%([0-9]+)\s*=\s*(.*?)\n%s', $pun_config['o_additional_navlinks']."\n", $extra_links)) 212 { 213 // Insert any additional links into the $links array (at the correct index) 214 $num_links = count($extra_links[1]); 215 for ($i = 0; $i < $num_links; ++$i) 216 array_splice($links, $extra_links[1][$i], 0, array('<li id="navextra'.($i + 1).'">'.$extra_links[2][$i].'</li>')); 217 } 218 } 219 220 $tpl_temp = '<div id="brdmenu" class="inbox">'."\n\t\t\t".'<ul>'."\n\t\t\t\t".implode("\n\t\t\t\t", $links)."\n\t\t\t".'</ul>'."\n\t\t".'</div>'; 221 $tpl_main = str_replace('<pun_navlinks>', $tpl_temp, $tpl_main); 150 222 // END SUBST - <pun_navlinks> 151 223 152 224 153 225 // START SUBST - <pun_status> 226 $page_statusinfo = $page_topicsearches = array(); 227 154 228 if ($pun_user['is_guest']) 155 $tpl_temp = '<div id="brdwelcome" class="inbox">'."\n\t\t\t".'<p>'.$lang_common['Not logged in'].'</p>'."\n\t\t".'</div>'; 156 else 157 { 158 $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>'; 159 160 if ($pun_user['g_id'] < PUN_GUEST) 161 { 162 $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()); 163 164 if ($db->result($result_header)) 165 $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>'; 229 $page_statusinfo = '<p class="conl">'.$lang_common['Not logged in'].'</p>'; 230 else 231 { 232 $page_statusinfo[] = '<li><span>'.$lang_common['Logged in as'].' <strong>'.pun_htmlspecialchars($pun_user['username']).'</strong></span></li>'; 233 $page_statusinfo[] = '<li><span>'.sprintf($lang_common['Last visit'], format_time($pun_user['last_visit'])).'</span></li>'; 234 235 if ($pun_user['is_admmod']) 236 { 237 if ($pun_config['o_report_method'] == '0' || $pun_config['o_report_method'] == '2') 238 { 239 $result_header = $db->query('SELECT 1 FROM '.$db->prefix.'reports WHERE zapped IS NULL') or error('Unable to fetch reports info', __FILE__, __LINE__, $db->error()); 240 241 if ($db->result($result_header)) 242 $page_statusinfo[] = '<li class="reportlink"><span><strong><a href="admin_reports.php">'.$lang_common['New reports'].'</a></strong></span></li>'; 243 } 166 244 167 245 if ($pun_config['o_maintenance'] == '1') 168 $tpl_temp .= "\n\t\t\t\t".'<li class="maintenancelink"><strong><a href="admin_options.php#maintenance">Le mode maintenance est activé !</a></strong></li>'; 169 } 170 171 if (in_array(basename($_SERVER['PHP_SELF']), array('index.php', 'search.php'))) 172 $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>'; 173 else 174 $tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>'; 175 } 246 $page_statusinfo[] = '<li class="maintenancelink"><span><strong><a href="admin_options.php#maintenance">'.$lang_common['Maintenance mode enabled'].'</a></strong></span></li>'; 247 } 248 249 if ($pun_user['g_read_board'] == '1' && $pun_user['g_search'] == '1') 250 { 251 $page_topicsearches[] = '<a href="search.php?action=show_replies" title="'.$lang_common['Show posted topics'].'">'.$lang_common['Posted topics'].'</a>'; 252 $page_topicsearches[] = '<a href="search.php?action=show_new" title="'.$lang_common['Show new posts'].'">'.$lang_common['New posts header'].'</a>'; 253 } 254 } 255 256 // Quick searches 257 if ($pun_user['g_read_board'] == '1' && $pun_user['g_search'] == '1') 258 { 259 $page_topicsearches[] = '<a href="search.php?action=show_recent" title="'.$lang_common['Show active topics'].'">'.$lang_common['Active topics'].'</a>'; 260 $page_topicsearches[] = '<a href="search.php?action=show_unanswered" title="'.$lang_common['Show unanswered topics'].'">'.$lang_common['Unanswered topics'].'</a>'; 261 } 262 263 264 // Generate all that jazz 265 $tpl_temp = '<div id="brdwelcome" class="inbox">'; 266 267 // The status information 268 if (is_array($page_statusinfo)) 269 { 270 $tpl_temp .= "\n\t\t\t".'<ul class="conl">'; 271 $tpl_temp .= "\n\t\t\t\t".implode("\n\t\t\t\t", $page_statusinfo); 272 $tpl_temp .= "\n\t\t\t".'</ul>'; 273 } 274 else 275 $tpl_temp .= "\n\t\t\t".$page_statusinfo; 276 277 // Generate quicklinks 278 if (!empty($page_topicsearches)) 279 { 280 $tpl_temp .= "\n\t\t\t".'<ul class="conr">'; 281 $tpl_temp .= "\n\t\t\t\t".'<li><span>'.$lang_common['Topic searches'].' '.implode(' | ', $page_topicsearches).'</span></li>'; 282 $tpl_temp .= "\n\t\t\t".'</ul>'; 283 } 284 285 $tpl_temp .= "\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>'; 176 286 177 287 $tpl_main = str_replace('<pun_status>', $tpl_temp, $tpl_main); … … 180 290 181 291 // START SUBST - <pun_announcement> 182 if ($pun_ config['o_announcement'] == '1')292 if ($pun_user['g_read_board'] == '1' && $pun_config['o_announcement'] == '1') 183 293 { 184 294 ob_start(); … … 186 296 ?> 187 297 <div id="announce" class="block"> 188 < h2><span><?php echo $lang_common['Announcement'] ?></span></h2>298 <div class="hd"><h2><span><?php echo $lang_common['Announcement'] ?></span></h2></div> 189 299 <div class="box"> 190 <div class="inbox">191 <div ><?php echo $pun_config['o_announcement_message'] ?></div>300 <div id="announce-block" class="inbox"> 301 <div class="usercontent"><?php echo $pun_config['o_announcement_message'] ?></div> 192 302 </div> 193 303 </div>
Note: See TracChangeset
for help on using the changeset viewer.