Blame Extras/Punbb/header.php

4c79b5
4c79b5
/***********************************************************************
4c79b5
4c79b5
  Copyright (C) 2002-2008  PunBB
4c79b5
4c79b5
  This file is part of PunBB.
4c79b5
4c79b5
  PunBB is free software; you can redistribute it and/or modify it
4c79b5
  under the terms of the GNU General Public License as published
4c79b5
  by the Free Software Foundation; either version 2 of the License,
4c79b5
  or (at your option) any later version.
4c79b5
4c79b5
  PunBB is distributed in the hope that it will be useful, but
4c79b5
  WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c79b5
  GNU General Public License for more details.
4c79b5
4c79b5
  You should have received a copy of the GNU General Public License
4c79b5
  along with this program; if not, write to the Free Software
4c79b5
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
4c79b5
  MA  02111-1307  USA
4c79b5
4c79b5
************************************************************************/
4c79b5
4c79b5
4c79b5
// Make sure no one attempts to run this script "directly"
4c79b5
if (!defined('PUN'))
4c79b5
	exit;
4c79b5
4c79b5
// Send no-cache headers
4c79b5
header('Expires: Thu, 21 Jul 1977 07:30:00 GMT');	// When yours truly first set eyes on this world! :)
4c79b5
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
4c79b5
header('Cache-Control: post-check=0, pre-check=0', false);
4c79b5
header('Pragma: no-cache');		// For HTTP/1.0 compability
4c79b5
4c79b5
4c79b5
// Load the template
4c79b5
if (defined('PUN_ADMIN_CONSOLE'))
4c79b5
	$tpl_main = file_get_contents(PUN_ROOT.'include/template/admin.tpl');
4c79b5
else if (defined('PUN_HELP'))
4c79b5
	$tpl_main = file_get_contents(PUN_ROOT.'include/template/help.tpl');
4c79b5
else
4c79b5
	$tpl_main = file_get_contents(PUN_ROOT.'include/template/main.tpl');
4c79b5
4c79b5
4c79b5
// START SUBST - <pun_include "*">
4c79b5
while (preg_match('#<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">#', $tpl_main, $cur_include))
4c79b5
{
4c79b5
	if (!file_exists(PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2]))
4c79b5
		error('Unable to process user include '.htmlspecialchars($cur_include[0]).' from template main.tpl. There is no such file in folder /include/user/');
4c79b5
4c79b5
	ob_start();
4c79b5
	include PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2];
4c79b5
	$tpl_temp = ob_get_contents();
4c79b5
	$tpl_main = str_replace($cur_include[0], $tpl_temp, $tpl_main);
4c79b5
    ob_end_clean();
4c79b5
}
4c79b5
// END SUBST - <pun_include "*">
4c79b5
4c79b5
4c79b5
// START SUBST - <pun_content_direction>
4c79b5
$tpl_main = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_main);
4c79b5
// END SUBST - <pun_content_direction>
4c79b5
4c79b5
4c79b5
// START SUBST - <pun_char_encoding>
4c79b5
$tpl_main = str_replace('<pun_char_encoding>', $lang_common['lang_encoding'], $tpl_main);
4c79b5
// END SUBST - <pun_char_encoding>
4c79b5
4c79b5
4c79b5
// START SUBST - <pun_head>
4c79b5
ob_start();
4c79b5
4c79b5
// Is this a page that we want search index spiders to index?
4c79b5
if (!defined('PUN_ALLOW_INDEX'))
4c79b5
	echo '<meta name="ROBOTS" content="NOINDEX, FOLLOW" />'."\n";
4c79b5
4c79b5
?>
4c79b5
<title></title>
4c79b5
<link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" />
4c79b5
4c79b5
4c79b5
if (defined('PUN_ADMIN_CONSOLE'))
4c79b5
	echo '<link rel="stylesheet" type="text/css" href="style/imports/base_admin.css" />'."\n";
4c79b5
4c79b5
if (isset($required_fields))
4c79b5
{
4c79b5
	// Output JavaScript to validate form (make sure required fields are filled out)
4c79b5
4c79b5
?>
4c79b5
<script type="text/javascript">
4c79b5
4c79b5
function process_form(the_form)
4c79b5
{
4c79b5
	var element_names = new Object()
4c79b5
4c79b5
4c79b5
	// Output a JavaScript array with localised field names
4c79b5
	while (list($elem_orig, $elem_trans) = @each($required_fields))
4c79b5
		echo "\t".'element_names["'.$elem_orig.'"] = "'.addslashes(str_replace(' ', ' ', $elem_trans)).'"'."\n";
4c79b5
4c79b5
?>
4c79b5
4c79b5
	if (document.all || document.getElementById)
4c79b5
	{
4c79b5
		for (i = 0; i < the_form.length; ++i)
4c79b5
		{
4c79b5
			var elem = the_form.elements[i]
4c79b5
			if (elem.name && elem.name.substring(0, 4) == "req_")
4c79b5
			{
4c79b5
				if (elem.type && (elem.type=="text" || elem.type=="textarea" || elem.type=="password" || elem.type=="file") && elem.value=='')
4c79b5
				{
4c79b5
					alert("\"" + element_names[elem.name] + "\" ")
4c79b5
					elem.focus()
4c79b5
					return false
4c79b5
				}
4c79b5
			}
4c79b5
		}
4c79b5
	}
4c79b5
4c79b5
	return true
4c79b5
}
4c79b5
// -->
4c79b5
</script>
4c79b5
4c79b5
4c79b5
}
4c79b5
4c79b5
$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : '';
4c79b5
if (strpos($user_agent, 'msie') !== false && strpos($user_agent, 'windows') !== false && strpos($user_agent, 'opera') === false)
4c79b5
	echo '<script type="text/javascript" src="style/imports/minmax.js"></script>';
