<%@language=vbscript codepage=936%>
<%
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
dim dns
dns="../"
%>
<!--#Include file="../Common/Inc_DatConn.asp"-->
<!--#Include file="Common/Inc_Config.asp"-->
<!--#Include file="Common/Inc_Function.asp"-->
<!--#Include file="fy_admin_check.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/Admin_Style.Css" rel="stylesheet" type="text/css">
<script src="../common/Admin.js" type="text/javascript"></script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border">
  <tr class="title"> 
    <td height="22" colspan="2" align="center"><strong>广告管理</strong></td>
  </tr>
  <tr class="tdbg"> 
    <td width="70" height="30"><strong>管理导航：</strong></td>
    <td height="30"><a href="ad.asp">全部列表</a> 
      | <a href="?action=stop">过期广告</a> 
      | <a href=?bbaction=add><font color="#0000FF">添加新广告</font></a> | <a href=?bbaction=code>使用说明</a></td>
  </tr>
</table>
<%
if fla27<>1 and Session("intUserLevel")<2 then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>错误：操作权限出错，您没有权限操作些功能！</li>"
Call Admin_ShowErr(ErrMsg)
end if
bbaction=changechr(request("bbaction"))
Select case bbaction
  	Case "add"
		call add
 	Case "saveaddad"
		call saveaddad
 	Case "code"
		call code
 	Case "editad"
		call editad
 	Case "saveeditad"
		call saveeditad
 	Case "delad"
		call delad
 	Case "jsad"
		call jsad
	Case else
%>
<br>
<%
Dim pagesize,rs,sql,curpage,strcate,i
Dim id,ADID,ADViews,ADHits,ADType,ADSrc,ADLink,ADAlt,ADWidth,ADHeight,ADNote,ADStopViews,ADStopHits,ADStopDate

pagesize=10		'设置每页显示广告树目

If Request.QueryString("page")="" Then
  	curpage = 1
Else
	curpage = cint(Request.QueryString("page"))
End If

Set rs = Server.CreateObject("ADODB.Recordset")
if Request.QueryString("action")="stop" then
if is_sqldata=0  then
sql = "SELECT * FROM [ad] where ( ADStopViews <> 0 and ADViews > ADStopViews) or ( ADStopHits <> 0 and ADHits > ADStopHits) or ( DateDiff('d',Now(),ADStopDate)<1 ) ORDER BY id DESC"
else
	sql = "SELECT * FROM [ad] where ( ADStopViews <> 0 and ADViews > ADStopViews) or ( ADStopHits <> 0 and ADHits > ADStopHits) or ( DateDiff(day,GetDate(),ADStopDate)<1 ) ORDER BY id DESC"
end  if
Else
	sql = "SELECT * FROM [ad] ORDER BY id DESC"
end If
rs.open sql, conn, 1, 1

If rs.bof or rs.eof Then
	rs.Close
	if Request.QueryString("action")="stop" Then
	%>
<table width="60%" height="200" border="0" align="center" cellpadding="0" cellspacing="1">
  <tr>
    <td align="center"><font color="#990000">暂时没有过期广告！</font></td>
  </tr>
</table>
	<%Else%>
<table width="60%" height="200" border="0" align="center" cellpadding="0" cellspacing="1">
  <tr class="tdbg">
    <td align="center">暂时没有任何广告！-- <a href=?bbaction=add>立即添加新广告</a></td>
  </tr>
</table>
	<%
	End If
	Response.End
End If

