<?php
	/**************************************************************************\
	* phpGroupWare - Session safe redirect                                     *
	* http://www.phpgroupware.org                                              *
	* Idea by: Jason Wies <jason@xc.net>                                       *
	* Poor implementation by: Lars Kneschke <lkneschke@linux-at-work.de>       *
	* Proper Implementation by: Dave Hall skwashd at phpgroupware.org	   *
	* Copyright (c) 2004 Free Software Foundation Inc - http://www.fsf.org/	   *
	* --------------------------------------------                             *
	*  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.                                              *
	\**************************************************************************/
	
	/* $Id: redirect.php,v 1.1.4.1 2004/09/03 10:24:17 skwashd Exp $ */

	//Get the session variables set for non cookie based sessions
	if (! (@isset($_COOKIES['PHPSESSID']) || @isset($_COOKIES['sessionid']) ) )
	{
		$get = array();
		$url = parse_url($_SERVER['HTTP_REFERER']);
		parse_str($url['query'], $get);
		foreach($get as $key => $val)
		{
			$_GET[$key] = $val;
		}

	}

	$GLOBALS['phpgw_info']['flags'] = array(
					'currentapp'	=> 'home',
					'noheader'	=> True,
					'nonavbar'	=> True,
					'noappheader'	=> True,
					'noappfooter'	=> True,
					'nofooter'	=> True
					);

	require_once('./header.inc.php');

	if( @isset($_GET['go']) )
	{
		$_GET['go'] = html_entity_decode($_GET['go']);
		?>
			<h2><?php lang('external link'); ?></h2>
			<p><?php lang('lang you are about to visit an external site'); ?><br />
			<?php lang('vist:'); ?> <a href="<?php echo $_GET['go']; ?>" 
				target="_blank"><?php echo $_GET['go']; ?></a></p>
			<script>window.location='<?php echo$_GET['go']; ?>';</script>
		<?php
	        exit;
	}
	else
	{
		
		$GLOBALS['phpgw_info']['flags']['header']	= True;
		$GLOBALS['phpgw_info']['flags']['navbar']	= True;
		$GLOBALS['phpgw_info']['flags']['footer']	= True;
		
		$GLOBALS['phpgw']->common->phpgw_header();
		echo parse_navbar();
		
		echo '<h2>' . lang('invalid link') . "</h2>\n"
			. '<p><a href="' . $GLOBALS['phpgw']->link('/index.php') 
			. lang('return to phpgroupware') . "\"></p>\n";
	}
?>
