Ignore:
Timestamp:
Nov 14, 2011, 11:17:15 PM (13 years ago)
Author:
dj3c1t
Message:

passage a Fluxbb 1.4.7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/rsr.v5.1.dev/web/punbb/header.php

    r1 r3  
    11<?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 
     2
     3/**
     4 * Copyright (C) 2008-2011 FluxBB
     5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
     6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
     7 */
    258
    269// Make sure no one attempts to run this script "directly"
     
    2912
    3013// Send no-cache headers
    31 header('Expires: Thu, 21 Jul 1977 07:30:00 GMT');       // When yours truly first set eyes on this world! :)
     14header('Expires: Thu, 21 Jul 1977 07:30:00 GMT'); // When yours truly first set eyes on this world! :)
    3215header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
    3316header('Cache-Control: post-check=0, pre-check=0', false);
    34 header('Pragma: no-cache');             // For HTTP/1.0 compability
    35 
     17header('Pragma: no-cache'); // For HTTP/1.0 compatibility
     18
     19// Send the Content-type header in case the web server is setup to send something else
     20header('Content-type: text/html; charset=utf-8');
    3621
    3722// Load the template
    3823if (defined('PUN_ADMIN_CONSOLE'))
    39         $tpl_main = file_get_contents(PUN_ROOT.'include/template/admin.tpl');
     24        $tpl_file = 'admin.tpl';
    4025else if (defined('PUN_HELP'))
    41         $tpl_main = file_get_contents(PUN_ROOT.'include/template/help.tpl');
    42 else
    43         $tpl_main = file_get_contents(PUN_ROOT.'include/template/main.tpl');
     26        $tpl_file = 'help.tpl';
     27else
     28        $tpl_file = 'main.tpl';
     29
     30if (file_exists(PUN_ROOT.'style/'.$pun_user['style'].'/'.$tpl_file))
     31{
     32        $tpl_file = PUN_ROOT.'style/'.$pun_user['style'].'/'.$tpl_file;
     33        $tpl_inc_dir = PUN_ROOT.'style/'.$pun_user['style'].'/';
     34}
     35else
     36{
     37        $tpl_file = PUN_ROOT.'include/template/'.$tpl_file;
     38        $tpl_inc_dir = PUN_ROOT.'include/user/';
     39}
     40
     41$tpl_main = file_get_contents($tpl_file);
     42
     43// START SUBST - <pun_include "*">
     44preg_match_all('%<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">%i', $tpl_main, $pun_includes, PREG_SET_ORDER);
     45
     46foreach ($pun_includes as $cur_include)
     47{
     48        ob_start();
     49
     50        // Allow for overriding user includes, too.
     51        if (file_exists($tpl_inc_dir.$cur_include[1].'.'.$cur_include[2]))
     52                require $tpl_inc_dir.$cur_include[1].'.'.$cur_include[2];
     53        else if (file_exists(PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2]))
     54                require PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2];
     55        else
     56                error(sprintf($lang_common['Pun include error'], htmlspecialchars($cur_include[0]), basename($tpl_file)));
     57
     58        $tpl_temp = ob_get_contents();
     59        $tpl_main = str_replace($cur_include[0], $tpl_temp, $tpl_main);
     60        ob_end_clean();
     61}
     62// END SUBST - <pun_include "*">
     63
     64
     65// START SUBST - <pun_language>
     66$tpl_main = str_replace('<pun_language>', $lang_common['lang_identifier'], $tpl_main);
     67// END SUBST - <pun_language>
    4468
    4569
     
    4973
    5074
    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 
    5675// START SUBST - <pun_head>
    5776ob_start();
     77
     78// Define $p if its not set to avoid a PHP notice
     79$p = isset($p) ? $p : null;
    5880
    5981// Is this a page that we want search index spiders to index?
     
    6284
    6385?>
    64 <title><?php echo $page_title ?></title>
     86<title><?php echo generate_page_title($page_title, $p) ?></title>
    6587<link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" />
    6688<?php
    6789
    6890if (defined('PUN_ADMIN_CONSOLE'))
    69         echo '<link rel="stylesheet" type="text/css" href="style/imports/base_admin.css" />'."\n";
     91{
     92        if (file_exists(PUN_ROOT.'style/'.$pun_user['style'].'/base_admin.css'))
     93                echo '<link rel="stylesheet" type="text/css" href="style/'.$pun_user['style'].'/base_admin.css" />'."\n";
     94        else
     95                echo '<link rel="stylesheet" type="text/css" href="style/imports/base_admin.css" />'."\n";
     96}
    7097
    7198if (isset($required_fields))
     
    75102?>
    76103<script type="text/javascript">
    77 <!--
     104/* <![CDATA[ */
    78105function process_form(the_form)
    79106{
    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 
     107        var element_names = {
     108<?php
     109        // Output a JavaScript object with localised field names
     110        $tpl_temp = count($required_fields);
     111        foreach ($required_fields as $elem_orig => $elem_trans)
     112        {
     113                echo "\t\t\"".$elem_orig.'": "'.addslashes(str_replace('&#160;', ' ', $elem_trans));
     114                if (--$tpl_temp) echo "\",\n";
     115                else echo "\"\n\t};\n";
     116        }
    87117?>
    88 
    89118        if (document.all || document.getElementById)
    90119        {
    91                 for (i = 0; i < the_form.length; ++i)
     120                for (var i = 0; i < the_form.length; ++i)
    92121                {
    93                         var elem = the_form.elements[i]
    94                         if (elem.name && elem.name.substring(0, 4) == "req_")
     122                        var elem = the_form.elements[i];
     123                        if (elem.name && (/^req_/.test(elem.name)))
    95124                        {
    96                                 if (elem.type && (elem.type=="text" || elem.type=="textarea" || elem.type=="password" || elem.type=="file") && elem.value=='')
     125                                if (!elem.value && elem.type && (/^(?:text(?:area)?|password|file)$/i.test(elem.type)))
    97126                                {
    98                                         alert("\"" + element_names[elem.name] + "\" <?php echo $lang_common['required field'] ?>")
    99                                         elem.focus()
    100                                         return false
     127                                        alert('"' + element_names[elem.name] + '" <?php echo $lang_common['required field'] ?>');
     128                                        elem.focus();
     129                                        return false;
    101130                                }
    102131                        }
    103132                }
    104133        }
    105 
    106         return true
    107 }
    108 // -->
     134        return true;
     135}
     136/* ]]> */
    109137</script>
    110138<?php
     
    112140}
    113141
    114 $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : '';
    115 if (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>';
     142// JavaScript tricks for IE6 and older
     143echo '<!--[if lte IE 6]><script type="text/javascript" src="style/imports/minmax.js"></script><![endif]-->'."\n";
     144
     145if (isset($page_head))
     146        echo implode("\n", $page_head)."\n";
    117147
    118148$tpl_temp = trim(ob_get_contents());
     
    125155if (isset($focus_element))
    126156{
    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);
     157        $tpl_main = str_replace('<body onload="', '<body onload="document.getElementById(\''.$focus_element[0].'\').elements[\''.$focus_element[1].'\'].focus();', $tpl_main);
     158        $tpl_main = str_replace('<body>', '<body onload="document.getElementById(\''.$focus_element[0].'\').elements[\''.$focus_element[1].'\'].focus()">', $tpl_main);
    129159}
    130160// END SUBST - <body>
     
    132162
    133163// START SUBST - <pun_page>
    134 $tpl_main = str_replace('<pun_page>', basename($_SERVER['PHP_SELF'], '.php'), $tpl_main);
     164$tpl_main = str_replace('<pun_page>', htmlspecialchars(basename($_SERVER['PHP_SELF'], '.php')), $tpl_main);
     165// END SUBST - <pun_page>
     166
     167
     168// START SUBST - <pun_title>
     169$tpl_main = str_replace('<pun_title>', '<h1><a href="index.php">'.pun_htmlspecialchars($pun_config['o_board_title']).'</a></h1>', $tpl_main);
    135170// END SUBST - <pun_title>
    136171
    137172
    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 
    143173// START SUBST - <pun_desc>
    144 $tpl_main = str_replace('<pun_desc>', '<p><span>'.$pun_config['o_board_desc'].'</span></p>', $tpl_main);
     174$tpl_main = str_replace('<pun_desc>', '<div id="brddesc">'.$pun_config['o_board_desc'].'</div>', $tpl_main);
    145175// END SUBST - <pun_desc>
    146176
    147177
    148178// 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);
     179$links = array();
     180
     181// Index should always be displayed
     182$links[] = '<li id="navindex"'.((PUN_ACTIVE_PAGE == 'index') ? ' class="isactive"' : '').'><a href="index.php">'.$lang_common['Index'].'</a></li>';
     183
     184if ($pun_user['g_read_board'] == '1' && $pun_user['g_view_users'] == '1')
     185        $links[] = '<li id="navuserlist"'.((PUN_ACTIVE_PAGE == 'userlist') ? ' class="isactive"' : '').'><a href="userlist.php">'.$lang_common['User list'].'</a></li>';
     186
     187if ($pun_config['o_rules'] == '1' && (!$pun_user['is_guest'] || $pun_user['g_read_board'] == '1' || $pun_config['o_regs_allow'] == '1'))
     188        $links[] = '<li id="navrules"'.((PUN_ACTIVE_PAGE == 'rules') ? ' class="isactive"' : '').'><a href="misc.php?action=rules">'.$lang_common['Rules'].'</a></li>';
     189
     190if ($pun_user['g_read_board'] == '1' && $pun_user['g_search'] == '1')
     191        $links[] = '<li id="navsearch"'.((PUN_ACTIVE_PAGE == 'search') ? ' class="isactive"' : '').'><a href="search.php">'.$lang_common['Search'].'</a></li>';
     192
     193if ($pun_user['is_guest'])
     194{
     195        $links[] = '<li id="navregister"'.((PUN_ACTIVE_PAGE == 'register') ? ' class="isactive"' : '').'><a href="register.php">'.$lang_common['Register'].'</a></li>';
     196        $links[] = '<li id="navlogin"'.((PUN_ACTIVE_PAGE == 'login') ? ' class="isactive"' : '').'><a href="login.php">'.$lang_common['Login'].'</a></li>';
     197}
     198else
     199{
     200        $links[] = '<li id="navprofile"'.((PUN_ACTIVE_PAGE == 'profile') ? ' class="isactive"' : '').'><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a></li>';
     201
     202        if ($pun_user['is_admmod'])
     203                $links[] = '<li id="navadmin"'.((PUN_ACTIVE_PAGE == 'admin') ? ' class="isactive"' : '').'><a href="admin_index.php">'.$lang_common['Admin'].'</a></li>';
     204
     205        $links[] = '<li id="navlogout"><a href="login.php?action=out&amp;id='.$pun_user['id'].'&amp;csrf_token='.pun_hash($pun_user['id'].pun_hash(get_remote_address())).'">'.$lang_common['Logout'].'</a></li>';
     206}
     207
     208// Are there any additional navlinks we should insert into the array before imploding it?
     209if ($pun_user['g_read_board'] == '1' && $pun_config['o_additional_navlinks'] != '')
     210{
     211        if (preg_match_all('%([0-9]+)\s*=\s*(.*?)\n%s', $pun_config['o_additional_navlinks']."\n", $extra_links))
     212        {
     213                // Insert any additional links into the $links array (at the correct index)
     214                $num_links = count($extra_links[1]);
     215                for ($i = 0; $i < $num_links; ++$i)
     216                        array_splice($links, $extra_links[1][$i], 0, array('<li id="navextra'.($i + 1).'">'.$extra_links[2][$i].'</li>'));
     217        }
     218}
     219
     220$tpl_temp = '<div id="brdmenu" class="inbox">'."\n\t\t\t".'<ul>'."\n\t\t\t\t".implode("\n\t\t\t\t", $links)."\n\t\t\t".'</ul>'."\n\t\t".'</div>';
     221$tpl_main = str_replace('<pun_navlinks>', $tpl_temp, $tpl_main);
    150222// END SUBST - <pun_navlinks>
    151223
    152224
    153225// START SUBST - <pun_status>
     226$page_statusinfo = $page_topicsearches = array();
     227
    154228if ($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>';
    156 else
    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>';
     229        $page_statusinfo = '<p class="conl">'.$lang_common['Not logged in'].'</p>';
     230else
     231{
     232        $page_statusinfo[] = '<li><span>'.$lang_common['Logged in as'].' <strong>'.pun_htmlspecialchars($pun_user['username']).'</strong></span></li>';
     233        $page_statusinfo[] = '<li><span>'.sprintf($lang_common['Last visit'], format_time($pun_user['last_visit'])).'</span></li>';
     234
     235        if ($pun_user['is_admmod'])
     236        {
     237                if ($pun_config['o_report_method'] == '0' || $pun_config['o_report_method'] == '2')
     238                {
     239                        $result_header = $db->query('SELECT 1 FROM '.$db->prefix.'reports WHERE zapped IS NULL') or error('Unable to fetch reports info', __FILE__, __LINE__, $db->error());
     240
     241                        if ($db->result($result_header))
     242                                $page_statusinfo[] = '<li class="reportlink"><span><strong><a href="admin_reports.php">'.$lang_common['New reports'].'</a></strong></span></li>';
     243                }
    166244
    167245                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 }
     246                        $page_statusinfo[] = '<li class="maintenancelink"><span><strong><a href="admin_options.php#maintenance">'.$lang_common['Maintenance mode enabled'].'</a></strong></span></li>';
     247        }
     248
     249        if ($pun_user['g_read_board'] == '1' && $pun_user['g_search'] == '1')
     250        {
     251                $page_topicsearches[] = '<a href="search.php?action=show_replies" title="'.$lang_common['Show posted topics'].'">'.$lang_common['Posted topics'].'</a>';
     252                $page_topicsearches[] = '<a href="search.php?action=show_new" title="'.$lang_common['Show new posts'].'">'.$lang_common['New posts header'].'</a>';
     253        }
     254}
     255
     256// Quick searches
     257if ($pun_user['g_read_board'] == '1' && $pun_user['g_search'] == '1')
     258{
     259        $page_topicsearches[] = '<a href="search.php?action=show_recent" title="'.$lang_common['Show active topics'].'">'.$lang_common['Active topics'].'</a>';
     260        $page_topicsearches[] = '<a href="search.php?action=show_unanswered" title="'.$lang_common['Show unanswered topics'].'">'.$lang_common['Unanswered topics'].'</a>';
     261}
     262
     263
     264// Generate all that jazz
     265$tpl_temp = '<div id="brdwelcome" class="inbox">';
     266
     267// The status information
     268if (is_array($page_statusinfo))
     269{
     270        $tpl_temp .= "\n\t\t\t".'<ul class="conl">';
     271        $tpl_temp .= "\n\t\t\t\t".implode("\n\t\t\t\t", $page_statusinfo);
     272        $tpl_temp .= "\n\t\t\t".'</ul>';
     273}
     274else
     275        $tpl_temp .= "\n\t\t\t".$page_statusinfo;
     276
     277// Generate quicklinks
     278if (!empty($page_topicsearches))
     279{
     280        $tpl_temp .= "\n\t\t\t".'<ul class="conr">';
     281        $tpl_temp .= "\n\t\t\t\t".'<li><span>'.$lang_common['Topic searches'].' '.implode(' | ', $page_topicsearches).'</span></li>';
     282        $tpl_temp .= "\n\t\t\t".'</ul>';
     283}
     284
     285$tpl_temp .= "\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';
    176286
    177287$tpl_main = str_replace('<pun_status>', $tpl_temp, $tpl_main);
     
    180290
    181291// START SUBST - <pun_announcement>
    182 if ($pun_config['o_announcement'] == '1')
     292if ($pun_user['g_read_board'] == '1' && $pun_config['o_announcement'] == '1')
    183293{
    184294        ob_start();
     
    186296?>
    187297<div id="announce" class="block">
    188         <h2><span><?php echo $lang_common['Announcement'] ?></span></h2>
     298        <div class="hd"><h2><span><?php echo $lang_common['Announcement'] ?></span></h2></div>
    189299        <div class="box">
    190                 <div class="inbox">
    191                         <div><?php echo $pun_config['o_announcement_message'] ?></div>
     300                <div id="announce-block" class="inbox">
     301                        <div class="usercontent"><?php echo $pun_config['o_announcement_message'] ?></div>
    192302                </div>
    193303        </div>
Note: See TracChangeset for help on using the changeset viewer.