2 /***********************************************************************
4 Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org)
6 This file is part of PunBB.
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.
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.
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,
23 ************************************************************************/
26 // Make sure no one attempts to run this script "directly"
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
38 if (defined('PUN_ADMIN_CONSOLE'))
39 $tpl_main = file_get_contents(PUN_ROOT
.'include/template/admin.tpl');
40 else if (defined('PUN_HELP'))
41 $tpl_main = file_get_contents(PUN_ROOT
.'include/template/help.tpl');
43 $tpl_main = file_get_contents(PUN_ROOT
.'include/template/main.tpl');
46 // START SUBST - <pun_include "*">
47 while (preg_match('#<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">#', $tpl_main, $cur_include))
49 if (!file_exists(PUN_ROOT
.'include/user/'.$cur_include[1].'.'.$cur_include[2]))
50 error('Unable to process user include '.htmlspecialchars($cur_include[0]).' from template main.tpl. There is no such file in folder /include/user/');
53 include PUN_ROOT
.'include/user/'.$cur_include[1].'.'.$cur_include[2];
54 $tpl_temp = ob_get_contents();
55 $tpl_main = str_replace($cur_include[0], $tpl_temp, $tpl_main);
58 // END SUBST - <pun_include "*">
61 // START SUBST - <pun_content_direction>
62 $tpl_main = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_main);
63 // END SUBST - <pun_content_direction>
66 // START SUBST - <pun_char_encoding>
67 $tpl_main = str_replace('<pun_char_encoding>', $lang_common['lang_encoding'], $tpl_main);
68 // END SUBST - <pun_char_encoding>
71 // START SUBST - <pun_head>
74 // Is this a page that we want search index spiders to index?
75 if (!defined('PUN_ALLOW_INDEX'))
76 echo '<meta name="ROBOTS" content="NOINDEX, FOLLOW" />'."\n";
79 <title
><?php
echo $page_title ?
></title
>
80 <link rel
="stylesheet" type
="text/css" href
="style/Archer.css" />
83 if (defined('PUN_ADMIN_CONSOLE'))
84 echo '<link rel="stylesheet" type="text/css" href="style/imports/base_admin.css" />'."\n";
86 if (isset($required_fields))
88 // Output JavaScript to validate form (make sure required fields are filled out)
91 <script type
="text/javascript">
93 function process_form(the_form
)
95 var element_names
= new Object()
98 // Output a JavaScript array with localised field names
99 while (list($elem_orig, $elem_trans) = @each
($required_fields))
100 echo "\t".'element_names["'.$elem_orig.'"] = "'.addslashes(str_replace(' ', ' ', $elem_trans)).'"'."\n";
104 if (document
.all || document
.getElementById
)
106 for (i
= 0; i
< the_form
.length
; ++i
)
108 var elem
= the_form
.elements
[i
]
109 if (elem
.name
&& elem
.name
.substring(0, 4) == "req_")
111 if (elem
.type
&& (elem
.type
=="text" || elem
.type
=="textarea" || elem
.type
=="password" || elem
.type
=="file") && elem
.value
=='')
113 alert("\"" + element_names
[elem
.name
] +
"\" <?php echo $lang_common['required field'] ?>")
129 $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ?
strtolower($_SERVER['HTTP_USER_AGENT']) : '';
130 if (strpos($user_agent, 'msie') !== false && strpos($user_agent, 'windows') !== false && strpos($user_agent, 'opera') === false)
131 echo '<script type="text/javascript" src="style/imports/minmax.js"></script>';
133 $tpl_temp = trim(ob_get_contents());
134 $tpl_main = str_replace('<pun_head>', $tpl_temp, $tpl_main);
136 // END SUBST - <pun_head>
139 // START SUBST - <body>
140 if (isset($focus_element))
142 $tpl_main = str_replace('<body onload="', '<body onload="document.getElementById(\''.$focus_element[0].'\').'.$focus_element[1].'.focus();', $tpl_main);
143 $tpl_main = str_replace('<body>', '<body onload="document.getElementById(\''.$focus_element[0].'\').'.$focus_element[1].'.focus()">', $tpl_main);
145 // END SUBST - <body>
148 // START SUBST - <pun_page>
149 $tpl_main = str_replace('<pun_page>', htmlspecialchars(basename($_SERVER['PHP_SELF'], '.php')), $tpl_main);
150 // END SUBST - <pun_page>
153 // START SUBST - <pun_title>
154 $tpl_main = str_replace('<pun_title>', '<h1><span>'.pun_htmlspecialchars($pun_config['o_board_title']).'</span></h1>', $tpl_main);
155 // END SUBST - <pun_title>
158 // START SUBST - <pun_desc>
159 $tpl_main = str_replace('<pun_desc>', '<p><span>'.$pun_config['o_board_desc'].'</span></p>', $tpl_main);
160 // END SUBST - <pun_desc>
163 // START SUBST - <pun_navlinks>
164 $tpl_main = str_replace('<pun_navlinks>','<div id="brdmenu" class="inbox">'."\n\t\t\t". generate_navlinks()."\n\t\t".'</div>', $tpl_main);
165 // END SUBST - <pun_navlinks>
168 // START SUBST - <pun_status>
169 if ($pun_user['is_guest'])
170 $tpl_temp = '<div id="brdwelcome" class="inbox">'."\n\t\t\t".'<p>'.$lang_common['Not logged in'].'</p>'."\n\t\t".'</div>';
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>';
175 if ($pun_user['g_id'] < PUN_GUEST
)
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());
179 if ($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>';
182 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>';
186 if (in_array(basename($_SERVER['PHP_SELF']), array('index.php', 'search.php')))
187 $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>';
189 $tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';
192 $tpl_main = str_replace('<pun_status>', $tpl_temp, $tpl_main);
193 // END SUBST - <pun_status>
196 // START SUBST - <pun_announcement>
197 if ($pun_config['o_announcement'] == '1')
202 <div id
="announce" class="block">
203 <h2
><span
><?php
echo $lang_common['Announcement'] ?
></span
></h2
>
206 <div
><?php
echo $pun_config['o_announcement_message'] ?
></div
>
212 $tpl_temp = trim(ob_get_contents());
213 $tpl_main = str_replace('<pun_announcement>', $tpl_temp, $tpl_main);
217 $tpl_main = str_replace('<pun_announcement>', '', $tpl_main);
218 // END SUBST - <pun_announcement>
221 // START SUBST - <pun_main>
225 define('PUN_HEADER', 1);