punbb/header.php
changeset 2 a8a21e1c7afa
parent 0 f9ffdbd96607
child 3 c0c445d4a13e
equal deleted inserted replaced
1:8f6143115bf5 2:a8a21e1c7afa
    20   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
    20   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
    21   MA  02111-1307  USA
    21   MA  02111-1307  USA
    22 
    22 
    23 ************************************************************************/
    23 ************************************************************************/
    24 
    24 
       
    25 // Import the Enano API
       
    26 global $db, $session, $paths, $template, $plugins; // Common objects
    25 
    27 
    26 // Make sure no one attempts to run this script "directly"
    28 // Make sure no one attempts to run this script "directly"
    27 if (!defined('PUN'))
    29 if (!defined('PUN'))
    28 	exit;
    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>');
    29 
    51 
    30 // Send no-cache headers
    52 // Send no-cache headers
    31 header('Expires: Thu, 21 Jul 1977 07:30:00 GMT');	// When yours truly first set eyes on this world! :)
    53 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');
    54 header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
    33 header('Cache-Control: post-check=0, pre-check=0', false);
    55 header('Cache-Control: post-check=0, pre-check=0', false);
    34 header('Pragma: no-cache');		// For HTTP/1.0 compability
    56 header('Pragma: no-cache');		// For HTTP/1.0 compability
    35 
    57 
    36 
       
    37 // Load the template
    58 // Load the template
    38 if (defined('PUN_ADMIN_CONSOLE'))
    59 if (defined('PUN_ADMIN_CONSOLE'))
       
    60 {
    39 	$tpl_main = file_get_contents(PUN_ROOT.'include/template/admin.tpl');
    61 	$tpl_main = file_get_contents(PUN_ROOT.'include/template/admin.tpl');
       
    62 }
    40 else if (defined('PUN_HELP'))
    63 else if (defined('PUN_HELP'))
       
    64 {
    41 	$tpl_main = file_get_contents(PUN_ROOT.'include/template/help.tpl');
    65 	$tpl_main = file_get_contents(PUN_ROOT.'include/template/help.tpl');
       
    66 }
    42 else
    67 else
    43 	$tpl_main = file_get_contents(PUN_ROOT.'include/template/main.tpl');
    68 {
       
    69 	// $tpl_main = file_get_contents(PUN_ROOT.'include/template/main.tpl');
       
    70   $inner = '<div id="punwrap">
       
    71 <div id="pun<pun_page>" class="pun">
       
    72 
       
    73 <div id="brdheader" class="block">
       
    74 	<div class="box">
       
    75 		<div id="brdtitle" class="inbox">
       
    76 			<pun_title>
       
    77 			<pun_desc>
       
    78 		</div>
       
    79 		<pun_navlinks>
       
    80 		<pun_status>
       
    81 	</div>
       
    82 </div>
       
    83 
       
    84 <pun_announcement>
       
    85 
       
    86 <pun_main>
       
    87 
       
    88 <pun_footer>
       
    89 
       
    90 </div>
       
    91 </div>';
       
    92 
       
    93   $tpl_main = $template->getHeader() . $inner . $template->getFooter();
       
    94 
       
    95 }
    44 
    96 
    45 
    97 
    46 // START SUBST - <pun_include "*">
    98 // START SUBST - <pun_include "*">
    47 while (preg_match('#<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">#', $tpl_main, $cur_include))
    99 while (preg_match('#<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">#', $tpl_main, $cur_include))
    48 {
   100 {
    55 	$tpl_main = str_replace($cur_include[0], $tpl_temp, $tpl_main);
   107 	$tpl_main = str_replace($cur_include[0], $tpl_temp, $tpl_main);
    56     ob_end_clean();
   108     ob_end_clean();
    57 }
   109 }
    58 // END SUBST - <pun_include "*">
   110 // END SUBST - <pun_include "*">
    59 
   111 
    60 
       
    61 // START SUBST - <pun_content_direction>
   112 // START SUBST - <pun_content_direction>
    62 $tpl_main = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_main);
   113 $tpl_main = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_main);
    63 // END SUBST - <pun_content_direction>
   114 // END SUBST - <pun_content_direction>
    64 
   115 
    65 
   116 
    66 // START SUBST - <pun_char_encoding>
   117 // START SUBST - <pun_char_encoding>
    67 $tpl_main = str_replace('<pun_char_encoding>', $lang_common['lang_encoding'], $tpl_main);
   118 $tpl_main = str_replace('<pun_char_encoding>', $lang_common['lang_encoding'], $tpl_main);
    68 // END SUBST - <pun_char_encoding>
   119 // END SUBST - <pun_char_encoding>
    69 
   120 
    70 
       
    71 // START SUBST - <pun_head>
   121 // START SUBST - <pun_head>
    72 ob_start();
   122 ob_start();
    73 
   123 
    74 // Is this a page that we want search index spiders to index?
   124 // Is this a page that we want search index spiders to index?
    75 if (!defined('PUN_ALLOW_INDEX'))
   125 if (!defined('PUN_ALLOW_INDEX'))
    76 	echo '<meta name="ROBOTS" content="NOINDEX, FOLLOW" />'."\n";
   126 	echo '<meta name="ROBOTS" content="NOINDEX, FOLLOW" />'."\n";
    77 
   127 
    78 ?>
   128 ?>
    79 <title><?php echo $page_title ?></title>
   129 <link rel="stylesheet" type="text/css" href="<?php echo scriptPath; ?>/punbb/style/<?php echo $pun_user['style'].'.css' ?>" />
    80 <link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" />
       
    81 <?php
   130 <?php
    82 
   131 
    83 if (defined('PUN_ADMIN_CONSOLE'))
   132 if (defined('PUN_ADMIN_CONSOLE'))
    84 	echo '<link rel="stylesheet" type="text/css" href="style/imports/base_admin.css" />'."\n";
   133 	echo '<link rel="stylesheet" type="text/css" href="style/imports/base_admin.css" />'."\n";
    85 
   134 
   145 // END SUBST - <body>
   194 // END SUBST - <body>
   146 
   195 
   147 
   196 
   148 // START SUBST - <pun_page>
   197 // START SUBST - <pun_page>
   149 $tpl_main = str_replace('<pun_page>', htmlspecialchars(basename($_SERVER['PHP_SELF'], '.php')), $tpl_main);
   198 $tpl_main = str_replace('<pun_page>', htmlspecialchars(basename($_SERVER['PHP_SELF'], '.php')), $tpl_main);
   150 // END SUBST - <pun_title>
   199 // END SUBST - <pun_page>
   151 
   200 
   152 
   201 
   153 // START SUBST - <pun_title>
   202 // START SUBST - <pun_title>
   154 $tpl_main = str_replace('<pun_title>', '<h1><span>'.pun_htmlspecialchars($pun_config['o_board_title']).'</span></h1>', $tpl_main);
   203 $tpl_main = str_replace('<pun_title>', '<h1><span>'.pun_htmlspecialchars($pun_config['o_board_title']).'</span></h1>', $tpl_main);
   155 // END SUBST - <pun_title>
   204 // END SUBST - <pun_title>
   170 	$tpl_temp = '<div id="brdwelcome" class="inbox">'."\n\t\t\t".'<p>'.$lang_common['Not logged in'].'</p>'."\n\t\t".'</div>';
   219 	$tpl_temp = '<div id="brdwelcome" class="inbox">'."\n\t\t\t".'<p>'.$lang_common['Not logged in'].'</p>'."\n\t\t".'</div>';
   171 else
   220 else
   172 {
   221 {
   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>';
   222 	$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 
   223 
   175 	if ($pun_user['g_id'] < PUN_GUEST)
   224 	if ($pun_user['g_id'] >= USER_LEVEL_MEMBER)
   176 	{
   225 	{
   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());
   226 		$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());
   178 
   227 
   179 		if ($db->result($result_header))
   228 		if ($pun_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>';
   229 			$tpl_temp .= "\n\t\t\t\t".'<li class="reportlink"><strong><a href="admin_reports.php">There are new reports</a></strong></li>';
   181 
   230 
   182 		if ($pun_config['o_maintenance'] == '1')
   231 		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>';
   232 			$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 	}
   233 	}
   189 		$tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';
   238 		$tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';
   190 }
   239 }
   191 
   240 
   192 $tpl_main = str_replace('<pun_status>', $tpl_temp, $tpl_main);
   241 $tpl_main = str_replace('<pun_status>', $tpl_temp, $tpl_main);
   193 // END SUBST - <pun_status>
   242 // END SUBST - <pun_status>
   194 
       
   195 
   243 
   196 // START SUBST - <pun_announcement>
   244 // START SUBST - <pun_announcement>
   197 if ($pun_config['o_announcement'] == '1')
   245 if ($pun_config['o_announcement'] == '1')
   198 {
   246 {
   199 	ob_start();
   247 	ob_start();
   215 }
   263 }
   216 else
   264 else
   217 	$tpl_main = str_replace('<pun_announcement>', '', $tpl_main);
   265 	$tpl_main = str_replace('<pun_announcement>', '', $tpl_main);
   218 // END SUBST - <pun_announcement>
   266 // END SUBST - <pun_announcement>
   219 
   267 
   220 
       
   221 // START SUBST - <pun_main>
   268 // START SUBST - <pun_main>
   222 ob_start();
   269 ob_start();
   223 
   270 
   224 
   271 
   225 define('PUN_HEADER', 1);
   272 define('PUN_HEADER', 1);