<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<!--#include file="../inc/setup.asp"-->
<!--#include file="../inc/sql.asp"-->
<%
	end if
	useflag=5
%>
<!--#include file="flag.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>广告列表</title>
<SCRIPT LANGUAGE="JavaScript">
function delad(){
if (confirm("确定要删除这则广告么?删除后不可以再恢复哦!?")){return true;}
return false;
}
</SCRIPT>
<LINK href="Include/Admin_Style.css" type=text/css rel=stylesheet>
</head>
<body topmargin="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="sortbutton">
	<tr>
		<td height="23" align="center" valign="middle">新增网站广告设置</td>
	</tr>
</table>
<%
	Dim pagesize,rs,sql,curpage,strcate,i,keyw
	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")="search" then
		adwd=Request("adwd")
		if(Request("mc"))="mc" then
			sql="select * from [ad] where (ADNote like '%"&adwd&"%') or ( ADID like '%"&adwd&"%')  order by id desc"
		else sql="select * from [ad] where ( adsrc like '%"&adwd&"%')  order by id desc"
		end if
	Else
		if Request.QueryString("action")="stop" then
			sql = "SELECT * FROM [ad] where ( ADStopViews <> 0 and ADViews > ADStopViews) or ( ADStopHits <> 0 and ADHits > ADStopHits) or ( DateDiff(d,getdate(),ADStopDate)<1 ) ORDER BY id DESC"
		else
			sql = "SELECT * FROM [ad] ORDER BY id DESC"
		end if
	end If
	rs.open sql, conn, 1, 1

'监测是否存在错误
	If err.number <> 0 Then
		Response.Write "打开数据库出错,请检查conn.asp中数据库地址是否正确"
		Response.End
	End If
	If rs.bof or rs.eof Then
		rs.Close
		if Request.QueryString("action")="search" Then
%>
<table width="100%" border="0" align="center" bgcolor="#FFFFFF">
  <tr>
    <td bgcolor="#FFFFFF">
	<table width="100%" height="200" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="DDDDDD" style="word-break:break-all">
  <tr>
    <td align="center" bgcolor="#FFFFFF"><font color="#990000">在广告文件名和备注中没有发现含 <%=Request("adwd")%> 的广告！</font></td>  
  </tr>
</table>
</td>
  </tr>
</table>
<% Else%>
<table width="100%" border="0" align="center" bgcolor="#FFFFFF">
  <tr>
    <td bgcolor="#FFFFFF">
	<table width="100%" height="200" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="DDDDDD" style="word-break:break-all">
  <tr>
    <td align="center" bgcolor="#FFFFFF">暂时没有此类广告！</td>         
  </tr>
</table>
</td>
  </tr>
</table>
<%
	End If
	Response.End
	End If
	rs.pagesize = pagesize
	rs.absolutepage = curpage
%>
<table width="100%" border="1" align="center" bgcolor="#FFFFFF">
  <tr>
    <td bgcolor="#FFFFFF">
<table width='100%' height="22" border=0 align=center cellpadding=0 cellspacing=0 bgcolor="#999999" style="word-break:break-all">
<tr>
  <td width="60" height="22" align="center"  class="sortbutton"><a href="index.asp?action=search&adwd=<%=Request("adwd")%>&page=<%=cstr(curpage)%>&pagesize=<%=pagesize%>">[刷新]</a></td>
  <td width="700" height="22" align=right  class="sortbutton">
      <%If curpage = 1 Then%>
      　    [首页] [上一页]                                                           
      <%Else%>
      [<a href='?page=1'>首页</a>] [<a href='index.asp?action=search&adwd=<%=Request("adwd")%>&page=<%=cstr(curpage-1)%>'>上一页</a>]                                                           
      <%End If
      If  curpage = rs.pagecount Then%>
      [下一页] [尾页]                                                           
      <%Else%>
      [<a href='index.asp?action=search&adwd=<%=Request("adwd")%>&page=<%=cstr(curpage+1)%>'>下一页</a>] [<a href='index.asp?action=search&adwd=<%=Request("adwd")%>&page=<%=cstr(rs.pagecount)%>'>尾页</a>]&nbsp;
<%End If%>
</td>
</tr>
</table>
<%
	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")
%>
<table width='100%' border="0" align=center cellpadding=3 cellspacing=1 style="word-break:break-all">
     <tr class="sortbutton"> 
          <td width="250" height="25">名称：<%=ADID%> <%if IsStop(ADViews,ADStopViews,ADStopHits,ADHits,ADStopDate) Then Response.Write(" <font color=red>(已过期)") End If%></td>                             
          <td width="72">显示：<%=ADViews%></td>
          <td width="166">点击：<%=ADHits%></td>
          <td width="327"><a href="ad_edit.asp?id=<%=id%>">编辑</a>:&nbsp;&nbsp;<a href="ad_createjs.asp?id=<%=ADID%>">生成JS</a>&nbsp;<a href="ad_del.asp?deljs=yes&amp;file=<%=ADID%>.js" onClick="{if(confirm(&quot;您确定删除吗?本程序并不能清除放在网页中已放置的该广告代码，可能导致无法显示。&quot;)){return true;}return false;}">&nbsp;删除JS文件</a> 
            <a href="ad_del.asp?id=<%=id%>" onClick="return delad();">删除广告</a></td>
          <td width="101"><a href="#" target="_self">&gt;&gt;回顶端&lt;&lt;</a></td>
        </tr>
        <tr> 
          <td height="25" colspan=2>广告类型：<%=ShowAdType(ADType,rs("ADSrc"))%></td>
          <td colspan=3>备    注：<%=ADNote%></td> 
        </tr>
        <tr> 
          <td height="25" colspan=2>链接地址：<a href=<%=ADLink%> target=_blank><font color="#000000"><%=ADLink%></a></td>
          <td colspan=3>提示文字：<%=ADAlt%></td>
        </tr>
        <tr> 
          <td height="6" colspan=2>广告规格：<%=ADWidth%>×<%=ADHeight%></td>
          <td colspan=3>生成JS后广告调用代码：<input type="text"  onfocus="this.select()"  name="T1" size="55" value="<SCRIPT src='http://<%= request.ServerVariables("Server_Name") %>/ad/js/<%=ADID%>.js'></SCRIPT>"></td>
		 </tr>
		<tr>
          <td height="8" colspan=5 class="sortbutton">显示地址或内容：<br>
          <%If ADType=11 Then%><div style="width:100%;height:50;overflow-x:hidden;overflow-y:scroll; background-color: #FFFFFF"><SCRIPT src="http://<%= request.ServerVariables("Server_Name") %>/ad/js/<%=ADID%>.js" type=text/javascript></SCRIPT>
          <% else%>
          <%If ADType<>6 Then%><a href=<%=ADSrc%> target=_blank><font color="#000000"><%=ADSrc%></a><%else%>不显示<%end if%><%end if%></div></td>
        </tr>
	</table>
<% 
    i=i+1
	rs.movenext
	If i>=rs.PageSize Then Exit Do     
	Loop
%>
<table width="100%" height="1" border="0" align="center" cellpadding="0" cellspacing="1" class="sortbutton" style="word-break:break-all">
      <tr align="center"> 
          <td height="25" colspan=4> <center>  第<%=cstr(curpage)%>页　总<%=cstr(rs.pagecount)%>页　本页<%=cstr(i-1)%>条　总<%=cstr(rs.recordcount)%>条&nbsp;                    
          <a href="#" target="_self">&gt;&gt;回顶端&lt;&lt;</a>
          </center></td>
    </tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<%
	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 11
			ShowAdType="JS式广告代码"
		Case else
			ShowAdType="<font color=red><b>错误!将不能正确显示</b>"
	End Select
end function
%>
