##############################################################
## MOD Title: 		Zero duplicate 0.4.6 => 0.4.8 update
## MOD Author: 		dcz <n/a> http://www.phpbb-seo.com/
## MOD Description: 	This are the update steps for the phpBB SEO Zero duplicate 0.4.6 => 0.4.8 update.
## 			Check http://www.phpbb-seo.com/boards/phpbb3-zero-duplicate/phpbb3-seo-zero-duplicate-vt1220.html
## 			for the latest version or to get help with this MOD
##
## MOD Version: 	1.0
##
## Installation Level: 	Eazy
## Installation Time: 	5 Minutes
## Files To Edit: 	3
##			index.php,
##			viewforum.php,
##			viewtopic.php.
##
## Included Files: n/a
##############################################################
## Author Notes:
## _____________
##
## This are the update steps for the phpBB3 SEO Zero duplicate 0.4.6 => 0.4.8 update.
##
##############################################################
## MOD History:
##
##	2008-12-22 - 1.0
##		- First version released
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################


#
#-----[ DIY INSTRUCTIONS ]--------------------------------------------------
#
_________________________________________
>>>>   INSTALLATION INSTRUCTIONS    <<<<<
_________________________________________

This update procedure is very easy and should not cause problem.

#
#-----[ OPEN ]------------------------------------------
#

index.php

#
#-----[ FIND ]------------------------------------------
#
	'mark' => array('val' => $seo_mark, 'keep' => $keep_mark),
	'hash' => array('val' => request_var('hash', ''), 'keep' => $keep_mark),
#
#-----[ REPLACE WITH ]------------------------------------------
#
	'hash' => array('val' => request_var('hash', ''), 'keep' => $keep_mark),
	'mark' => array('val' => $seo_mark, 'keep' => $keep_mark),

#-----[ OPEN ]------------------------------------------
#

viewforum.php

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

$phpbb_seo->seo_opt['zero_dupe']['redir_def'] = array(
	'uid' => array('val' => request_var('uid', 0), 'keep' => $keep_hash),
	'f' => array('val' => $forum_id, 'keep' => true, 'force' => true),
	'st' => array('val' => $sort_days, 'keep' => true),
	'sk' => array('val' => $sort_key, 'keep' => true),
	'sd' => array('val' => $sort_dir, 'keep' => true),
	'mark' => array('val' => $mark_read, 'keep' => $keep_mark),
	'watch' => array('val' => $seo_watch, 'keep' => $keep_watch),
	'unwatch' => array('val' => $seo_unwatch, 'keep' => $keep_unwatch),
	'start' => array('val' => $phpbb_seo->seo_opt['zero_dupe']['start'], 'keep' => true),
	'hash' => array('val' => request_var('hash', ''), 'keep' => $keep_hash),
);

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

$seo_uid = max(0, request_var('uid', 0));
$phpbb_seo->seo_opt['zero_dupe']['redir_def'] = array(
	'uid' => array('val' => $seo_uid, 'keep' => (boolean) ($keep_hash && $seo_uid) ),
	'hash' => array('val' => request_var('hash', ''), 'keep' => $keep_hash),
	'f' => array('val' => $forum_id, 'keep' => true, 'force' => true),
	'st' => array('val' => $sort_days, 'keep' => true),
	'sk' => array('val' => $sort_key, 'keep' => true),
	'sd' => array('val' => $sort_dir, 'keep' => true),
	'mark' => array('val' => $mark_read, 'keep' => $keep_mark),
	'watch' => array('val' => $seo_watch, 'keep' => $keep_watch),
	'unwatch' => array('val' => $seo_unwatch, 'keep' => $keep_unwatch),
	'start' => array('val' => $phpbb_seo->seo_opt['zero_dupe']['start'], 'keep' => true),
);
if ($seo_uid) { // Reorder vars a bit as required
	// Note : watch and unwatch cases could just not be handled by the zero dupe (no redirect at all when used),
	// but the handling as well acts as a poweful security shield so, it's worth it ;)
	$_hash_tmp = $phpbb_seo->seo_opt['zero_dupe']['redir_def']['hash'];
	unset($phpbb_seo->seo_opt['zero_dupe']['redir_def']['hash']);
	$phpbb_seo->seo_opt['zero_dupe']['redir_def']['hash'] = $_hash_tmp; 
} else {
	unset($phpbb_seo->seo_opt['zero_dupe']['redir_def']['uid']);
}

