<!--#include file="down_conn.asp"-->
<!-- #include file="inc/const.asp" -->
<!-- #include file="down_function.asp" -->
<!-- #include file="inc/dv_ubbcode.asp" -->

<%
Dim dv_ubb
Set dv_ubb=new Dvbbs_UbbCode

Dvbbs.LoadTemplates("index")
Dvbbs.Stats="<a href=down_default.asp>下载中心</a>-软件列表"
Dvbbs.Nav()'输出头
Dvbbs.Head_var 2,0,Dvbbs.Stats,""

dim MaxPerPage,Forum_body,abgcolor
if request("classid")<>"" then
if isnumeric(request("classid"))=0 then 
  FoundErrs  "<FONT color=red>指定的一级分类ID必须为正整数</font>"
ShowErrs(Dvbbs.Stats)
end if
end if
if request("Nclassid")<>"" then
if isnumeric(request("Nclassid"))=0 then 
  FoundErrs  "<FONT color=red>指定的二级分类ID必须为正整数</font>"
ShowErrs(Dvbbs.Stats)
end if
end if

	
	MaxPerPage=listnum	'每页显示程序最大数量
	Const ScriptTimeOut	= 300	'服务器ASP脚本超时时间值，建议不要使用 
	const makejs=0		'是否自动生成更新js文件，必须有Fso支持，请确认，默认为否
	
   	dim totalPut   
   	dim CurrentPage
   	dim TotalPages
   	dim j
   	dim keyword
   	
	dim updown
	dim order_name
	order_name=Request("Order")
   	if not isempty(request("page")) then
      		currentPage=cint(request("page"))
   	else
      		currentPage=1
   	end if
	if request("updown")<>"" then
		updown="desc"
	else
		updown=""
	end if
	select case order_name
		case "showname"
		order_name="showname"
		case "hot"
		order_name="hot"
		case "dateandtime"
		order_name="dateandtime"
		case "hits"
		order_name="hits"
		case "orders"
		order_name="orders"
		case "size"
		order_name="size"
		case else
		order_name="dateandtime"
		updown="desc"
	end select
 	dim classid,Nclassid
	dim classname,Nclassname
set rs=server.createobject("adodb.recordset")
	if request("classid")="" then
'		classid=""
'		classname="所有软件"
		classid="classid=1 and  "
		sql="select class from Dclass where classid=1"
		rs.open sql,conndown,1,1
		if rs.bof and rs.eof then
  FoundErrs  "<FONT color=red>你没有指定分类ID呢！请确认ID后下载</font>"
ShowErrs(Dvbbs.Stats)
		else
		classname=rs("class")
		end if
		rs.close
	else
		classid="classid="&cstr(request("classid"))&" and  "
		sql="select class from Dclass where classid="&request("classid")
		rs.open sql,conndown,1,1
                 		if rs.bof and rs.eof then
  FoundErrs  "<FONT color=red>该一级分类不存在或被删除</font>"
ShowErrs(Dvbbs.Stats)  
              end if
		classname=rs("class")
		rs.close
	end if
	if request("Nclassid")="" then
		Nclassid=""
		Nclassname="所有软件"
	else
		Nclassid=" Nclassid="&cstr(request("Nclassid"))&" and  "
		sql="select DNclass.Nclass,Dclass.class from DNclass,Dclass where DNclass.classid=Dclass.classid and DNclass.Nclassid="&cstr(request("Nclassid"))
		rs.open sql,conndown,1,1
    		
                 		if rs.bof and rs.eof then
  FoundErrs  "<FONT color=red>该二级分类不存在或被删除</font>"
ShowErrs(Dvbbs.Stats)  
              end if
		classname=rs("class")
		Nclassname=rs("Nclass")
		rs.close
	end if
	
%>
<!-- #include file="down_Forum_js.asp" -->

<table class="tableborder1" cellspacing=1 width="<%= Dvbbs.mainsetting(0) %>" align=center>
        <tr>
          <th valign=middle height=25 width="100%"><%
	dim sql1,rs1
	set rs=server.createobject("adodb.recordset")
	sql="select class,classid from Dclass"
	rs.open sql,conndown,1,3
	do while not rs.eof
%>
<a href="down_index.asp?classid=<%=rs("classid")%>" onMouseOver="showmenu(event,'<%=showdown(rs("classid"),0)%>')" style="CURSOR:hand"><font color="ffffff"><%=rs("class")%></font></a>|        
<%
	rs.movenext
	loop
	rs.close
