PageRenderTime 58ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/header.php

https://github.com/Dratone/EveBB
PHP | 350 lines | 300 code | 26 blank | 24 comment | 13 complexity | 054daa0a435a10a83f37c194aed5a578 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * Copyright (C) 2008-2010 FluxBB
  4. * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
  5. * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
  6. */
  7. // Make sure no one attempts to run this script "directly"
  8. if (!defined('PUN'))
  9. exit;
  10. // Send no-cache headers
  11. header('Expires: Thu, 21 Jul 1977 07:30:00 GMT'); // When yours truly first set eyes on this world! :)
  12. header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
  13. header('Cache-Control: post-check=0, pre-check=0', false);
  14. header('Pragma: no-cache'); // For HTTP/1.0 compatibility
  15. // Send the Content-type header in case the web server is setup to send something else
  16. header('Content-type: text/html; charset=utf-8');
  17. // Load the template
  18. if (defined('PUN_ADMIN_CONSOLE'))
  19. $tpl_file = 'admin.tpl';
  20. else if (defined('PUN_HELP'))
  21. $tpl_file = 'help.tpl';
  22. else
  23. $tpl_file = 'main.tpl';
  24. if (file_exists(PUN_ROOT.'style/'.$pun_user['style'].'/'.$tpl_file))
  25. {
  26. $tpl_file = PUN_ROOT.'style/'.$pun_user['style'].'/'.$tpl_file;
  27. $tpl_inc_dir = PUN_ROOT.'style/'.$pun_user['style'].'/';
  28. }
  29. else
  30. {
  31. $tpl_file = PUN_ROOT.'include/template/'.$tpl_file;
  32. $tpl_inc_dir = PUN_ROOT.'include/user/';
  33. }
  34. $tpl_main = file_get_contents($tpl_file);
  35. // START SUBST - <pun_include "*">
  36. preg_match_all('#<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">#', $tpl_main, $pun_includes, PREG_SET_ORDER);
  37. foreach ($pun_includes as $cur_include)
  38. {
  39. ob_start();
  40. // Allow for overriding user includes, too.
  41. if (file_exists($tpl_inc_dir.$cur_include[1].'.'.$cur_include[2]))
  42. require $tpl_inc_dir.$cur_include[1].'.'.$cur_include[2];
  43. else if (file_exists(PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2]))
  44. require PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2];
  45. else
  46. error(sprintf($lang_common['Pun include error'], htmlspecialchars($cur_include[0]), basename($tpl_file)));
  47. $tpl_temp = ob_get_contents();
  48. $tpl_main = str_replace($cur_include[0], $tpl_temp, $tpl_main);
  49. ob_end_clean();
  50. }
  51. // END SUBST - <pun_include "*">
  52. // START SUBST - <pun_language>
  53. $tpl_main = str_replace('<pun_language>', $lang_common['lang_identifier'], $tpl_main);
  54. // END SUBST - <pun_language>
  55. // START SUBST - <pun_content_direction>
  56. $tpl_main = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_main);
  57. // END SUBST - <pun_content_direction>
  58. // START SUBST - <server_name>
  59. $tpl_main = str_replace('<request_trust>', (($_SESSION['igb']) ? ' onload="CCPEVE.requestTrust(\'http://'.$_SERVER['SERVER_NAME'].'\')' : ''), $tpl_main);
  60. // END SUBST - <server_name>
  61. // START SUBST - <pun_head>
  62. ob_start();
  63. // Define $p if its not set to avoid a PHP notice
  64. $p = isset($p) ? $p : null;
  65. // Is this a page that we want search index spiders to index?
  66. if (!defined('PUN_ALLOW_INDEX'))
  67. echo '<meta name="ROBOTS" content="NOINDEX, FOLLOW" />'."\n";
  68. ?>
  69. <title><?php echo generate_page_title($page_title, $p) ?></title>
  70. <?php require PUN_ROOT.'plugins/ezbbc/ezbbc_head.php'; ?>
  71. <link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" />
  72. <script type="text/javascript" src="apiFetching.js"></script>
  73. <?php
  74. if (defined('PUN_ADMIN_CONSOLE'))
  75. {
  76. if (file_exists(PUN_ROOT.'style/'.$pun_user['style'].'/base_admin.css'))
  77. echo '<link rel="stylesheet" type="text/css" href="style/'.$pun_user['style'].'/base_admin.css" />'."\n";
  78. else
  79. echo '<link rel="stylesheet" type="text/css" href="style/imports/base_admin.css" />'."\n";
  80. }
  81. if (isset($required_fields))
  82. {
  83. // Output JavaScript to validate form (make sure required fields are filled out)
  84. ?>
  85. <script type="text/javascript">
  86. /* <![CDATA[ */
  87. function process_form(the_form)
  88. {
  89. var element_names = {
  90. <?php
  91. // Output a JavaScript object with localised field names
  92. $tpl_temp = count($required_fields);
  93. foreach ($required_fields as $elem_orig => $elem_trans)
  94. {
  95. echo "\t\t\"".$elem_orig.'": "'.addslashes(str_replace('&#160;', ' ', $elem_trans));
  96. if (--$tpl_temp) echo "\",\n";
  97. else echo "\"\n\t};\n";
  98. }
  99. ?>
  100. if (document.all || document.getElementById)
  101. {
  102. for (var i = 0; i < the_form.length; ++i)
  103. {
  104. var elem = the_form.elements[i];
  105. if (elem.name && (/^req_/.test(elem.name)))
  106. {
  107. if (!elem.value && elem.type && (/^(?:text(?:area)?|password|file)$/i.test(elem.type)))
  108. {
  109. alert('"' + element_names[elem.name] + '" <?php echo $lang_common['required field'] ?>');
  110. elem.focus();
  111. return false;
  112. }
  113. }
  114. }
  115. }
  116. return true
  117. }
  118. /* ]]> */
  119. </script>
  120. <?php
  121. }
  122. // JavaScript tricks for IE6 and older
  123. echo '<!--[if lte IE 6]><script type="text/javascript" src="style/imports/minmax.js"></script><![endif]-->'."\n";
  124. // New PMS
  125. require PUN_ROOT.'include/pms_new/pmsnheader.php';
  126. if (!isset($page_head))
  127. $page_head = array();
  128. $page_head['top'] = '<link rel="top" href="index.php" title="'.$lang_common['Forum index'].'" />';
  129. // New PMS
  130. require PUN_ROOT.'include/pms_new/pmsnheader.php';
  131. echo implode("\n", $page_head)."\n";
  132. $tpl_temp = trim(ob_get_contents());
  133. $tpl_main = str_replace('<pun_head>', $tpl_temp, $tpl_main);
  134. ob_end_clean();
  135. // END SUBST - <pun_head>
  136. // START SUBST - <body>
  137. if (isset($focus_element))
  138. {
  139. $tpl_main = str_replace('<body onload="', '<body onload="document.getElementById(\''.$focus_element[0].'\').elements[\''.$focus_element[1].'\'].focus();', $tpl_main);
  140. $tpl_main = str_replace('<body>', '<body onload="document.getElementById(\''.$focus_element[0].'\').elements[\''.$focus_element[1].'\'].focus()">', $tpl_main);
  141. }
  142. // END SUBST - <body>
  143. // START SUBST - <pun_page>
  144. $tpl_main = str_replace('<pun_page>', htmlspecialchars(basename($_SERVER['PHP_SELF'], '.php')), $tpl_main);
  145. // END SUBST - <pun_page>
  146. //START SUBST - <pun_banner> (EvE-BB)
  147. $rep = "";
  148. if ($pun_config['o_eve_use_banner'] == '1') {
  149. //$rep = '<img src="'.$pun_config['o_eve_banner_dir'].'/'.$pun_config['o_eve_banner'].'" height="150" width="1000"/>';
  150. $rep .= "style=\"background-image:url('".get_base_url().'/'.$pun_config['o_eve_banner_dir']."/".$pun_config['o_eve_banner']."'); height: ".$pun_config['o_eve_banner_height']."px; background-repeat: no-repeat; background-position: top center;\"";
  151. } //End if.
  152. $tpl_main = str_replace('<pun_banner>', $rep, $tpl_main);
  153. //END SUBST - <pun_banner> (EvE-BB)
  154. // START SUBST - <pun_title>
  155. $rep = "";
  156. if ($pun_config['o_eve_banner_text_enable'] == '1') {
  157. $rep = '<h1><a href="index.php">'.pun_htmlspecialchars($pun_config['o_board_title']).'</a></h1>';
  158. } //End if.
  159. $tpl_main = str_replace('<pun_title>', $rep, $tpl_main);
  160. // END SUBST - <pun_title>
  161. // START SUBST - <pun_desc>
  162. $rep = "";
  163. if ($pun_config['o_eve_banner_text_enable'] == '1') {
  164. $rep = '<div id="brddesc">'.$pun_config['o_board_desc'].'</div>';
  165. } //End if.
  166. $tpl_main = str_replace('<pun_desc>', $rep, $tpl_main);
  167. // END SUBST - <pun_desc>
  168. // START SUBST - <pun_navlinks>
  169. $links = array();
  170. // Index should always be displayed
  171. $links[] = '<li id="navindex"'.((PUN_ACTIVE_PAGE == 'index') ? ' class="isactive"' : '').'><a href="index.php">'.$lang_common['Index'].'</a></li>';
  172. if ($pun_user['g_read_board'] == '1' && $pun_user['g_view_users'] == '1')
  173. $links[] = '<li id="navuserlist"'.((PUN_ACTIVE_PAGE == 'userlist') ? ' class="isactive"' : '').'><a href="userlist.php">'.$lang_common['User list'].'</a></li>';
  174. if ($pun_config['o_rules'] == '1' && (!$pun_user['is_guest'] || $pun_user['g_read_board'] == '1' || $pun_config['o_regs_allow'] == '1'))
  175. $links[] = '<li id="navrules"'.((PUN_ACTIVE_PAGE == 'rules') ? ' class="isactive"' : '').'><a href="misc.php?action=rules">'.$lang_common['Rules'].'</a></li>';
  176. if ($pun_user['g_read_board'] == '1' && $pun_user['g_search'] == '1')
  177. $links[] = '<li id="navsearch"'.((PUN_ACTIVE_PAGE == 'search') ? ' class="isactive"' : '').'><a href="search.php">'.$lang_common['Search'].'</a></li>';
  178. if ($pun_user['is_guest'])
  179. {
  180. $links[] = '<li id="navregister"'.((PUN_ACTIVE_PAGE == 'register') ? ' class="isactive"' : '').'><a href="register.php">'.$lang_common['Register'].'</a></li>';
  181. $links[] = '<li id="navlogin"'.((PUN_ACTIVE_PAGE == 'login') ? ' class="isactive"' : '').'><a href="login.php">'.$lang_common['Login'].'</a></li>';
  182. }
  183. else
  184. {
  185. $links[] = '<li id="navprofile"'.((PUN_ACTIVE_PAGE == 'profile') ? ' class="isactive"' : '').'><a href="profile.php?'.($pun_config['o_eve_profile_page'] == '0' ? '' : 'section=characters&amp;').'id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a></li>';
  186. // New PMS
  187. if ($pun_config['o_pms_enabled'] == '1' && ($pun_user['g_pm'] == 1 || $pun_user['messages_new'] > 0))
  188. $links[] = '<li id="navpmsnew"'.(((PUN_ACTIVE_PAGE == 'pms_new') || ($pun_user['messages_new'] > 0)) ? ' class="isactive"' : '').'><a href="pmsnew.php">'.$lang_common['PM'].(($pun_user['messages_new'] > 0) ? ' ('.$pun_user['messages_new'].(empty($pun_config['o_pms_flasher']) ? '' : '&nbsp;<img style="border: 0 none; vertical-align: middle;" src="img/flasher.gif" alt="flasher" />' ).')' : '').'</a></li>';
  189. // New PMS
  190. if ($pun_user['is_admmod'])
  191. $links[] = '<li id="navadmin"'.((PUN_ACTIVE_PAGE == 'admin') ? ' class="isactive"' : '').'><a href="admin_index.php">'.$lang_common['Admin'].'</a></li>';
  192. $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>';
  193. }
  194. // Are there any additional navlinks we should insert into the array before imploding it?
  195. if ($pun_user['g_read_board'] == '1' && $pun_config['o_additional_navlinks'] != '')
  196. {
  197. if (preg_match_all('#([0-9]+)\s*=\s*(.*?)\n#s', $pun_config['o_additional_navlinks']."\n", $extra_links))
  198. {
  199. // Insert any additional links into the $links array (at the correct index)
  200. $num_links = count($extra_links[1]);
  201. for ($i = 0; $i < $num_links; ++$i)
  202. array_splice($links, $extra_links[1][$i], 0, array('<li id="navextra'.($i + 1).'">'.$extra_links[2][$i].'</li>'));
  203. }
  204. }
  205. $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>';
  206. $tpl_main = str_replace('<pun_navlinks>', $tpl_temp, $tpl_main);
  207. // END SUBST - <pun_navlinks>
  208. // START SUBST - <pun_status>
  209. $page_statusinfo = $page_topicsearches = array();
  210. if ($pun_user['is_guest'])
  211. $page_statusinfo = '<p>'.$lang_common['Not logged in'].'</p>';
  212. else
  213. {
  214. $page_statusinfo[] = '<li><span>'.$lang_common['Logged in as'].' <strong>'.($pun_config['o_eve_use_iga'] == '1' ? pun_htmlspecialchars($pun_user['character_name']) : pun_htmlspecialchars($pun_user['username'])).'</strong></span></li>';
  215. $page_statusinfo[] = '<li><span>'.sprintf($lang_common['Last visit'], format_time($pun_user['last_visit'])).'</span></li>';
  216. if ($pun_user['is_admmod'])
  217. {
  218. if ($pun_config['o_report_method'] == '0' || $pun_config['o_report_method'] == '2')
  219. {
  220. $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());
  221. if ($db->result($result_header))
  222. $page_statusinfo[] = '<li class="reportlink"><span><strong><a href="admin_reports.php">'.$lang_common['New reports'].'</a></strong></span></li>';
  223. }
  224. if ($pun_config['o_maintenance'] == '1')
  225. $page_statusinfo[] = '<li class="maintenancelink"><span><strong><a href="admin_options.php#maintenance">'.$lang_common['Maintenance mode enabled'].'</a></strong></span></li>';
  226. }
  227. if ($pun_user['g_read_board'] == '1' && $pun_user['g_search'] == '1')
  228. {
  229. $page_topicsearches[] = '<a href="search.php?action=show_replies" title="'.$lang_common['Show posted topics'].'">'.$lang_common['Posted topics'].'</a>';
  230. $page_topicsearches[] = '<a href="search.php?action=show_new" title="'.$lang_common['Show new posts'].'">'.$lang_common['New posts header'].'</a>';
  231. }
  232. }
  233. // Quick searches
  234. if ($pun_user['g_read_board'] == '1' && $pun_user['g_search'] == '1')
  235. {
  236. $page_topicsearches[] = '<a href="search.php?action=show_recent" title="'.$lang_common['Show active topics'].'">'.$lang_common['Active topics'].'</a>';
  237. $page_topicsearches[] = '<a href="search.php?action=show_unanswered" title="'.$lang_common['Show unanswered topics'].'">'.$lang_common['Unanswered topics'].'</a>';
  238. }
  239. // Generate all that jazz
  240. $tpl_temp = '<div id="brdwelcome" class="inbox">'."\n\t\t\t";
  241. // The status information
  242. if (is_array($page_statusinfo))
  243. {
  244. $tpl_temp .= "\n\t\t\t".'<ul class="conl">';
  245. $tpl_temp .= "\n\t\t\t\t".implode("\n\t\t\t\t", $page_statusinfo);
  246. $tpl_temp .= "\n\t\t\t".'</ul>';
  247. }
  248. else
  249. $tpl_temp .= "\n\t\t\t".$page_statusinfo;
  250. // Generate quicklinks
  251. if (!empty($page_topicsearches))
  252. {
  253. $tpl_temp .= "\n\t\t\t".'<ul class="conr">';
  254. $tpl_temp .= "\n\t\t\t\t".'<li><span>'.$lang_common['Topic searches'].' '.implode(' | ', $page_topicsearches).'</span></li>';
  255. $tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>';
  256. }
  257. $tpl_temp .= "\n\t\t".'</div>';
  258. $tpl_main = str_replace('<pun_status>', $tpl_temp, $tpl_main);
  259. // END SUBST - <pun_status>
  260. // START SUBST - <pun_announcement>
  261. if ($pun_user['g_read_board'] == '1' && $pun_config['o_announcement'] == '1')
  262. {
  263. ob_start();
  264. ?>
  265. <div id="announce" class="block">
  266. <div class="hd"><h2><span><?php echo $lang_common['Announcement'] ?></span></h2></div>
  267. <div class="box">
  268. <div id="announce-block" class="inbox">
  269. <div class="usercontent"><?php echo $pun_config['o_announcement_message'] ?></div>
  270. </div>
  271. </div>
  272. </div>
  273. <?php
  274. $tpl_temp = trim(ob_get_contents());
  275. $tpl_main = str_replace('<pun_announcement>', $tpl_temp, $tpl_main);
  276. ob_end_clean();
  277. }
  278. else
  279. $tpl_main = str_replace('<pun_announcement>', '', $tpl_main);
  280. // END SUBST - <pun_announcement>
  281. // START SUBST - <pun_main>
  282. ob_start();
  283. define('PUN_HEADER', 1);