rs.pagesize = pagesize
rs.absolutepage = curpage
%>
	<div align="center">
      <table width='100%' border="0" cellpadding=3 cellspacing=1 class="border">
        <% Do While NOT rs.eof 
		id=rs("id")
		ADID=rs("ADID")
		ADViews=rs("ADViews")
		ADHits=rs("ADHits")
		ADType=rs("ADType")
		ADSrc=rs("ADSrc")
		ADLink=rs("ADLink")
		ADAlt=rs("ADAlt")
		ADSrc=rs("ADSrc")
		ADWidth=rs("ADWidth")
		ADHeight=rs("ADHeight")
		ADNote=rs("ADNote") 
		ADStopViews=rs("ADStopViews")
		ADStopHits=rs("ADStopHits")
		ADStopDate=rs("ADStopDate")%>
        <tr class="title"> 
          <td width="20%" height="25">名称：<%=ADID%> <%if IsStop(ADViews,ADStopViews,ADStopHits,ADHits,ADStopDate) Then Response.Write(" <font color=#FF0000>过期") End If%></td>
          <td width="20%">显示：<%=ADViews%></td>
          <td width="20%">点击：<%=ADHits%></td>
          <td width="40%">管理：<a href="?bbaction=editad&id=<%=id%>">编辑</a>&nbsp;&nbsp;<a href="?bbaction=jsad&id=<%=ADID%>">生成JS</a>&nbsp;&nbsp;<a href="?bbaction=delad&id=<%=id%>" onclick="{if(confirm('确定删除吗?')){return true;}return false;}">删除</a></td>
        </tr>
        <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'"> 
          <td width="50%" height="25" colspan=2>广告类型：<%=ShowAdType(ADType,rs("ADSrc"))%></td>
          <td width="50%" colspan=2>显示地址：
          <%If ADType<>6 Then%><a href=<%=ADSrc%> target=_blank><font color="#000000"><%=ADSrc%></font></a><font color="#000000"><%else%>不显示<%end if%></td>
        </tr>
        <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'"> 
          <td height="25" colspan=2>链接地址：<a href=<%=ADLink%> target=_blank><font color="#000000"><%=ADLink%></a></td>
          <td colspan=2>提示文字：<%=ADAlt%></td>
        </tr>
        <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'"> 
          <td height="25" colspan=2>广告规格：<%=ADWidth%>×<%=ADHeight%></td>
          <td colspan=2>备    注：<%=ADNote%></td>                         
        </tr>
        <% 
        i=i+1
		rs.movenext
		If i>=rs.PageSize Then Exit Do     
		Loop
		%>
		    <table width="90%"  border="0" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td>
              <div align="right">
                <%If curpage = 1 Then%>
    　 首页 上一页
      <%Else%>
      <a href='?page=1'>首页</a> <a href='?page=<%=cstr(curpage-1)%>'>上一页</a>
      <%End If
      If  curpage = rs.pagecount Then%>
      下一页 尾页&nbsp;
      <%Else%>
      <a href='?page=<%=cstr(curpage+1)%>'>下一页</a> <a href='?page=<%=cstr(rs.pagecount)%>'>尾页</a>&nbsp;
      <%End If%>
              </div></td>
      </tr>
    </table>
<%
rs.close
set rs=nothing
conn.Close
set conn=nothing

'检测是否过期
function IsStop(ADViews,ADStopViews,ADStopHits,ADHits,ADStopDate)
	IsStop=false
	If ( ADStopViews <> 0 and ADViews > ADStopViews) Then 
		IsStop=true
		Exit function
	ElseIf ( ADStopHits <> 0 and ADHits > ADStopHits) Then
		IsStop=true
		Exit function
	ElseIf ( DateDiff("d",Now(),ADStopDate)<1 ) Then	
		IsStop=true
		Exit function
	End If
end function

'判断广告类型
function ShowAdType(ADType,ADSrc)
	Dim ADExt
	ADExt="图片"
	If InStr(1,ADSrc,".swf",1)>0 Then ADExt="FLASH"
	Select Case ADType
		Case 1
			ShowAdType="普通"&ADExt
		Case 2
			ShowAdType="全屏浮动"&ADExt
		Case 3
			ShowAdType="上下浮动 - 右"&ADExt
		Case 4
			ShowAdType="上下浮动 - 左"&ADExt
		Case 5
			ShowAdType="渐隐消失"&ADExt
		Case 6
			ShowAdType="网页对话框"
		Case 7
			ShowAdType="移动透明对话框"
		Case 8
			ShowAdType="打开新窗口"
		Case 9
			ShowAdType="弹出新窗口"
		Case 10 
			ShowAdType="对联式广告"
		Case else
			ShowAdType="<font color=red><b>错误!将不能正确显示</b>"
	End Select
