<?php

include "mainfile.php";

// security check
if( ! isset( $_SESSION['AUTOLOGIN_REQUEST_URI'] ) ) exit ;

// get URI
$url = $_SESSION['AUTOLOGIN_REQUEST_URI'] ;
unset( $_SESSION['AUTOLOGIN_REQUEST_URI'] ) ;
if( preg_match('/javascript:/si', $url) ) exit ; // black list of url
$url4disp = preg_replace("/&amp;/i", '&', htmlspecialchars($url, ENT_QUOTES));


if( isset( $_SESSION['AUTOLOGIN_POST'] ) ) {

	// posting confirmation

	$old_post = $_SESSION['AUTOLOGIN_POST'] ;
	unset( $_SESSION['AUTOLOGIN_POST'] ) ;

	$hidden_str = '' ;
	foreach( $old_post as $k => $v ) {
		$hidden_str .= "\t".'      <input type="hidden" name="'.htmlspecialchars($k,ENT_QUOTES).'" value="'.htmlspecialchars($v,ENT_QUOTES).'" />'."\n" ;
	}

	echo '
	<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset='._CHARSET.'" />
	<title>'.$xoopsConfig['sitename'].'</title>
	</head>
	<body>
	<div style="text-align:center; background-color: #EBEBEB; border-top: 1px solid #FFFFFF; border-left: 1px solid #FFFFFF; border-right: 1px solid #AAAAAA; border-bottom: 1px solid #AAAAAA; font-weight : bold;">
	  <h4>'._RETRYPOST.'</h4>
	  <form action="'.$url4disp.'" method="POST">
	  '.$hidden_str.'
	    <input type="submit" name="timeout_repost" value="'._SUBMIT.'" />
	  </form>
	</div>
	</body>
	</html>
	' ;
	exit ;

} else {

	// just redirecting

	$time = 1 ;
	// $message = empty( $message ) ? _TAKINGBACK : $message ;
	$message = _TAKINGBACK ;

	echo '
	<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset='._CHARSET.'" />
	<meta http-equiv="Refresh" content="'.$time.'; url='.$url4disp.'" />
	<title>'.$xoopsConfig['sitename'].'</title>
	</head>
	<body>
	<div style="text-align:center; background-color: #EBEBEB; border-top: 1px solid #FFFFFF; border-left: 1px solid #FFFFFF; border-right: 1px solid #AAAAAA; border-bottom: 1px solid #AAAAAA; font-weight : bold;">
	  <h4>'.$message.'</h4>
	  <p>'.sprintf(_IFNOTRELOAD, $url4disp).'</p>
	</div>
	</body>
	</html>
	' ;
	exit ;

}

?>