PageRenderTime 25ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/footer.php

https://gitlab.com/LibreTitan/Panther
PHP | 181 lines | 149 code | 21 blank | 11 comment | 65 complexity | b6173da20c9c908497a7a307aac60aef MD5 | raw file
  1. <?php
  2. /**
  3. * Copyright (C) 2015 Panther (https://www.pantherforum.org)
  4. * based on code by FluxBB copyright (C) 2008-2012 FluxBB
  5. * License: http://www.gnu.org/licenses/gpl.html GPL version 3 or higher
  6. */
  7. // Make sure no one attempts to run this script "directly"
  8. if (!defined('PANTHER'))
  9. exit;
  10. $controls = $links = array();
  11. if (isset($footer_style) && ($footer_style == 'viewforum' || $footer_style == 'viewtopic') && $is_admmod)
  12. {
  13. if ($footer_style == 'viewforum')
  14. $controls[] = array('link' => panther_link($panther_url['moderate_forum_p'], array($forum_id, $p)), 'lang' => $lang_common['Moderate forum']);
  15. else if ($footer_style == 'viewtopic')
  16. {
  17. if ($cur_topic['archived'] != '1')
  18. {
  19. $controls[] = array('link' => panther_link($panther_url['moderate_topic_p'], array($forum_id, $id, $p)), 'lang' => $lang_common['Moderate topic'], 'num_pages' => $num_pages, 'moderate_all' => panther_link($panther_url['moderate_all'], array($forum_id, $id)), 'all' => $lang_common['All']);
  20. $controls[] = array('link' => panther_link($panther_url['move'], array($forum_id, $id, $csrf_token)), 'lang' => $lang_common['Move topic']);
  21. if ($cur_topic['closed'] == '1')
  22. $controls[] = array('link' => panther_link($panther_url['open'], array($forum_id, $id, $csrf_token)), 'lang' => $lang_common['Open topic']);
  23. else
  24. $controls[] = array('link' => panther_link($panther_url['close'], array($forum_id, $id, $csrf_token)), 'lang' => $lang_common['Close topic']);
  25. if ($cur_topic['sticky'] == '1')
  26. $controls[] = array('link' => panther_link($panther_url['unstick'], array($forum_id, $id, $csrf_token)), 'lang' => $lang_common['Unstick topic']);
  27. else
  28. $controls[] = array('link' => panther_link($panther_url['stick'], array($forum_id, $id, $csrf_token)), 'lang' => $lang_common['Stick topic']);
  29. $controls[] = array('link' => panther_link($panther_url['archive'], array($forum_id, $id, $csrf_token)), 'lang' => $lang_common['Archive topic']);
  30. $controls[] = array('link' => panther_link($panther_url['moderate_multi'], array($forum_id, $id, $csrf_token)), 'lang' => $lang_common['multi_moderate topic']);
  31. }
  32. else if ($panther_user['is_admin'])
  33. $controls[] = array('link' => panther_link($panther_url['unarchive'], array($forum_id, $id, $csrf_token)), 'lang' => $lang_common['Unarchive topic']);
  34. }
  35. ($hook = get_extensions('footer_moderator_controls')) ? eval($hook) : null;
  36. }
  37. // Display the "Jump to" drop list
  38. if ($panther_config['o_quickjump'] == '1')
  39. {
  40. ob_start();
  41. // Load cached quick jump
  42. if (file_exists(FORUM_CACHE_DIR.'cache_quickjump_'.$panther_user['g_id'].'.php'))
  43. require FORUM_CACHE_DIR.'cache_quickjump_'.$panther_user['g_id'].'.php';
  44. if (!defined('PANTHER_QJ_LOADED'))
  45. {
  46. if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
  47. require PANTHER_ROOT.'include/cache.php';
  48. generate_quickjump_cache($panther_user['g_id']);
  49. require FORUM_CACHE_DIR.'cache_quickjump_'.$panther_user['g_id'].'.php';
  50. }
  51. $quickjump_tpl = trim(ob_get_contents());
  52. ob_end_clean();
  53. }
  54. else
  55. $quickjump_tpl = '';
  56. $feed = array();
  57. if (isset($footer_style) && $footer_style == 'warnings')
  58. {
  59. $links[] = array('url' => panther_link($panther_url['warnings']), 'lang' => $lang_warnings['Show warning types']);
  60. if ($panther_user['is_admmod'])
  61. $links[] = array('url' => panther_link($panther_url['warnings_recent']), 'lang' => $lang_warnings['Show recent warnings']);
  62. ($hook = get_extensions('footer_warnings')) ? eval($hook) : null;
  63. }
  64. elseif (isset($footer_style) && ($footer_style == 'index' || $footer_style == 'viewforum' || $footer_style == 'viewtopic') && ($panther_config['o_feed_type'] == '1' || $panther_config['o_feed_type'] == '2'))
  65. {
  66. switch ($footer_style)
  67. {
  68. case 'index':
  69. if ($panther_config['o_feed_type'] == '1')
  70. {
  71. $feed = array(
  72. 'type' => 'rss',
  73. 'link' => panther_link($panther_url['index_rss']),
  74. 'lang' => $lang_common['RSS active topics feed']
  75. );
  76. }
  77. else if ($panther_config['o_feed_type'] == '2')
  78. {
  79. $feed = array(
  80. 'type' => 'atom',
  81. 'link' => panther_link($panther_url['index_atom']),
  82. 'lang' => $lang_common['Atom active topics feed']
  83. );
  84. }
  85. break;
  86. case 'viewforum':
  87. if ($panther_config['o_feed_type'] == '1')
  88. {
  89. $feed = array(
  90. 'type' => 'rss',
  91. 'link' => panther_link($panther_url['forum_rss'], array($id)),
  92. 'lang' => $lang_common['RSS forum feed']
  93. );
  94. }
  95. else if ($panther_config['o_feed_type'] == '2')
  96. {
  97. $feed = array(
  98. 'type' => 'atom',
  99. 'link' => panther_link($panther_url['forum_atom'], array($id)),
  100. 'lang' => $lang_common['Atom forum feed']
  101. );
  102. }
  103. break;
  104. case 'viewtopic':
  105. if ($panther_config['o_feed_type'] == '1')
  106. {
  107. $feed = array(
  108. 'type' => 'rss',
  109. 'link' => panther_link($panther_url['topic_rss'], array($id)),
  110. 'lang' => $lang_common['RSS topic feed']
  111. );
  112. }
  113. else if ($panther_config['o_feed_type'] == '2')
  114. {
  115. $feed = array(
  116. 'type' => 'atom',
  117. 'link' => panther_link($panther_url['topic_atom'], array($id)),
  118. 'lang' => $lang_common['Atom topic feed']
  119. );
  120. }
  121. break;
  122. }
  123. ($hook = get_extensions('footer_feedsr')) ? eval($hook) : null;
  124. }
  125. // Display debug info (if enabled/defined)
  126. if ($panther_config['o_debug_mode'] == '1')
  127. {
  128. // Calculate script generation time
  129. $time_diff = sprintf('%.3f', microtime(true) - $panther_start);
  130. $debug_info = sprintf($lang_common['Querytime'], $time_diff, $db->get_num_queries());
  131. if (function_exists('memory_get_usage'))
  132. {
  133. $debug_info .= ' - '.sprintf($lang_common['Memory usage'], file_size(memory_get_usage()));
  134. if (function_exists('memory_get_peak_usage'))
  135. $debug_info .= ' '.sprintf($lang_common['Peak usage'], file_size(memory_get_peak_usage()));
  136. }
  137. }
  138. else
  139. $debug_info = '';
  140. $queries = ($panther_config['o_show_queries'] == '1') ? display_saved_queries() : '';
  141. // End the transaction
  142. $db->end_transaction();
  143. $style_path = (($panther_config['o_style_path'] != 'style') ? $panther_config['o_style_path'] : PANTHER_ROOT.$panther_config['o_style_path']).'/'.$panther_user['style'].'/templates/';
  144. $tpl = (defined('PANTHER_ADMIN_CONSOLE') && (file_exists($style_path.'admin_footer.tpl') || $panther_user['style'] == $panther_config['o_default_style'] && !file_exists($style_path)) ? 'admin_footer.tpl' : 'footer.tpl');
  145. $tpl = load_template($tpl);
  146. echo $tpl->render(
  147. array(
  148. 'footer_style' => isset($footer_style) ? $footer_style : '',
  149. 'controls' => $controls,
  150. 'quickjump' => $quickjump_tpl,
  151. 'lang_common' => $lang_common,
  152. 'links' => $links,
  153. 'panther_config' => $panther_config,
  154. 'feed' => $feed,
  155. 'debug_info' => $debug_info,
  156. 'queries' => $queries,
  157. )
  158. );
  159. ob_flush();
  160. exit;