############################################################## 
## MOD Title:		Categories hierarchy - upgrade from v 2.0.4-RC 1 to v 2.0.4-RC 2
## MOD Author:		Ptirhiik < ptirhiik@clanmckeen.com > (Pierre) http://rpgnet.clanmckeen.com
## MOD Description:
##			Upgrade from categories hierarchy v 2.0.4-RC 1 to 2.0.4-RC 2
## MOD Version:		2.0.4-RC 2
## 
## Installation Level:	Easy
## Installation Time:	20 Minutes
## Files To Edit:
##			index.php
##			viewforum.php
##
##			admin/admin_forumauth.php
##			admin/admin_forums.php
##			admin/admin_styles.php
##			admin/admin_ug_auth.php
##			admin/admin_words.php
##
##			includes/auth.php
##			includes/functions.php
##			includes/functions_admin.php
##			includes/functions_categories_hierarchy.php
##			includes/functions_post.php
##			includes/mods_settings/mod_categories_hierarchy.php
##
##			templates/subSilver/admin/forum_admin_body.tpl
##
## Included Files:
##			admin_forums_extend.php
##			def_themes.php
##			def_tree.php
##			def_words.php
##
##			def_themes_def.tpl
##			def_tree_def.tpl
##			def_words_def.tpl
##
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/ 
############################################################## 
## Author Notes: 
##
##	o You have to CHMOD 666 those files if you want to use the cache system :
##
##		includes/def_themes.php
##		includes/def_tree.php
##		includes/def_words.php
##
##
##	o If you don't want to use the cache system, just comment or remove at top 
##	of functions_categories_hierarchy.php the following lines :
##
##		define('CACHE_TREE', true);
##		define('CACHE_WORDS', true);
##		define('CACHE_THEMES', true);
##
##
##	o Although the detailled upgrade of functions_categories_hierarchy is detailled, you may
##	consider simply to copy the file coming with the pack if you didn't modify the v 2.0.4-RC 1
##
##	o if you are using the management + (admin/admin_forums_extend.php), the modification of 
##	admin/admin_forums.php is facultative.
## 
############################################################## 
## MOD History: 
## 
##   2003-11-13 - Version 2.0.4 - RC 2
##      - add a cache system for tables : categories, forums, themes, and words
##	- fix : standard forums admin : icons not saved
##	- fix : extended forums admin : some forums options were showing in categories if topic display order was installed
##	- fix : extended forums admin : sql generated if no use of real subforums was wrong
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
##############################################################
#
#-----[ COPY ]------------------------------------------------
#
copy admin_forums_extend.php to admin/admin_forums_extend.php
copy forum_extend_body.tpl to templates/subSilver/admin/forum_extend_body.tpl
copy forum_extend_edit_body.tpl to templates/subSilver/admin/forum_extend_edit_body.tpl
#
#-----[ COPY ]------------------------------------------------
#
copy def_themes.php to includes/def_themes.php
copy def_tree.php to includes/def_tree.php
copy def_words.php to includes/def_words.php
#
#-----[ COPY ]------------------------------------------------
#
copy def_themes_def.tpl to includes/cache_tpls/def_themes_def.tpl
copy def_tree_def.tpl to includes/cache_tpls/def_tree_def.tpl
copy def_words_def.tpl to includes/cache_tpls/def_words_def.tpl
#
#-----[ OPEN ]------------------------------------------------
#
index.php
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
include_once($phpbb_root_path . 'includes/mods_settings/mod_categories_hierarchy.' . $phpEx);
if (($board_config['display_viewonline'] == 2) || (($viewcat < 0) && ($board_config['display_viewonline'] == 1)))
{
//-- fin mod : categories hierarchy ----------------------------------------------------------------
$total_posts = get_db_stat('postcount');
$total_users = get_db_stat('usercount');
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
// $total_posts = get_db_stat('postcount');
// $total_users = get_db_stat('usercount');
//-- add
include_once($phpbb_root_path . 'includes/mods_settings/mod_categories_hierarchy.' . $phpEx);
if ( ($board_config['display_viewonline'] == 2) || ( ($viewcat < 0) && ($board_config['display_viewonline'] == 1) ) )
{
	if ( empty($board_config['max_posts']) || empty($board_config['max_users']) )
	{
		board_stats();
	}
	$total_posts = $board_config['max_posts'];
	$total_users = $board_config['max_users'];
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
viewforum.php
#
#-----[ FIND ]------------------------------------------------
#
if ( !empty($forum_id) )
{
	$sql = "SELECT *
		FROM " . FORUMS_TABLE . "
		WHERE forum_id = $forum_id";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
	}
}
else
{
	message_die(GENERAL_MESSAGE, 'Forum_not_exist');
}

//
// If the query doesn't return any rows this isn't a valid forum. Inform
// the user.
//
if ( !($forum_row = $db->sql_fetchrow($result)) )
{
	message_die(GENERAL_MESSAGE, 'Forum_not_exist');
}
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- deleted
// if ( !empty($forum_id) )
// {
//	$sql = "SELECT *
//		FROM " . FORUMS_TABLE . "
//		WHERE forum_id = $forum_id";
//	if ( !($result = $db->sql_query($sql)) )
//	{
//		message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
//	}
// }
// else
// {
//	message_die(GENERAL_MESSAGE, 'Forum_not_exist');
// }
//
//
// If the query doesn't return any rows this isn't a valid forum. Inform
// the user.
//
// if ( !($forum_row = $db->sql_fetchrow($result)) )
// {
//	message_die(GENERAL_MESSAGE, 'Forum_not_exist');
// }
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
// handle forum link type
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
// get the forum row
$forum_row = $tree['data'][ $tree['keys'][ POST_FORUM_URL . $forum_id ] ];
if ( empty($forum_row) )
{
	message_die(GENERAL_MESSAGE, 'Forum_not_exist');
}

#
#-----[ FIND ]------------------------------------------------
#
$sql = "SELECT u.user_id, u.username 
	FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u
	WHERE aa.forum_id = $forum_id 
		AND aa.auth_mod = " . TRUE . " 
		AND g.group_single_user = 1
		AND ug.group_id = aa.group_id 
		AND g.group_id = aa.group_id 
		AND u.user_id = ug.user_id 
	GROUP BY u.user_id, u.username  
	ORDER BY u.user_id";
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
}

$moderators = array();
while( $row = $db->sql_fetchrow($result) )
{
	$moderators[] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $row['username'] . '</a>';
}

$sql = "SELECT g.group_id, g.group_name 
	FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g 
	WHERE aa.forum_id = $forum_id
		AND aa.auth_mod = " . TRUE . " 
		AND g.group_single_user = 0
		AND g.group_type <> ". GROUP_HIDDEN ."
		AND ug.group_id = aa.group_id 
		AND g.group_id = aa.group_id 
	GROUP BY g.group_id, g.group_name  
	ORDER BY g.group_id";
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
}

