############################################################## 
## MOD Title:		Categories hierarchy - upgrade to 2.0.5-RC1
## MOD Author:		Ptirhiik < ptirhiik@clanmckeen.com > (Pierre) http://rpgnet.clanmckeen.com
## MOD Description:	Upgrade Categories hierachy mod from 2.0.4(final) to 2.0.5
##
## MOD Version:		2.0.5
## 
## Installation Level:	Easy
## Installation Time:	30 Minutes
## Files To Edit:
##			index.php
##			viewforum.php
##			viewtopic.php
##
##			admin/admin_forumauth.php
##			admin/admin_ranks.php
##			admin/admin_smilies.php
##			admin/admin_styles.php
##			admin/admin_ug_auth.php
##			admin/admin_words.php
##
##			includes/auth.php
##			includes/bbcode.php
##			includes/constants.php
##			includes/functions.php
##			includes/functions_admin.php
##			includes/functions_categories_hierarchy.php
##			includes/functions_post.php
##			includes/page_header.php
##			includes/usercp_register.php
##
##			templates/subSilver/admin/auth_ug_body.tpl
##
## Included Files:
##			includes/def_birthday.php
##			includes/def_ranks.php
##			includes/def_smilies.php
##			includes/def_themes.php
##			includes/def_tree.php
##			includes/def_words.php
##
##			includes/functions_cache.php
##
##			includes/cache_tpls/def_birthday_def.tpl
##			includes/cache_tpls/def_ranks_def.tpl
##			includes/cache_tpls/def_smilies_def.tpl
##			includes/cache_tpls/def_themes_def.tpl
##			includes/cache_tpls/def_tree_def.tpl
##			includes/cache_tpls/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 :
##	(nb.: all caches are not fully used by this mod)
##
##			includes/def_birthday.php
##			includes/def_ranks.php
##			includes/def_smilies.php
##			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_cache.php the following lines :
##
##			define('CACHE_WORDS', true);
##			define('CACHE_THEMES', true);
##			define('CACHE_SMILIES', true);
##			define('CACHE_RANKS', true);
##			define('CACHE_BIRTHDAY', true);
##			define('CACHE_TREE', true);
##
##	For more details, refer to MOD-cat_hierarchy-part1.txt
##
############################################################## 
## MOD History: 
##
##   2003-11-22 - Version 2.0.5
##      - fix moderators not displaied in forums view
##	- split the cache module to a separate installation to use with other mods
##	- analyse and removal of sql requests usage
##	- reoganize distribution pack
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
##############################################################
#
#-----[ COPY ]------------------------------------------------
#
copy includes/def_birthday.php to includes/def_birthday.php
copy includes/def_ranks.php to includes/def_ranks.php
copy includes/def_smilies.php to includes/def_smilies.php
copy includes/def_themes.php to includes/def_themes.php
copy includes/def_tree.php to includes/def_tree.php
copy includes/def_words.php to includes/def_words.php
#
#-----[ COPY ]------------------------------------------------
#
copy includes/functions_cache.php to includes/functions_cache.php
#
#-----[ COPY ]------------------------------------------------
#
#		copy includes/cache_tpls/*.* to includes/cache_tpls/*.*
#
copy includes/cache_tpls/def_birthday_def.tpl to includes/cache_tpls/def_birthday_def.tpl
copy includes/cache_tpls/def_ranks_def.tpl to includes/cache_tpls/def_ranks_def.tpl
copy includes/cache_tpls/def_smilies_def.tpl to includes/cache_tpls/def_smilies_def.tpl
copy includes/cache_tpls/def_themes_def.tpl to includes/cache_tpls/def_themes_def.tpl
copy includes/cache_tpls/def_tree_def.tpl to includes/cache_tpls/def_tree_def.tpl
copy includes/cache_tpls/def_words_def.tpl to includes/cache_tpls/def_words_def.tpl
#
#-----[ OPEN ]------------------------------------------------
#
index.php
#
#-----[ FIND ]------------------------------------------------
#
# here we remove the previous modifications : you can uncomment them if you prefer
#
//-- 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 ----------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
$total_posts = get_db_stat('postcount');
$total_users = get_db_stat('usercount');
#
#-----[ FIND ]------------------------------------------------
#
}
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
}
#
#-----[ OPEN ]------------------------------------------------
#
viewforum.php
#
#-----[ FIND ]------------------------------------------------
#
if (isset($HTTP_GET_VARS['selected_id']) || isset($HTTP_POST_VARS['selected_id']))
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
if ( isset($HTTP_GET_VARS['selected_id']) || isset($HTTP_POST_VARS['selected_id']) )
#
#-----[ FIND ]------------------------------------------------
#
for ( $i = 0; $i < count($data['user_id']); $i++ )
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
for ( $i = 0; $i < count($tree['mods'][$idx]['user_id']); $i++ )
#
#-----[ FIND ]------------------------------------------------
#
for ( $i = 0; $i < count($data['group_id']); $i++ )
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
for ( $i = 0; $i < count($tree['mods'][$idx]['group_id']); $i++ )
#
#-----[ OPEN ]------------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
$forum_name = get_object_lang(POST_FORUM_URL . $forum_topic_data['forum_id'], 'name');
#
#-----[ AFTER, ADD ]------------------------------------------
#
$topic_forum_id = $forum_topic_data['forum_id'];
$topic_topic_title = $forum_topic_data['topic_title'];
#
#-----[ FIND ]------------------------------------------------
#
$sql = "SELECT *
	FROM " . RANKS_TABLE . "
	ORDER BY rank_special, rank_min";
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
$ranks = array();
$ranksrow = array();
if ( defined('CACHE_RANKS') )
{
	@include( $phpbb_root_path . './includes/def_ranks.' . $phpEx );
	if ( empty($ranks) )
	{
		cache_ranks();
		include( $phpbb_root_path . './includes/def_ranks.' . $phpEx );
	}
	@reset($ranks);
	while ( list($rank_id, $rank_data) = @each($ranks) )
	{
		$ranksrow[] = $rank_data;
	}
}
if ( empty($ranks) && !defined('CACHE_RANKS') )
{
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	$ranksrow[] = $row;
}
$db->sql_freeresult($result);
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
}
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_forumauth.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	cache_tree(true);
//-- fin mod : categories hierarchy ----------------------------------------------------------------

	$template->assign_vars(array(
		'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("admin_forumauth.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">')
	);
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	$template->assign_vars(array(
		'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("admin_forumauth.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">')
	);
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
	cache_tree(true);
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	$switch_mode = append_sid("admin_forumauth.$phpEx?" . POST_FORUM_URL . "=f" . $forum_id . "&adv=". $adv_mode);
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	$switch_mode = append_sid("admin_forumauth.$phpEx?" . POST_FORUM_URL . "=" . POST_FORUM_URL . "$forum_id&adv=$adv_mode");
#
#-----[ FIND ]------------------------------------------------
#
	$s_hidden_fields = '<input type="hidden" name="' . POST_FORUM_URL . '" value="f' . $forum_id . '">';
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	$s_hidden_fields = '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . POST_FORUM_URL . $forum_id . '">';
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_ranks.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
		$message .= "<br /><br />" . sprintf($lang['Click_return_rankadmin']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
		cache_ranks();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
			$message = $lang['Rank_removed']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
			cache_ranks();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_smilies.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
		$message = $lang['smiley_import_success']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
		cache_smilies();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
			$message = $lang['smiley_del_success']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
			cache_smilies();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
			$message = $lang['smiley_edit_success']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
			cache_smilies();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full-line is longer
#
			$message = $lang['smiley_add_success']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
			cache_smilies();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
# ----------------------------------------
# Not detailled : change all the trackers comments refering to categories hierarchy mod with 
#	trackers comments refering to the cache mod
# ----------------------------------------
#
admin/admin_styles.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
<?php
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_ug_auth.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		}

//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
		cache_tree(true);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
		}

//-- mod : cache -----------------------------------------------------------------------------------
//-- add
		cache_tree(true);
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
		cache_tree(true);
//-- fin mod : categories hierarchy ----------------------------------------------------------------

		if ( $unset_mod != '' )
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
		cache_tree(true);
//-- fin mod : cache -------------------------------------------------------------------------------

		if ( $unset_mod != '' )
#
#-----[ OPEN ]------------------------------------------------
#
# ----------------------------------------
# Not detailled : change all the trackers comments refering to categories hierarchy mod with 
#	trackers comments refering to the cache mod
# ----------------------------------------
#
admin/admin_words.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
<?php
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/auth.php
#
#-----[ FIND ]------------------------------------------------
#
		$forum_match_sql = ( $forum_id != AUTH_LIST_ALL ) ? "AND a.forum_id = $forum_id" : '';
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
		if ( isset( $userdata['user_forums_auth'] ) )
		{
			if ( $forum_id != AUTH_LIST_ALL)
			{
				$u_access[] = $userdata['user_forums_auth'][$forum_id];
			}
			else
			{
				$u_access = $userdata['user_forums_auth'];
			}
		}
		else
		{
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			while( $row = $db->sql_fetchrow($result) );
		}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
		}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	if (!isset($orig))
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
	global $phpEx, $phpbb_root_path, $smilies, $board_config;

	if ( defined('CACHE_SMILIES') )
	{
		@include( $phpbb_root_path . './includes/def_smilies.' . $phpEx );
		if ( empty($smilies) )
		{
			cache_smilies();
			include( $phpbb_root_path . './includes/def_smilies.' . $phpEx );
		}
	}
	else
	{
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		$smilies = $db->sql_fetchrowset($result);
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
		}
	}
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	}

	if (count($orig))
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- delete
//	}
//-- fin mod : cache -------------------------------------------------------------------------------

	if (count($orig))
#
#-----[ OPEN ]------------------------------------------------
#
includes/constants.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
define('CATEGORIES_HIERARCHY_INSTALLED', true);
//-- fin mod : categories hierarchy ----------------------------------------------------------------

#
#-----[ OPEN ]------------------------------------------------
#
includes/functions.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
//-- mod : language settings -----------------------------------------------------------------------
//-- mod : mods settings ---------------------------------------------------------------------------
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *
 ***************************************************************************/
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
include_once( $phpbb_root_path . './includes/functions_cache.' . $phpEx);
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
function get_db_stat($mode)
{
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
	global $board_config;

	// first inits
	if ( !isset($board_config['max_users']) || !isset($board_config['record_last_user_id']) || !isset($board_config['record_last_username']) )
	{
		users_stats();
		cache_birthday();
	}
	if ( !isset($board_config['max_posts']) || !isset($board_config['max_topics']) )
	{
		board_stats();
	}
	switch ( $mode )
	{
		case 'usercount':
			return intval($board_config['max_users']);
			break;
		case 'newestuser':
			$row = array( 'user_id' => intval($board_config['record_last_user_id']), 'username' => $board_config['record_last_username']);
			return $row;
			break;
		case 'postcount':
			return intval($board_config['max_posts']);
			break;
		case 'topiccount':
			return intval($board_config['max_topics']);
			break;
	}
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- 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 ----------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- 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 : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
	$template_path = 'templates/' ;
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
	}
//-- fin mod : cache -------------------------------------------------------------------------------

	$template_path = 'templates/' ;
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	global $global_orig_word, $global_replacement_word;

	global $phpbb_root_path, $phpEx;
	if (isset($global_orig_word))
	{
		$orig_word			= $global_orig_word;
		$replacement_word	= $global_replacement_word;
	}
	else
	{
		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
		{
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
	global $phpbb_root_path, $phpEx;

	// not processed yet
	if ( empty($orig_word) )
	{
		// take them from the cache
		if ( defined('CACHE_WORDS') )
		{
			@include($phpbb_root_path . './includes/def_words.' . $phpEx);
			if ( !isset($censored_words) )
			{
				$censored_words = array();
				cache_words();
				include($phpbb_root_path . './includes/def_words.' . $phpEx);
			}

			// convert
			$orig_word = array();
			$replacement_word = array();
			@reset($censored_words);
			while ( list($word_id, $row) = @each($censored_words) )
			{
				$orig_word[] = '#\b(' . str_replace('\*', '\w*?', phpbb_preg_quote($row['word'], '#')) . ')\b#i';
				$replacement_word[] = $row['replacement'];
			}
		}
		else
		{
			// get them from the database
			$sql = "SELECT * FROM  " . WORDS_TABLE;
			if ( !$result = $db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, 'Could not get censored words from database', '', __LINE__, __FILE__, $sql);
			}
			// get the data
			$censored_words = array();
			while ( $row = $db->sql_fetchrow($result) )
			{
				$orig_word[] = '#\b(' . str_replace('\*', '\w*?', phpbb_preg_quote($row['word'], '#')) . ')\b#i';
				$replacement_word[] = $row['replacement'];
			}
		}
	}

	// end the function
	return true;
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	}
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
		}
		$global_orig_word			= $orig_word;
		$global_replacement_word	= $replacement_word;
	}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	}
#
#-----[ OPEN ]------------------------------------------------
#
# ----------------------------------------
# Not detailled : change all the trackers comments refering to categories hierarchy mod with 
#	trackers comments refering to the cache mod
# ----------------------------------------
#
includes/functions_admin.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
<?php
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
# NB.: you may prefer simply copy the new file if you haven't modify this one :)
#
includes/functions_categories_hierarchy.php
#
#-----[ FIND ]------------------------------------------------
#
 *	Version			: 1.0.2 - 12/11/2003
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
 *	Version			: 1.0.4 - 22/12/2003
#
#-----[ FIND ]------------------------------------------------
#
}
//--------------------------------------------------------------------------------------------------
//
// 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);
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
}
#
#-----[ FIND ]------------------------------------------------
#
# some cleaning first
#
//--------------------------------------------------------------------------------------------------
//
// 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);
		}
	}
}

//--------------------------------------------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#

//--------------------------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#

//--------------------------------------------------------------------------------------------------
//
// 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();
	}
}

//--------------------------------------------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#

//--------------------------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# now let's deal with the real changes : take care if you have the tracking unread flag mod, you will have to reapply it here
#
	// 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";
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	// read the user auth and the last post of each forums
	if ( $userdata['session_logged_in'] )
	{
		$sql_select = ', a.*, ug.user_id';
		$sql_from = "LEFT JOIN " . AUTH_ACCESS_TABLE . " a ON a.forum_id = f.forum_id )
					LEFT JOIN " . USER_GROUP_TABLE . " ug ON ug.group_id = a.group_id AND ug.user_id = " . intval($userdata['user_id']) . " AND ug.user_pending=0 )";
	}
	else
	{
		$sql_select = '';
		$sql_from = '))';
	}
	$sql = "SELECT f.forum_id AS forum_id_main, f.forum_last_post_id $sql_select
				FROM ((" . FORUMS_TABLE . " f $sql_from";
	if ( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Couldn\'t access list of last posts from forums', '', __LINE__, __FILE__, $sql);
	}

	$u_access = array();
	$s_last_posts = '';
	$last_posts = array();
	while ( $row = $db->sql_fetchrow($result) )
	{
		// get the last post
		if ( !empty($row['forum_last_post_id']) && !isset($last_posts[ $row['forum_last_post_id'] ]) )
		{
			$last_posts[ $row['forum_last_post_id'] ] = $row['forum_id_main'];
			$s_last_posts .= ( empty($s_last_posts) ? '' : ', ' ) . $row['forum_last_post_id'];
		}

		// get the access auth
		if ( $userdata['session_logged_in'] && ($row['user_id'] == $userdata['user_id']) )
		{
			$u_access[ $row['forum_id_main'] ][] = $row;
		}
	}

	$userdata['user_forums_auth'] = $u_access;
	$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, " . TOPICS_TABLE . " t, " . USERS_TABLE . " u
				WHERE ( p.post_time > $user_lastvisit $sql_last_posts )
						AND p.post_id = t.topic_last_post_id
						AND t.topic_id = p.topic_id AND t.forum_id = p.forum_id AND t.topic_moved_id = 0
						AND u.user_id = p.poster_id";
#
#-----[ FIND ]------------------------------------------------
#
// get_auth_keys() : return an array() with only the viewable row id
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
// get_auth_keys() : return an array() with only the row id verifying the auth asked
#
#-----[ FIND ]------------------------------------------------
#
function make_cat_nav_tree($cur, $pgm='', $nav_class='nav')
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
function make_cat_nav_tree($cur, $pgm='', $nav_class='nav', $topic_title='', $forum_id=0)
#
#-----[ FIND ]------------------------------------------------
#
	$id = intval(substr($cur,1));
	$topic_title = '';
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	$id = intval(substr($cur,1));
#
#-----[ FIND ]------------------------------------------------
#
		case POST_TOPIC_URL:
			$sql = "SELECT forum_id, topic_title 
						FROM " . TOPICS_TABLE . " WHERE topic_id = $id";
			if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query topics information', '', __LINE__, __FILE__, $sql);
			if ($row = $db->sql_fetchrow($result))
			{
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
		case POST_TOPIC_URL:
			if ( empty($forum_id) || empty($topic_title) )
			{
				$sql = "SELECT forum_id, topic_title 
							FROM " . TOPICS_TABLE . " WHERE topic_id = $id";
				if ( !$result = $db->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, 'Could not query topics information', '', __LINE__, __FILE__, $sql);
				}
				if ( $row = $db->sql_fetchrow($result) )
				{
					$topic_title = $row['topic_title'];
					$forum_id = $row['forum_id'];
				}
			}
			else
			{
				$row = array();
				$row['topic_title'] = $topic_title;
				$row['forum_id'] = $forum_id;
			}
			if ( !empty($forum_id) )
			{
#
#-----[ FIND ]------------------------------------------------
#
		case POST_POST_URL:
			$sql = "SELECT t.forum_id, t.topic_title 
						FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t 
						WHERE t.topic_id=p.topic_id AND post_id = $id";
			if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query posts information', '', __LINE__, __FILE__, $sql);
			if ($row = $db->sql_fetchrow($result))
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
		case POST_POST_URL:
			if ( empty($forum_id) || empty($topic_title) )
			{
				$sql = "SELECT t.forum_id, t.topic_title 
							FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t 
							WHERE t.topic_id=p.topic_id AND post_id = $id";
				if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query posts information', '', __LINE__, __FILE__, $sql);
				if ( !$row = $db->sql_fetchrow($result) )
				{
					$row['forum_id'] = 0;
					$row['topic_title'] = '';
				}
			}
			else
			{
				$row['forum_id'] = $forum_id;
				$row['topic_title'] = $topic_title;
			}
			if ( !empty($forum_id) && !empty($topic_title) )
#
#-----[ FIND ]------------------------------------------------
#
	if (!isset($tree['keys'][$cur])) $cur = isset($tree['keys'][POST_CAT_URL . $cur]) ? POST_CAT_URL . $cur : $cur;
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	if (!isset($tree['keys'][$cur]))
	{
		$cur = isset($tree['keys'][POST_CAT_URL . $cur]) ? POST_CAT_URL . $cur : $cur;
	}
#
#-----[ OPEN ]------------------------------------------------
#
includes/functions_post.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
//-- mod : categories hierarchy --------------------------------------------------------------------
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
<?php
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	board_stats();
	cache_tree(true);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
	$meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">';
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	$meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">';
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
	board_stats();
	cache_tree(true);
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
	board_stats();
	cache_tree(true);
//-- fin mod : categories hierarchy ----------------------------------------------------------------
	return;
}

//
// Delete a post/poll
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
	board_stats();
	cache_tree(true);
//-- fin mod : cache -------------------------------------------------------------------------------
	return;
}

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