end function
%></TD></TR><TR><TD height=1 width="100%"></TD></TR></TABLE><%
end Select
sub add
%>
<br>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border" height="73">
  <tr class="title"> 
    <td height="22" colspan="2" align="center"><strong>添加新广告</strong></td>
  </tr><form method="post" action="?bbaction=saveaddad" name="form" onsubmit="return chkinput()">
        <tr class="tdbg">
          <td  align="right" width="80">广告&nbsp; ID：</td>
          <td>
              <INPUT name=ADID type="text" class="input1" size="10" maxlength="20"> 不能重名</td>
        </tr>
        <tr class="tdbg">
          <td align="right" width="80">广告类型：</td>
          <td>
              <select size="1" name="ADType" class="input1" onChange="ChangeType(this.options[this.selectedIndex].value)">
                <option value="1">普通显示</option>
                <option value="2">满屏浮动显示</option>
                <option value="3">上下浮动显示-右</option>
                <option value="4">上下浮动显示-左</option>
                <option value="5">全屏幕渐隐消失</option>
                <option value="6">普通网页对话框 </option>
                <option value="7">可移动透明对话框 </option>
                <option value="8">打开新窗口</option>
                <option value="9">弹出新窗口</option>
				<option value="10">对联式广告</option>
              </select></td>
        </tr>
        <tr class="tdbg">
          <td align="right" id="adsrc_text" width="80">广告地址：</td>
          <td height="17">
              <INPUT name=ADSrc type="text" class="input1" value="http://" size=30> <a href="#" onclick=openhelp("ext")>图片或FLASH地址？</a></td>
        </tr>
        <tr class="tdbg">
          <td align="right" width="80">广告规格：</td>
          <td height="17">
              <INPUT name=ADWidth type="text" class="input1" onkeypress="return Num();" value="468" size=8 maxlength=4>
              ×
              <INPUT name=ADHeight type="text" class="input1" onkeypress="return Num();" value="60" size=8 maxlength=4></td>
        </tr>
        <tr class="tdbg">
          <td align="right" width="80">链接地址：</td>
          <td height="17">
              <INPUT name=ADLink type="text" class="input1" size=30 maxlength=100></td>
        </tr>
        <tr class="tdbg">
          <td align="right" width="80">提示文字：</td>
          <td height="17">
              <INPUT name=ADAlt type="text" class="input1" size=30 maxlength=50></td>
        </tr>
        <tr class="tdbg">
          <td align="right" width="80">投放限制：</td>
          <td height="18">
            <INPUT name=ADStopViews type="text" class="input1" onkeypress="return Num();" value="0" size=7 maxlength=10>
            ·
            <INPUT name=ADStopHits type="text" class="input1" onkeypress="return Num();" value="0" size=7 maxlength=10>
            ·
            <INPUT name=ADStopDate type="text" class="input1" value="<%=date()%>" size=13 maxlength=19> <a href="#" onclick=openhelp("stop")>显示·点击·日期？</a></td>
        </tr>
        <tr class="tdbg">
          <td align="right" width="80">简单注释：</td>
          <td height="17">
              <INPUT name=ADNote type="text" class="input1" size=30 maxlength=100> 备注不显示在广告中</td>
        </tr>        <tr class="tdbg">
          <td height="12" align="right" colspan="2">
			<p align="center"><input type="submit" value="提 交" name="Submit"> <input onclick="parent.location.href='Javascript:history.back()'" type="button" value="返 回" name=button1></td>
        </tr></form>
</table>
<%
end sub
sub code
%>
<br>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border" height="73">
  <tr class="title"> 
    <td height="22" align="center"><strong>广告代码使用帮助</strong></td>
  </tr>
  <tr class="tdbg">
    <td width="99%" height="23" align="center">纯JS文件（需要使用“生成JS”功能后才可使用）</td>
  </tr>
  <tr class="tdbg">
    <td width="99%" height="23" align="center">
        <textarea name="S1" cols="80" rows="6" class="face"><!--广告代码开始-->
  <script src="<%=gqwebdir%>ad/js/广告名称.js"></script>
  <!--广告代码结束-->
      </textarea></td>
  </tr>
  <tr class="tdbg">
    <td width="99%" height="23" align="center">JS代码（ASP调用方式）</td>
  </tr>  
  <tr class="tdbg">
    <td width="99%" height="23" align="center">
      <textarea name="textarea" cols="80" rows="6" class="face"><!--广告代码开始-->
  <script src="<%=gqwebdir%>ad/js/ad.asp?adid=广告名称"></script>
<!--广告代码结束-->
      </textarea></td>
  </tr>    
        <tr class="tdbg">
          <td height="12" align="center">
			将上面代码的“广告名称”更改成，相应广告的ID。<br>
*推荐! 纯JS文件代码，不需要服务器执行，速度第一。缺点不统计显示次数。<br>
*对于普通固定显示的图片/FLASH广告，将上面的代码复制到要显示广告的位置。<br>
*对于其他类型广告复制到显示页面的任意位置即可。</td>
        </tr>    
        <tr class="tdbg">
          <td height="12" align="right">
			<p align="center">&nbsp;<input onclick="parent.location.href='Javascript:history.back()'" type="button" value="返 回" name=button1></td>
        </tr>
</table>
<%
end sub
sub editad
id=Request("id")
'打开/更新广告数据
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select ADID,ADType,ADSrc,ADHeight,ADWidth,ADLink,ADAlt,ADStopViews,ADStopHits,ADStopDate,ADNote,ADViews,ADHits from [ad] where id=" & id
rs.Open sql,conn,1,3
%>
<br><SCRIPT LANGUAGE="JavaScript" src="images/js.js"></SCRIPT>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border" height="73">
  <tr class="title"> 
    <td height="22" align="center" colspan="2"><strong>修改广告信息</strong></td>
  </tr><form name=form action=?bbaction=saveeditad&id=<%=id%>  method=post onsubmit="return chkinput()">
  <tr class="tdbg">
    <td height="25" align="right" width="80" >广告 &nbsp;ID：</td>                                                          
    <td><INPUT name=ADID type="text" class="input1" value="<%=rs("ADID")%>" size=10 maxlength=20> 不能重名</td>                                                         
  </tr>
  <tr class="tdbg">
    <td height="25" align="right" width="80" >广告类型：</td>
    <td ><select name="ADType" size="1" class="input1" onChange="ChangeType(this.options[this.selectedIndex].value)">
  <option <%If rs("ADType")=1 Then Response.Write"selected"%> value="1">普通显示</option>
  <option <%If rs("ADType")=2 Then Response.Write"selected"%> value="2">满屏浮动显示</option>
  <option <%If rs("ADType")=3 Then Response.Write"selected"%> value="3">上下浮动显示 - 右</option>
  <option <%If rs("ADType")=4 Then Response.Write"selected"%> value="4">上下浮动显示 - 左</option>
  <option <%If rs("ADType")=5 Then Response.Write"selected"%> value="5">全屏幕渐隐消失</option>
  <option <%If rs("ADType")=6 Then Response.Write"selected"%> value="6">普通网页对话框 </option>
  <option <%If rs("ADType")=7 Then Response.Write"selected"%> value="7">可移动透明对话框 </option>
  <option <%If rs("ADType")=8 Then Response.Write"selected"%> value="8">打开新窗口</option>
  <option <%If rs("ADType")=9 Then Response.Write"selected"%> value="9">弹出新窗口</option>
  <option <%If rs("ADType")=10 Then Response.Write"selected"%> value="10">对联式广告</option>
</select></td>                                                         
  </tr>
  <tr class="tdbg">
    <td height="25" align="right" id="adsrc_text" width="80">广告地址：</td>
	<td >
	<%If rs("ADType")= 6 Then
    	Response.Write ("<textarea rows=3 name=ADSrc cols=27 class=input2>"&server.HTMLencode(rs("ADSrc"))&"</textarea>")
	else%>
	<INPUT name="ADSrc" type="text" class="input1" value="<%=rs("ADSrc")%>" size=30>                                                      
	<%end if%>   
    *<a href="#" onclick=openhelp("ext") title="点击查看帮助">图片或FLASH地址？</a></td>   
  </tr>
  <tr class="tdbg">
    <td height="25" align="right" width="80" >广告规格：</td>
    <td ><INPUT name=ADWidth type="text" class="input1" onkeypress="return Num();" value="<%=rs("ADWidth")%>" size=8 maxlength=4>  
      × <INPUT name=ADHeight type="text" class="input1" onkeypress="return Num();" value="<%=rs("ADHeight")%>" size=8 maxlength=4></td>                     
  </tr>
  <tr class="tdbg">
    <td height="25" align="right" width="80" >链接地址：</td>
    <td ><INPUT name=ADLink type="text" class="input1" value="<%=rs("ADLink")%>" size=30 maxlength=150></td>                      
  </tr>
  <tr class="tdbg">
    <td height="25" align="right" width="80" >提示文字：</td>
    <td ><INPUT name=ADAlt type="text" class="input1" value="<%=rs("ADAlt")%>" size=30 maxlength=50></td>                      
  </tr>
  <tr class="tdbg">
    <td height="25" align="right" width="80" >投放限制：</td>
    <td ><INPUT name=ADStopViews type="text" class="input1" onkeypress="return Num();" value="<%=rs("ADStopViews")%>" size=8 maxlength=10>
      ·<INPUT name=ADStopHits type="text" class="input1" onkeypress="return Num();" value="<%=rs("ADStopHits")%>" size=8 maxlength=10>
      ·<INPUT name=ADStopDate type="text" class="input1" value="<%=rs("ADStopDate")%>" size=8 maxlength=19> <a href="#" onclick=openhelp("stop") title="点击查看帮助">显示·点击·日期？</a></td>      
  </tr>
  <tr class="tdbg">
    <td height="25" align="right" width="80" >重新统计：</td>
    <td ><input type="checkbox" name="ADRESET" value="YES"> 重置显示和点击次数</td>                     
  </tr>
  <tr class="tdbg">
    <td height="25" align="right" width="80" >简单注释：</td>
    <td ><INPUT name=ADNote type="text" class="input1" value="<%=rs("ADNote")%>" size=30 maxlength=100> 备注不显示在广告中</td>                     
  </tr>

        <tr class="tdbg">
          <td height="12" align="right" colspan="2">
			<p align="center"><input type="submit" value="提 交" name="Submit">&nbsp;<input onclick="parent.location.href='Javascript:history.back()'" type="button" value="返 回" name=button1></td>
        </tr></form>
</table>
<%
end sub

%>