<!--#include file="down_conn.asp"-->
<!-- #include file="inc/const.asp" -->
<!--#include file="down_function.asp"-->
<%
dim MaxPerPage,currentPage,keyword,likeword,Classid,nClassid,TitleName,count
dim msginfo,totalPut,findword,founderr,msgtitle,i,flagd,sql2,rs2
Dvbbs.LoadTemplates("index")
Dvbbs.Stats="<a href=down_default.asp>下载中心</a>→编辑软件"
Dvbbs.Nav()'输出头
Dvbbs.Head_var 2,0,Dvbbs.Stats,""
sql2="select flag from [admin] where username='"&Dvbbs.membername&"'"
set rs2=conndown.execute(sql2)
if not(rs2.eof and rs2.bof) then
flagd=rs2("flag")
End if
if not dvbbs.founduser then
FoundErrs  "您没有登陆，请<a href=login.asp>登陆</a>或者同管理员联系。"
ShowErrs(Dvbbs.Stats)

elseif (flagd>2 or flagdown="" or flagdown<=0) and not dvbbs.master then
FoundErrs  "<font color=red>您没有管理软件的权限</font>，请<a href=login.asp>登陆</a>或者同管理员联系。"
ShowErrs(Dvbbs.Stats)
else

MaxPerPage=editnum
   	
    if not isempty(request("page")) then
      		currentPage=cint(request("page"))
   	else
      		currentPage=1
   	end if
	keyword=Trim(Request("keyword"))
	if not isnull(keyword) and keyword<>"" then 
	keyword=checkStr(keyword)
	else
	likeword=""
	end if
set Rs=server.createobject("adodb.recordset")
	
	if request("Classid")<>"" and request("NcalssID")<>"" then
       sql="select * from DNclass where Nclassid="&request("NcalssID")
	   rs.open sql,conndown,1,1
     set rss=conndown.execute("select * from [Dclass] where Classid="&request("Classid"))
	   TitleName=trim(rss("Class"))&"  ->>-  "&trim(rs("Nclass"))
           rss.close
	   rs.close
	
     elseif request("Classid")<>"" and request("Nclassid")="" then
		sql="select Class from Dclass where Classid="&request("Classid")
		rs.open sql,conndown,1,1
		TitleName=trim(rs("Class"))
		rs.close
	
	elseif request("Classid")="" and request("Nclassid")="" then
    TitleName="全部软件"
	end if
	

%>

<!-- #include file="down_Forum_js.asp" -->
<table cellpadding=3 cellspacing=1 border=0 width="70%" align=center>
  <tr>
    <td width="100%" align="center" valign=top> 
    <a href='?'><font color=red>全部软件</font> </a>
      <% 
	  dim sql1,rs1
	  set rs1=server.createobject("adodb.recordset")
	  sql1="select * from Dclass order by Classid asc"
	   rs1.open sql1,conndown,1,1
	 if rs1.bof and rs1.eof then
	   response.write "没有添加大类"
	 else
	   do while not rs1.eof
	   Response.Write " <a href=""down_adminedit.asp?Classid="&rs1("Classid")&""" onMouseOver=""showmenu(event,'"& showdown(rs1("Classid"),1) &"')"" style=""CURSOR:hand"">"&rs1("Class")&"</a>" & vbcrlf
	   rs1.movenext
	   loop
	 end if
	 rs1.close
	 %>
    </td>
</tr>
</table>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<% sub showContent 
    dim i 
	i=0 
    if dvbbs.master or flagd=1 or flagd=2 then  Response.Write("<form name=""myform"" method=""post"" action="""">") 
	 do while not rs.eof
	%>
  <tr> 
    <td class="tablebody2">
	<% 