#
#-----[ OPEN ]------------------------------------------
#

viewtopic.php

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

if ( $post_id && !$phpbb_seo->set_do_redir_post()) {

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

if ( $post_id && !$view && !$phpbb_seo->set_do_redir_post()) {

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

	$phpbb_seo->seo_opt['zero_dupe']['redir_def'] = array(
		'uid' => array('val' => request_var('uid', 0), 'keep' => $keep_hash),
		'f' => array('val' => $forum_id, 'keep' => true, 'force' => true),
		't' => array('val' => $topic_id, 'keep' => true, 'force' => true),
		'p' => array('val' => $post_id, 'keep' =>  ($view == 'show' ? true : false)),
		'watch' => array('val' => $seo_watch, 'keep' => $keep_watch),
		'unwatch' => array('val' => $seo_unwatch, 'keep' => $keep_unwatch),
		'bookmark' => array('val' => $seo_bookmark, 'keep' => (boolean) ($user->data['is_registered'] && $config['allow_bookmarks'] && $seo_bookmark)),
		'start' => array('val' => $phpbb_seo->seo_opt['zero_dupe']['start'], 'keep' => true, 'force' => true),
		'hash' => array('val' => request_var('hash', ''), 'keep' => $keep_hash),
		'st' => array('val' => $sort_days, 'keep' => true),
		'sk' => array('val' => $sort_key, 'keep' => true),
		'sd' => array('val' => $sort_dir, 'keep' => true),
		'view' => array('val' => $view, 'keep' => $view == 'print' ? (boolean) $auth->acl_get('f_print', $forum_id) : ($view == 'viewpoll' ? true : false)),
		'hilit' => array('val' => (($highlight_match) ? $highlight : ''), 'keep' => (boolean) !(!$user->data['is_registered'] && $phpbb_seo->seo_opt['rem_hilit'])),
	);

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

	$seo_uid = max(0, request_var('uid', 0));
	$phpbb_seo->seo_opt['zero_dupe']['redir_def'] = array(
		'uid' => array('val' => $seo_uid, 'keep' => (boolean) ($keep_hash && $seo_uid)),
		'f' => array('val' => $forum_id, 'keep' => true, 'force' => true),
		't' => array('val' => $topic_id, 'keep' => true, 'force' => true),
		'p' => array('val' => $post_id, 'keep' =>  ($view == 'show' ? true : false)),
		'watch' => array('val' => $seo_watch, 'keep' => $keep_watch),
		'unwatch' => array('val' => $seo_unwatch, 'keep' => $keep_unwatch),
		'bookmark' => array('val' => $seo_bookmark, 'keep' => (boolean) ($user->data['is_registered'] && $config['allow_bookmarks'] && $seo_bookmark)),
		'start' => array('val' => $phpbb_seo->seo_opt['zero_dupe']['start'], 'keep' => true, 'force' => true),
		'hash' => array('val' => request_var('hash', ''), 'keep' => $keep_hash),
		'st' => array('val' => $sort_days, 'keep' => true),
		'sk' => array('val' => $sort_key, 'keep' => true),
		'sd' => array('val' => $sort_dir, 'keep' => true),
		'view' => array('val' => $view, 'keep' => $view == 'print' ? (boolean) $auth->acl_get('f_print', $forum_id) : (($view == 'viewpoll' || $view == 'show') ? true : false)),
		'hilit' => array('val' => (($highlight_match) ? $highlight : ''), 'keep' => (boolean) !(!$user->data['is_registered'] && $phpbb_seo->seo_opt['rem_hilit'])),
	);
	if ($phpbb_seo->seo_opt['zero_dupe']['redir_def']['bookmark']['keep']) { // Prevent unessecary redirections
		// Note : bookmark, watch and unwatch cases could just not be handled by the zero dupe (no redirect at all when used),
		// but the handling as well acts as a poweful security shield so, it's worth it ;)
		unset($phpbb_seo->seo_opt['zero_dupe']['redir_def']['start']);
	}

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
