<?php

/*
*	Copyright VeryIDE,2007-2010
*	http://www.veryide.com/
*
*	2011/6/5 Lay
*/

//载入全局配置和函数包
require '../../include/global.php';

//module
require 'config.php';
require 'function.php';

$keys = $_GET["keys"];

$hash = unserialize(authcrypt( $keys, VI_START, 'decode' ));

$out  = $_GET["out"];

//验证数据
if( is_array($hash) ){	
		
	//加载缓存
	Cached :: loader( $hash['appid'], "form.".$hash['fid'] );
	
	//解析配置
	$config = $_CACHE[ $hash['appid'] ]['form']["config"];
		
	$base = array();
	
	//处理扩展项
	foreach( $config as  $key => $val ){
		if( ( strpos($key,"ANY_") !== false || strpos($key,"REG-") !== false ) && $val == "Y" ){
			$base[ strtolower( str_replace( array("ANY_","REG-"), array('',''), $key ) ) ] = "Y";
		}
	}
	
}

if( $out == "true" && time() - $hash['expire'] < $_G['setting']['global']['expire'] ){
	
	//关闭压缩
	ob_end_clean();
	
	//开启缓冲
	ob_start();
	
	Member :: getReport( $hash['appid'], $hash['fid'], $base );
	
	exit();
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $_G['product']['charset'];?>" />
<title>分享数据 - Powered By VeryIDE</title>
<?php
echo loader_style(VI_BASE."style/share.css","utf-8",$_G['product']['version']);
echo loader_script(array(VI_HOST."js/mo.js",VI_HOST."js/serv.share.js"),"utf-8",$_G['product']['version']);
?>
</head>

<body>

	<div id="wrapper" class="<?php echo getcookie('toggle');?>">
    
    	<div id="header">
			<div id="toggle"></div>
        	<h2>分享数据</h2>		
        </div>
        
        <div id="main">
        	
		<?php
			
		if( !is_array($hash) ){
			
			echo ' <p>无效链接！</p>';
			
		}elseif( time() - $hash['expire'] > $_G['setting']['global']['expire'] ){
			
			echo '<p>已过期链接！</p>';
			
		}else{
		?>
		
		<p style="float:right; text-align:right;">
			<button type="button" class="save" onclick="location.href=location.href+'&out=true';" title="立即下载"></button>
			<br />
			<em>下载及查看有效期：<?php echo date("Y-m-d",$hash['expire']+$_G['setting']['global']['expire']);?></em>
		</p>
		<p>数据名称：<strong><?php echo $hash['name'];?></strong></p>
		<p>活动时间：<strong><?php echo date("Y-m-d",$_CACHE[ $hash['appid'] ]['form']["start"]);?> 至 <?php echo date("Y-m-d",$_CACHE[ $hash['appid'] ]['form']["expire"]);?></strong></p>
		<p></p>
                
		<?php
			if( $_G['licence']['type'] != 'free' ) include("include.share.php");
		}

		?>

        </div>
        
        <div id="adsense">        
        	<?php echo $_G['adsense']["share"];?>        
        </div>
    
    	<div id="footer">
			<?php echo $_G['project']['powered'];?>
            <?php echo $_G['product']['appname'];?>
            <?php echo $_G['product']['version'];?>
        </div>
    
    
    </div>

</body>
</html>