4c79b5
4c79b5
$tpl_temp = trim(ob_get_contents());
4c79b5
$tpl_main = str_replace('<pun_head>', $tpl_temp, $tpl_main);
4c79b5
ob_end_clean();
4c79b5
// END SUBST - <pun_head>
4c79b5
4c79b5
4c79b5
// START SUBST - <body>
4c79b5
if (isset($focus_element))
4c79b5
{
4c79b5
	$tpl_main = str_replace('
4c79b5
	$tpl_main = str_replace('<body>', '<body onload="document.getElementById(\''.$focus_element[0].'\').'.$focus_element[1].'.focus()">', $tpl_main);
4c79b5
}
4c79b5
// END SUBST - <body>
4c79b5
4c79b5
4c79b5
// START SUBST - <pun_page>
4c79b5
$tpl_main = str_replace('<pun_page>', htmlspecialchars(basename($_SERVER['PHP_SELF'], '.php')), $tpl_main);
4c79b5
// END SUBST - <pun_page>
4c79b5
4c79b5
4c79b5
// START SUBST - <pun_title>
4c79b5
$tpl_main = str_replace('<pun_title>', ''.pun_htmlspecialchars($pun_config['o_board_title']).'

'.pun_htmlspecialchars($pun_config['o_board_title']).'

', $tpl_main);
4c79b5
// END SUBST - <pun_title>
4c79b5
4c79b5
4c79b5
// START SUBST - <pun_desc>
4c79b5
$tpl_main = str_replace('<pun_desc>', '

'.$pun_config['o_board_desc'].'

', $tpl_main);
4c79b5
// END SUBST - <pun_desc>
4c79b5
4c79b5
4c79b5
// START SUBST - <pun_navlinks>
4c79b5
$tpl_main = str_replace('<pun_navlinks>','
'."\n\t\t\t". generate_navlinks()."\n\t\t".'
', $tpl_main);
4c79b5
// END SUBST - <pun_navlinks>
4c79b5
4c79b5
4c79b5
// START SUBST - <pun_status>
4c79b5
if ($pun_user['is_guest'])
4c79b5
	$tpl_temp = '
'."\n\t\t\t".'

'.$lang_common['Not logged in'].'

'."\n\t\t".'
';
4c79b5
else
4c79b5
{
4c79b5
	$tpl_temp = '
'."\n\t\t\t".'
    '."\n\t\t\t\t".'
  • '.$lang_common['Logged in as'].' '.pun_htmlspecialchars($pun_user['username']).'
  • '."\n\t\t\t\t".'
  • '.$lang_common['Last visit'].': '.format_time($pun_user['last_visit']).'
  • ';
4c79b5
4c79b5
	if ($pun_user['g_id'] < PUN_GUEST)
4c79b5
	{
4c79b5
		$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());
4c79b5
4c79b5
		if ($db->result($result_header))
4c79b5
			$tpl_temp .= "\n\t\t\t\t".'
  • There are new reports
  • ';
    4c79b5
    4c79b5
    		if ($pun_config['o_maintenance'] == '1')
    4c79b5
    			$tpl_temp .= "\n\t\t\t\t".'
  • Maintenance mode is enabled!
  • ';
    4c79b5
    	}
    4c79b5
    4c79b5
    	if (in_array(basename($_SERVER['PHP_SELF']), array('index.php', 'search.php')))
    4c79b5
    		$tpl_temp .= "\n\t\t\t".''."\n\t\t\t".''."\n\t\t\t".'
    '."\n\t\t".'';
    4c79b5
    	else
    4c79b5
    		$tpl_temp .= "\n\t\t\t".''."\n\t\t\t".'
    '."\n\t\t".'';
    4c79b5
    }
    4c79b5
    4c79b5
    $tpl_main = str_replace('<pun_status>', $tpl_temp, $tpl_main);
    4c79b5
    // END SUBST - <pun_status>
    4c79b5
    4c79b5
    4c79b5
    // START SUBST - <pun_announcement>
    4c79b5
    if ($pun_config['o_announcement'] == '1')
    4c79b5
    {
    4c79b5
    	ob_start();
    4c79b5
    4c79b5
    ?>
    4c79b5
    4c79b5
    	

    4c79b5
    	
    4c79b5
    		
    4c79b5
    			
    4c79b5
    		
    4c79b5
    	
    4c79b5
    4c79b5
    4c79b5
    4c79b5
    	$tpl_temp = trim(ob_get_contents());
    4c79b5
    	$tpl_main = str_replace('<pun_announcement>', $tpl_temp, $tpl_main);
    4c79b5
    	ob_end_clean();
    4c79b5
    }
    4c79b5
    else
    4c79b5
    	$tpl_main = str_replace('<pun_announcement>', '', $tpl_main);
    4c79b5
    // END SUBST - <pun_announcement>
    4c79b5
    4c79b5
    4c79b5
    // START SUBST - <pun_main>
    4c79b5
    ob_start();
    4c79b5
    4c79b5
    4c79b5
    define('PUN_HEADER', 1);