Response.Write("<input type=""checkbox"" name=""selID"" value="""&rs("ID")&""" title="""&rs("ID")&""">")
%>
<a href="down_editsoft.asp?id=<%=rs("id")%>&classid=<%=rs("classid")%>&Nclassid=<%=rs("Nclassid")%>"
><%=rs("showname")%></a>
	</td>
    <td align="center" class="tablebody2"><%if rs("stop")=1 then 
    response.write "隐藏"
    else 
    response.write "正常" 
    end if 
    %>  
</td>
    <td align="center" class="tablebody2"><% if rs("hots")=1 then
			response.write "<font color=red><b>√</b></font>"
			else
			response.write "<b>×</b>"
			end if %></td>
    <td align="center" class="tablebody2"><% response.write downshow(rs("downshow")) %></td>
	<td align="center" class="tablebody2"><% if rs("dateandtime")=Date() then
			response.write "<font color=red>"&rs("dateandtime")&"</font>"
			else
			response.write rs("dateandtime")
			end if %></td>
  </tr>
  <% i=i+1
   if i>=MaxPerPage then exit do
	rs.movenext
	loop 
	rs.close
	
if dvbbs.master or flagd=1 or flagd=2 then
     sql = "select * from DNclass order by Nclassid asc"
     rs.open sql,conndown,1,1
%>
<tr>    
<td colspan="5" class="tablebody2">
<SCRIPT language = "JavaScript">
    var onecount;
    onecount=0;
    subcat = new Array();
        <%count = 0
        do while not rs.eof %>
    subcat[<%=count%>] = new Array("<%= trim(rs("Nclass"))%>","<%=cstr(rs("Classid"))%>","<%=cstr(rs("Nclassid"))%>");<%count = count + 1
        rs.movenext
        loop
        rs.close
        %>
    onecount=<%=count%>;

function changelocation(locationid)
    {
    document.myform.selNclassid.length = 0; 

    var locationid=locationid;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            { 
                document.myform.selNclassid.options[document.myform.selNclassid.length] = new 

Option(subcat[i][0], subcat[i][2]);
            }        
        }
        
    }    

function SelectAll() {
	for (var i=0;i<document.myform.selID.length;i++) {
		var e=document.myform.selID[i];
		e.checked=!e.checked;
	}
}
</script>
<a href="javascript:SelectAll()">全选/反选</a>
       <select name="selClassid" onChange="changelocation(document.myform.selClassid.options[document.myform.selClassid.selectedIndex].value)"> 
     <%
	 Response.Write("<option value="""&Trim(Request.QueryString("Classid"))&""">↓移时选择↓</option>")
    sql="select * from Dclass"
 	rs.open sql,conndown,1,1
	if rs.eof and rs.bof then
		response.write "<option value""0"">没有大类</option>"
	else
	do while not rs.eof
	response.write "<option value="""&cstr(rs("Classid"))&""">"+trim(rs("Class"))+"</option>"
	rs.movenext
    loop
	end if
	rs.close
%> </select>  
 <select name="selNclassid" > 
<% 
 Response.Write("<option value="""&Trim(Request.QueryString("Nclassid"))&""">↓移时选择↓</option>")
sql="select * from DNclass"
 	    rs.open sql,conndown,1,1
	    if rs.eof and rs.bof then
		    response.write "<option value""0"">没有小类</option>"
	    else
            do while not rs.eof
   response.write "<option value="""&cstr(rs("Nclassid"))&""">" + trim(rs("Nclass")) +"</option>"
            rs.MoveNext
            Loop
	    end if
        rs.close
%>  </select>
	 <select name="downshow"> 
          <option value="">↓下载属性↓</option>
          <option value="1">开放下载</option>
          <option value="2">会员下载</option>
          <%if vipshow=0 then%>
          <option value="3">VIP下载</option>
          <option value="5">收费下载</option>
          <option value="6">贵宾下载</option>
            <option value="7">帖数下载</option>
          <%end if%>
          <option value="4">特约下载</option>
      </select><br> 
			<input type="radio" name="action_type" value="isdel">批量删除 
            <input type="radio" name="action_type" value="ismove">批量移动 
			<input type="radio" name="action_type" value="setSoftType">设置下载属性 
			<input type="radio" name="action_type" value="isCommend">设置推荐 
			<input type="radio" name="action_type" value="noCommend">取消推荐
			<input type="radio" name="action_type" value="ishide">批量隐藏
 			<input type="radio" name="action_type" value="nohide">取消隐藏
<input type="submit" name="Submit" value="执行"  onclick="{if(confirm('您确定执行的操作吗?')){this.document.myform.submit();return true;}return false;}">
 </td></tr>
</table >
</form>
<% 
end if
end sub
  if dvbbs.master or flagd=1 or flagd=2 then
      if not isempty(Request.Form("selID")) then
      dim selID
      selID=Request.Form("selID")
      select case Trim(Request.Form("action_type"))
      case "isdel"
		call isdel()
      case "ismove"
		call ismove()
	  case "setSoftType"
	    call setSoftType()
	  case "isCommend"
	    call isCommend()
	  case "noCommend"
	    call noCommend()
	  case "ishide"
	    call ishide()
	  case "nohide"
	  	call nohide()
      case else
		founderr=true
      end select
      end if 
call SoftList()
else
founderr=true
end if

sub ishide()
conndown.execute("update [download] set stop=1 where ID in ("&selID&")")
Response.Write("批量隐藏操作成功！")
end sub

sub nohide()
conndown.execute("update [download] set stop=0 where ID in ("&selID&")")
Response.Write("批量取消隐藏操作成功！")
end sub


sub isdel()
Response.Write("批量删除操作成功！")
conndown.execute("delete from [download] where ID in ("&selID&")")
end sub

sub ismove()
if Trim(Request.Form("selClassid"))<>"" and Trim(Request.Form("selNclassid"))<>"" then
conndown.execute("update [download] set Classid='"&Trim(Request.Form("selClassid"))&"',Nclassid='"&Trim(Request.Form("selNclassid"))&"' where ID in ("&selID&")")
Response.Write("批量删除操作成功！")
end if
end sub

Sub setSoftType()
if Trim(Request.Form("downshow"))<>"" then
conndown.execute("update [download] set downshow="&Request.Form("downshow")&" where ID in ("&selID&")")
Response.Write("批量设置软件下载属性操作成功！")
end if
end Sub

sub isCommend()
conndown.execute("update [download] set hots=1 where ID in ("&selID&")")
end sub

sub noCommend()
conndown.execute("update [download] set hots=0 where ID in ("&selID&")")
end sub

 sub SoftList()
 %>
<table cellpadding="3" cellspacing="1" border="0" width="95%" class="tableBorder2" align=center>
  <tr> 
    <th  height="22" nowrap>软件名称</th>
    <th nowrap>是否隐藏</th>
	<th nowrap>推荐</th>
    <th nowrap>软件类型</th>
    <th nowrap>整理时间</th>
  </tr>
  <%
if not isnull(keyword) and keyword<>"" then 
		sql="select * from [download] where showname like '%"&keyword&"%'"
		sql=sql&" order by id desc"
else
  	if request("Classid")<>"" and request("NcalssID")<>"" then
	sql="select * from [download] where Classid="&request("Classid")&" and Nclassid="&request("NcalssID")&""
		sql=sql&" order by id desc"
	end if
	if request("Classid")<>"" and request("NcalssID")="" then
	    sql="select * from [download] where Classid="&request("Classid")&""
		sql=sql&" order by id desc"
	end if
	if request("Classid")="" and request("Nclassid")="" then
		sql="select * from [download]"
		sql=sql&" order by id desc"
	end if
end if
	rs.open sql,conndown,1,1
                if rs.eof and rs.bof then
      response.write"<font color=red>该类没有软件信息</font>"
 
	   elseif not(rs.eof and rs.bof) then 		 
     		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
       		if currentPage=1 then
             		showpage totalput,MaxPerPage,"down_adminedit.asp"
            		showContent
            		showpage totalput,MaxPerPage,"down_adminedit.asp"
       		else
          		if (currentPage-1)*MaxPerPage<totalPut then
            			rs.move  (currentPage-1)*MaxPerPage
            			dim bookmark
            			bookmark=rs.bookmark
            			showpage totalput,MaxPerPage,"down_adminedit.asp"
            			showContent
             			showpage totalput,MaxPerPage,"down_adminedit.asp"
        		else
	        		currentPage=1
           			showpage totalput,MaxPerPage,"down_adminedit.asp"
           			showContent
           			showpage totalput,MaxPerPage,"down_adminedit.asp"
	      		end if
		    end if
		 end if

%>
</table>
<% end sub 
	function showpage(totalnumber,maxperpage,filename)
  	dim n

  	if totalnumber mod maxperpage=0 then
     		n= totalnumber \ maxperpage
  	else
     		n= totalnumber \ maxperpage+1
  	end if
  	response.write "<form method=Post action="&filename&"?Classid="&request("Classid")&"&NcalssID="&request("NcalssID")&"><tr><td align=""center"" class=""forumRow""  colspan=""5"">"
  	response.write "[<font color='red'>"&TitleName&"</font>] "

  	if CurrentPage<2 then
    		response.write "共"&totalnumber&"个软件 首页 上一页 "
  	else
    		response.write "共"&totalnumber&"个软件 <a href="&filename&"?page=1&Classid="&request("Classid")&"&NcalssID="&request("NcalssID")&">首页</a> "
    		response.write "<a href="&filename&"?page="&CurrentPage-1&"&classID="&request("Classid")&"&NcalssID="&request("NcalssID")&">上一页</a> "
  	end if

  	if n-currentpage<1 then
    		response.write "下一页 尾页"
  	else
    		response.write "<a href="&filename&"?page="&(CurrentPage+1)&"&classID="&request("classID")&"&NcalssID="&request("NcalssID")&">"
    		response.write "下一页</a> <a href="&filename&"?page="&n&"&Classid="&request("Classid")&"&NcalssID="&request("NcalssID")&">尾页</a>"
  	end if
   	response.write " 页次：<strong><font color=red>"&CurrentPage&"</font>/"&n&"</strong>页 "
    	response.write " <b>"&maxperpage&"</b>个软件/页 "
		   response.write " 转到：<select name=""page"" size=""1"" style=""font-size: 9pt"" onChange=""javascript:submit()"">" & vbcrlf
		   for i = 1 to n
           response.write "<option value="""&i&""""
		   if CurrentPage=cint(i) then Response.Write " selected"
		   Response.Write ">第"&i&"页</option>" & vbcrlf
           next
           Response.Write "</select>" & vbcrlf
	       response.write "</td></tr></FORM>"
end function
sub Sysmsg(msgtitle,msginfo)
%>
 <br> 
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableBorder2" >
  <tr> 
   <th><%=msgtitle%></th>
  </tr>
  <tr>           
    <td  ><%=msginfo%></td>
  </tr>
   <tr>           
    <td height="22" align="center"  ><a href="javascript:history.go(-1)" >返回</a></td>
   </tr>
</table>
      <br> 
<%end sub 
end if

%>
</body>
</html>