%></th>
        </tr>
</table><br>
<table align=center border="0" width="<%= Dvbbs.mainsetting(0) %>">
  <tr>
    <td width="24%" class=tablebody1 valign="top" align="left">
<%if showset(5)=1 then%><!--#include file="down_allhot.asp"--><br><%end if%>
<%if showset(6)=1 then%><!--#include file="down_hot.asp"--><br><%end if%>
<%if showset(7)=1 then%><!--#include file="down_day.asp"--><br><%end if%>
<%if showset(8)=1 then%><!--#include file="down_week.asp"--><br><%end if%>
<%if showset(9)=1 then%><!--#include file="down_all.asp"--><br><%end if%></td>
    <td width="76%" class=tablebody1 valign="top" align="left">
     <table border="0" width="100%" cellspacing="0" cellpadding="0">
        <tr>
          <td width="50%"><a href=down_default.asp>下载分类</a>&gt;&gt;<%if request("classid")<>"" then%><a href='down_index.asp?classid=<%=request("classid")%>'><%=classname%></a>&gt;&gt;      <%end if%>
<%=Nclassname%><br><br></td>
	  <td width="16%" align=right>
<form action="down_index.asp" method=get>
<select name="classid" size="1" style='background-color:#ffffff' onchange='javascript:submit()'>
<%set rs=server.createobject("adodb.recordset")
	sql="select class,classid from Dclass"
	rs.open sql,conndown,1,1
	if rs.bof and rs.eof then
%>
<option value="">Not Record!</option>
<%else%>
<%
	do while not rs.eof
%>
<option <%if request("classid")<>"" then%><%if cint(rs("classid"))=cint(request("classid")) then%> selected  <%end if%><%end if%>value="<%=rs("classid")%>"><%=rs("class")%></option>
<%
	rs.movenext
	loop
	end if
	rs.close
%>
</select>
</form>
	  </td>
	  <td width=19%>
<form action="down_index.asp" method=get>
<input type=hidden name=classid value="<%=request("classid")%>"> 
<select name="Nclassid" size="1" style='background-color:#ffffff' onchange='javascript:submit()'>
<%
	if request("classid")="" then
	set rs=server.createobject("adodb.recordset")
	sql="select Nclass,Nclassid from DNclass"
	else
	sql="select Nclass,Nclassid from DNclass where classid="&request("classid")
	end if
	rs.open sql,conndown,1,1
	if rs.bof and rs.eof then
%>
<option value="">Not Record!</option>
<%else%>
<%
	do while not rs.eof
%>
<option <%if request("Nclassid")<>"" then%><%if cint(rs("Nclassid"))=cint(request("Nclassid")) then%> selected  <%end if%><%end if%>value="<%=rs("Nclassid")%>"><%=rs("Nclass")%></option>
<%
	rs.movenext
	loop
	end if
	rs.close
%>
</select>
</form>
	  </td>
	  <td width=15%>
<form action="down_index.asp" method=get>
<select name="order" size="1" style='background-color:#ffffff' onchange='javascript:submit()'>
<option value="id">按序号排序</option>
<option value="showname">按标题排序</option>
<option value="hot">按推荐排序</option>
<option value="hits">按下载排序</option>
<option selected value="dateandtime">按日期排序</option>
</select>
<input type=hidden name=updown value="desc">      
<input type=hidden name=classid value="<%=request("classid")%>">      
<input type=hidden name=Nclassid value="<%=request("Nclassid")%>">      
</form>
	  </td>
        </tr></table>
<% set rs=server.createobject("adodb.recordset")

if vipshow=2 then 
sqlvip="select * from [DV_user] where username='"&DVBBS.membername&"' and vip=5"
    rs.open sqlvip,conn,1,3
     if not(rs.bof and rs.eof) then
	if request("Nclassid")="" then
		sql="select * from download where "&classid&" stop=0"
		sql=sql&" order by "&order_name&" "&updown
	else
		sql="select * from download where "&classid&" "&Nclassid&" stop=0"

		sql=sql&" order by "&order_name&" "&updown
	end if
   else
      if request("Nclassid")="" then
		sql="select * from download where "&classid&" stop=0 and downshow<>6"
		sql=sql&" order by "&order_name&" "&updown
	else
		sql="select * from download where "&classid&" "&Nclassid&" stop=0 and downshow<>6"

		sql=sql&" order by "&order_name&" "&updown
	end if
end if
rs.close
else
	if request("Nclassid")="" then
		sql="select * from download where "&classid&" stop=0"
		sql=sql&" order by "&order_name&" "&updown
	else
		sql="select * from download where "&classid&" "&Nclassid&" stop=0"

		sql=sql&" order by "&order_name&" "&updown
	end if
end if


	rs.open sql,conndown,1,3
  	if rs.eof and rs.bof then 
       		response.write "<p align='center'>没有或没有找到任何程序</p>" 
   	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 
       		if currentPage=1 then 
            		showContent 
            		showpage totalput,MaxPerPage,"down_index.asp" 
       		else 
          		if (currentPage-1)*MaxPerPage<totalPut then 
            			rs.move  (currentPage-1)*MaxPerPage 
            			dim bookmark 
            			bookmark=rs.bookmark 
            			showContent 
             			showpage totalput,MaxPerPage,"down_index.asp" 
        		else 
	        		currentPage=1 
           			showContent 
           			showpage totalput,MaxPerPage,"down_index.asp" 
	      		end if 
	   	end if 
   	rs.close 
   	end if 
	         
   	sub showContent 
       	dim i 
	   	i=0 
%>  <center><div align=center>
      <table border="0" width="100%" cellspacing="0" cellpadding="0">
<%if request("updown")="" then%>
      <tr>
        <th width="41%"  height=22><a href="down_index.asp?classid=<%=request("classid")%>&Nclassid=<%=request("Nclassid")%>&order=showname&updown=desc" title="点击按升序排列"><font style='TEXT-DECORATION: underline' color="ffffff">软件名称和简介</font></a></td>
  <th width="11%"  align="center"><a href="down_index.asp?classid=<%=request("classid")%>&Nclassid=<%=request("Nclassid")%>&order=hot&updown=desc" title="点击按升序排列"><font style='TEXT-DECORATION: underline' color="ffffff">推 荐</font></a></td>
  <th width="20%"  align="center"><a href="down_index.asp?classid=<%=request("classid")%>&Nclassid=<%=request("Nclassid")%>&order=dateandtime&updown=desc" title="点击按升序排列"><font style='TEXT-DECORATION: underline' color="ffffff">更新日期</font></a></td>
  <th width="14%"  align="center"><a href="down_index.asp?classid=<%=request("classid")%>&Nclassid=<%=request("Nclassid")%>&order=orders&updown=desc" title="点击按升序排列"><font style='TEXT-DECORATION: underline' color="ffffff">授权形式</font></a></td>
  <th width="14%"  align="center">文件大小</td>
        </tr>
<%else%>
      <tr>
        <th width="41%"  height=22><a href="down_index.asp?classid=<%=request("classid")%>&Nclassid=<%=request("Nclassid")%>&order=showname" title="点击按降序排列"><font style='TEXT-DECORATION: underline' color="ffffff">软件名称和简介</font></a></td>
  <th width="11%" class=tablebody1 align="center"><a href="down_index.asp?classid=<%=request("classid")%>&Nclassid=<%=request("Nclassid")%>&order=hot" title="点击按降序排列"><font style='TEXT-DECORATION: underline' color="ffffff">推 荐</font></a></td>
  <th width="20%" class=tablebody1 align="center"><a href="down_index.asp?classid=<%=request("classid")%>&Nclassid=<%=request("Nclassid")%>&order=dateandtime" title="点击按降序排列"><font style='TEXT-DECORATION: underline' color="ffffff">更新日期</font></a></td>
  <th width="14%" class=tablebody1 align="center"><a href="down_index.asp?classid=<%=request("classid")%>&Nclassid=<%=request("Nclassid")%>&order=orders" title="点击按降序排列"><font style='TEXT-DECORATION: underline' color="ffffff">授权形式</font></a></td>
  <th width="14%" class=tablebody1 align="center">文件大小</td>
        </tr>
<%end if%>
<%do while not rs.eof%>
        <tr>
          <td width="100%" colspan="5" height=22><IMG SRC="down_images/CLICK.GIF"><a href="down_list.asp?id=<%=rs("id")%>" title="点击查看详细介绍"><%=rs("showname")%></a></td>
        </tr>
        <tr>
          <td width="41%" height=22>&nbsp;&nbsp;<%
          
