Advertisement
Kervinou

forum header.php

Jan 18th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 13.30 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * Copyright (C) 2008-2012 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.  */
  8.  
  9.  
  10.  
  11. // Make sure no one attempts to run this script "directly"
  12. if (!defined('PUN'))
  13.     exit;
  14.  
  15. // Send no-cache headers
  16. header('Expires: Thu, 21 Jul 1977 07:30:00 GMT'); // When yours truly first set eyes on this world! :)
  17. header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
  18. header('Cache-Control: post-check=0, pre-check=0', false);
  19. header('Pragma: no-cache'); // For HTTP/1.0 compatibility
  20.  
  21. // Send the Content-type header in case the web server is setup to send something else
  22. header('Content-type: text/html; charset=utf-8');
  23.  
  24. // Load the template
  25. if (defined('PUN_ADMIN_CONSOLE'))
  26.     $tpl_file = 'admin.tpl';
  27. else if (defined('PUN_HELP'))
  28.     $tpl_file = 'help.tpl';
  29. else
  30.     $tpl_file = 'main.tpl';
  31.  
  32. if (file_exists(PUN_ROOT.'style/'.$pun_user['style'].'/'.$tpl_file))
  33. {
  34.     $tpl_file = PUN_ROOT.'style/'.$pun_user['style'].'/'.$tpl_file;
  35.     $tpl_inc_dir = PUN_ROOT.'style/'.$pun_user['style'].'/';
  36. }
  37. else
  38. {
  39.     $tpl_file = PUN_ROOT.'include/template/'.$tpl_file;
  40.     $tpl_inc_dir = PUN_ROOT.'include/user/';
  41. }
  42.  
  43. $tpl_main = file_get_contents($tpl_file);
  44.  
  45. // START SUBST - <pun_include "*">
  46. preg_match_all('%<pun_include "([^"]+)">%i', $tpl_main, $pun_includes, PREG_SET_ORDER);
  47.  
  48. foreach ($pun_includes as $cur_include)
  49. {
  50.     ob_start();
  51.  
  52.     $file_info = pathinfo($cur_include[1]);
  53.    
  54.     if (!in_array($file_info['extension'], array('php', 'php4', 'php5', 'inc', 'html', 'txt'))) // Allow some extensions
  55.         error(sprintf($lang_common['Pun include extension'], pun_htmlspecialchars($cur_include[0]), basename($tpl_file), pun_htmlspecialchars($file_info['extension'])));
  56.        
  57.     if (strpos($file_info['dirname'], '..') !== false) // Don't allow directory traversal
  58.         error(sprintf($lang_common['Pun include directory'], pun_htmlspecialchars($cur_include[0]), basename($tpl_file)));
  59.  
  60.     // Allow for overriding user includes, too.
  61.     if (file_exists($tpl_inc_dir.$cur_include[1]))
  62.         require $tpl_inc_dir.$cur_include[1];
  63.     else if (file_exists(PUN_ROOT.'include/user/'.$cur_include[1]))
  64.         require PUN_ROOT.'include/user/'.$cur_include[1];
  65.     else
  66.         error(sprintf($lang_common['Pun include error'], pun_htmlspecialchars($cur_include[0]), basename($tpl_file)));
  67.  
  68.     $tpl_temp = ob_get_contents();
  69.     $tpl_main = str_replace($cur_include[0], $tpl_temp, $tpl_main);
  70.     ob_end_clean();
  71. }
  72. // END SUBST - <pun_include "*">
  73.  
  74.  
  75. // START SUBST - <pun_language>
  76. $tpl_main = str_replace('<pun_language>', $lang_common['lang_identifier'], $tpl_main);
  77. // END SUBST - <pun_language>
  78.  
  79.  
  80. // START SUBST - <pun_content_direction>
  81. $tpl_main = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_main);
  82. // END SUBST - <pun_content_direction>
  83.  
  84.  
  85. // START SUBST - <pun_head>
  86. ob_start();
  87.  
  88. // Define $p if it's not set to avoid a PHP notice
  89. $p = isset($p) ? $p : null;
  90.  
  91. // Is this a page that we want search index spiders to index?
  92. if (!defined('PUN_ALLOW_INDEX'))
  93.     echo '<meta name="ROBOTS" content="NOINDEX, FOLLOW" />'."\n";
  94.  
  95. ?>
  96. <title><?php echo generate_page_title($page_title, $p) ?></title>
  97. <?php require PUN_ROOT.'plugins/ezbbc/ezbbc_head.php'; ?>
  98. <link rel="shortcut icon" type="image/x-icon" href="http://madincraft.fr/favicon.ico" />
  99.  
  100. <?php
  101.   // 07/07/2015 désactivation
  102.   // <script type="text/javascript" src="http://mod.postimage.org/fluxbb-french.js" charset="utf-8"></script>
  103. ?>
  104.  
  105. <link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" />
  106. <?php
  107.  
  108. if (defined('PUN_ADMIN_CONSOLE'))
  109. {
  110.     if (file_exists(PUN_ROOT.'style/'.$pun_user['style'].'/base_admin.css'))
  111.         echo '<link rel="stylesheet" type="text/css" href="style/'.$pun_user['style'].'/base_admin.css" />'."\n";
  112.     else
  113.         echo '<link rel="stylesheet" type="text/css" href="style/imports/base_admin.css" />'."\n";
  114. }
  115.  
  116. if (isset($required_fields))
  117. {
  118.     // Output JavaScript to validate form (make sure required fields are filled out)
  119.  
  120. ?>
  121. <script type="text/javascript">
  122. /* <![CDATA[ */
  123. function process_form(the_form)
  124. {
  125.     var required_fields = {
  126. <?php
  127.     // Output a JavaScript object with localised field names
  128.     $tpl_temp = count($required_fields);
  129.     foreach ($required_fields as $elem_orig => $elem_trans)
  130.     {
  131.         echo "\t\t\"".$elem_orig.'": "'.addslashes(str_replace('&#160;', ' ', $elem_trans));
  132.         if (--$tpl_temp) echo "\",\n";
  133.         else echo "\"\n\t};\n";
  134.     }
  135. ?>
  136.     if (document.all || document.getElementById)
  137.     {
  138.         for (var i = 0; i < the_form.length; ++i)
  139.         {
  140.             var elem = the_form.elements[i];
  141.             if (elem.name && required_fields[elem.name] && !elem.value && elem.type && (/^(?:text(?:area)?|password|file)$/i.test(elem.type)))
  142.             {
  143.                 alert('"' + required_fields[elem.name] + '" <?php echo $lang_common['required field'] ?>');
  144.                 elem.focus();
  145.                 return false;
  146.             }
  147.         }
  148.     }
  149.     return true;
  150. }
  151. /* ]]> */
  152. </script>
  153. <?php
  154.  
  155. }
  156.  
  157. require PUN_ROOT.'plugins/apms/header_add3.php';
  158.  
  159. // JavaScript tricks for IE6 and older
  160. echo '<!--[if lte IE 6]><script type="text/javascript" src="style/imports/minmax.js"></script><![endif]-->'."\n";
  161.  
  162. $page_head['colorize_groups'] = '<style type="text/css">'.$GLOBALS['pun_colorize_groups']['style'].'</style>'; // need $GLOBALS for message function
  163.  
  164. if (isset($page_head))
  165.     echo implode("\n", $page_head)."\n";
  166.  
  167. $tpl_temp = trim(ob_get_contents());
  168. $tpl_main = str_replace('<pun_head>', $tpl_temp, $tpl_main);
  169. ob_end_clean();
  170. // END SUBST - <pun_head>
  171.  
  172.  
  173. // START SUBST - <body>
  174. if (isset($focus_element))
  175. {
  176.     $tpl_main = str_replace('<body onload="', '<body onload="document.getElementById(\''.$focus_element[0].'\').elements[\''.$focus_element[1].'\'].focus();', $tpl_main);
  177.     $tpl_main = str_replace('<body>', '<body onload="document.getElementById(\''.$focus_element[0].'\').elements[\''.$focus_element[1].'\'].focus()">', $tpl_main);
  178. }
  179. // END SUBST - <body>
  180.  
  181.  
  182. // START SUBST - <pun_page>
  183. $tpl_main = str_replace('<pun_page>', htmlspecialchars(basename($_SERVER['PHP_SELF'], '.php')), $tpl_main);
  184. // END SUBST - <pun_page>
  185.  
  186.  
  187. // START SUBST - <pun_title>
  188. $tpl_main = str_replace('<pun_title>', '<h1><a href="index.php">'.pun_htmlspecialchars($pun_config['o_board_title']).'</a></h1>', $tpl_main);
  189. // END SUBST - <pun_title>
  190.  
  191.  
  192.  
  193. // START SUBST - <pun_desc>
  194. $tpl_main = str_replace('<pun_desc>', '<div id="brddesc">'.$pun_config['o_board_desc'].'</div>', $tpl_main);
  195. // END SUBST - <pun_desc>
  196.  
  197.  
  198. // START SUBST - <pun_navlinks>
  199. $links = array();
  200.  
  201. // Index should always be displayed
  202. $links[] = '<li id="navindex"'.((PUN_ACTIVE_PAGE == 'index') ? ' class="isactive"' : '').'><a href="index.php">'.$lang_common['Index'].'</a></li>';
  203.  
  204. if ($pun_user['g_read_board'] == '1' && $pun_user['g_view_users'] == '1')
  205.     $links[] = '<li id="navuserlist"'.((PUN_ACTIVE_PAGE == 'userlist') ? ' class="isactive"' : '').'><a href="userlist.php">'.$lang_common['User list'].'</a></li>';
  206.  
  207. if ($pun_config['o_rules'] == '1' && (!$pun_user['is_guest'] || $pun_user['g_read_board'] == '1' || $pun_config['o_regs_allow'] == '1'))
  208.     $links[] = '<li id="navrules"'.((PUN_ACTIVE_PAGE == 'rules') ? ' class="isactive"' : '').'><a href="misc.php?action=rules">'.$lang_common['Rules'].'</a></li>';
  209.  
  210. if ($pun_user['g_read_board'] == '1' && $pun_user['g_search'] == '1')
  211.     $links[] = '<li id="navsearch"'.((PUN_ACTIVE_PAGE == 'search') ? ' class="isactive"' : '').'><a href="search.php">'.$lang_common['Search'].'</a></li>';
  212.  
  213. if ($pun_user['is_guest'])
  214. {
  215.     $links[] = '<li id="navregister"'.((PUN_ACTIVE_PAGE == 'register') ? ' class="isactive"' : '').'><a href="viewtopic.php?pid=20#p20">'.$lang_common['Register'].'</a></li>';
  216.     $links[] = '<li id="navlogin"'.((PUN_ACTIVE_PAGE == 'login') ? ' class="isactive"' : '').'><a href="login.php">'.$lang_common['Login'].'</a></li>';
  217. }
  218. else
  219. {
  220.     $links[] = '<li id="navprofile"'.((PUN_ACTIVE_PAGE == 'profile') ? ' class="isactive"' : '').'><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a></li>';
  221.  
  222.     require PUN_ROOT.'plugins/apms/header_add2.php';
  223.  
  224.  
  225.     if ($pun_user['is_admmod'])
  226.         $links[] = '<li id="navadmin"'.((PUN_ACTIVE_PAGE == 'admin') ? ' class="isactive"' : '').'><a href="admin_index.php">'.$lang_common['Admin'].'</a></li>';
  227.  
  228.     $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>';
  229. }
  230.  
  231. // Are there any additional navlinks we should insert into the array before imploding it?
  232. if ($pun_user['g_read_board'] == '1' && $pun_config['o_additional_navlinks'] != '')
  233. {
  234.     if (preg_match_all('%([0-9]+)\s*=\s*(.*?)\n%s', $pun_config['o_additional_navlinks']."\n", $extra_links))
  235.     {
  236.         // Insert any additional links into the $links array (at the correct index)
  237.         $num_links = count($extra_links[1]);
  238.         for ($i = 0; $i < $num_links; ++$i)
  239.             array_splice($links, $extra_links[1][$i], 0, array('<li id="navextra'.($i + 1).'">'.$extra_links[2][$i].'</li>'));
  240.     }
  241. }
  242.  
  243. $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>';
  244. $tpl_main = str_replace('<pun_navlinks>', $tpl_temp, $tpl_main);
  245. // END SUBST - <pun_navlinks>
  246.  
  247. // START SUBST - <pun_sidelinks>
  248. $tpl_main = str_replace('<pun_sidelinks>','<div class="inbox">'."".'<ul>'."".implode("", $links)."".'</ul>'."".'</div>', $tpl_main);
  249. //$tpl_main = str_replace('<pun_sidelinks>','<div class="inbox">'.'<ul><img src="http://minecraft.kerv.org/forum/img/p_nous_end.jpg" height="170" width="288"></ul>'.'</div>', $tpl_main);
  250. // END SUBST - <pun_sidelinks>
  251.  
  252. // START SUBST - <pun_status>
  253. $page_statusinfo = $page_topicsearches = array();
  254.  
  255. if ($pun_user['is_guest'])
  256.     $page_statusinfo = '<p class="conl">'.$lang_common['Not logged in'].'</p>';
  257. else
  258. {
  259.     // avant colorize_groups -- $page_statusinfo[] = '<li><span>'.$lang_common['Logged in as'].' <strong>'.pun_htmlspecialchars($pun_user['username']).'</strong></span></li>';
  260.     $page_statusinfo[] = '<li><span>'.$lang_common['Logged in as'].' <strong>'.colorize_group($pun_user['username'], $pun_user['g_id'], $pun_user['id']).'</strong></span></li>';
  261.     $page_statusinfo[] = '<li><span>'.sprintf($lang_common['Last visit'], format_time($pun_user['last_visit'])).'</span></li>';
  262.  
  263.     if ($pun_user['is_admmod'])
  264.     {
  265.         if ($pun_config['o_report_method'] == '0' || $pun_config['o_report_method'] == '2')
  266.         {
  267.             $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());
  268.  
  269.             if ($db->result($result_header))
  270.                 $page_statusinfo[] = '<li class="reportlink"><span><strong><a href="admin_reports.php">'.$lang_common['New reports'].'</a></strong></span></li>';
  271.         }
  272.  
  273.         if ($pun_config['o_maintenance'] == '1')
  274.             $page_statusinfo[] = '<li class="maintenancelink"><span><strong><a href="admin_options.php#maintenance">'.$lang_common['Maintenance mode enabled'].'</a></strong></span></li>';
  275.     }
  276.  
  277.     require PUN_ROOT.'plugins/apms/header_add1.php';
  278.  
  279.     if ($pun_user['g_read_board'] == '1' && $pun_user['g_search'] == '1')
  280.     {
  281.         $page_topicsearches[] = '<a href="search.php?action=show_replies" title="'.$lang_common['Show posted topics'].'">'.$lang_common['Posted topics'].'</a>';
  282.         $page_topicsearches[] = '<a href="search.php?action=show_new" title="'.$lang_common['Show new posts'].'">'.$lang_common['New posts header'].'</a>';
  283.     }
  284. }
  285.  
  286. // Quick searches
  287. if ($pun_user['g_read_board'] == '1' && $pun_user['g_search'] == '1')
  288. {
  289.     $page_topicsearches[] = '<a href="search.php?action=show_recent" title="'.$lang_common['Show active topics'].'">'.$lang_common['Active topics'].'</a>';
  290.     $page_topicsearches[] = '<a href="search.php?action=show_unanswered" title="'.$lang_common['Show unanswered topics'].'">'.$lang_common['Unanswered topics'].'</a>';
  291. }
  292.  
  293.  
  294. // Generate all that jazz
  295. $tpl_temp = '<div id="brdwelcome" class="inbox">';
  296.  
  297. // The status information
  298. if (is_array($page_statusinfo))
  299. {
  300.     $tpl_temp .= "\n\t\t\t".'<ul class="conl">';
  301.     $tpl_temp .= "\n\t\t\t\t".implode("\n\t\t\t\t", $page_statusinfo);
  302.     $tpl_temp .= "\n\t\t\t".'</ul>';
  303. }
  304. else
  305.     $tpl_temp .= "\n\t\t\t".$page_statusinfo;
  306.  
  307. // Generate quicklinks
  308. if (!empty($page_topicsearches))
  309. {
  310.     $tpl_temp .= "\n\t\t\t".'<ul class="conr">';
  311.     $tpl_temp .= "\n\t\t\t\t".'<li><span>'.$lang_common['Topic searches'].' '.implode(' | ', $page_topicsearches).'</span></li>';
  312.     $tpl_temp .= "\n\t\t\t".'</ul>';
  313. }
  314.  
  315. $tpl_temp .= "\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';
  316.  
  317. $tpl_main = str_replace('<pun_status>', $tpl_temp, $tpl_main);
  318. // END SUBST - <pun_status>
  319.  
  320.  
  321. // START SUBST - <pun_announcement>
  322. if ($pun_user['g_read_board'] == '1' && $pun_config['o_announcement'] == '1')
  323. {
  324.     ob_start();
  325.  
  326.  
  327. ?>
  328. <div id="announce" class="block">
  329.     <div class="hd"><h2><span><?php echo $lang_common['Announcement'] ?></span></h2></div>
  330.     <div class="box">
  331.         <div id="announce-block" class="inbox">
  332.             <div class="usercontent"><?php echo $pun_config['o_announcement_message'] ?></div>
  333.         </div>
  334.     </div>
  335. </div>
  336. <?php
  337.  
  338.     $tpl_temp = trim(ob_get_contents());
  339.     $tpl_main = str_replace('<pun_announcement>', $tpl_temp, $tpl_main);
  340.     ob_end_clean();
  341. }
  342. else
  343.     $tpl_main = str_replace('<pun_announcement>', '', $tpl_main);
  344. // END SUBST - <pun_announcement>
  345.  
  346.  
  347. // START SUBST - <pun_main>
  348. ob_start();
  349.  
  350.  
  351. define('PUN_HEADER', 1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement