##############################################################
## MOD Title:		Categories hierarchy - Upgrade from 2.0.5-RC1 to 2.0.5-RC2
## MOD Author:		Ptirhiik < ptirhiik@clanmckeen.com > (Pierre) http://rpgnet.clanmckeen.com
## MOD Description:
##			Upgrade from categories hierarchy 2.0.5-RC1 to 2.0.5-RC2
## MOD Version:		2.0.5-RC2
##
## Installation Level:	Easy
## Installation Time:	~20 Minutes
## Files To Edit:
##			search.php
##			viewforum.php
##
##			admin/admin_forums.php
##			admin/admin_forums_extend.php
##			admin/admin_ug_auth.php
##			admin/admin_users.php
##
##			includes/functions_admin.php
##			includes/functions_cache.php
##			includes/functions_categories_hierarchy.php
##			includes/usercp_register.php
##			includes/cache_tpls/def_smilies_def.tpl
##
##			language/lang_english/lang_extend_categories_hierarchy.php
##
##############################################################
## 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:
##
##   2004-07-21 - Version 2.0.5-RC2
##      - some bugs updated
##      - fix various errors or omissions of variables (language and image)
##      - fix auto pruning in Management + : the number of days and frequency always returns to the default value
##      - fix bad indentation of the under-forums when the hierachy is not compressed
##      - fix topic title no viewable in search results for user no authorized
##      - fix cache reconstruction during an event of synchronization
##      - fix sort in Management + : sort function inoperative
##      - fix images url in hierarchy
##	- new jumpbox by flashdagger
##	- compliance PHP v5.x.x
##	A great thanks to akzhaiyk, cifroes, easythomas, PghBiker, tr3vor, Waagenbauer and others
##	for reports and fixs.
##
##   2003-11-22 - Version 2.0.5-RC1
##      - 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
##############################################################
#
#-----[ OPEN ]------------------------------------------------
#
search.php
#
#-----[ FIND ]------------------------------------------------
#
		if ($s_flist != '')
		{
			$auth_sql .= (( $auth_sql != '' ) ? " AND" : '') . " f.forum_id IN ($s_flist) ";
		}
#
#-----[ AFTER, ADD ]------------------------------------------
#
		else
		{
			message_die(GENERAL_MESSAGE, $lang['No_searchable_forums']);
		}
#
#-----[ OPEN ]------------------------------------------------
#
viewforum.php
#
#-----[ FIND ]------------------------------------------------
#
$this = isset($tree['keys'][$selected_id]) ? $tree['keys'][$selected_id] : -1;
if ( ($this > -1) && !empty($tree['data'][$this]['forum_link']))
#
#-----[ REPLACE WITH ]----------------------------------------
#
$this_key = isset($tree['keys'][$selected_id]) ? $tree['keys'][$selected_id] : -1;
if ( ($this_key > -1) && !empty($tree['data'][$this_key]['forum_link']))
#
#-----[ FIND ]------------------------------------------------
#
	if ($tree['data'][$this]['forum_link_hit_count'])
#
#-----[ REPLACE WITH ]----------------------------------------
#
	if ($tree['data'][$this_key]['forum_link_hit_count'])
#
#-----[ FIND ]------------------------------------------------
#
	$url = $tree['data'][$this]['forum_link'];
	if ($tree['data'][$this]['forum_link_internal'])
#
#-----[ REPLACE WITH ]----------------------------------------
#
	$url = $tree['data'][$this_key]['forum_link'];
	if ($tree['data'][$this_key]['forum_link_internal'])
#
#-----[ OPEN ]------------------------------------------------
#
# this one is optional : do it only if you don't use the forum extend administration
#
admin/admin_forums.php
#
#-----[ FIND ]------------------------------------------------
#
	$this = (isset($tree['keys'][ $type . $id ])) ? $tree['keys'][ $type . $id ] : -1;
#
#-----[ REPLACE WITH ]----------------------------------------
#
	$this_key = (isset($tree['keys'][ $type . $id ])) ? $tree['keys'][ $type . $id ] : -1;
#
#-----[ FIND ]------------------------------------------------
#
	$main = ($this < 0) ? 'Root' : $tree['main'][$this];
#
#-----[ REPLACE WITH ]----------------------------------------
#
	$main = ($this_key < 0) ? 'Root' : $tree['main'][$this_key];
#
#-----[ FIND ]------------------------------------------------
#
			$worder = ($i == $this) ? $order + $move : $order;
#
#-----[ REPLACE WITH ]----------------------------------------
#
			$worder = ($i == $this_key) ? $order + $move : $order;
#
#-----[ FIND ]------------------------------------------------
#
					$this = $tree['keys'][$type . $id];
					if (!empty($tree['data'][$this]['forum_link']))
#
#-----[ REPLACE WITH ]----------------------------------------
#
					$this_key = $tree['keys'][$type . $id];
					if (!empty($tree['data'][$this_key]['forum_link']))
#
#-----[ FIND ]------------------------------------------------
#
					$this = $tree['keys'][$type . $id];
					if (!empty($tree['data'][$this]['forum_link']))
#
#-----[ REPLACE WITH ]----------------------------------------
#
					$this_key = $tree['keys'][$type . $id];
					if (!empty($tree['data'][$this_key]['forum_link']))
#
#-----[ FIND ]------------------------------------------------
#
				$this = $tree['keys'][$cat_main_type . $cat_main];
				if (!empty($tree['data'][$this]['forum_link']))
