
<!--#include file="../inc/Conn.asp"-->
<!--#include file="Inc/Admin.Asp"-->
<!--#include file="../Inc/Ubbcode.asp"-->
<!--#include file="Inc/Function.asp"-->
<%
PurviewValue="downloadmanage"
If not CheckAdmin(PurviewValue) then
Response.Write("<script language=""JavaScript"">alert(""越权操作!"");history.go(-1);")
response.end
End If
%>
<%
dim strFileName
const MaxPerPage=20
dim totalPut,CurrentPage,TotalPages
dim i,j
dim BigClassName,SmallClassName
dim ID,Title
dim sql,rs
dim PurviewChecked
dim strAdmin,arrAdmin

PurviewChecked=false
strFileName="Download.asp?BigClassName=" & BigClassName & "&SmallClassName=" & SmallClassName

ID=Request("ID")
BigClassName=Trim(request("BigClassName"))
SmallClassName=Trim(request("SmallClassName"))
Title=Trim(request("Title"))

if request("page")<>"" then
    currentPage=cint(request("page"))
else
	currentPage=1
end if
'============
sql="select * from Download where ID>0"
if session("purview")>4 then
	sql=sql & " and Editor='" & Session("Admin") & "' and Passed=false"
end if
if Title<>"" then
	sql=sql & " and Title like '%" & Title & "%' "
end if
if BigClassName<>"" then
	sql=sql & " and BigClassName='" & BigClassName & "' "
	if SmallClassName<>"" then
		sql=sql & " and SmallClassName='" & SmallClassName & "' "
	end if
end if
'============
sql=sql & " order by ID desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
%>

<SCRIPT language=javascript>
function unselectall()
{
    if(document.del.chkAll.checked){
	document.del.chkAll.checked = document.del.chkAll.checked&0;
    } 	
}

function CheckAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.Name != "chkAll")
       e.checked = form.chkAll.checked;
    }
  }
function ConfirmDel()
{
   if(confirm("确定要删除选中的下载吗？一旦删除将不能恢复！"))
     return true;
   else
     return false;
	 
}
</SCRIPT>

<!-- #include file="Inc/Head.asp" -->
<table  border="0" align="center" cellpadding="5" cellspacing="1"  class="border">
  <tr>
    <td height="25"  class="tdbg">|&nbsp;
        <%
dim sqlBigClass,sqlSmallClass,rsBigClass,rsSmallClass,sqlSpecial,rsSpecial
sqlBigClass="select * from BigClass_down"
Set rsBigClass= Server.CreateObject("ADODB.Recordset")
rsBigClass.open sqlBigClass,conn,1,1
if rsBigClass.eof then 
	response.Write("还没有任何栏目，请首先添加栏目。")
end if
do while not rsBigClass.eof
	if rsBigClass("BigClassName")=BigClassName then
		response.Write("<a href='Down_Manage.asp?BigClassName=" & rsBigClass("BigClassName") & "'><font color='red'>" & rsBigClass("BigClassName") & "</font></a> | ")		
	else
		response.Write("<a href='Down_Manage.asp?BigClassName=" & rsBigClass("BigClassName") & "'>" & rsBigClass("BigClassName") & "</a> | ")
	end if
	rsBigClass.movenext
loop
rsBigClass.close
set rsBigClass=nothing
%>
    </td>
  </tr>
  <%
if BigClassName<>"" then
	sqlSmallClass="select * from SmallClass_down where BigClassName='" & BigClassName & "'"
	Set rsSmallClass= Server.CreateObject("ADODB.Recordset")
	rsSmallClass.open sqlSmallClass,conn,1,1
	if not (rsSmallClass.bof and rsSmallClass.eof) then
		response.write "<tr><td  class='tdbg'>"
		do while not rsSmallClass.eof
			if rsSmallClass("SmallClassName")=SmallClassName then
				response.Write("&nbsp;<a href='Down_Manage.asp?BigClassName=" & rsSmallClass("BigClassName") & "&SmallClassName=" & rsSmallClass("SmallClassName") & "'><font color='red'>" & rsSmallClass("SmallClassName") & "</font></a>&nbsp;&nbsp;")				
			else
				response.Write("&nbsp;<a href='Down_Manage.asp?BigClassName=" & rsSmallClass("BigClassName") & "&SmallClassName=" & rsSmallClass("SmallClassName") & "'>" & rsSmallClass("SmallClassName") & "</a>&nbsp;&nbsp;")
			end if
			rsSmallClass.movenext
		loop
		response.write "</td></tr>"
	end if
	rsSmallClass.close
	set rsSmallClass=nothing
end if
%>
</table>
<br>
<table width="100%"  border="0" cellpadding="2" cellspacing="1" class="border">
  <tr>
    <td height="25"  class="tdbg"><a href="Download.asp">&nbsp;下载管理</a>&gt;&gt;
        <% 'Start 菜单树
if request.querystring="" then
	response.write "所有下载"
else
	if request("Query")<>"" then
		if Title<>"" then
			response.write "名称中含有“<font color=blue>" & Title & "</font>”的下载"
		else
			response.Write("所有下载")
		end if
 	else
		if BigClassName<>"" then
			response.write "<a href='Download.asp?BigClassName=" & BigClassName & "'>" & BigClassName & "</a>&nbsp;&gt;&gt;&nbsp;"
			if SmallClassName<>"" then
				response.write "<a href='Download.asp?BigClassName=" & BigClassName & "&SmallClassName=" & SmallClassName & "'>" & SmallClassName & "</a>"
			else
				response.write "所有小类"
			end if
		end if
	end if
end if
'END 菜单树
%>
    </td>
    <td width="151"  class="tdbg">&nbsp;
        <%
if rs.eof and rs.bof then
	response.write "共找到 0 个下载</td></tr></table>"
	else
    totalPut=rs.recordcount
		if currentpage<1 then
       currentpage=1
   	end if

		if (currentpage-1)*MaxPerPage>totalput then
			if (totalPut mod MaxPerPage)=0 then
				currentpage= totalPut \ MaxPerPage
			else
					currentpage= totalPut \ MaxPerPage + 1
			end if
		end if

		response.Write "共找到 " & totalPut & " 个下载"
%>
    </td>
  </tr>
</table>
<br>
<table cellpadding="2" cellspacing="1" border="0" width="660" align="center" class="border">
	<tr>
		<td class="topbg" height="25" align="center"><strong>下 载 管 理</strong></td>
	</tr>
	<tr>
	  <td align="center"><form name="del" method="Post" action="Download_Del.asp" onSubmit="return ConfirmDel();">
        <%		
		if currentPage=1 then
			showContent
			showpage strFileName,totalput,MaxPerPage,true,false,"个下载"
		else
			if (currentPage-1)*MaxPerPage<totalPut then
				rs.move  (currentPage-1)*MaxPerPage
				dim bookmark
				bookmark=rs.bookmark
				showContent
				showpage strFileName,totalput,MaxPerPage,true,false,"个下载"
			else
				currentPage=1
				showContent
				showpage strFileName,totalput,MaxPerPage,true,false,"个下载"
			end if
		end if
end if
%>

<%  
sub showContent
   	dim i
    i=0
%>
        <table width="100%" border="0"  cellpadding="0" cellspacing="1" class="a3" style="word-break:break-all">
          <tr  > 
            <td width="46" height="25" align="center" class="Title"><strong>选中</strong></td>
            <td width="30"  height="25" align="center"  class="Title"><strong>ID</strong></td>
            <td width="350" align="center"  class="Title" ><strong>下载名称</strong></td>
            <td width="72" align="center" class="Title" ><strong>加入时间</strong></td>
            <td width="72" align="center" class="Title" ><strong>审核情况</strong></td>
            <td width="80" align="center" class="Title" ><strong>操作</strong></td>
          </tr>
          <%do while not rs.eof%>
          <tr> 
            <td width="46" height="22" align="center"  class="tdbg"> <input name='ID' type='checkbox' onClick="unselectall()" id="ID" value='<%=cstr(rs("ID"))%>'> 
            </td>
            <td width="30" align="center"  class="tdbg"><%=rs("ID")%></td>
            <td  class="tdbg"><a href="../DownloadShow.asp?ID=<%=rs("ID")%>" target="_blank"	><%=rs("Title")%></a></td>
            <td width="72" align="center"  class="tdbg"><%= FormatDateTime(rs("AddDate"),2) %></td>
            <td width="72" align="center"  class="tdbg"> 
              <%if rs("Passed")=true then%>
              已审核 
              <%else%>
              <font color="#FF0000">未审核</font> 
              <%end if%>
            </td>
            <td width="80" align="center"  class="tdbg"> 
              <a href="Download_edit.asp?ID=<%=rs("ID")%>">修改</a> 
              <a href="Download_Del.asp?ID=<%=rs("ID")%>&Action=Del" onClick="return ConfirmDel();">删除</a>            </td>
          </tr>
<%
	i=i+1
		if i>=MaxPerPage then exit do
		rs.movenext
	loop
%>
        </table>
        <table width="100%"  border="0" cellpadding="2" cellspacing="1" class="a3">
          <tr> 
            <td width="250" height="30" class="tdbg"><input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">
            选中本页显示的所有下载</td>
            <td class="tdbg"><input name="submit" type='submit' value='删除选定的下载' <%if session("purview")>=3 and session("purview")<=4 and PurviewChecked=False then response.write "disabled"%>> 
            <input name="Action" type="hidden" id="Action" value="Del"></td>
          </tr>
        </table>
        <%
   end sub 
%>
      </form>
      </td>
	</tr>
</table>
<table  border="0" cellpadding="2" cellspacing="1" class="border">
  <tr>
    <form name="searchsoft" method="get" action="Download.asp">
      <td height="25" class="tdbg"><strong>查找下载：</strong>
          <input name="Title" type="text" class=smallInput id="Title3" size="20" maxlength="50">
          <input name="Query" type="submit" id="Query" value="查 询">
        &nbsp;&nbsp;请输入下载名称。如果为空，则查找所有下载。</td>
    </form>
  </tr>
</table>
<%
rs.close
set rs=nothing  
call CloseConn()
%><!-- #include file="Inc/Foot.asp" -->