while( $row = $db->sql_fetchrow($result) )
{
	$moderators[] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' . $row['group_name'] . '</a>';
}
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
// $sql = "SELECT u.user_id, u.username 
//	FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u
//	WHERE aa.forum_id = $forum_id 
//		AND aa.auth_mod = " . TRUE . " 
//		AND g.group_single_user = 1
//		AND ug.group_id = aa.group_id 
//		AND g.group_id = aa.group_id 
//		AND u.user_id = ug.user_id 
//	GROUP BY u.user_id, u.username  
//	ORDER BY u.user_id";
// if ( !($result = $db->sql_query($sql)) )
// {
//	message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
// }
//
// $moderators = array();
// while( $row = $db->sql_fetchrow($result) )
// {
//	$moderators[] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $row['username'] . '</a>';
// }
//
// $sql = "SELECT g.group_id, g.group_name 
//	FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g 
//	WHERE aa.forum_id = $forum_id
//		AND aa.auth_mod = " . TRUE . " 
//		AND g.group_single_user = 0
//		AND g.group_type <> ". GROUP_HIDDEN ."
//		AND ug.group_id = aa.group_id 
//		AND g.group_id = aa.group_id 
//	GROUP BY g.group_id, g.group_name  
//	ORDER BY g.group_id";
// if ( !($result = $db->sql_query($sql)) )
// {
//	message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
// }
//
// while( $row = $db->sql_fetchrow($result) )
// {
//	$moderators[] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' . $row['group_name'] . '</a>';
// }
//-- add
// moderators list
$moderators = array();
$idx = $tree['keys'][ POST_FORUM_URL . $forum_id ];
for ( $i = 0; $i < count($data['user_id']); $i++ )
{
	$moderators[] = '<a href="' . append_sid("./profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $tree['mods'][$idx]['user_id'][$i]) . '">' . $tree['mods'][$idx]['username'][$i] . '</a>';
}
for ( $i = 0; $i < count($data['group_id']); $i++ )
{
	$moderators[] = '<a href="' . append_sid("./groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $tree['mods'][$idx]['group_id'][$i]) . '">' . $tree['mods'][$idx]['group_name'][$i] . '</a>';
}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_forumauth.php
#
#-----[ FIND ]------------------------------------------------
#
		$forum_sql = '';
		$adv = 0;
	}
#
#-----[ AFTER, ADD ]------------------------------------------
#

//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	cache_tree(true);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_forums.php
#
#-----[ FIND ]------------------------------------------------
#
	$new_topic_data = array();
	$tracking_topics = array();
	$tracking_forums = array();
	$tracking_all = -1;
	build_tree($cats, $forums, $new_topic_data, $tracking_topic, $tracking_forums, $tracking_all, $parents);
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	cache_tree_level('Root', $parents, $cats, $forums);
#
#-----[ FIND ]------------------------------------------------
#
					message_die(GENERAL_ERROR, "Couldn't insert row in prune table", "", __LINE__, __FILE__, $sql);
				}
			}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			cache_tree(true);
			board_stats();
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			$message = $lang['Forums_updated'] . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

			message_die(GENERAL_MESSAGE, $message);

			break;
			
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- delete
//		case 'addcat':
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			cache_tree(true);
			board_stats();
//-- fin mod : categories hierarchy ----------------------------------------------------------------

#
#-----[ FIND ]------------------------------------------------
#
		case 'createcat':
			// Create a category in the DB
			$icon = isset($HTTP_POST_VARS['icon']) ? trim(stripslashes($HTTP_POST_VARS['icon'])) : '';
#
#-----[ REPLACE WITH ]----------------------------------------
#
		case 'createcat':
			// Create a category in the DB
			$icon = isset($HTTP_POST_VARS['icon']) ? trim($HTTP_POST_VARS['icon']) : '';
#
#-----[ FIND ]------------------------------------------------
#
			$sql = "INSERT INTO " . CATEGORIES_TABLE . " (cat_title, cat_main_type, cat_main, cat_desc, icon, cat_order)
				VALUES ('" . str_replace("\'", "''", $HTTP_POST_VARS['cat_title']) . "', '" . $cat_main_type . "', " . $cat_main . ", '" . str_replace("\'", "''", $HTTP_POST_VARS['cat_desc']) . "', '" . str_replace("\'", "''", $HTTP_POST_VARS['icon']) . "', $next_order)";
#
#-----[ REPLACE WITH ]----------------------------------------
#
			$sql = "INSERT INTO " . CATEGORIES_TABLE . " (cat_title, cat_main_type, cat_main, cat_desc, icon, cat_order)
				VALUES ('" . str_replace("\'", "''", $HTTP_POST_VARS['cat_title']) . "', '" . $cat_main_type . "', " . $cat_main . ", '" . str_replace("\'", "''", $HTTP_POST_VARS['cat_desc']) . "', '" . str_replace("\'", "''", $icon) . "', $next_order)";
#
#-----[ FIND ]------------------------------------------------
#
//-- fin mod : categories hierarchy ----------------------------------------------------------------

			$message = $lang['Forums_updated'] . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

			message_die(GENERAL_MESSAGE, $message);

			break;
			
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
		case 'addcat':
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
			cache_tree(true);
			board_stats();
#
#-----[ FIND ]------------------------------------------------
#
		case 'modcat':
			// Modify a category in the DB
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			$icon = isset($HTTP_POST_VARS['icon']) ? $HTTP_POST_VARS['icon'] : '';
#
#-----[ REPLACE WITH ]----------------------------------------
#
		case 'modcat':
			// Modify a category in the DB
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			$icon = isset($HTTP_POST_VARS['icon']) ? trim($HTTP_POST_VARS['icon']) : '';
#
#-----[ FIND ]------------------------------------------------
#
			$err = admin_check_cat();
			if ( $err ) $message = $lang['Category_config_error_fixed'] . "<br /><br />" . $message;
//-- fin mod : categories hierarchy ----------------------------------------------------------------
			message_die(GENERAL_MESSAGE, $message);

			break;

		case 'deleteforum':
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
			cache_tree(true);
			board_stats();

#
#-----[ FIND ]------------------------------------------------
#
			$message = $lang['Forums_updated'] . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

			message_die(GENERAL_MESSAGE, $message);

			break;
			
		case 'deletecat':
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			cache_tree(true);
			board_stats();
//-- fin mod : categories hierarchy ----------------------------------------------------------------

#
#-----[ FIND ]------------------------------------------------
#
			$err = admin_check_cat();
			if ( $err ) $message = $lang['Category_config_error_fixed'] . "<br /><br />" . $message;
//-- fin mod : categories hierarchy ----------------------------------------------------------------

			message_die(GENERAL_MESSAGE, $message);

			break;

		case 'forum_order':
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
			cache_tree(true);
			board_stats();
#
#-----[ FIND ]------------------------------------------------
#
//-- fin mod : categories hierarchy ----------------------------------------------------------------
			$show_index = TRUE;

			break;
			
		case 'cat_order':
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
			cache_tree(true);
			board_stats();
#
#-----[ FIND ]------------------------------------------------
#
//-- fin mod : categories hierarchy ----------------------------------------------------------------
			$show_index = TRUE;

			break;

		case 'forum_sync':
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
			cache_tree(true);
			board_stats();
#
#-----[ FIND ]------------------------------------------------
#
			// send to template
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
			// title and icon
			$cat_desc = $cat['cat_desc'];
			$cat_desc_trad = get_object_lang(POST_CAT_URL . $cat_id, 'desc');
			if ($cat_desc != $cat_desc_trad)
			{
				$cat_desc = '(' . $cat_desc . ') ' . $cat_desc_trad;
			}
			$cat_icon = empty($cat['icon']) ? '' : '<img src="' . ( isset($images[ $cat['icon'] ]) ? $phpbb_root_path . $images[ $cat['icon'] ] : $cat['icon'] ) . '" border="0" alt="' . $cat['icon'] . '" title="' . $cat['icon'] . '" />';

#
#-----[ FIND ]------------------------------------------------
#
			$template->assign_block_vars('catrow.cathead', array(
				'CAT_ID'			=> $cat_id,
				'CAT_TITLE'			=> $cat_title,
#
#-----[ AFTER, ADD ]------------------------------------------
#
				'CAT_DESCRIPTION'	=> $cat_desc,
				'ICON_IMG'			=> $cat_icon,
#
#-----[ FIND ]------------------------------------------------
#
			for ($k=1; $k <= $level; $k++) $template->assign_block_vars('catrow.cathead.inc', array('ROWSPAN' => $rowspan));

			if ( !empty($cat['cat_desc']) || !empty($cat['icon']) )
			{
				$cat_desc = $cat['cat_desc'];
				$cat_desc_trad = get_object_lang(POST_CAT_URL . $cat_id, 'desc');
				if ($cat_desc != $cat_desc_trad) $cat_desc = '(' . $cat_desc . ') ' . $cat_desc_trad;

				$template->assign_block_vars('catrow', array());
				$template->assign_block_vars('catrow.cattitle', array(
					'CAT_DESCRIPTION'	=> $cat_desc,
					'INC_SPAN_ALL'		=> $max_level - $level+7,
					'ICON_IMG'			=> empty($cat['icon']) ? '' : '<img src="' . ( isset($images[ $cat['icon'] ]) ? $phpbb_root_path . $images[ $cat['icon'] ] : $cat['icon'] ) . '" border="0" alt="' . $cat['icon'] . '" title="' . $cat['icon'] . '" />',
					)
				);
			}
#
#-----[ REPLACE WITH ]----------------------------------------
#
			for ($k=1; $k <= $level; $k++) 
			{
				$template->assign_block_vars('catrow.cathead.inc', array('ROWSPAN' => $rowspan));
			}
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_styles.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			$message = $lang['Theme_installed'] . "<br /><br />" . sprintf($lang['Click_return_styleadmin'], "<a href=\"" . append_sid("admin_styles.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

			message_die(GENERAL_MESSAGE, $message);
		}
		else
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			cache_themes();
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
				$message = $lang['Theme_updated'] . "<br /><br />" . sprintf($lang['Click_return_styleadmin'], "<a href=\"" . append_sid("admin_styles.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

				message_die(GENERAL_MESSAGE, $message);
			}
			else
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
				cache_themes();
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
				$message = $lang['Theme_created'] . "<br /><br />" . sprintf($lang['Click_return_styleadmin'], "<a href=\"" . append_sid("admin_styles.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

				message_die(GENERAL_MESSAGE, $message);
			}
		}
		else
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
				cache_themes();
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			$message = $lang['Theme_info_saved'] . "<br /><br />" . sprintf($lang['Click_return_styleadmin'], "<a href=\"" . append_sid("admin_styles.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

			message_die(GENERAL_MESSAGE, $message);

		}
		else if($HTTP_POST_VARS['send_file'])
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			cache_themes();
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			$message = $lang['Style_removed'] . "<br /><br />" . sprintf($lang['Click_return_styleadmin'], "<a href=\"" . append_sid("admin_styles.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

			message_die(GENERAL_MESSAGE, $message);
		}
		break;
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			cache_themes();
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_ug_auth.php
#
#-----[ FIND ]------------------------------------------------
#
		$message = $lang['Auth_updated'] . '<br /><br />' . sprintf($lang['Click_return_userauth'], '<a href="' . append_sid("admin_ug_auth.$phpEx?mode=$mode") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>');
		message_die(GENERAL_MESSAGE, $message);
	}
	else
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
		cache_tree(true);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
				message_die(GENERAL_ERROR, "Couldn't update user level", "", __LINE__, __FILE__, $sql);
			}
		}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
		cache_tree(true);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_words.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		message_die(GENERAL_MESSAGE, $message);
	}
	else if( $mode == "delete" )
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
		cache_words();
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			$message = $lang['Word_removed'] . "<br /><br />" . sprintf($lang['Click_return_wordadmin'], "<a href=\"" . append_sid("admin_words.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

			message_die(GENERAL_MESSAGE, $message);
		}
		else
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
		cache_words();
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/auth.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
function auth($type, $forum_id, $userdata, $f_access = '')
{
	global $db, $lang;
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	global $tree;

	if ( !empty($tree['data']) )
	{
		$f_access = array();
		if ( !empty($forum_id) )
		{
			$idx = $tree['keys'][ POST_FORUM_URL . $forum_id ];
			$f_access = $tree['data'][$idx];
		}
		else
		{
			for ( $i = 0; $i < count($tree['data']); $i++ )
			{
				if ( $tree['type'][$i] == POST_FORUM_URL )
				{
					$f_access[] = $tree['data'][$i];
				}
			}
		}
	}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/functions.php
#
#-----[ FIND ]------------------------------------------------
#
function setup_style($style)
{
	global $db, $board_config, $template, $images, $phpbb_root_path;
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	global $phpEx, $themes_style;

	if ( defined('CACHE_THEMES') )
	{
		include( $phpbb_root_path . './includes/def_themes.' . $phpEx );
		if ( empty($themes_style) )
		{
			cache_themes();
			@include( $phpbb_root_path . './includes/def_themes.' . $phpEx );
		}
	}
	if ( !empty($themes_style[$style]) )
	{
		$row = $themes_style[$style];
	}
	else
	{
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	$template_path = 'templates/' ;
	$template_name = $row['template_name'] ;
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	if (isset($global_orig_word))
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
	global $phpbb_root_path, $phpEx;
#
#-----[ FIND ]------------------------------------------------
#
//-- fin mod : categories hierarchy ----------------------------------------------------------------

	//
	// Define censored word matches
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
		if ( defined('CACHE_WORDS') )
		{
			@include($phpbb_root_path . './includes/def_words.' . $phpEx);
			if ( !isset($word_replacement) )
			{
				cache_words();
				@include($phpbb_root_path . './includes/def_words.' . $phpEx);
			}
		}
		if ( isset($word_replacement) )
		{
			$orig_word = array();
			$replacement_word = array();
			@reset($word_replacement);
			while ( list($word, $replacement) = @each($word_replacement) )
			{
				$orig_word[] = '#\b(' . str_replace('\*', '\w*?', phpbb_preg_quote(stripslashes($word), '#')) . ')\b#i';
				$replacement_word[] = $replacement;
			}
		}
		else
		{
#
#-----[ FIND ]------------------------------------------------
#
		while ( $row = $db->sql_fetchrow($result) );
	}
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
#
#-----[ AFTER, ADD ]------------------------------------------
#
		}
#
#-----[ OPEN ]------------------------------------------------
#
includes/functions_admin.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	return true;
}

?>
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	global $board_config;
	board_stats();
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/functions_categories_hierarchy.php
#
#-----[ FIND ]------------------------------------------------
#
 *	Version			: 1.0.1 - 10/11/2003
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
 *	Version			: 1.0.2 - 12/11/2003
#
#-----[ FIND ]------------------------------------------------
#
	die("Hacking attempt");
}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//--------------------------------------------------------------------------------------------------
//
// CACHE_* : comment these ones if you doesn't want to use the caches
// --------
//--------------------------------------------------------------------------------------------------
define('CACHE_TREE', true);
define('CACHE_WORDS', true);
define('CACHE_THEMES', true);
#
#-----[ FIND ]------------------------------------------------
#
$nav_separator = "&nbsp;->&nbsp;";
#
#-----[ AFTER, ADD ]------------------------------------------
#

//--------------------------------------------------------------------------------------------------
//
// board_stats : update the board stats (topics, posts and users)
// -----------
//--------------------------------------------------------------------------------------------------
function board_stats()
{
	global $db, $board_config;

	// max users
	$sql = "SELECT COUNT(user_id) AS user_total FROM " . USERS_TABLE . " WHERE user_id > 0";
	if ( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Couldn\'t access users table', '', __LINE__, __FILE__, $sql);
	}
	$row = $db->sql_fetchrow($result);
	$max_users = intval( $row['user_total'] );

	// update
	if ( $board_config['max_users'] != $max_users )
	{
		$board_config['max_users'] = $max_users;
		$sql = "UPDATE " . CONFIG_TABLE . " 
					SET config_value = " . $board_config['max_users'] . " 
					WHERE config_name = 'max_users'";
		if ( !$db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, 'Couldn\'t update config table', '', __LINE__, __FILE__, $sql);
		}
	}

	// topics and posts
	$sql = "SELECT SUM(forum_topics) AS topic_total, SUM(forum_posts) AS post_total FROM " . FORUMS_TABLE;
	if ( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Couldn\'t access forums table', '', __LINE__, __FILE__, $sql);
	}
	$row = $db->sql_fetchrow($result);
	$max_topics = intval( $row['topic_total'] );
	$max_posts = intval( $row['post_total'] );

	// update
	if ( $board_config['max_topics'] != $max_topics )
	{
		$board_config['max_topics'] = $max_topics;
		$sql = "UPDATE " . CONFIG_TABLE . " 
					SET config_value = " . $board_config['max_topics'] . " 
					WHERE config_name = 'max_topics'";
		if ( !$db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, 'Couldn\'t update config table', '', __LINE__, __FILE__, $sql);
		}
	}
	if ( $board_config['max_posts'] != $max_posts )
	{
		$board_config['max_posts'] = $max_posts;
		$sql = "UPDATE " . CONFIG_TABLE . " 
					SET config_value = " . $board_config['max_posts'] . " 
					WHERE config_name = 'max_posts'";
		if ( !$db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, 'Couldn\'t update config table', '', __LINE__, __FILE__, $sql);
		}
	}
}
#
#-----[ FIND ]------------------------------------------------
#
//--------------------------------------------------------------------------------------------------
//
// build_tree() : fill each level of the hierarchy tree recursivly : use read_tree() as entry point
//
//--------------------------------------------------------------------------------------------------
function build_tree(&$cats, &$forums, &$new_topic_data, &$tracking_topics, &$tracking_forums, &$tracking_all, &$parents, $level=-1, $main='Root')
{
	global $db;
	global $tree;

	$tree_level = array();

	// get the forums of the level
	for ($i=0; $i < count($parents[POST_FORUM_URL][$main]); $i++)
	{
		$idx = $parents[POST_FORUM_URL][$main][$i];
		$tree_level['type'][]	= POST_FORUM_URL;
		$tree_level['id'][]		= $forums[$idx]['forum_id'];
		$tree_level['sort'][]	= $forums[$idx]['forum_order'];
		$tree_level['data'][]	= $forums[$idx];
	}
	// add the categories of this level
	for ($i=0; $i < count($parents[POST_CAT_URL][$main]); $i++)
	{
		$idx = $parents[POST_CAT_URL][$main][$i];
		$tree_level['type'][]	= POST_CAT_URL;
		$tree_level['id'][]		= $cats[$idx]['cat_id'];
		$tree_level['sort'][]	= $cats[$idx]['cat_order'];
		$tree_level['data'][]	= $cats[$idx];
	}

	// sort both
	if (!empty($tree_level['data'])) array_multisort($tree_level['sort'], $tree_level['type'], $tree_level['id'], $tree_level['data']);

	// add the tree_level to the tree
	$level++;
	$order = 0;
	for ($i=0; $i < count($tree_level['data']); $i++)
	{
		$this = count($tree['data']);
		$key = $tree_level['type'][$i] . $tree_level['id'][$i];
		$order = $order + 10;
		$tree['keys'][$key] = $this;
		$tree['main'][]		= $main;
		$tree['type'][]		= $tree_level['type'][$i];
		$tree['id'][]		= $tree_level['id'][$i];
		$tree['data'][]		= $tree_level['data'][$i];

		$tree['sub'][$main][] = $key;

		// cookies only set on forums
		$unread_topics = false;
		if ($tree['type'][$this] == POST_FORUM_URL)
		{
			$forum_id = $tree['id'][$this];
			if (!empty($new_topic_data[$forum_id]) )
			{
				$forum_last_post_time = 0;
				while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) )
				{
					if ( empty($tracking_topics[$check_topic_id]) )
					{
						$unread_topics = true;
						$forum_last_post_time = max($check_post_time, $forum_last_post_time);
					}
					else
					{
						if ( $tracking_topics[$check_topic_id] < $check_post_time )
						{
							$unread_topics = true;
							$forum_last_post_time = max($check_post_time, $forum_last_post_time);
						}
					}
				} //  end while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) )
				if ( !empty($tracking_forums[$forum_id]) )
				{
					if ( $tracking_forums[$forum_id] > $forum_last_post_time )
					{
						$unread_topics = false;
					}
				}
				if ( $tracking_all > $forum_last_post_time )
				{
					$unread_topics = false;
				}
			} //  if (!empty($new_topic_data[$forum_id]) )
		}
		$tree['unread_topics'][$this] = $unread_topics;

		// add sub levels
		build_tree($cats, $forums, $new_topic_data, $tracking_topics, $tracking_forums, $tracking_all, $parents, $level, $tree_level['type'][$i] . $tree_level['id'][$i]);
	}

	return;
}
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//--------------------------------------------------------------------------------------------------
//
// cache_words() : buid the cache words file
//
//--------------------------------------------------------------------------------------------------
function cache_words()
{
	global $tree, $phpbb_root_path, $phpEx, $userdata, $db;

	if ( !defined('CACHE_WORDS') )
	{
		return;
	}

	// template
	include_once($phpbb_root_path . 'includes/template.' . $phpEx);
	$template = new Template($phpbb_root_path);

	$template->set_filenames(array(
		'def_words' => 'includes/cache_tpls/def_words_def.tpl')
	);

	$template->assign_vars(array(
		'TIME'		=> date('Y-m-d H:i:s', time()) . ' (GMT)',
		'USERNAME'	=> $userdata['username'],
		)
	);

	$sql = "SELECT word, replacement FROM  " . WORDS_TABLE;
	if( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not get censored words from database', '', __LINE__, __FILE__, $sql);
	}
	while ( $row = $db->sql_fetchrow($result) )
	{
		$template->assign_block_vars('word', array(
			'WORD'			=> str_replace( "'", "\'", $row['word']),
			'REPLACEMENT'	=> str_replace( "'", "\'", $row['replacement']),
			)
		);
	}

	// transfert to a var
	$template->assign_var_from_handle('def_words', 'def_words');
	$res = "<?php\n" . $template->_tpldata['.'][0]['def_words'] . "\n?>";

	// output to file
	$fname = $phpbb_root_path . './includes/def_words.' . $phpEx;
	@chmod($fname, 0666);
	$handle = @fopen($fname, 'w');
	@fwrite($handle, $res);
	@fclose($handle);
}

//--------------------------------------------------------------------------------------------------
//
// cache_themes() : buid the cache theme file
//
//--------------------------------------------------------------------------------------------------
function cache_themes()
{
	global $tree, $phpbb_root_path, $phpEx, $userdata, $db;

	if ( !defined('CACHE_THEMES') )
	{
		return;
	}

	// template
	include_once($phpbb_root_path . 'includes/template.' . $phpEx);
	$template = new Template($phpbb_root_path);

	$template->set_filenames(array(
		'def_themes' => 'includes/cache_tpls/def_themes_def.tpl')
	);

	$template->assign_vars(array(
		'TIME'		=> date('Y-m-d H:i:s', time()) . ' (GMT)',
		'USERNAME'	=> $userdata['username'],
		)
	);

	$sql = "SELECT * FROM  " . THEMES_TABLE;
	if( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not read themes table', '', __LINE__, __FILE__, $sql);
	}
	while ( $row = $db->sql_fetchrow($result) )
	{
		$id = $row['themes_id'];
		$cells = array();
		@reset($row);
		while ( list($key, $value) = @each($row) )
		{
			$nkey = intval($key);
			if ( $key != "$nkey" )
			{
				$cells[] = sprintf( "'%s' => '%s'", str_replace("'", "\'", $key), str_replace("'", "\'", $value));
			}
		}
		$s_cells = empty($cells) ? '' : implode(', ', $cells);

		$template->assign_block_vars('theme', array(
			'ID'		=> $id,
			'CELLS'		=> $s_cells,
			)
		);
	}

	// transfert to a var
	$template->assign_var_from_handle('def_themes', 'def_themes');
	$res = "<?php\n" . $template->_tpldata['.'][0]['def_themes'] . "\n?>";

	// output to file
	$fname = $phpbb_root_path . './includes/def_themes.' . $phpEx;
	@chmod($fname, 0666);
	$handle = @fopen($fname, 'w');
	@fwrite($handle, $res);
	@fclose($handle);
}

//--------------------------------------------------------------------------------------------------
//
// cache_tree() : buid the cache tree file
//
//--------------------------------------------------------------------------------------------------
function cache_tree_output()
{
	global $tree, $phpbb_root_path, $phpEx, $userdata;

	if ( !defined('CACHE_TREE') )
	{
		return;
	}

	// template
	include_once($phpbb_root_path . 'includes/template.' . $phpEx);
	$template = new Template($phpbb_root_path);

	$template->set_filenames(array(
		'def_tree' => 'includes/cache_tpls/def_tree_def.tpl')
	);

	$template->assign_vars(array(
		'TIME'		=> date('Y-m-d H:i:s', time()) . ' (GMT)',
		'USERNAME'	=> $userdata['username'],
		)
	);

	// keys
	$cells = array();
	@reset($tree['keys']);
	while ( list($key, $value) = @each($tree['keys']) )
	{
		$cells[] = sprintf("'%s' => %s", $key, $value);
	}
	$keys = @implode(', ', $cells);

	// types
	$cells = array();
	for ( $i = 0; $i < count($tree['type']); $i++ )
	{
		$cells[] = sprintf("'%s'", $tree['type'][$i]);
	}
	$types = @implode(', ', $cells);

	// ids
	$cells = array();
	for ( $i = 0; $i < count($tree['id']); $i++ )
	{
		$cells[] = sprintf("'%s'", $tree['id'][$i]);
	}
	$ids = @implode(', ', $cells);

	// mains
	$cells = array();
	for ( $i = 0; $i < count($tree['main']); $i++ )
	{
		$cells[] = sprintf("'%s'", $tree['main'][$i]);
	}
	$mains = @implode(', ', $cells);

	$template->assign_vars(array(
		'KEYS'	=> $keys,
		'TYPES'	=> $types,
		'IDS'	=> $ids,
		'MAINS'	=> $mains,
		)
	);

	// data
	for ($i = 0; $i < count($tree['data']); $i++ )
	{
		$template->assign_block_vars('data', array());

		@reset($tree['data'][$i]);
		while ( list($key, $value) = @each($tree['data'][$i]) )
		{
			$nkey = intval($key);
			if ( $key != "$nkey" )
			{
				$template->assign_block_vars('data.field', array(
					'FIELD_NAME'	=> $key,
					'FIELD_VALUE'	=> str_replace("\n", "' . \"\\n\" . '", str_replace("\r\n", "' . \"\\r\\n\" . '", str_replace("'", "\'", $value))),
					)
				);
			}
		}
	}

	// subs
	@reset($tree['sub']);
	while ( list($main, $data) = @each($tree['sub']) )
	{
		$cells = array();
		for ( $i = 0; $i < count($data); $i++ )
		{
			$cells[] = sprintf("'%s'", $data[$i]);
		}
		$subs = @implode(', ', $cells);
		$template->assign_block_vars('sub', array(
			'THIS'	=> $main,
			'SUBS'	=> $subs,
			)
		);
	}

	// moderators
	@reset($tree['mods']);
	while ( list($idx, $data) = @each($tree['mods']) )
	{
		$s_user_ids = empty($data['user_id']) ? '' : implode(', ', $data['user_id']);
		$s_group_ids = empty($data['group_id']) ? '' : implode(', ', $data['group_id']);
		$s_usernames = '';
		for ( $j = 0; $j < count($data['username']); $j++ )
		{
			$s_usernames .= ( empty($s_usernames) ? '' : ', ' ) . sprintf("'%s'", str_replace("'", "\'", $data['username'][$j]));
		}
		$s_group_names = '';
		for ( $j = 0; $j < count($data['group_name']); $j++ )
		{
			$s_group_names .= ( empty($s_group_names) ? '' : ', ' ) . sprintf("'%s'", str_replace("'", "\'", $data['group_name'][$j]));
		}
		$template->assign_block_vars('mods', array(
			'IDX'			=> $idx,
			'USER_IDS'		=> $s_user_ids,
			'USERNAMES'		=> $s_usernames,
			'GROUP_IDS'		=> $s_group_ids,
			'GROUP_NAMES'	=> $s_group_names,
			)
		);
	}

	// transfert to a var
	$template->assign_var_from_handle('def_tree', 'def_tree');
	$res = "<?php\n" . $template->_tpldata['.'][0]['def_tree'] . "\n?>";

	// output to file
	$fname = $phpbb_root_path . './includes/def_tree.' . $phpEx;
	@chmod($fname, 0666);
	$handle = @fopen($fname, 'w');
	@fwrite($handle, $res);
	@fclose($handle);
}