#
#-----[ REPLACE WITH ]----------------------------------------
#
				$this_key = $tree['keys'][$cat_main_type . $cat_main];
				if (!empty($tree['data'][$this_key]['forum_link']))
#
#-----[ FIND ]------------------------------------------------
#
				$this = $tree['keys'][$cat_main_type . $cat_main];
				if (!empty($tree['data'][$this]['forum_link']))
#
#-----[ REPLACE WITH ]----------------------------------------
#
				$this_key = $tree['keys'][$cat_main_type . $cat_main];
				if (!empty($tree['data'][$this_key]['forum_link']))
#
#-----[ FIND ]------------------------------------------------
#
			$this = $tree['keys'][POST_FORUM_URL . $forum_id];
			$name = $tree['data'][$this]['forum_name'];
			$desc = $tree['data'][$this]['forum_desc'];
#
#-----[ REPLACE WITH ]----------------------------------------
#
			$this_key = $tree['keys'][POST_FORUM_URL . $forum_id];
			$name = $tree['data'][$this_key]['forum_name'];
			$desc = $tree['data'][$this_key]['forum_desc'];
#
#-----[ FIND ]------------------------------------------------
#
			$this = $tree['keys'][POST_CAT_URL . $cat_id];
			$name = $tree['data'][$this]['cat_title'];
			$desc = $tree['data'][$this]['cat_desc'];
#
#-----[ REPLACE WITH ]----------------------------------------
#
			$this_key = $tree['keys'][POST_CAT_URL . $cat_id];
			$name = $tree['data'][$this_key]['cat_title'];
			$desc = $tree['data'][$this_key]['cat_desc'];
#
#-----[ FIND ]------------------------------------------------
#
			if ($tree['main'][$this] == 'Root')
#
#-----[ REPLACE WITH ]----------------------------------------
#
			if ($tree['main'][$this_key] == 'Root')
#
#-----[ FIND ]------------------------------------------------
#
					$found = (($i != $this) && ($tree['main'][$i] == 'Root'));
#
#-----[ REPLACE WITH ]----------------------------------------
#
					$found = (($i != $this_key) && ($tree['main'][$i] == 'Root'));
#
#-----[ FIND ]------------------------------------------------
#
				if( !$result = $db->sql_query($sql) )
				{
					message_die(GENERAL_ERROR, "Couldn't move forums to other category", "", __LINE__, __FILE__, $sql);
				}
			}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : categories hierarchy --------------------------------------------------------------------
//-- add
			else if ( $to_fid == 'Root' )
			{
				$found = false;
				for ($i=0; $i < count($tree['sub'][POST_CAT_URL . $from_id]); $i++)
				{
					$found = ($tree['type'][$tree['keys'][$tree['sub'][POST_CAT_URL . $from_id][$i]]] == POST_FORUM_URL);
				}
				if ($found)
				{
					message_die(GENERAL_ERROR, $lang['Must_delete_forums']);
				}
			}
//-- fin mod : categories hierarchy ----------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	$this = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1;
#
#-----[ REPLACE WITH ]----------------------------------------
#
	$this_key = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1;