if len(rs("note"))>18 then%><%=left(rs("note"),20)%>……<%else%><%=rs("note")%><%end if%></td>
          <td width="11%" align=center><%if rs("hot")>3 then%><font color=red>推 荐</font><%end if%></td>    
          <td width="20%" align=center><%=rs("dateandtime")%></td>
          <td width="14%" align=center><%=rs("orders")%><br><%=downshow(rs("downshow"))%></td>
          <td width="14%" align=center><%=rs("size")%></td>
        </tr>
        <tr>
          <td width="100%" colspan="5" height=22>
<font color="#6699FF">下载有效期：<%=downtime(rs("dateandtime"),rs("usetime"))%></font><br>
本日下载：      
<%if day(rs("lasthits"))=day(now()) and month(rs("lasthits"))=month(now()) and year(rs("lasthits"))=year(now()) then%>
<font color=red><%=rs("dayhits")%></font><%else%><font color=red>0</font><%end if%>        
 　      
本周：      
<%dim p_year,p_month,p_day,period_time
   	p_year=CInt(year(Now()))-CInt(year(rs("lasthits")))
   	p_month=CInt(month(Now()))-CInt(month(rs("lasthits")))
   	p_day=CInt(day(Now()))-CInt(day(rs("lasthits")))
   	period_time=((p_year*12+p_month)*30+p_day)
	if cint(period_time)>=cint(7) then
%>0<%else%>
<%=rs("weekhits")%><%end if%>　      
总计：<%=rs("hits")%><br>
<font color="#FF6699">
<%=daydownload(rs("dayhits"),rs("daydown"))%></font>
	  </td>
        </tr>
    <tr>                     
      <td background=down_images/bg02.gif height=1 colspan="5" width=85%>    
      </td>                    
    </tr>
<%
	 i=i+1
	 if i>=MaxPerPage then exit do
	 	rs.movenext
	 loop
%>
    </table>
    </center></div>
<%
   end sub 

	function showpage(totalnumber,maxperpage,filename)
  	dim n,i,page

  	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")&"&Nclassid="&request("Nclassid")&"&order="&request("order")&"&updown="&request("updown")&">"
  	response.write "<p align='right'><font color='red'>"&Nclassname&"</font>"

  	if CurrentPage<2 then
    		response.write ""&totalnumber&"个&nbsp;首页 上一页&nbsp;"
  	else
    		response.write ""&totalnumber&"个&nbsp;<a href="&filename&"?page=1&classid="&request("classid")&"&Nclassid="&request("Nclassid")&"&order="&request("order")&"&updown="&request("updown")&">首页</a>&nbsp;"
    		response.write "<a href="&filename&"?page="&CurrentPage-1&"&classid="&request("classid")&"&Nclassid="&request("Nclassid")&"&order="&request("order")&"&updown="&request("updown")&">上一页</a>&nbsp;"
  	end if

  	if n-currentpage<1 then
    		response.write "下一页 尾页"
  	else
    		response.write "<a href="&filename&"?page="&(CurrentPage+1)&"&classid="&request("classid")&"&Nclassid="&request("Nclassid")&"&order="&request("order")&"&updown="&request("updown")&">"
    		response.write "下一页</a> <a href="&filename&"?page="&n&"&classid="&request("classid")&"&Nclassid="&request("Nclassid")&"&order="&request("order")&"&updown="&request("updown")&">尾页</a>"
  	end if
   	response.write "&nbsp;页次：<strong><font color=red>"&CurrentPage&"</font>/"&n&"</strong>页 "
    	response.write "&nbsp;<b>"&maxperpage&"</b>个软件/页 "
%>
转到：<select name='page' size='1' style='background-color:#ffffff' onchange='javascript:submit()'>   
              <%for i = 1 to n%>   
              <option value='<%=i%>' <%if cint(Page)=cint(i) then%> selected <%end if%>>第<%=i%>页</option>   
              <%next%>   
            </select>
      </form>     
<%           
end function
%>
<!--#include file=down_query.asp-->      
      </td>                           
    </tr>                           
  </table>    
<%

call down_payuser()
	call down_manage()
conndown.close
	set conndown=nothing
Dvbbs.footer()%>




