source: branches/rsr.v5.1.dev/web/punbb/header.php @ 1

Last change on this file since 1 was 1, checked in by dj3c1t, 12 years ago

import initial

File size: 7.1 KB
Line 
1<?php
2/***********************************************************************
3
4  Copyright (C) 2002-2005  Rickard Andersson (rickard@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"
27if (!defined('PUN'))
28        exit;
29
30// Send no-cache headers
31header('Expires: Thu, 21 Jul 1977 07:30:00 GMT');       // When yours truly first set eyes on this world! :)
32header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
33header('Cache-Control: post-check=0, pre-check=0', false);
34header('Pragma: no-cache');             // For HTTP/1.0 compability
35
36
37// Load the template
38if (defined('PUN_ADMIN_CONSOLE'))
39        $tpl_main = file_get_contents(PUN_ROOT.'include/template/admin.tpl');
40else if (defined('PUN_HELP'))
41        $tpl_main = file_get_contents(PUN_ROOT.'include/template/help.tpl');
42else
43        $tpl_main = file_get_contents(PUN_ROOT.'include/template/main.tpl');
44
45
46// START SUBST - <pun_content_direction>
47$tpl_main = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_main);
48// END SUBST - <pun_content_direction>
49
50
51// START SUBST - <pun_char_encoding>
52$tpl_main = str_replace('<pun_char_encoding>', $lang_common['lang_encoding'], $tpl_main);
53// END SUBST - <pun_char_encoding>
54
55
56// START SUBST - <pun_head>
57ob_start();
58
59// Is this a page that we want search index spiders to index?
60if (!defined('PUN_ALLOW_INDEX'))
61        echo '<meta name="ROBOTS" content="NOINDEX, FOLLOW" />'."\n";
62
63?>
64<title><?php echo $page_title ?></title>
65<link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" />
66<?php
67
68if (defined('PUN_ADMIN_CONSOLE'))
69        echo '<link rel="stylesheet" type="text/css" href="style/imports/base_admin.css" />'."\n";
70
71if (isset($required_fields))
72{
73        // Output JavaScript to validate form (make sure required fields are filled out)
74
75?>
76<script type="text/javascript">
77<!--
78function process_form(the_form)
79{
80        var element_names = new Object()
81<?php
82
83        // Output a JavaScript array with localised field names
84        while (list($elem_orig, $elem_trans) = @each($required_fields))
85                echo "\t".'element_names["'.$elem_orig.'"] = "'.addslashes(str_replace('&#160;', ' ', $elem_trans)).'"'."\n";
86
87?>
88
89        if (document.all || document.getElementById)
90        {
91                for (i = 0; i < the_form.length; ++i)
92                {
93                        var elem = the_form.elements[i]
94                        if (elem.name && elem.name.substring(0, 4) == "req_")
95                        {
96                                if (elem.type && (elem.type=="text" || elem.type=="textarea" || elem.type=="password" || elem.type=="file") && elem.value=='')
97                                {
98                                        alert("\"" + element_names[elem.name] + "\" <?php echo $lang_common['required field'] ?>")
99                                        elem.focus()
100                                        return false
101                                }
102                        }
103                }
104        }
105
106        return true
107}
108// -->
109</script>
110<?php
111
112}
113
114$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : '';
115if (strpos($user_agent, 'msie') !== false && strpos($user_agent, 'windows') !== false && strpos($user_agent, 'opera') === false)
116        echo '<script type="text/javascript" src="style/imports/minmax.js"></script>';
117
118$tpl_temp = trim(ob_get_contents());
119$tpl_main = str_replace('<pun_head>', $tpl_temp, $tpl_main);
120ob_end_clean();
121// END SUBST - <pun_head>
122
123
124// START SUBST - <body>
125if (isset($focus_element))
126{
127        $tpl_main = str_replace('<body onload="', '<body onload="document.getElementById(\''.$focus_element[0].'\').'.$focus_element[1].'.focus();', $tpl_main);
128        $tpl_main = str_replace('<body>', '<body onload="document.getElementById(\''.$focus_element[0].'\').'.$focus_element[1].'.focus()">', $tpl_main);
129}
130// END SUBST - <body>
131
132
133// START SUBST - <pun_page>
134$tpl_main = str_replace('<pun_page>', basename($_SERVER['PHP_SELF'], '.php'), $tpl_main);
135// END SUBST - <pun_title>
136
137
138// START SUBST - <pun_title>
139$tpl_main = str_replace('<pun_title>', '<h1><span>'.pun_htmlspecialchars($pun_config['o_board_title']).'</span></h1>', $tpl_main);
140// END SUBST - <pun_title>
141
142
143// START SUBST - <pun_desc>
144$tpl_main = str_replace('<pun_desc>', '<p><span>'.$pun_config['o_board_desc'].'</span></p>', $tpl_main);
145// END SUBST - <pun_desc>
146
147
148// START SUBST - <pun_navlinks>
149$tpl_main = str_replace('<pun_navlinks>','<div id="brdmenu" class="inbox">'."\n\t\t\t". generate_navlinks()."\n\t\t".'</div>', $tpl_main);
150// END SUBST - <pun_navlinks>
151
152
153// START SUBST - <pun_status>
154if ($pun_user['is_guest'])
155        $tpl_temp = '<div id="brdwelcome" class="inbox">'."\n\t\t\t".'<p>'.$lang_common['Not logged in'].'</p>'."\n\t\t".'</div>';
156else
157{
158        $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>';
159
160        if ($pun_user['g_id'] < PUN_GUEST)
161        {
162                $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());
163
164                if ($db->result($result_header))
165                        $tpl_temp .= "\n\t\t\t\t".'<li class="reportlink"><strong><a href="admin_reports.php">Il y a de nouveaux signalements</a></strong></li>';
166
167                if ($pun_config['o_maintenance'] == '1')
168                        $tpl_temp .= "\n\t\t\t\t".'<li class="maintenancelink"><strong><a href="admin_options.php#maintenance">Le mode maintenance est activé&#160;!</a></strong></li>';
169        }
170
171        if (in_array(basename($_SERVER['PHP_SELF']), array('index.php', 'search.php')))
172                $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>';
173        else
174                $tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';
175}
176
177$tpl_main = str_replace('<pun_status>', $tpl_temp, $tpl_main);
178// END SUBST - <pun_status>
179
180
181// START SUBST - <pun_announcement>
182if ($pun_config['o_announcement'] == '1')
183{
184        ob_start();
185
186?>
187<div id="announce" class="block">
188        <h2><span><?php echo $lang_common['Announcement'] ?></span></h2>
189        <div class="box">
190                <div class="inbox">
191                        <div><?php echo $pun_config['o_announcement_message'] ?></div>
192                </div>
193        </div>
194</div>
195<?php
196
197        $tpl_temp = trim(ob_get_contents());
198        $tpl_main = str_replace('<pun_announcement>', $tpl_temp, $tpl_main);
199        ob_end_clean();
200}
201else
202        $tpl_main = str_replace('<pun_announcement>', '', $tpl_main);
203// END SUBST - <pun_announcement>
204
205
206// START SUBST - <pun_main>
207ob_start();
208
209
210define('PUN_HEADER', 1);
Note: See TracBrowser for help on using the repository browser.