#
#-----[ FIND ]------------------------------------------------
#
	if ($this >= -1)
	{
		// cat header row
		if ($tree['type'][$this] == POST_CAT_URL)
		{
			// display a cat row
			$cat = $tree['data'][$this];
			$cat_id = $tree['id'][$this];
#
#-----[ REPLACE WITH ]----------------------------------------
#
	if ($this_key >= -1)
	{
		// cat header row
		if ($tree['type'][$this_key] == POST_CAT_URL)
		{
			// display a cat row
			$cat = $tree['data'][$this_key];
			$cat_id = $tree['id'][$this_key];
#
#-----[ FIND ]------------------------------------------------
#
		if ($tree['type'][$this] == POST_FORUM_URL)
		{
			$forum = $tree['data'][$this];
			$forum_id = $tree['id'][$this];
			$forum_link_img = '';
			if (!empty($tree['data'][$this]['forum_link']))
#
#-----[ REPLACE WITH ]----------------------------------------
#
		if ($tree['type'][$this_key] == POST_FORUM_URL)
		{
			$forum = $tree['data'][$this_key];
			$forum_id = $tree['id'][$this_key];
			$forum_link_img = '';
			if (!empty($tree['data'][$this_key]['forum_link']))
#
#-----[ FIND ]------------------------------------------------
#
				if ($tree['data'][$this]['forum_status'] == FORUM_LOCKED)
#
#-----[ REPLACE WITH ]----------------------------------------
#
				if ($tree['data'][$this_key]['forum_status'] == FORUM_LOCKED)
#
#-----[ FIND ]------------------------------------------------
#
		if ($tree['type'][$this] == POST_CAT_URL)
#
#-----[ REPLACE WITH ]----------------------------------------
#
		if ($tree['type'][$this_key] == POST_CAT_URL)
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_forums_extend.php
#
#-----[ FIND ]------------------------------------------------
#
 *	version			: 1.0.1 - 22/11/2003
#
#-----[ REPLACE WITH ]----------------------------------------
#
 *	version			: 1.0.2 - 23/06/2004
#
#-----[ FIND ]------------------------------------------------
#
	$forums_fields_list['forum_display_sort'] = 'display_sort';
	$forums_fields_list['forum_display_order'] = 'display_order';
	$fields_type['display_sort'] = 'INTEGER';
	$fields_type['display_order'] = 'INTEGER';
#
#-----[ REPLACE WITH ]----------------------------------------
#
	$forums_fields_list['forum_display_sort'] = 'forum_display_sort';
	$forums_fields_list['forum_display_order'] = 'forum_display_order';
	$fields_type['forum_display_sort'] = 'INTEGER';
	$fields_type['forum_display_order'] = 'INTEGER';
#
#-----[ FIND ]------------------------------------------------
#
	$this = isset($tree['keys'][$fid]) ? $fid : ''; 
#
#-----[ REPLACE WITH ]----------------------------------------
#
	$this_key = isset($tree['keys'][$fid]) ? $fid : ''; 
#
#-----[ FIND ]------------------------------------------------
#
	$old_type = empty($this) ? POST_FORUM_URL : substr($fid, 0, 1);
	$old_id = empty($this) ? 0 : intval(substr($fid, 1));
#
#-----[ REPLACE WITH ]----------------------------------------
#
	$old_type = empty($this_key) ? POST_FORUM_URL : substr($fid, 0, 1);
	$old_id = empty($this_key) ? 0 : intval(substr($fid, 1));
#
#-----[ FIND ]------------------------------------------------
#
		$item[$process_field] = empty($this) ? '' : trim($tree['data'][$idx][$table_field]);
#
#-----[ REPLACE WITH ]----------------------------------------
#
		$item[$process_field] = empty($this_key) ? '' : trim($tree['data'][$idx][$table_field]);
#
#-----[ FIND ]------------------------------------------------
#
	$item['main'] = empty($this) ? $selected_id : $item['main_type'] . $item['main_id'];
#
#-----[ REPLACE WITH ]----------------------------------------
#
	$item['main'] = empty($this_key) ? $selected_id : $item['main_type'] . $item['main_id'];
#
#-----[ FIND ]------------------------------------------------
#
	if ( !empty($this) )
#
#-----[ REPLACE WITH ]----------------------------------------
#
	if ( !empty($this_key) )
#
#-----[ FIND ]------------------------------------------------
#
	if ( !empty($this) && ($item['type'] == POST_FORUM_URL) )
#
#-----[ REPLACE WITH ]----------------------------------------
#
	if ( !empty($this_key) && ($item['type'] == POST_FORUM_URL) )
#
#-----[ FIND ]------------------------------------------------
#
				if( $db->sql_numrows($result) > 0 )
				{
					$sql = "UPDATE " . PRUNE_TABLE . " 
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
				$item['prune_days'] = $HTTP_POST_VARS['prune_days'];
				$item['prune_freq'] = $HTTP_POST_VARS['prune_freq'];
#
#-----[ FIND ]------------------------------------------------
#
			$forum_display_sort_list = get_forum_display_sort_option($item['display_sort'], 'list', 'sort');
			$forum_display_order_list = get_forum_display_sort_option($item['display_order'], 'list', 'order');
#
#-----[ REPLACE WITH ]----------------------------------------
#
			$forum_display_sort_list = get_forum_display_sort_option($item['forum_display_sort'], 'list', 'sort');
			$forum_display_order_list = get_forum_display_sort_option($item['forum_display_order'], 'list', 'order');
#
#-----[ FIND ]------------------------------------------------
#
		$this = $tree['sub'][$selected_id][$i];
		$idx = $tree['keys'][$this];
#
#-----[ REPLACE WITH ]----------------------------------------
#
		$this_key = $tree['sub'][$selected_id][$i];
		$idx = $tree['keys'][$this_key];
#
#-----[ FIND ]------------------------------------------------
#
		if ( ($tree['type'][$idx] == POST_CAT_URL) || !empty($tree['sub'][$this]) )
#
#-----[ REPLACE WITH ]----------------------------------------
#
		if ( ($tree['type'][$idx] == POST_CAT_URL) || !empty($tree['sub'][$this_key]) )
#
#-----[ FIND ]------------------------------------------------
#
				$folder = $images['category_lock'];
#
#-----[ REPLACE WITH ]----------------------------------------
#
				$folder = $images['category_locked'];
#
#-----[ FIND ]------------------------------------------------
#
		$sub = isset($tree['sub'][$this]);
#
#-----[ REPLACE WITH ]----------------------------------------
#
		$sub = isset($tree['sub'][$this_key]);
#
#-----[ FIND ]------------------------------------------------
#
		for ($j = 0; $j < count($tree['sub'][$this]); $j++ )
#
#-----[ REPLACE WITH ]----------------------------------------
#
		for ($j = 0; $j < count($tree['sub'][$this_key]); $j++ )
#
#-----[ FIND ]------------------------------------------------
#
			$sub_this = $tree['sub'][$this][$j];
#
#-----[ REPLACE WITH ]----------------------------------------
#
			$sub_this = $tree['sub'][$this_key][$j];
#
#-----[ FIND ]------------------------------------------------
#
			'FORUM_NAME'	=> get_object_lang($this, 'name', true),
			'FORUM_DESC'	=> get_object_lang($this, 'desc', true),
#
#-----[ REPLACE WITH ]----------------------------------------
#
			'FORUM_NAME'	=> get_object_lang($this_key, 'name', true),
			'FORUM_DESC'	=> get_object_lang($this_key, 'desc', true),
#
#-----[ FIND ]------------------------------------------------
#
			'U_FORUM'		=> append_sid("./admin_forums_extend.$phpEx?selected_id=$this"),
			'U_EDIT'		=> append_sid("./admin_forums_extend.$phpEx?mode=edit&fid=$this"),
			'U_DELETE'		=> append_sid("./admin_forums_extend.$phpEx?mode=delete&fid=$this"),
			'U_RESYNC'		=> append_sid("./admin_forums_extend.$phpEx?mode=resync&fid=$this"),
			'U_MOVEUP'		=> append_sid("./admin_forums_extend.$phpEx?mode=moveup&fid=$this"),
			'U_MOVEDW'		=> append_sid("./admin_forums_extend.$phpEx?mode=movedw&fid=$this"),
#
#-----[ REPLACE WITH ]----------------------------------------
#
			'U_FORUM'		=> append_sid("./admin_forums_extend.$phpEx?selected_id=$this_key"),
			'U_EDIT'		=> append_sid("./admin_forums_extend.$phpEx?mode=edit&fid=$this_key"),
			'U_DELETE'		=> append_sid("./admin_forums_extend.$phpEx?mode=delete&fid=$this_key"),
			'U_RESYNC'		=> append_sid("./admin_forums_extend.$phpEx?mode=resync&fid=$this_key"),
			'U_MOVEUP'		=> append_sid("./admin_forums_extend.$phpEx?mode=moveup&fid=$this_key"),
			'U_MOVEDW'		=> append_sid("./admin_forums_extend.$phpEx?mode=movedw&fid=$this_key"),
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_ug_auth.php
#
#-----[ FIND ]------------------------------------------------
#
		$this	= $keys['idx'][$i];
#
#-----[ REPLACE WITH ]----------------------------------------
#
		$this_key	= $keys['idx'][$i];
#
#-----[ FIND ]------------------------------------------------
#
		if ($tree['type'][$this] == POST_CAT_URL)
#
#-----[ REPLACE WITH ]----------------------------------------
#
		if ($tree['type'][$this_key] == POST_CAT_URL)
#
#-----[ FIND ]------------------------------------------------
#
				'CAT_TITLE' => get_object_lang( $tree['type'][$this] . $tree['id'][$this], 'name'),
#
#-----[ REPLACE WITH ]----------------------------------------
#
				'CAT_TITLE' => get_object_lang( $tree['type'][$this_key] . $tree['id'][$this_key], 'name'),
#
#-----[ FIND ]------------------------------------------------
#
		if ($tree['type'][$this] == POST_FORUM_URL)
#
#-----[ REPLACE WITH ]----------------------------------------
#
		if ($tree['type'][$this_key] == POST_FORUM_URL)
#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_users.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			$message = $lang['User_deleted'] . '<br /><br />' . sprintf($lang['Click_return_useradmin'], '<a href="' . append_sid("admin_users.$phpEx") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>');
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
			users_stats();
			cache_birthday();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			$message .= '<br /><br />' . sprintf($lang['Click_return_useradmin'], '<a href="' . append_sid("admin_users.$phpEx") . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>');
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
			// the username may have changed
			users_stats();
			cache_birthday();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/functions_admin.php
#
#-----[ FIND ]------------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
	global $board_config;
	board_stats();
#
#-----[ AFTER, ADD ]------------------------------------------
#
	cache_tree(true);
#
#-----[ OPEN ]------------------------------------------------
#
includes/functions_cache.php
#
#-----[ FIND ]------------------------------------------------
#
 *	version			: 1.0.0 - 15/12/2003
#
#-----[ REPLACE WITH ]----------------------------------------
#
 *	version			: 1.0.2 - 20/07/2004
#
#-----[ FIND ]------------------------------------------------
#
	if ( defined('USERS_STATS_DONE') )
	{
		return;
	}
	define('USERS_STATS_DONE', true);

	// read registered users info (number and last)
#
#-----[ REPLACE WITH ]----------------------------------------
#
	// read registered users info (number and last)
#
#-----[ FIND ]------------------------------------------------
#
	if ( defined('BOARD_STATS_DONE') )
	{
		return;
	}
	define('BOARD_STATS_DONE', true);

	// read topics and posts info
#
#-----[ REPLACE WITH ]----------------------------------------
#
	// read topics and posts info
#
#-----[ FIND ]------------------------------------------------
#
	// output to file
	$fname = $phpbb_root_path . './includes/def_tree.' . $phpEx;
	@chmod($fname, 0666);
	$handle = @fopen($fname, 'w');
	@fwrite($handle, $res);
	@fclose($handle);
#
#-----[ REPLACE WITH ]----------------------------------------
#
	// output to file
	$cache_path = 'includes/';
	$cache_file = 'def_tree';
	$handle = @fopen($phpbb_root_path . $cache_path . $cache_file . '.' . $phpEx, 'w');
	@flock($fp, LOCK_EX);
	@fwrite($handle, $res);
	@flock($fp, LOCK_UN);
	@fclose($handle);
	@umask(0000);
	@chmod($phpbb_root_path . $cache_path . $cache_file . '.' . $phpEx, 0666);
#
#-----[ FIND ]------------------------------------------------
#
		$this = count($tree['data']);
#
#-----[ REPLACE WITH ]----------------------------------------
#
		$this_key = count($tree['data']);
#
#-----[ FIND ]------------------------------------------------
#
		$tree['keys'][$key] = $this;
#
#-----[ REPLACE WITH ]----------------------------------------
#
		$tree['keys'][$key] = $this_key;
#
#-----[ FIND ]------------------------------------------------
#
	if ( !defined('CACHE_WORDS') || defined('CACHE_WORDS_DONE') )
	{
		return;
	}
	define('CACHE_WORDS_DONE', true);
	cache_generic('def_words_def', 'def_words', WORDS_TABLE, 'word_id');
#
#-----[ REPLACE WITH ]----------------------------------------
#
	if ( !defined('CACHE_WORDS') )
	{
		return;
	}
	cache_generic('def_words_def', 'def_words', WORDS_TABLE, 'word_id');
#
#-----[ FIND ]------------------------------------------------
#
	if ( !defined('CACHE_THEMES') || defined('CACHE_THEMES_DONE') )
	{
		return;
	}
	define('CACHE_THEMES_DONE', true);
	cache_generic('def_themes_def', 'def_themes', THEMES_TABLE, 'themes_id');
#
#-----[ REPLACE WITH ]----------------------------------------
#
	if ( !defined('CACHE_THEMES') )
	{
		return;
	}
	cache_generic('def_themes_def', 'def_themes', THEMES_TABLE, 'themes_id');
#
#-----[ FIND ]------------------------------------------------
#
	if ( !defined('CACHE_SMILIES') || defined('CACHE_SMILIES_DONE') )
	{
		return;
	}
	define('CACHE_SMILIES_DONE', true);
	cache_generic('def_smilies_def', 'def_smilies', SMILIES_TABLE, 'smilies_id');
#
#-----[ REPLACE WITH ]----------------------------------------
#
	if ( !defined('CACHE_SMILIES') )
	{
		return;
	}
	cache_generic('def_smilies_def', 'def_smilies', SMILIES_TABLE, 'smilies_id');
#
#-----[ FIND ]------------------------------------------------
#
	if ( !defined('CACHE_RANKS') || defined('CACHE_RANKS_DONE') )
	{
		return;
	}
	define('CACHE_RANKS_DONE', true);
	cache_generic('def_ranks_def', 'def_ranks', RANKS_TABLE, 'rank_id');
#
#-----[ REPLACE WITH ]----------------------------------------
#
	if ( !defined('CACHE_RANKS') )
	{
		return;
	}
	cache_generic('def_ranks_def', 'def_ranks', RANKS_TABLE, 'rank_id');
#
#-----[ FIND ]------------------------------------------------
#
	if ( !defined('CACHE_BIRTHDAY') || !defined('PCP_INSTALLED') || defined('CACHE_BIRTHDAY_DONE') )
	{
		return;
	}
	define('CACHE_BIRTHDAY_DONE', true);
	$sql_where = "WHERE user_id <> " . ANONYMOUS . " AND user_active = 1 AND RIGHT(user_birthday, 4) = " . date( "md", time() );
	cache_generic('def_birthday_def', 'def_birthday', USERS_TABLE, 'user_id', $sql_where);
#
#-----[ REPLACE WITH ]----------------------------------------
#
	if ( !defined('CACHE_BIRTHDAY') || !defined('PCP_INSTALLED') )
	{
		return;
	}
	$sql_where = "WHERE user_id <> " . ANONYMOUS . " AND user_active = 1 AND RIGHT(user_birthday, 4) = " . date( "md", time() );
	cache_generic('def_birthday_def', 'def_birthday', USERS_TABLE, 'user_id', $sql_where);
#
#-----[ FIND ]------------------------------------------------
#
	// output to file
	$fname = $phpbb_root_path . './includes/' . $cache_file . '.' . $phpEx;
	@chmod($fname, 0666);
	$handle = @fopen($fname, 'w');
	@fwrite($handle, $res);
	@fclose($handle);
#
#-----[ REPLACE WITH ]----------------------------------------
#
	// output to file
	$cache_path = 'includes/';
	$handle = @fopen($phpbb_root_path . $cache_path . $cache_file . '.' . $phpEx, 'w');
	@flock($fp, LOCK_EX);
	@fwrite($handle, $res);
	@flock($fp, LOCK_UN);
	@fclose($handle);
	@umask(0000);
	@chmod($phpbb_root_path . $cache_path . $cache_file . '.' . $phpEx, 0666);
#
#-----[ OPEN ]------------------------------------------------
#
includes/functions_categories_hierarchy.php
#
#-----[ FIND ]------------------------------------------------
#
 *	Version			: 1.0.4 - 22/12/2003
#
#-----[ REPLACE WITH ]----------------------------------------
#
 *	Version			: 1.0.7 - 20/07/2004
#
#-----[ FIND ]------------------------------------------------
#
	$this	= $tree['keys'][$cur];
	$type	= $tree['type'][$this];
#
#-----[ REPLACE WITH ]----------------------------------------
#
	$this_key	= $tree['keys'][$cur];
	$type	= $tree['type'][$this_key];
#
#-----[ FIND ]------------------------------------------------
#
		$res = ($tree['auth'][$cur]['auth_view'] || $all) ? $tree['data'][$this][$field] : '';
#
#-----[ REPLACE WITH ]----------------------------------------
#
		$res = ($tree['auth'][$cur]['auth_view'] || $all) ? $tree['data'][$this_key][$field] : '';
#
#-----[ FIND ]------------------------------------------------
#
	$remplacement_word = array();
#
#-----[ REPLACE WITH ]----------------------------------------
#
	$replacement_word = array();
#
#-----[ FIND ]------------------------------------------------
#
			$u_access[ $row['forum_id_main'] ][] = $row;
#
#-----[ REPLACE WITH ]----------------------------------------
#
			$u_access[ $row['forum_id_main'] ] = $row;
#
#-----[ FIND ]------------------------------------------------
#
function get_auth_keys($cur='Root', $all=false, $level=-1, $max=-1, $auth_key='auth_view')
#
#-----[ REPLACE WITH ]----------------------------------------
#
function get_auth_keys($cur='Root', $all=false, $level=-1, $max=-1, $auth_key='auth_view', $align_level = 0)
#
#-----[ FIND ]------------------------------------------------
#
				if (($level > 0) && ((substr($cur, 0, 1) == POST_FORUM_URL) || (intval($board_config['sub_forum']) > 0)) && (substr($tree['main'][$tree['keys'][$cur]], 0, 1) == POST_CAT_URL)) $level = $level-1;
#
#-----[ REPLACE WITH ]----------------------------------------
#
				if (($level > 0) && ((substr($cur, 0, 1) == POST_FORUM_URL) || (intval($board_config['sub_forum']) > 0)) && (substr($tree['main'][$tree['keys'][$cur]], 0, 1) == POST_CAT_URL))
				{
					$align_level++;   
				}
				$level = $level-$align_level;
#
#-----[ FIND ]------------------------------------------------
#
				$tkeys = get_auth_keys($tree['sub'][$cur][$i], $all, $orig_level+1, $max, $auth_key);
#
#-----[ REPLACE WITH ]----------------------------------------
#
				$tkeys = get_auth_keys($tree['sub'][$cur][$i], $all, $orig_level+1, $max, $auth_key, $align_level);
#
#-----[ FIND ]------------------------------------------------
#
//--------------------------------------------------------------------------------------------------
//
// get_tree_option() : return a drop down menu list of <option></option>
//
//--------------------------------------------------------------------------------------------------
function get_tree_option($cur='', $all=false)
{
	global $tree, $lang;

	$keys = array();
	$keys = get_auth_keys('Root', $all);
	$res = '';
	for ($i=0; $i < count($keys['id']); $i++)
	{
		// only get object that are not forum links type
		if ( ($tree['type'][ $keys['idx'][$i] ] != POST_FORUM_URL) || empty($tree['data'][ $keys['idx'][$i] ]['forum_link']) || $all)
		{
			$selected = ($cur == $keys['id'][$i]) ? ' selected="selected"' : '';
			$res .= '<option value="' . $keys['id'][$i] . '"' .  $selected . '>';

			// name
			$name = get_object_lang($keys['id'][$i], 'name', $all);

			// increment
			$inc = '';
			for ($k=1; $k <= $keys['real_level'][$i]; $k++)
			{
				$inc .= '|&nbsp;&nbsp;&nbsp;';
			}
			if ($keys['level'][$i] >=0) $inc .= '|--';
			$name = $inc . $name;

			$res .= $name . '</option>';
		}
	}
	return $res;
}
#
#-----[ REPLACE WITH ]----------------------------------------
#
//-- mod : new jumpbox by flashdagger --------------------------------------------------------------
//-- delete
//--------------------------------------------------------------------------------------------------
//
// get_tree_option() : return a drop down menu list of <option></option>
//
//--------------------------------------------------------------------------------------------------
//function get_tree_option($cur='', $all=false)
//{
//	global $tree, $lang;
//
//	$keys = array();
//	$keys = get_auth_keys('Root', $all);
//	$res = '';
//	for ($i=0; $i < count($keys['id']); $i++)
//	{
//		// only get object that are not forum links type
//		if ( ($tree['type'][ $keys['idx'][$i] ] != POST_FORUM_URL) || empty($tree['data'][ $keys['idx'][$i] ]['forum_link']) || $all)
//		{
//			$selected = ($cur == $keys['id'][$i]) ? ' selected="selected"' : '';
//			$res .= '<option value="' . $keys['id'][$i] . '"' .  $selected . '>';
//
//			// name
//			$name = get_object_lang($keys['id'][$i], 'name', $all);
//
//			// increment
//			$inc = '';
//			for ($k=1; $k <= $keys['real_level'][$i]; $k++)
//			{
//				$inc .= '|&nbsp;&nbsp;&nbsp;';
//			}
//			if ($keys['level'][$i] >=0) $inc .= '|--';
//			$name = $inc . $name;
//
//			$res .= $name . '</option>';
//		}
//	}
//	return $res;
//}
//-- add
//-------------------------------------------------------------------------------------------------- 
// 
// get_tree_option() : return a drop down menu list of <option></option> 
// 
//-------------------------------------------------------------------------------------------------- 
function get_tree_option($cur='', $all=false)
{
	global $tree, $lang;

	$keys = array();
	$keys = get_auth_keys('Root', $all);
	$last_level = -1;

	for ($i=0; $i < count($keys['id']); $i++)
	{
		// only get object that are not forum links type
		if ( ($tree['type'][ $keys['idx'][$i] ] != POST_FORUM_URL) || empty($tree['data'][ $keys['idx'][$i] ]['forum_link']) )
		{
			$level = $keys['real_level'][$i];

			$inc = '';
			for ($k = 0; $k < $level; $k++)
			{
				$inc .= "[*$k*]&nbsp;&nbsp;&nbsp;";
			}

			if ($level < $last_level)
			{
				//insert spacer if level goes down
				$res .='<option value="-1">' . $inc . '|&nbsp;&nbsp;&nbsp;</option>';
				// make valid lines solid
				$res = str_replace("[*$level*]", "|", $res);

				// erase all unnessecary lines
				for ($k = $level + 1; $k < $last_level; $k++)
				{
					$res = str_replace("[*$k*]", "&nbsp;", $res);
				}
            
			} elseif ($level == 0 && $last_level == -1) $res .='<option value="-1">|</option>';

			$last_level = $level;

			$selected = ($cur == $keys['id'][$i]) ? ' selected="selected"' : '';
			$res .= '<option value="' . $keys['id'][$i] . '"' .  $selected . '>';

			// name
			$name = get_object_lang($keys['id'][$i], 'name', $all);

			if ($keys['level'][$i] >=0) $res .= $inc . '|--';

			$res .= $name . '</option>';
		}
	}

	// erase all unnessecary lines
	for ($k = 0; $k < $last_level; $k++)
	{
		$res = str_replace("[*$k*]", "&nbsp;", $res);
	}

	return $res;
}
//-- fin mod : new jumpbox by flashdagger ----------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	$this = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1;
#
#-----[ REPLACE WITH ]----------------------------------------
#
	$this_key = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1;
#
#-----[ FIND ]------------------------------------------------
#
				if ( $start && ($tree['main'][$keys['idx'][$i]] == $tree['main'][$this]))
#
#-----[ REPLACE WITH ]----------------------------------------
#
				if ( $start && ($tree['main'][$keys['idx'][$i]] == $tree['main'][$this_key]))
#
#-----[ FIND ]------------------------------------------------
#
			'L_FORUM'	=> ($this < 0) ? $lang['Forum'] : get_object_lang($cur, 'name'),
#
#-----[ REPLACE WITH ]----------------------------------------
#
			'L_FORUM'	=> ($this_key < 0) ? $lang['Forum'] : get_object_lang($cur, 'name'),
#
#-----[ FIND ]------------------------------------------------
#
		if ( ($tree['type'][$this] == POST_CAT_URL) && $pull_down)
#
#-----[ REPLACE WITH ]----------------------------------------
#
		if ( ($tree['type'][$this_key] == POST_CAT_URL) && $pull_down)
#
#-----[ FIND ]------------------------------------------------
#
			$cat = $tree['data'][$this];
			$cat_id = $tree['id'][$this];
#
#-----[ REPLACE WITH ]----------------------------------------
#
			$cat = $tree['data'][$this_key];
			$cat_id = $tree['id'][$this_key];
#
#-----[ FIND ]------------------------------------------------
#
		if ( ($tree['type'][$this] == POST_FORUM_URL) || (($tree['type'][$this] == POST_CAT_URL) && !$pull_down))
#
#-----[ REPLACE WITH ]----------------------------------------
#
		if ( ($tree['type'][$this_key] == POST_FORUM_URL) || (($tree['type'][$this_key] == POST_CAT_URL) && !$pull_down))
#
#-----[ FIND ]------------------------------------------------
#
			$data	= $tree['data'][$this];
			$id		= $tree['id'][$this];
			$type	= $tree['type'][$this];
#
#-----[ REPLACE WITH ]----------------------------------------
#
			$data	= $tree['data'][$this_key];
			$id		= $tree['id'][$this_key];
			$type	= $tree['type'][$this_key];
#
#-----[ FIND ]------------------------------------------------
#
			if (($tree['type'][$this] == POST_FORUM_URL) && !empty($tree['data'][$this]['forum_link']))
#
#-----[ REPLACE WITH ]----------------------------------------
#
			if (($tree['type'][$this_key] == POST_FORUM_URL) && !empty($tree['data'][$this_key]['forum_link']))
#
#-----[ FIND ]------------------------------------------------
#
						$wlast_post  = '<a href="' . append_sid("./viewtopic.$phpEx?"  . POST_POST_URL . '=' . $wdata['tree.topic_last_post_id']) . '#' . $wdata['tree.topic_last_post_id'] . '">';
						$wlast_post .= '<img src="' . $wfolder_image . '" border="0" alt="' . $wfolder_alt . '" title="' . $wfolder_alt . '" align="middle" /></a>';
#
#-----[ REPLACE WITH ]----------------------------------------
#
						if ( $tree['type'][$wthis] == POST_FORUM_URL && (!empty($wdata['forum_link']) OR empty($wdata['tree.topic_last_post_id'])))
						{
							$wlast_post  = '<a href="' . append_sid("./viewforum.$phpEx?"  . POST_FORUM_URL . '=' . $wdata['forum_id']) . '">';
						}
						else if ($tree['type'][$wthis] == POST_CAT_URL && empty($wdata['tree.topic_last_post_id']))
						{
							$wlast_post  = '<a href="' . append_sid("index.$phpEx?"  . POST_CAT_URL . '=' . $wdata['cat_id']) . '">';
						}
						else
						{
							$wlast_post  = '<a href="' . append_sid("./viewtopic.$phpEx?"  . POST_POST_URL . '=' . $wdata['tree.topic_last_post_id']) . '#' . $wdata['tree.topic_last_post_id'] . '">';
						}
						$wlast_post .= '<img src="' . $wfolder_image . '" border="0" alt="' . $wfolder_alt . '" title="' . $wfolder_alt . '" align="middle" /></a>';
#
#-----[ FIND ]------------------------------------------------
#
			if (($tree['type'][$this] == POST_FORUM_URL) && !empty($tree['data'][$this]['forum_link']))
#
#-----[ REPLACE WITH ]----------------------------------------
#
			if (($tree['type'][$this_key] == POST_FORUM_URL) && !empty($tree['data'][$this_key]['forum_link']))
#
#-----[ FIND ]------------------------------------------------
#
				if ($tree['data'][$this]['forum_link_hit_count'])
#
#-----[ REPLACE WITH ]----------------------------------------
#
				if ($tree['data'][$this_key]['forum_link_hit_count'])
#
#-----[ FIND ]------------------------------------------------
#
					$s_hit_count = sprintf($lang['Forum_link_visited'], $tree['data'][$this]['forum_link_hit']);
#
#-----[ REPLACE WITH ]----------------------------------------
#
					$s_hit_count = sprintf($lang['Forum_link_visited'], $tree['data'][$this_key]['forum_link_hit']);
#
#-----[ FIND ]------------------------------------------------
#
		if ($tree['type'][$this] == POST_FORUM_URL)
#
#-----[ REPLACE WITH ]----------------------------------------
#
		if ($tree['type'][$this_key] == POST_FORUM_URL)
#
#-----[ FIND ]------------------------------------------------
#
		if ( ($tree['type'][$this] == POST_CAT_URL) && $pull_down)
#
#-----[ REPLACE WITH ]----------------------------------------
#
		if ( ($tree['type'][$this_key] == POST_CAT_URL) && $pull_down)
#
#-----[ FIND ]------------------------------------------------
#
				$remplacement_word = array();
#
#-----[ REPLACE WITH ]----------------------------------------
#
				$replacement_word = array();
#
#-----[ FIND ]------------------------------------------------
#
				$remplacement_word = array();
#
#-----[ REPLACE WITH ]----------------------------------------
#
				$replacement_word = array();
#
#-----[ FIND ]------------------------------------------------
#
	$this = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1;
#
#-----[ REPLACE WITH ]----------------------------------------
#
	$this_key = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1;
#
#-----[ FIND ]------------------------------------------------
#
	while (($this >= 0) || ($fcur != ''))
#
#-----[ REPLACE WITH ]----------------------------------------
#
	while (($this_key >= 0) || ($fcur != ''))
#
#-----[ FIND ]------------------------------------------------
#
		$type = (substr($fcur, 0, 1) != '') ? substr($cur, 0, 1) : $tree['type'][$this];
#
#-----[ REPLACE WITH ]----------------------------------------
#
		$type = (substr($fcur, 0, 1) != '') ? substr($cur, 0, 1) : $tree['type'][$this_key];
#
#-----[ FIND ]------------------------------------------------
#
				$param_value	= $tree['id'][$this];
#
#-----[ REPLACE WITH ]----------------------------------------
#
				$param_value	= $tree['id'][$this_key];
#
#-----[ FIND ]------------------------------------------------
#
				$param_value	= $tree['id'][$this];
#
#-----[ REPLACE WITH ]----------------------------------------
#
				$param_value	= $tree['id'][$this_key];
#
#-----[ FIND ]------------------------------------------------
#
			$cur = $tree['main'][$this];
#
#-----[ REPLACE WITH ]----------------------------------------
#
			$cur = $tree['main'][$this_key];
#
#-----[ FIND ]------------------------------------------------
#
		$this = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1;
#
#-----[ REPLACE WITH ]----------------------------------------
#
		$this_key = isset($tree['keys'][$cur]) ? $tree['keys'][$cur] : -1;
#
#-----[ OPEN ]------------------------------------------------
#
includes/usercp_register.php
#
#-----[ FIND ]------------------------------------------------
#
				$message = $lang['Profile_updated'] . '<br /><br />' . sprintf($lang['Click_return_index'],  '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
			}
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : cache -----------------------------------------------------------------------------------
//-- add
			// the username may have changed
			users_stats();
			cache_birthday();
//-- fin mod : cache -------------------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
includes/cache_tpls/def_smilies_def.tpl
#
#-----[ FIND ]------------------------------------------------
#
 *	version			: 1.0.0 - 15/12/2003
#
#-----[ REPLACE WITH ]----------------------------------------
#
 *	version			: 1.0.1 - 16/01/2004
#
#-----[ FIND ]------------------------------------------------
#
	<!-- END smilies -->
#
#-----[ REPLACE WITH ]----------------------------------------
#
	<!-- END cache_row -->
#
#-----[ OPEN ]------------------------------------------------
#
language/lang_english/lang_extend_categories_hierarchy.php
#
#-----[ FIND ]------------------------------------------------
#
 *	version				: 1.0.1 - 10/11/2003
#
#-----[ REPLACE WITH ]----------------------------------------
#
 *	version				: 1.0.2 - 23/06/2004
#
#-----[ FIND ]------------------------------------------------
#
$lang['Forum_link']					= 'Link redirection';
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
$lang['Category_locked'] = 'This category is locked: you cannot post, reply to, or edit topics.';
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoM