<?php

//载入全局配置和函数包
require '../../include/global.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 $_G['product']['charset'];?>" />
<title>广告预览</title>
<?php    
echo loader_script(array(VI_BASE."js/mo.js",VI_BASE."js/mo.flash.js","content/adsview.js"),$_G['product']['charset'],$_G['product']['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 = getgpc('action');
	
	switch( $action ){
	
		//广告预览
		case "ad":
		
			$id = getgpc("id");
		
			Cached :: loader($appid,"adsview.".$id);
		
			//代码广告
			if ( $_CACHE['adsview']['adsview']["form"] ){
				
				$str = addslashes($_CACHE['adsview']['adsview']["script"]);
				
			}else{
				
				$file_type = fileext($_CACHE['adsview']['adsview']["file"]);
				
				$config = fix_json( $_CACHE['adsview']['adsview']["config"] );
				
				if($_CACHE['adsview']['adsview']["file"]){
					
					//flash
					if ($file_type=="swf"){
						
						$str='Mo.Flash("id","'.$t_key.'","width","'.$_CACHE['adsview']['adsview']["width"].'","height","'.$_CACHE['adsview']['adsview']["height"].'","src","'.str_replace(".swf","",$_CACHE['adsview']['adsview']["file"]).'","quality","high");';
						
					}else{
						
						$str='VAD.$V(\'<a href="'.$_CACHE['adsview']['adsview']["link"].'" target="_blank"><img src="'.$_CACHE['adsview']['adsview']["file"].'" alt="'.$_CACHE['adsview']['adsview']["name"].'" width="'.$_CACHE['adsview']['adsview']["width"].'" height="'.$_CACHE['adsview']['adsview']["height"].'" style="'.(isset($config["SHOW-STYLE"])?$config["SHOW-STYLE"]:'').'" /></a>\')';
						
					}
					
				}else{
					$str='VAD.$V(\'<a href="'.$_CACHE['adsview']['adsview']["link"].'" target="_blank"><font style="'.$_CACHE['adsview']['adsview']["style"].'">'.$_CACHE['adsview']['adsview']["name"].'</font></a>\')';
				}
			}
			
			echo '<script type="text/javascript">'.stripcslashes($str).'</script>';
		
		break;
	
		//广告位预览
		case "channel":
			$key = getgpc('key');
			$show = getnum("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",$_G['module']['adsview']["manager"]))."'></script>");
	*/
	?>
    
    </div>

</body>
</html>