<?php
require("../../config/config.php");
require("../../config/version.php");
require("../../function/system.php");
require("../../function/library.php");
require("../../function/cache.php");

require("config.php");
require("function.php");	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $Project["charset"];?>" />
<title>广告预览</title>
<?php    
echo loader_script(array(VI_BASE."js/mo.js",VI_BASE."js/mo.flash.js",$Modules["adsview"]["manager"]),$Project["charset"],$Project["version"]);    
?>

<script type='text/javascript'>
//调试模式
VAD.debug = true;

Mo.reader(function(){

    //设置框架
    try{
        if( self.location != top.location ){
            parent.Mo("#iframe").style( {"height" : document.body.scrollHeight + 20 + "px"} );
        }
    }catch(e){
    
    }	

});

</script>    
</head>

<body style=" text-align:center;">
    
    <div>    
    
	<?php
	$action = GetQuery("action");
	
	switch( $action ){
	
		//广告预览
		case "ad":
		
			$id = GetQuery("id");
		
			loader_cache($appid,"adsview.".$id);
		
			if ($VICACHE["mod.adsview"]["form"]){
				$str=$VICACHE["mod.adsview"]["script"];
			}else{
				
				$file_type=fileext($VICACHE["mod.adsview"]["file"]);
				
				$config = json_decode($VICACHE["mod.adsview"]["config"],true);
				
				if($VICACHE["mod.adsview"]["file"]){
					if ($file_type=="swf"){
						$str='Mo.Flash("id","'.$t_key.'","width","'.$VICACHE["mod.adsview"]["width"].'","height","'.$VICACHE["mod.adsview"]["height"].'","src","'.str_replace(".swf","",$VICACHE["mod.adsview"]["file"]).'","quality","high");';
					}else{
						$str='VAD.$V(\'<a href="'.$VICACHE["mod.adsview"]["link"].'" target="_blank"><img src="'.$VICACHE["mod.adsview"]["file"].'" alt="'.$VICACHE["mod.adsview"]["name"].'" width="'.$VICACHE["mod.adsview"]["width"].'" height="'.$VICACHE["mod.adsview"]["height"].'" style="'.(isset($config["SHOW-STYLE"])?$config["SHOW-STYLE"]:'').'" /></a>\')';
					}
				}else{
					$str='VAD.$V(\'<a href="'.$VICACHE["mod.adsview"]["link"].'" target="_blank"><font style="'.$VICACHE["mod.adsview"]["style"].'">'.$VICACHE["mod.adsview"]["name"].'</font></a>\')';
				}
			}
			
			echo '<script type="text/javascript">'.stripcslashes($str).'</script>';
		
		break;
	
		//广告位预览
		case "channel":
			$key = GetQuery("key");
			$show = GetNumber("show",0);
		
			echo '<script type="text/javascript" src="content/?action=proxy&key='.$key.'&charset=utf-8"></script>';
			
			//对联广告
			if( $show == 3 ){
			
				for( $i=0; $i<50; $i++ ){
					echo '<p>&nbsp;</p>';	
				}
			
			}
		
		break;
		
		//API
		case "api":
		
			$var = "?";
			foreach( $_GET as $key => $val ){				
				$var .= $key."=".urlencode(stripcslashes($val))."&";				
			}
		
			echo '<script type="text/javascript" src="content/api.php'.$var.'"></script>';
		
		break;
		
	}
	
	/*
	echo ("<script type='text/javascript' src='".(str_replace("adsview.js","adsview.min.js",$Modules["adsview"]["manager"]))."'></script>");
	*/
	?>
    
    </div>

</body>
</html>