From 268d936f4673974e46d16d8ddd7edba1422aba9a Mon Sep 17 00:00:00 2001
From: Ludovic Arnaud <ludovic_arnaud@users.sourceforge.net>
Date: Thu, 3 Oct 2002 02:43:41 +0000
Subject: Subforums handling part 2, it almost works. Also added: the "Explain"
 link at the bottom page, can be removed easily before official release if
 necessary.

git-svn-id: file:///svn/phpbb/trunk@2913 89ea8834-ac86-4346-8a33-228a782c2dd0
---
 phpBB/includes/functions.php         | 23 +++++++++++++++++++++++
 phpBB/includes/functions_posting.php |  7 +------
 phpBB/includes/page_tail.php         | 31 ++++++++++++++++---------------
 phpBB/includes/template.php          |  8 +++++++-
 4 files changed, 47 insertions(+), 22 deletions(-)

(limited to 'phpBB/includes')

diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index aa7feba656..9b3d079e31 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -583,6 +583,29 @@ function on_page($num_items, $per_page, $start)
 	return sprintf($lang['Page_of'], floor( $start / $per_page ) + 1, max(ceil( $num_items / $per_page ), 1) );
 }
 
+function format_subforums_list($subforums)
+{
+	if (empty($subforums))
+	{
+		return '';
+	}
+
+	global $phpEx, $SID;
+	foreach ($subforums as $row)
+	{
+		$alist[$row['forum_id']] = $row['forum_name'];
+	}
+	asort($alist);
+
+	$links = array();
+	foreach ($alist as $forum_id => $forum_name)
+	{
+		$links[] = '<a href="viewforum.' . $phpEx . $SID . '&f=' . $forum_id . '">' . htmlspecialchars($forum_name) . '</a>';
+	}
+
+	return implode(', ', $links);
+}
+
 //
 // Obtain list of naughty words and build preg style replacement arrays for use by the
 // calling script, note that the vars are passed as references this just makes it easier
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index efab3f4550..bae5a9674c 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *                            functions_post.php
+ *                           functions_posting.php
  *                            -------------------
  *   begin                : Saturday, Feb 13, 2001
  *   copyright            : (C) 2001 The phpBB Group
@@ -19,11 +19,6 @@
  *
  ***************************************************************************/
 
-if ( !defined('IN_PHPBB') )
-{
-	die('Hacking attempt');
-}
-
 $html_entities_match = array('#&#', '#<#', '#>#');
 $html_entities_replace = array('&amp;', '&lt;', '&gt;');
 
diff --git a/phpBB/includes/page_tail.php b/phpBB/includes/page_tail.php
index a4441ac38a..1c91e48399 100644
--- a/phpBB/includes/page_tail.php
+++ b/phpBB/includes/page_tail.php
@@ -19,21 +19,28 @@
  *
  ***************************************************************************/
 
-if ( !defined('IN_PHPBB') )
-{
-	die('Hacking attempt');
-}
+//
+// Close our DB connection.
+//
+$db->sql_close();
 
 //
 // Output page creation time
 //
-if ( defined('DEBUG') )
+if (defined('DEBUG'))
 {
-	$mtime = microtime();
-	$mtime = explode(' ', $mtime);
-	$totaltime = ( $mtime[1] + $mtime[0] ) - $starttime;
+	$mtime = explode(' ', microtime());
+	$totaltime = $mtime[0] + $mtime[1] - $starttime;
+
+	if (!empty($_REQUEST['explain']))
+	{
+		echo $db->sql_report;
+		echo "<pre><b>Page generated in $totaltime seconds with " . $db->num_queries . " queries,\nspending " . $db->sql_time . ' doing MySQL queries and ' . ($totaltime - $db->sql_time) . ' doing PHP things.</b></pre>';
 
-	$debug_output = sprintf('<br /><br />[ Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' .  ( ( $board_config['gzip_compress'] ) ? 'On' : 'Off' ) . ' | Load : '  . ( ( $session->load ) ? $session->load : 'N/A') . ' ]', $totaltime);
+		exit;
+	}
+
+	$debug_output = sprintf('<br /><br />[ Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' .  ( ( $board_config['gzip_compress'] ) ? 'On' : 'Off' ) . ' | Load : '  . ( ( $session->load ) ? $session->load : 'N/A') . ' | <a href="' . $_SERVER['REQUEST_URI'] . '&explain=1">Explain</a> ]', $totaltime);
 }
 
 $template->assign_vars(array(
@@ -44,11 +51,5 @@ $template->assign_vars(array(
 
 $template->display('body');
 
-//
-// Close our DB connection.
-//
-$db->sql_close();
-
 exit;
-
 ?>
\ No newline at end of file
diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php
index 70d6053517..e8bb63e56b 100644
--- a/phpBB/includes/template.php
+++ b/phpBB/includes/template.php
@@ -171,9 +171,15 @@ class Template {
 	 */
 	function display($handle)
 	{
+		if (!empty($_REQUEST['explain']))
+		{
+			global $db;
+			echo $this->sql_report();
+			return TRUE;
+		}
 		$_str = '';
 
-		if ( !($this->compile_load($_str, $handle, true)) )
+		if (!$this->compile_load($_str, $handle, true))
 		{
 			if ( !$this->loadfile($handle) )
 			{
-- 
cgit v1.2.1