punbb/header.php
changeset 7 98bbc533541c
child 9 a932ce8c4827
equal deleted inserted replaced
6:5e1f1e916419 7:98bbc533541c
       
     1 <?php
       
     2 /***********************************************************************
       
     3 
       
     4   Copyright (C) 2002-2008  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 // Send the Content-type header in case the web server is setup to send something else
       
    37 header('Content-type: text/html; charset=utf-8');
       
    38 
       
    39 // Load the main template
       
    40 if (substr(PUN_PAGE, 0, 5) == 'admin')
       
    41 {
       
    42 	if (file_exists(PUN_ROOT.'style/'.$pun_user['style'].'/admin.tpl'))
       
    43 		$tpl_main = file_get_contents(PUN_ROOT.'style/'.$pun_user['style'].'/admin.tpl');
       
    44 	else
       
    45 		$tpl_main = file_get_contents(PUN_ROOT.'include/template/admin.tpl');
       
    46 }
       
    47 else if (PUN_PAGE == 'help')
       
    48 	$tpl_main = file_get_contents(PUN_ROOT.'include/template/help.tpl');
       
    49 else
       
    50 {
       
    51 	if (file_exists(PUN_ROOT.'style/'.$pun_user['style'].'/main.tpl'))
       
    52 		$tpl_main = file_get_contents(PUN_ROOT.'style/'.$pun_user['style'].'/main.tpl');
       
    53 	else
       
    54 		$tpl_main = file_get_contents(PUN_ROOT.'include/template/main.tpl');
       
    55 }
       
    56 
       
    57 ($hook = get_hook('hd_template_loaded')) ? eval($hook) : null;
       
    58 
       
    59 
       
    60 // START SUBST - <!-- pun_local -->
       
    61 $tpl_main = str_replace('<!-- pun_local -->', 'xml:lang="'.$lang_common['lang_identifier'].'" lang="'.$lang_common['lang_identifier'].'" dir="'.$lang_common['lang_direction'].'"', $tpl_main);
       
    62 // END SUBST - <!-- pun_local -->
       
    63 
       
    64 
       
    65 // START SUBST - <!-- pun_head -->
       
    66 ob_start();
       
    67 
       
    68 // Is this a page that we want search index spiders to index?
       
    69 if (!defined('PUN_ALLOW_INDEX'))
       
    70 	echo '<meta name="ROBOTS" content="NOINDEX, FOLLOW" />'."\n";
       
    71 else
       
    72 	echo '<meta name="description" content="'.generate_crumbs(true).'" />'."\n";
       
    73 
       
    74 // Should we output a MicroID? http://microid.org/
       
    75 if (strpos(PUN_PAGE, 'profile') === 0)
       
    76 	echo '<meta name="microid" content="mailto+http:sha1:'.sha1(sha1('mailto:'.$user['email']).sha1(pun_link($pun_url['user'], $id))).'" />'."\n";
       
    77 
       
    78 ?>
       
    79 <title><?php echo generate_crumbs(true) ?></title>
       
    80 <?php
       
    81 
       
    82 // Should we output feed links?
       
    83 if (PUN_PAGE == 'viewtopic')
       
    84 {
       
    85 	echo '<link rel="alternate" type="application/rss+xml" href="'.pun_link($pun_url['topic_rss'], $id).'" title="'.$lang_common['RSS Feed'].'" />'."\n";
       
    86 	echo '<link rel="alternate" type="application/atom+xml" href="'.pun_link($pun_url['topic_atom'], $id).'" title="'.$lang_common['ATOM Feed'].'" />'."\n";
       
    87 }
       
    88 else if (PUN_PAGE == 'viewforum')
       
    89 {
       
    90 	echo '<link rel="alternate" type="application/rss+xml" href="'.pun_link($pun_url['forum_rss'], $id).'" title="RSS" />'."\n";
       
    91 	echo '<link rel="alternate" type="application/atom+xml" href="'.pun_link($pun_url['forum_atom'], $id).'" title="ATOM" />'."\n";
       
    92 }
       
    93 
       
    94 ?>
       
    95 <link rel="top" href="<?php echo $base_url ?>" title="<?php echo $lang_common['Forum index'] ?>" />
       
    96 <?php
       
    97 
       
    98 // If there are more than two breadcrumbs, add the "up" link (second last)
       
    99 if (count($pun_page['crumbs']) > 2)
       
   100 	echo '<link rel="up" href="'.$pun_page['crumbs'][count($pun_page['crumbs']) - 2][1].'" title="'.htmlspecialchars($pun_page['crumbs'][count($pun_page['crumbs']) - 2][0]).'" />'."\n";
       
   101 
       
   102 // If there are other page navigation links (first, next, prev and last)
       
   103 if (!empty($pun_page['nav']))
       
   104 	echo implode("\n", $pun_page['nav'])."\n";
       
   105 
       
   106 ?>
       
   107 <link rel="search" href="<?php echo pun_link($pun_url['search']) ?>" title="<?php echo $lang_common['Search'] ?>" />
       
   108 <link rel="author" href="<?php echo pun_link($pun_url['users']) ?>" title="<?php echo $lang_common['User list'] ?>" />
       
   109 <?php
       
   110 
       
   111 // Include stylesheets
       
   112 	require PUN_ROOT.'style/'.$pun_user['style'].'/'.$pun_user['style'].'.php';
       
   113 
       
   114 ?>
       
   115 <script type="text/javascript" src="<?php echo $base_url ?>/include/js/common.js"></script>
       
   116 
       
   117 <!-- ugly style override for oxygen -->
       
   118 <style type="text/css">
       
   119 div.pun-page ul li {
       
   120   list-style-image: none !important;
       
   121   list-style-type: none !important;
       
   122 }
       
   123 div.pun-page h2 {
       
   124   border-bottom-width: 0 !important;
       
   125 }
       
   126 </style>
       
   127 
       
   128 <?php
       
   129 
       
   130 ($hook = get_hook('hd_'.PUN_PAGE.'_head')) ? eval($hook) : null;
       
   131 
       
   132 ($hook = get_hook('hd_head')) ? eval($hook) : null;
       
   133 
       
   134 $tpl_temp = trim(ob_get_contents());
       
   135 $template->add_header($tpl_temp);
       
   136 ob_end_clean();
       
   137 // END SUBST - <!-- pun_head -->
       
   138 
       
   139 
       
   140 // START SUBST - <!-- pun_page -->
       
   141 $tpl_main = str_replace('<!-- pun_page -->', 'id="pun-'.PUN_PAGE.'"', $tpl_main);
       
   142 // END SUBST - <!-- pun_page -->
       
   143 
       
   144 
       
   145 // START SUBST - <!-- pun_skip -->
       
   146 $tpl_main = str_replace('<!-- pun_skip -->', '<div id="pun-access"><a href="#pun-main">'.$lang_common['Skip to content'].'</a></div>'."\n", $tpl_main);
       
   147 // END SUBST - <!-- pun_skip -->
       
   148 
       
   149 // START SUBST - <!-- pun_title -->
       
   150 $tpl_main = str_replace('<!-- pun_title -->', '<div id="pun-title">'."\n\t".'<div><strong>'.htmlspecialchars($pun_config['o_board_title']).'</strong></div>'."\n".'</div>'."\n", $tpl_main);
       
   151 // END SUBST - <!-- pun_title -->
       
   152 
       
   153 
       
   154 // START SUBST - <!-- pun_desc -->
       
   155 if ($pun_config['o_board_desc'] != '')
       
   156 	$tpl_main = str_replace('<!-- pun_desc -->', '<div id="pun-desc">'."\n\t".'<div>'.htmlspecialchars($pun_config['o_board_desc']).'</div>'."\n".'</div>'."\n", $tpl_main);
       
   157 // END SUBST - <!-- pun_desc -->
       
   158 
       
   159 
       
   160 // START SUBST - <!-- pun_navlinks -->
       
   161 $tpl_main = str_replace('<!-- pun_navlinks -->', '<div id="pun-navlinks">'."\n\t".'<ul>'."\n\t\t".generate_navlinks()."\n\t".'</ul>'."\n".'</div>'."\n", $tpl_main);
       
   162 // END SUBST - <!-- pun_navlinks -->
       
   163 
       
   164 
       
   165 // START SUBST - <!-- pun_crumbs -->
       
   166 $tpl_main = str_replace('<!-- pun_crumbs -->', '<div id="pun-crumbs-head">'."\n\t".'<p class="crumbs">'.generate_crumbs(false).'</p>'."\n".'</div>'."\n", $tpl_main);
       
   167 // END SUBST - <!-- pun_crumbs -->
       
   168 
       
   169 
       
   170 // START SUBST - <!-- pun_visit -->
       
   171 ob_start();
       
   172 
       
   173 if ($pun_user['is_guest'])
       
   174 {
       
   175 	$visit_msg = array(
       
   176 		'<span id="vs-logged">'.$lang_common['Not logged in'].'</span>',
       
   177 		'<span id="vs-message">'.$lang_common['Login nag'].'</span>'
       
   178 	);
       
   179 }
       
   180 else
       
   181 {
       
   182 	$visit_msg = array(
       
   183 		'<span id="vs-logged">'.sprintf($lang_common['Logged in as'], '<strong>'.htmlspecialchars($pun_user['username']).'</strong>').'</span>',
       
   184 		'<span id="vs-message">'.sprintf($lang_common['Last visit'], '<strong>'.format_time($pun_user['last_visit']).'</strong>').'</span>'
       
   185 	);
       
   186 
       
   187 	$visit_links = array(
       
   188 		'<li id="vs-searchnew"><a href="'.pun_link($pun_url['search_new']).'" title="'.$lang_common['New posts info'].'">'.$lang_common['New posts'].'</a></li>',
       
   189 		'<li id="vs-markread"><a href="'.pun_link($pun_url['mark_read']).'">'.$lang_common['Mark all as read'].'</a></li>'
       
   190 	);
       
   191 
       
   192 	if ($pun_user['is_admmod'])
       
   193 	{
       
   194 		$query = array(
       
   195 			'SELECT'	=> 'COUNT(r.id)',
       
   196 			'FROM'		=> 'reports AS r',
       
   197 			'WHERE'		=> 'r.zapped IS NULL',
       
   198 		);
       
   199 
       
   200 		($hook = get_hook('hd_qr_get_unread_reports_count')) ? eval($hook) : null;
       
   201 		$result_header = $pun_db->query_build($query) or error(__FILE__, __LINE__);
       
   202 
       
   203 		if ($pun_db->result($result_header))
       
   204 			$visit_links[] = '<li id="vs-reports"><a href="'.pun_link($pun_url['admin_reports']).'"><strong>'.$lang_common['New reports'].'</strong></a></li>';
       
   205 	}
       
   206 }
       
   207 
       
   208 ($hook = get_hook('hd_visit')) ? eval($hook) : null;
       
   209 
       
   210 ?>
       
   211 <div id="pun-visit">
       
   212 <?php if (!$pun_user['is_guest']): ?>	<ul>
       
   213 		<?php echo implode("\n\t\t", $visit_links)."\n" ?>
       
   214 	</ul>
       
   215 <?php endif; ?>	<p>
       
   216 		<?php echo implode("\n\t\t", $visit_msg)."\n" ?>
       
   217 	</p>
       
   218 </div>
       
   219 <?php
       
   220 
       
   221 $tpl_temp = ob_get_contents();
       
   222 $tpl_main = str_replace('<!-- pun_visit -->', $tpl_temp, $tpl_main);
       
   223 ob_end_clean();
       
   224 // END SUBST - <!-- pun_visit -->
       
   225 
       
   226 
       
   227 // START SUBST - <!-- pun_alert -->
       
   228 $alert_items = array();
       
   229 
       
   230 if ($pun_config['o_maintenance'] == '1' && $session->user_level >= USER_LEVEL_ADMIN)
       
   231 	$alert_items[] = '<p id="maint-alert"'.(empty($alert_items) ? ' class="first-alert"' : '').'><strong>'.$lang_common['Maintenance mode'].'</strong> <span>'.$lang_common['Maintenance alert'].'</span></p>';
       
   232 
       
   233 if ($session->user_level >= USER_LEVEL_ADMIN && $pun_config['o_check_for_updates'] == '1')
       
   234 {
       
   235 	if ($pun_updates['fail'])
       
   236 		$alert_items[] = '<p id="updates-alert"'.(empty($alert_items) ? ' class="first-alert"' : '').'><strong>'.$lang_common['Updates'].'</strong> <span>'.$lang_common['Updates failed'].'</span></p>';
       
   237 	else if (isset($pun_updates['version']) && isset($pun_updates['hotfix']))
       
   238 		$alert_items[] = '<p id="updates-alert"'.(empty($alert_items) ? ' class="first-alert"' : '').'><strong>'.$lang_common['Updates'].'</strong> <span>'.sprintf($lang_common['Updates version n hf'], $pun_updates['version']).'</span></p>';
       
   239 	else if (isset($pun_updates['version']))
       
   240 		$alert_items[] = '<p id="updates-alert"'.(empty($alert_items) ? ' class="first-alert"' : '').'><strong>'.$lang_common['Updates'].'</strong> <span>'.sprintf($lang_common['Updates version'], $pun_updates['version']).'</span></p>';
       
   241 	else if (isset($pun_updates['hotfix']))
       
   242 		$alert_items[] = '<p id="updates-alert"'.(empty($alert_items) ? ' class="first-alert"' : '').'><strong>'.$lang_common['Updates'].'</strong> <span>'.$lang_common['Updates hf'].'</span></p>';
       
   243 }
       
   244 
       
   245 ($hook = get_hook('hd_alert')) ? eval($hook) : null;
       
   246 
       
   247 if (!empty($alert_items))
       
   248 {
       
   249 	ob_start();
       
   250 
       
   251 ?>
       
   252 <div id="pun-alert">
       
   253 	<h1 class="warn"><strong><?php echo $lang_common['Attention'] ?></strong></h1>
       
   254 	<div>
       
   255 		<?php echo implode("\n\t\t", $alert_items)."\n" ?>
       
   256 	</div>
       
   257 </div>
       
   258 <?php
       
   259 
       
   260 	$tpl_temp = ob_get_contents();
       
   261 	$tpl_main = str_replace('<!-- pun_alert -->', $tpl_temp, $tpl_main);
       
   262 	ob_end_clean();
       
   263 }
       
   264 // END SUBST - <!-- pun_alert -->
       
   265 
       
   266 
       
   267 // START SUBST - <!-- pun_announcement -->
       
   268 if ($pun_config['o_announcement'] == '1')
       
   269 	$tpl_main = str_replace('<!-- pun_announcement -->', '<div id="pun-announcement">'."\n\t".'<div class="userbox">'.($pun_config['o_announcement_heading'] != '' ? "\n\t\t".'<h2 class="msg-head">'.$pun_config['o_announcement_heading'].'</h2>' : '')."\n\t\t".$pun_config['o_announcement_message']."\n\t".'</div>'."\n".'</div>'."\n", $tpl_main);
       
   270 // END SUBST - <!-- pun_announcement -->
       
   271 
       
   272 
       
   273 // START SUBST - <!-- pun_main -->
       
   274 ob_start();
       
   275 
       
   276 define('PUN_HEADER', 1);