//
// Handle user notification on new post
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
	board_stats();
	cache_tree(true);
//-- fin mod : cache -------------------------------------------------------------------------------
	return;
}

//
// Handle user notification on new post
#
#-----[ FIND ]------------------------------------------------
#
	$sql = "SELECT emoticon, code, smile_url   
		FROM " . SMILIES_TABLE . " 
		ORDER BY smilies_id";
	if ($result = $db->sql_query($sql))
	{
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
	if ( defined('CACHE_SMILIES') )
	{
		@include( $phpbb_root_path . './includes/def_smilies.' . $phpEx );
		if ( empty($smilies) )
		{
			cache_smilies();
			include( $phpbb_root_path . './includes/def_smilies.' . $phpEx );
		}
	}
	if ( empty($smilies) && !defined('CACHE_SMILIES') )
	{
		$smilies = array();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
			while ( $row = $db->sql_fetchrow($result) )
			{
				$smilies[] = $row;
			}
		}
	}
	if ( !empty($smilies) )
	{
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
		$num_smilies = 0;
		$rowset = array();
		while ($row = $db->sql_fetchrow($result))
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
		$num_smilies = 0;
		$rowset = array();
//-- mod : cache -----------------------------------------------------------------------------------
//-- delete
//		while ($row = $db->sql_fetchrow($result))
//-- add
		@reset($smilies);
		while ( list($row_id, $row) = @each($smilies) )
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/page_header.php
#
#-----[ FIND ]------------------------------------------------
#
if (empty($nav_key)) $nav_key = 'Root';
$nav_cat_desc = make_cat_nav_tree($nav_key, $nav_pgm);
if ($nav_cat_desc != '') $nav_cat_desc = $nav_separator . $nav_cat_desc;
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
if ( empty($nav_key) )
{
	$nav_key = 'Root';
}
$nav_cat_desc = make_cat_nav_tree($nav_key, $nav_pgm, 'nav', $topic_topic_title, $topic_forum_id);
if ( !empty($nav_cat_desc) )
{
	$nav_cat_desc = $nav_separator . $nav_cat_desc;
}
#
#-----[ OPEN ]------------------------------------------------
#
includes/usercp_register.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full line is longer
#
			$message = $message . '<br /><br />' . sprintf($lang['Click_return_index']
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
			users_stats();
			cache_birthday();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/admin/auth_ug_body.tpl
#
#-----[ FIND ]------------------------------------------------
#
		<td colspan="{row.cathead.INC_SPAN}" class="{row.cathead.CLASS_CAT}" align="left" nowrap> <span class="cattitlemed">{row.cathead.CAT_TITLE}</span></td>
		<!-- BEGIN aclvalues -->
		<td class="{row.cathead.CLASS_CAT}" align="left" nowrap><span class="cattitlemed">&nbsp;</span></td>
		<!-- END aclvalues -->
		<td class="{row.cathead.CLASS_CAT}" align="left" nowrap><span class="cattitlemed">&nbsp;</span></td>
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
		<td colspan="{row.cathead.INC_SPAN}" class="{row.cathead.CLASS_CAT}" align="left" nowrap="nowrap"> <span class="cattitlemed">{row.cathead.CAT_TITLE}</span></td>
		<!-- BEGIN aclvalues -->
		<td class="{row.cathead.CLASS_CAT}" align="left" nowrap="nowrap"><span class="cattitlemed">&nbsp;</span></td>
		<!-- END aclvalues -->
		<td class="{row.cathead.CLASS_CAT}" align="left" nowrap="nowrap"><span class="cattitlemed">&nbsp;</span></td>
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoM