<?php
/***********************************************************************
Copyright (C) 2002, 2003, 2004 Rickard Andersson (rickard@punbb.org)
This file is part of PunBB.
PunBB is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PunBB is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU G>eneral Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA 02111-1307 USA
************************************************************************/
// Send no-cache headers
//header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Expires: Thu, 21 Jul 1977 07:30:00 GMT'); // When yours truly first set eyes on this world! :)
header('Pragma: no-cache');
// Load the main template
$fp = fopen($pun_root.'include/template/main.tpl', 'r');
$tpl_main = trim(fread($fp, filesize($pun_root.'include/template/main.tpl')));
fclose($fp);
// START SUBST - <pun_content_direction>
$tpl_main = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_main);
// END SUBST - <pun_content_direction>
// START SUBST - <pun_char_encoding>
$tpl_main = str_replace('<pun_char_encoding>', $lang_common['lang_encoding'], $tpl_main);
// END SUBST - <pun_char_encoding>
// START SUBST - <pun_head>
ob_start();
if (isset($destination))
echo '<meta http-equiv="refresh" content="'.$delay.';URL='.$destination.'">'."\n";
else if (isset($validate_form))
{
// Output javascript(s)
// With a quick and dirty hack to not disable submit buttons if user agent is Opera (since Opera
// refused to re-enable the button if we submit and then go back to this page)
?>
<script type="text/javascript">
<!--
function process_form(theform)
{
<?php
if (isset($element_names))
{
echo "\t".'var element_names = new Object()'."\n";
while (list($elem_orig, $elem_trans) = @each($element_names))
echo "\t".'element_names["'.$elem_orig.'"] = "'.addslashes($elem_trans).'"'."\n";
?>
// Check for required elements
if (document.images) {
for (i = 0; i < theform.length; ++i) {
if (theform.elements[i].name.substring(0, 4) == "req_") {
if ((theform.elements[i].type=="text" || theform.elements[i].type=="textarea" || theform.elements[i].type=="password" || theform.elements[i].type=="file") && theform.elements[i].value=='') {
alert("\"" + element_names[theform.elements[i].name] + "\" <?php echo $lang_common['required field'] ?>")
return false
}
}
}
}
<?php
}
if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Opera'))
{
?>
// Disable any submit buttons we find
if (document.all || document.getElementById) {
for (i = 0; i < theform.length; ++i) {
var elem = theform.elements[i]
if (elem.type.toLowerCase() == "submit")
elem.disabled = true
}
return true
}
<?php
}
?>
return true
}
// -->
</script>
<?php
}
$style = (isset($cur_user)) ? $cur_user['style'] : $pun_config['o_default_style'];
?>
<title><?php echo $page_title ?></title>
<link rel="stylesheet" type="text/css" href="style/<?php echo $style.'.css' ?>">
<?php
$tpl_temp = trim(ob_get_contents());
$tpl_main = str_replace('<pun_head>', $tpl_temp, $tpl_main);
ob_end_clean();
// END SUBST - <pun_head>
// START SUBST - <pun_body>
ob_start();
if (isset($form_name) && isset($focus_element))
echo ' onLoad="document.getElementById(\''.$form_name.'\').'.$focus_element.'.focus()"';
$tpl_temp = ob_get_contents();
$tpl_main = str_replace('<pun_body>', $tpl_temp, $tpl_main);
ob_end_clean();
// END SUBST - <pun_body>
// START SUBST - <pun_title>
$tpl_main = str_replace('<pun_title>', pun_htmlspecialchars($pun_config['o_board_title']), $tpl_main);
// END SUBST - <pun_title>
// START SUBST - <pun_desc>
$tpl_main = str_replace('<pun_desc>', $pun_config['o_board_desc'], $tpl_main);
// END SUBST - <pun_desc>
// START SUBST - <pun_navlinks>
$tpl_main = str_replace('<pun_navlinks>', generate_navlinks(), $tpl_main);
// END SUBST - <pun_navlinks>
// START SUBST - <pun_status>
if ($cookie['is_guest'])
$tpl_temp = $lang_common['Not logged in'];
else
$tpl_temp = $lang_common['Logged in as'].' <b>'.pun_htmlspecialchars($cur_user['username']).'</b>.<br>'.$lang_common['Last visit'].': '.format_time($cur_user['last_visit']);
if ($cur_user['status'] > PUN_USER)
{
$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());
if ($db->result($result_header, 0))
$tpl_temp .= '<br><a class="punhot" href="admin_reports.php">There are new reports</a>';
if ($pun_config['o_maintenance'] == '1')
$tpl_temp .= '<br><a class="punhot" href="admin_options.php#maintenance"><b>Maintenance mode is enabled!</b></a>';
}
$tpl_main = str_replace('<pun_status>', $tpl_temp, $tpl_main);
// END SUBST - <pun_status>
// START SUBST - <pun_announcement>
if ($pun_config['o_announcement'] == '1' && basename($SERVER['SCRIPT_FILENAME']) == 'index.php')
{
ob_start();
?>
<table class="punspacer" cellspacing="1" cellpadding="4"><tr><td> </td></tr></table>
<table class="punmain" cellspacing="1" cellpadding="4">
<tr class="punhead">
<td class="punhead"><?php echo $lang_common['Announcement'] ?></td>
</tr>
<tr>
<td class="puncon2">
<?php echo $pun_config['o_announcement_message'] ?><br><br>
</td>
</tr>
</table>
<?php
$tpl_temp = trim(ob_get_contents());
$tpl_main = str_replace('<pun_announcement>', $tpl_temp, $tpl_main);
ob_end_clean();
}
else
$tpl_main = str_replace('<pun_announcement>', '', $tpl_main);
// END SUBST - <pun_announcement>
// START SUBST - <pun_main>
ob_start();
define('PUN_HEADER', 1);