function cache_tree_level($main, &$parents, &$cats, &$forums)
{
	global $tree;

	// read all parents
	$tree_level = array();

	// get the forums of the level
	for ($i=0; $i < count($parents[POST_FORUM_URL][$main]); $i++)
	{
		$idx = $parents[POST_FORUM_URL][$main][$i];
		$tree_level['type'][]	= POST_FORUM_URL;
		$tree_level['id'][]		= $forums[$idx]['forum_id'];
		$tree_level['sort'][]	= $forums[$idx]['forum_order'];
		$tree_level['data'][]	= $forums[$idx];
	}

	// add the categories of this level
	for ($i=0; $i < count($parents[POST_CAT_URL][$main]); $i++)
	{
		$idx = $parents[POST_CAT_URL][$main][$i];
		$tree_level['type'][]	= POST_CAT_URL;
		$tree_level['id'][]		= $cats[$idx]['cat_id'];
		$tree_level['sort'][]	= $cats[$idx]['cat_order'];
		$tree_level['data'][]	= $cats[$idx];
	}

	// sort the level
	@array_multisort($tree_level['sort'], $tree_level['type'], $tree_level['id'], $tree_level['data']);

	// add the tree_level to the tree
	$order = 0;
	for ($i=0; $i < count($tree_level['data']); $i++)
	{
		$this = count($tree['data']);
		$key = $tree_level['type'][$i] . $tree_level['id'][$i];
		$order = $order + 10;
		$tree['keys'][$key] = $this;
		$tree['main'][]		= $main;
		$tree['type'][]		= $tree_level['type'][$i];
		$tree['id'][]		= $tree_level['id'][$i];
		$tree['data'][]		= $tree_level['data'][$i];
		$tree['sub'][$main][] = $key;

		cache_tree_level($key, $parents, $cats, $forums);
	}
}

