<?php

//当前 APPID
$appid = Module :: get_appid();

//加载模块配置及函数包
require("config.php");
require_once("setting.php");
require_once("function.php");

////////////////////////////////

$cur=GetCurFile();

$set = '
<li><a href="adsview.edit.php" ext-hash="true">新增广告</a></li>
<li><a href="adsview.list.php" ext-hash="true">管理广告</a></li>
<li><a href="adsarea.list.php" rel="adsarea.edit.php|adsarea.list.php|adsarea.channel.php" ext-hash="true">广告位</a></li>
<!--li><a href="adsarea.edit.php" ext-hash="true">广告位添加</a></li-->
<!--li><a href="adsarea.calendar.php" ext-hash="true">广告位排期</a></li-->
<!--li><a href="adsarea.list.php" ext-hash="true">广告位管理</a></li-->
<!--li><a href="adsarea.channel.php" ext-hash="true">频道</a></li-->
<li><a href="adsview.value.php" ext-hash="true">报告</a></li>
';
	
if( file_exists("adstrade.list.php") ) $set .= '<li><a href="adstrade.list.php" rel="adstrade.edit.php" ext-hash="true">订单</a></li>'.chr(13);
if( file_exists("api.php") ) $set .= '<li><a href="api.php" ext-hash="true">API</a></li>'.chr(13);
	
//公共菜单
switch($cur){
	
	case "adsview.list.php":
	
		//连接数据库
		System :: connect();
		
		$nav='	<a href="?sel=">全部广告</a> | <a href="?sel=normal">在播广告 ('. Adsview :: count('normal') .')</a> | <a href="?sel=last">'.$_G['setting'][$appid]["expire"].'天内到期广告 ('. Adsview :: count('last') .')</a> | <a href="?sel=expire">过期广告 ('. Adsview :: count('expire') .')</a>  | <a href="?sel=stop">停播广告 ('. Adsview :: count('stop') .')</a><!-- | <a href="?sel=engage">预定广告</a> | <a href="?sel=expire-engage">过期预定</a-->';
		
		//关闭数据库
		System :: connect();
		
	break;
	
	case "adsview.value.php":
	
		$nav='	<a href="?start=&end=">全部广告</a> | <a href="?start='.date("Y-m-d").'&end='.date("Y-m-d").'">今日广告</a> | <a href="?start='.date("Y-m-d", time() - 3600*24 ).'&end='.date("Y-m-d", time() - 3600*24 ).'">昨日广告</a> | <a href="?start='.date("Y-m-d", time() - 3600*24*7 ).'&end='.date("Y-m-d", time() ).'">7天内的广告</a> | <a href="?start='.date("Y-m-d", time() - 3600*24*30 ).'&end='.date("Y-m-d", time() ).'">30天内的广告</a>  | <a href="?start='.(date("Y")-1).'-'.date("m-d").'&end='.date("Y-m-d", time() ).'">1年内的广告</a>';
		
	break;
	
	case "adsview.top.php":
		$nav='	<a href="?sel=">全部位置</a> | <a href="?sel=order-click-ratio">点击率排行 ↑</a> | <a href="?sel=order-click-ratio-asc">点击率倒排 ↓</a> | <a href="?sel=order-click">点击排行 ↑</a> | <a href="?sel=order-click-asc">点击倒排 ↓</a> | <a href="?sel=order-view">展示排行 ↑</a> | <a href="?sel=order-view-asc">展示倒排 ↓</a>';
	break;
	
	/*
	case "adsarea.list.php":
		$nav='	<a href="?sel=">全部位置</a> | <a href="?sel=free">空闲位置</a> | <a href="?sel=full">已满位置</a> | <a href="?sel=space">零广告位置</a> | <a href="?sel=zero">零预定位置</a> | <a href="?sel=engage">被预定位置</a> | <a href="?sel=expire">快到期位置</a>';
	break;
	*/
	
	case "adsarea.edit.php":
	case "adsarea.list.php":
	case "adsarea.channel.php":
		$nav='	<a href="adsarea.edit.php">新增</a> | <a href="adsarea.list.php">广告位</a> | <a href="adsarea.channel.php">频道</a>';
	break;
	
	case "adstrade.list.php":
		$nav='<a class="action" href="content/" target="_blank">营销中心&raquo;</a>	<a href="?sel=">全部</a> | <a href="?sel=0">未处理</a> | <a href="?sel=1">处理中</a> | <a href="?sel=2">已处理</a> | <a href="?sel=3">无效</a>';
	break;
	
}
?>

 <!--ul id="setp">
	<li><span>1</span><a href="adsarea.edit.php">添加频道</a></li>
	<li><span>2</span><a href="adsarea.edit.php?model=box">添加广告位</a></li>
	<li><span>3</span><a href="adsview.edit.php">添加广告</a></li>
	<li><span>4</span><a href="adsarea.list.php">获取广告代码</a></li>
</ul>

<div id="nav">
	<strong>广告系统</strong> 
	( 
	<a onclick="parent.Mo.Window('window','广告系统使用说明' ,'http://www.veryide.com/archive.php?id=5' ,940,800,{});">使用教程</a>
	 )
</div-->

<?php

echo '<ul id="naver">';
	echo $set;
echo '</ul>';

if($nav){
	//高亮当前链接
	$nav=str_replace( 'href="?sel='.$_GET["sel"].'"' , ' class="active" ' , $nav);

	//高亮当前链接
	$nav=str_replace( 'href="?start='.$_GET["start"].'&end='.$_GET["end"].'"' , ' class="active" ' , $nav);

	//高亮当前链接
	$nav=str_replace( 'href="'.$cur.'"' , ' class="active" ' , $nav);

	echo '<div id="subnav">';
		echo $nav;
	echo '</div>';
}

?>