function cache_tree($write=false)
{
	global $db, $tree, $userdata, $phpbb_root_path, $phpEx, $board_config;

	// extended auth compliancy
	$sql_extend_auth = '';
	if ( defined('EXTEND_AUTH_INSTALLED') )
	{
		$sql_extend_auth = ' AND aa.auth_type = ' . POST_FORUM_URL;
	}

	$parents = array();

	// read categories
	$cats = array();
	$sql = "SELECT * FROM " . CATEGORIES_TABLE . " ORDER BY cat_order, cat_id";
	if ( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Couldn\'t access list of Categories', '', __LINE__, __FILE__, $sql);
	}
	while ($row = $db->sql_fetchrow($result))
	{
		if ($row['cat_main'] == $row['cat_id'])
		{
			$row['cat_main'] = 0;
		}
		if ( empty($row['cat_main_type']) )
		{
			$row['cat_main_type'] = POST_CAT_URL;
			$row['cat_order'] = $row['cat_order'] + 9000000;
		}
		$row['main'] = ($row['cat_main'] == 0) ? 'Root' : $row['cat_main_type'] . $row['cat_main'];
		$idx = count($cats);
		$cats[$idx] = $row;
		$parents[POST_CAT_URL][ $row['main'] ][] = $idx;
	}

	// read forums
	$sql = "SELECT * FROM " . FORUMS_TABLE . " ORDER BY forum_order, forum_id";
	if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't access list of Forums", "", __LINE__, __FILE__, $sql);
	while ($row = $db->sql_fetchrow($result))
	{
		$main_type = (empty($row['main_type'])) ? POST_CAT_URL : $row['main_type'];
		$row['main'] = ($row['cat_id'] == 0) ? 'Root' : $main_type . $row['cat_id'];
		$idx = count($forums);
		$forums[$idx] = $row;
		$parents[POST_FORUM_URL][ $row['main'] ][] = $idx;
	}

	// build the tree
	$tree = array();
	cache_tree_level('Root', $parents, $cats, $forums);

	//
	// Obtain list of moderators of each forum
	// First users, then groups ... broken into two queries
	//
	$sql = "SELECT aa.forum_id, u.user_id, u.username 
			FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u
			WHERE aa.auth_mod = " . TRUE . " 
				AND g.group_single_user = 1 
				AND ug.group_id = aa.group_id 
				AND g.group_id = aa.group_id 
				AND u.user_id = ug.user_id 
				$sql_extend_auth
			GROUP BY u.user_id, u.username, aa.forum_id 
			ORDER BY aa.forum_id, u.user_id";
	if ( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
	}
	while( $row = $db->sql_fetchrow($result) )
	{
		$idx = $tree['keys'][ POST_FORUM_URL . $row['forum_id'] ];
		$tree['mods'][$idx]['user_id'][] = $row['user_id'];
		$tree['mods'][$idx]['username'][] = $row['username'];
	}

	$sql = "SELECT aa.forum_id, g.group_id, g.group_name 
			FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g 
			WHERE aa.auth_mod = " . TRUE . " 
				AND g.group_single_user = 0 
				AND g.group_type <> " . GROUP_HIDDEN . "
				AND ug.group_id = aa.group_id 
				AND g.group_id = aa.group_id 
				$sql_extend_auth
			GROUP BY g.group_id, g.group_name, aa.forum_id 
			ORDER BY aa.forum_id, g.group_id";
	if ( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
	}
	while( $row = $db->sql_fetchrow($result) )
	{
		$idx = $tree['keys'][ POST_FORUM_URL . $row['forum_id'] ];
		$tree['mods'][$idx]['group_id'][] = $row['group_id'];
		$tree['mods'][$idx]['group_name'][] = $row['group_name'];
	}

	if ($write)
	{
		cache_tree_output();
	}
}
#
#-----[ FIND ]------------------------------------------------
#
//--------------------------------------------------------------------------------------------------
//
// read_tree() : read the tables and fill the hierarchical tree
//
//--------------------------------------------------------------------------------------------------
function read_tree()
{
	global $db, $userdata, $board_config, $HTTP_COOKIE_VARS;
	global $tree;

	// get censored words
	$orig_word = array();
	$remplacement_word = array();
	obtain_word_list($orig_word, $replacement_word);

	// mains
	$parents = array();

	// read cats
	$cats = array();
	$sql = "SELECT * FROM " . CATEGORIES_TABLE . " ORDER BY cat_order, cat_id";
	if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't access list of Categories", "", __LINE__, __FILE__, $sql);
	while ($row = $db->sql_fetchrow($result))
	{
		if ($row['cat_main'] == $row['cat_id']) $row['cat_main'] = 0;
		if (empty($row['cat_main_type'])) 
		{
			$row['cat_main_type'] = POST_CAT_URL;
			$row['cat_order'] = $row['cat_order'] + 9000000;
		}
		$row['main'] = ($row['cat_main'] == 0) ? 'Root' : $row['cat_main_type'] . $row['cat_main'];
		$idx = count($cats);
		$cats[$idx] = $row;
		$parents[POST_CAT_URL][ $row['main'] ][] = $idx;
	}

	// read forums
	$forums = array();
	$sql = "SELECT 
					f.*, 
					p.post_time, p.post_username, 
					u.username, u.user_id, 
					t.topic_last_post_id, t.topic_title 
				FROM ((( " . FORUMS_TABLE . " f 
				LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id ) 
				LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id ) 
				LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_id = p.topic_id AND t.forum_id = f.forum_id)
				ORDER BY f.forum_order, f.forum_id";
	if ( !$result = $db->sql_query($sql) ) message_die(GENERAL_ERROR, "Couldn't access list of Forums", "", __LINE__, __FILE__, $sql);
	while ($row = $db->sql_fetchrow($result))
	{
		$main_type = (empty($row['main_type'])) ? POST_CAT_URL : $row['main_type'];
		$row['main'] = ($row['cat_id'] == 0) ? 'Root' : $main_type . $row['cat_id'];
		if ( count($orig_word) )
		{
			$row['topic_title'] = preg_replace($orig_word, $replacement_word, $row['topic_title']);
		}
		$idx = count($forums);
		$forums[$idx] = $row;
		$parents[POST_FORUM_URL][ $row['main'] ][] = $idx;
	}

	//
	// Obtain a list of topic ids which contain
	// posts made since user last visited
	//
	$new_topic_data = array();
	if ( $userdata['session_logged_in'] )
	{
		$user_lastvisit = $userdata['user_lastvisit'];
		$sql = "SELECT t.forum_id, t.topic_id, p.post_time 
			FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p 
			WHERE p.post_id = t.topic_last_post_id 
				AND p.post_time > $user_lastvisit 
				AND t.topic_moved_id = 0"; 
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not query new topic information', '', __LINE__, __FILE__, $sql);
		}

		while( $topic_data = $db->sql_fetchrow($result) )
		{
			$new_topic_data[$topic_data['forum_id']][$topic_data['topic_id']] = $topic_data['post_time'];
		}
	}

	// read the user cookie
	$tracking_topics	= ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array();
	$tracking_forums	= ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array();
	$tracking_all		= ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) ) ? intval($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) : -1;

	// build the tree
	$tree = array();
	build_tree($cats, $forums, $new_topic_data, $tracking_topics, $tracking_forums, $tracking_all, $parents);

	return;
}
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//--------------------------------------------------------------------------------------------------
//
// read_tree() : read the tables and fill the hierarchical tree
//
//--------------------------------------------------------------------------------------------------
function read_tree($force=false)
{
	global $db, $userdata, $board_config, $HTTP_COOKIE_VARS;
	global $tree;
	global $phpbb_root_path, $phpEx;

	// get censored words
	$orig_word = array();
	$remplacement_word = array();
	obtain_word_list($orig_word, $replacement_word);

	// read the user cookie
	$tracking_topics	= ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array();
	$tracking_forums	= ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array();
	$tracking_all		= ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) ) ? intval($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) : -1;

	// extended auth compliancy
	$sql_extend_auth = '';
	if ( defined('EXTEND_AUTH_INSTALLED') )
	{
		$sql_extend_auth = ' AND aa.auth_type = ' . POST_FORUM_URL;
	}

	// try the cache
	$use_cache_file = false;
	if ( defined('CACHE_TREE') )
	{
		$cache_file = $phpbb_root_path . 'includes/def_tree.' . $phpEx;
		@include($cache_file);
		if ( empty($tree) || $force)
		{
			cache_tree(true);
			@include($cache_file);
		}
		if ( !empty($tree) )
		{
			$use_cache_file = true;
		}
	}
	else
	{
		cache_tree();
	}

	// read the last post
	$sql = "SELECT forum_id, forum_last_post_id FROM " . FORUMS_TABLE;
	if ( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Couldn\'t access list of last posts from forums', '', __LINE__, __FILE__, $sql);
	}
	$s_last_posts = '';
	$last_posts = array();
	while ( $row = $db->sql_fetchrow($result) )
	{
		if ( !empty($row['forum_last_post_id']) )
		{
			$last_posts[ $row['forum_last_post_id'] ] = $row['forum_id'];
			$s_last_posts .= ( empty($s_last_posts) ? '' : ', ' ) . $row['forum_last_post_id'];
		}
	}
	$sql_last_posts = empty($s_last_posts) ? '' : " OR p.post_id IN ($s_last_posts)";

	// read the last or unread posts
	$user_lastvisit = $userdata['session_logged_in'] ? $userdata['user_lastvisit'] : 99999999999;
	$sql = "SELECT p.forum_id, p.topic_id, p.post_time, p.post_username, u.username, u.user_id, t.topic_last_post_id, t.topic_title
				FROM ((" . POSTS_TABLE . " p
					LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_id = p.topic_id AND t.forum_id = p.forum_id AND t.topic_moved_id = 0)
					LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
				WHERE ( p.post_time > $user_lastvisit $sql_last_posts )
					 AND p.post_id = t.topic_last_post_id";
	if ( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Couldn\'t access list of unread posts from forums', '', __LINE__, __FILE__, $sql);
	}
	$new_topic_data = array();
	while ($row = $db->sql_fetchrow($result))
	{
		if ( $row['post_time'] > $user_lastvisit )
		{
			$new_topic_data[ $row['forum_id'] ][ $row['topic_id'] ] = $row['post_time'];
		}
		if ( isset($last_posts[ $row['topic_last_post_id'] ]) )
		{
			// topic title censor
			if ( count($orig_word) )
			{
				$row['topic_title'] = preg_replace($orig_word, $replacement_word, $row['topic_title']);
			}

			// store the added columns
			$idx = $tree['keys'][POST_FORUM_URL . $row['forum_id'] ];
			@reset($row);
			while ( list($key, $value) = @each($row) )
			{
				$nkey = intval($key);
				if ( $key != "$nkey" )
				{
					$tree['data'][$idx][$key] = $row[$key];
				}
			}
		}
	}

	// set the unread flag
	$tree['unread_topics'] = array();
	for ($i=0; $i < count($tree['data']); $i++)
	{
		if ( $tree['type'][$i] == POST_FORUM_URL )
		{
			// get the last post time per forums
			$forum_id = $tree['id'][$i];
			$unread_topics = false;
			if ( !empty($new_topic_data[$forum_id]) )
			{
				$forum_last_post_time = 0;
				@reset($new_topic_data[$forum_id]);
				while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) )
				{
					if ( empty($tracking_topics[$check_topic_id]) )
					{
						$unread_topics = true;
						$forum_last_post_time = max($check_post_time, $forum_last_post_time);
					}
					else
					{
						if ( $tracking_topics[$check_topic_id] < $check_post_time )
						{
							$unread_topics = true;
							$forum_last_post_time = max($check_post_time, $forum_last_post_time);
						}
					}
				}

				// is there a cookie for this forum ?
				if ( !empty($tracking_forums[$forum_id]) )
				{
					if ( $tracking_forums[$forum_id] > $forum_last_post_time )
					{
						$unread_topics = false;
					}
				}

				// is there a cookie for all forums ?
				if ( $tracking_all > $forum_last_post_time )
				{
					$unread_topics = false;
				}
			}

			// store the result
			$tree['unread_topics'][$i] = $unread_topics;
		}
	}

	return;
}
#
#-----[ FIND ]------------------------------------------------
#
//--------------------------------------------------------------------------------------------------
//
// display_index() : display the index using the tpl var {BOARD_INDEX}, return true if the index is not empty
//
//--------------------------------------------------------------------------------------------------
function display_index($cur='Root')
{
	global $board_config, $template, $userdata, $lang, $db, $nav_links, $phpEx;
	global $images, $nav_separator, $nav_cat_desc;

	$template->set_filenames(array(
		'index' => 'index_box.tpl')
	);

	// extended auth compliancy
	$sql_extend_auth = '';
	if ( defined('EXTEND_AUTH_INSTALLED') )
	{
		$sql_extend_auth = ' AND aa.auth_type = ' . POST_FORUM_URL;
	}

	//
	// Obtain list of moderators of each forum
	// First users, then groups ... broken into two queries
	//
	$sql = "SELECT aa.forum_id, u.user_id, u.username 
		FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u
		WHERE aa.auth_mod = " . TRUE . " 
			AND g.group_single_user = 1 
			AND ug.group_id = aa.group_id 
			AND g.group_id = aa.group_id 
			AND u.user_id = ug.user_id 
			$sql_extend_auth
		GROUP BY u.user_id, u.username, aa.forum_id 
		ORDER BY aa.forum_id, u.user_id";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
	}

	$forum_moderators = array();
	while( $row = $db->sql_fetchrow($result) )
	{
		$forum_moderators[$row['forum_id']][] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $row['username'] . '</a>';
	}

	$sql = "SELECT aa.forum_id, g.group_id, g.group_name 
		FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g 
		WHERE aa.auth_mod = " . TRUE . " 
			AND g.group_single_user = 0 
			AND g.group_type <> " . GROUP_HIDDEN . "
			AND ug.group_id = aa.group_id 
			AND g.group_id = aa.group_id 
			$sql_extend_auth
		GROUP BY g.group_id, g.group_name, aa.forum_id 
		ORDER BY aa.forum_id, g.group_id";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
	}

	while( $row = $db->sql_fetchrow($result) )
	{
		$forum_moderators[$row['forum_id']][] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' . $row['group_name'] . '</a>';
	}

	// let's dump all of this on the template
	$keys = array();
	$display = build_index($cur, $board_config['split_cat'], $forum_moderators, -1, -1, $keys);

	// constants
	$template->assign_vars(array(
		'L_FORUM' => $lang['Forum'],
		'L_TOPICS' => $lang['Topics'],
		'L_POSTS' => $lang['Posts'],
		'L_LASTPOST' => $lang['Last_Post'],
		)
	);
	$template->assign_vars(array(
		'SPACER'		=> $images['spacer'],
		'NAV_SEPARATOR' => $nav_separator,
		'NAV_CAT_DESC'	=> $nav_cat_desc,
		)
	);
	if ($display) $template->assign_var_from_handle('BOARD_INDEX', 'index');

	return $display;
}
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//--------------------------------------------------------------------------------------------------
//
// display_index() : display the index using the tpl var {BOARD_INDEX}, return true if the index is not empty
//
//--------------------------------------------------------------------------------------------------
function display_index($cur='Root')
{
	global $board_config, $template, $userdata, $lang, $db, $nav_links, $phpEx;
	global $images, $nav_separator, $nav_cat_desc;
	global $tree;

	$template->set_filenames(array(
		'index' => 'index_box.tpl')
	);

	// moderators list
	$forum_moderators = array();
	@reset($tree['mods']);
	while ( list($idx, $data) = @each($tree['mods']) )
	{
		if ( $tree['type'][$idx] == POST_FORUM_URL )
		{
			for ( $i = 0; $i < count($data['user_id']); $i++ )
			{
				$forum_moderators[ $tree['id'][$idx] ][] = '<a href="' . append_sid("./profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $data['user_id'][$i]) . '">' . $data['username'][$i] . '</a>';
			}
			for ( $i = 0; $i < count($data['group_id']); $i++ )
			{
				$forum_moderators[ $tree['id'][$idx] ][] = '<a href="' . append_sid("./groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $data['group_id'][$i]) . '">' . $data['group_name'][$i] . '</a>';
			}
		}
	}

	// let's dump all of this on the template
	$keys = array();
	$display = build_index($cur, $board_config['split_cat'], $forum_moderators, -1, -1, $keys);

	// constants
	$template->assign_vars(array(
		'L_FORUM' => $lang['Forum'],
		'L_TOPICS' => $lang['Topics'],
		'L_POSTS' => $lang['Posts'],
		'L_LASTPOST' => $lang['Last_Post'],
		)
	);
	$template->assign_vars(array(
		'SPACER'		=> $images['spacer'],
		'NAV_SEPARATOR' => $nav_separator,
		'NAV_CAT_DESC'	=> $nav_cat_desc,
		)
	);
	if ($display) $template->assign_var_from_handle('BOARD_INDEX', 'index');

	return $display;
}
#
#-----[ OPEN ]------------------------------------------------
#
includes/functions_post.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	$meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">';
	$message = $lang['Stored'] . '<br /><br />' . sprintf($lang['Click_view_message'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	board_stats();
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	return;
}

//
// Delete a post/poll
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	board_stats();
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	return;
}

//
// Handle user notification on new post
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	board_stats();
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/mods_settings/mod_categories_hierarchy.php
#
#-----[ FIND ]------------------------------------------------
#
 *	mod version		: categories hierarchy v 2.0.2
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
 *	mod version		: categories hierarchy v 2.0.4
#
#-----[ FIND ]------------------------------------------------
#
);

// init config table
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
	'max_posts' => array(
		'lang_key'	=> 'max_posts',
		'type'		=> 'INT',
		'default'	=> '0',
		'hide'		=> true,
		),

	'max_topics' => array(
		'lang_key'	=> 'max_topics',
		'type'		=> 'INT',
		'default'	=> '0',
		'hide'		=> true,
		),

	'max_users' => array(
		'lang_key'	=> 'max_users',
		'type'		=> 'INT',
		'default'	=> '0',
		'hide'		=> true,
		),
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/admin/forum_admin_body.tpl
#
#-----[ FIND ]------------------------------------------------
#
<!-- END cathead -->
<!-- BEGIN cattitle -->
<tr>
	<td class="row3" colspan="{catrow.cattitle.INC_SPAN_ALL}"><span class="gensmall">{catrow.cattitle.ICON_IMG}{catrow.cattitle.CAT_DESCRIPTION}</span></td>
</tr>
<!-- END cattitle -->
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
<tr>
	<!-- BEGIN inc -->
	<td class="row2" width="46"><img src="{SPACER}" width="46" height="0" /></td>
	<!-- END inc -->
	<td class="row3" colspan="{catrow.cathead.INC_SPAN}"><table cellpadding="2" cellspacing="0" border="0" width="100%"><tr><td>{catrow.cathead.ICON_IMG}</td><td width="100%"><span class="gensmall">{catrow.cathead.CAT_DESCRIPTION}</span></td></tr></table></td>
	<td class="row3"><span class="gensmall">&nbsp;</span></td>
	<td class="row3"><span class="gensmall">&nbsp;</span></td>
	<td class="row3"><span class="gensmall">&nbsp;</span></td>
	<td class="row3"><span class="gensmall">&nbsp;</span></td>
</tr>
<!-- END cathead -->
#
#-----[ FIND ]------------------------------------------------
#
	<td class="row2" colspan="{catrow.forumrow.INC_SPAN}" {catrow.forumrow.WIDTH}><table cellpadding="0" cellspacing="0" width="100%"><tr><td>{catrow.forumrow.LINK_IMG}</td><td width="100%"><span class="gen"><a href="{catrow.forumrow.U_VIEWFORUM}">{catrow.forumrow.FORUM_NAME}</a></span><br /><span class="gensmall">{catrow.forumrow.ICON_IMG}{catrow.forumrow.FORUM_DESC}</span></td></tr></table></td>
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	<td class="row2" colspan="{catrow.forumrow.INC_SPAN}" {catrow.forumrow.WIDTH}><table cellpadding="0" cellspacing="0" width="100%"><tr><td>{catrow.forumrow.LINK_IMG}</td><td>{catrow.forumrow.ICON_IMG}</td><td width="100%"><span class="gen"><a href="{catrow.forumrow.U_VIEWFORUM}">{catrow.forumrow.FORUM_NAME}</a></span><br /><span class="gensmall">{catrow.forumrow.FORUM_DESC}</span></td></tr></table></td>
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoM