<%
'**************************************
'* 最后更新 2010-05-10 by 56770.kingdge
'* Copyright www.56770.com
'*************************************
'On Error Resume Next
strwebtitle = "下载中心-"
sitename = site_name
Showpath = "<a href='"& Eshop_url & LangPath &"'>"& Lebi_word(0) &"</a> → 下载中心"
Function DownLoadMenu()
		DownLoadMenu = "<table width=""100%"" cellspacing=""0"" cellpadding=""0"" border=""0"" align=""center"" style=""margin-bottom:5px;""><tr><td height=""25"" style=""padding-top:3px"">"
		set rs=conn.execute("Select * From [56770_down_class] order by c_order desc")
		do while not rs.eof
				DownLoadMenu = DownLoadMenu &"<a href=""?do=class&c_id="&rs("c_id")&""">"&rs("c_name")&"</a>&nbsp;&nbsp;|&nbsp;&nbsp;"
		rs.movenext
		loop
		rs.close
		set rs=nothing
        DownLoadMenu = DownLoadMenu &"</td></tr></table>"
end function
Select Case request("do")
         Case "class" : other_main = DownLoadMenu() & download_class()
		 Case "list" : other_main = DownLoadMenu() & download_info()
		 Case "down" : other_main = DownLoadMenu() & download()
		 Case Else
		 other_main = DownLoadMenu() & download_main()
End Select

Function download_main()
		download_main = "<div class='myuserinfo'><table width=""100%"" cellspacing=""0"" cellpadding=""2"" border=""0"" align=""center""><tr>"
		set rs=conn.execute("Select c_id,c_name From [56770_down_class] order by c_order desc")
		class_num = 1
		do while not rs.eof
				download_main = download_main &"<td width='50%' valign='top'>"
				download_main = download_main &"<h2 style='width:98%;border:none;'>"& rs(1) &"</h2><div class='basketlist' style='width:98%'><table cellspacing='0' cellpadding='0' border='0'>"
				Set rss = conn.execute("select top 20 l_id,l_name,l_date from [56770_down_list] where c_id = "& rs(0) &" order by l_id desc")
				Do While Not rss.eof
				download_main = download_main &"<tr class='list'><td height='25' class='list'>["& rss(2) &"] <a href='?do=list&id="& rss(0) &"' title='"& rss(1) &"'>"& rss(1) &"</a></td></tr>"
				rss.movenext
				Loop
				download_main = download_main &"</table></div></td>"
				If class_num Mod 2 = 0 Then download_main = download_main &"</tr>"
		rs.movenext
		class_num = class_num + 1
		Loop
		rs.close : Set rs = Nothing
		download_main = download_main &"</table></div>"
End Function

Function download_class()
		c_id = request("c_id")
		If Not IsNumeric(c_id) Or IsEmpty(c_id) Then c_id = 0
		set rs=conn.execute("Select c_name From [56770_down_class] where c_id = "& c_id &"")
		c_name = rs(0)
		rs.close : Set rs = Nothing
		page = request("page")
		If Not IsNumeric(page) Or IsEmpty(page) Then page = 1
		download_class = "<div class='myuserinfo'>"
		download_class = download_class &"<h2>"& c_name &"</h2>"
		download_class = download_class &"<table width=""100%"" cellspacing=""1"" cellpadding=""2"" border=""0"" align=""center""><tr><th class=""headmenu"" height=""25"" width=""10%"" align=""center"">发布日期</th><th class=""headmenu"" width='20%'>下载名称</th><th class=""headmenu"" width='60%'>下载说明</th><th class=""headmenu"" width='10%' align='center'>下载</th>"
	    Set ors=new Cls_vbsPage
	    Set ors.Conn=conn
	    With ors
		    .PageSize=20
		    .PageName="Page"
			If IsSqlDataBase = 0 Then
		            .DbType="AC"
			Else
			        .DbType="MSSQL"
			End If
		    .RecType=-1
		    .Pkey="l_id"
    	    .Field="l_id,l_name,l_date,l_content"
		    .Table="[56770_down_list]"
			sql = "c_id = "& c_id &""
			.Condition=sql
            .OrderBy="l_id desc"
	    End With
	    DataCount=ors.RecCount()
	    DataList=ors.ResultSet()
		If DataCount > 0 Then
		        For i = 0 To Ubound(DataList,2)
				download_class = download_class &"<tr class='list'><td class='list' height='30' align='center'>"& DataList(2,i) &"</td>"
				download_class = download_class &"<td class='list'><a href='?do=list&id="& DataList(0,i) &"' title='"& DataList(1,i) &"'>"& DataList(1,i) &"</a></td>"
				download_class = download_class &"<td class='list'>"& RemoveHTML(DataList(3,i)) &"</td>"
				download_class = download_class &"<td class='list' align='center'><a href='?do=down&id="& DataList(0,i) &"'><img src='images/button_xz.gif' alt='点此下载' border='0'></a></td></tr>"
				Next
		End If
		download_class = download_class &"</table>"
		download_class = download_class &"</table><div style='float:right'>"& ors.ShowPageHead("download.asp") &"</div><div class='both'></div>"
End Function

Function download_info()
		id = request("id")
		If Not IsNumeric(id) Or IsEmpty(id) Then id = 0
		Set rs = conn.execute("select l_id,l_name,l_content,l_date,l_downurl from [56770_down_list] where l_id = "& id &"")
		If Not rs.eof Then
		l_id = rs(0)
		l_name = rs(1)
		l_content = rs(2)
		l_date = rs(3)
		l_downurl = rs(4)
		End If
		rs.close : Set rs= Nothing
		download_info = "<div class='myuserinfo'><h2>"& l_name &"</h2><table width=""100%"" cellspacing=""1"" cellpadding=""2"" border=""0"" align=""center"">"
		download_info = download_info &"<tr><th>发布日期</th><td class=""list2"">"& l_date &"</td></tr>"
		download_info = download_info &"<tr><th>下载地址</th><td class=""list2""><a href=""?do=down&id="& l_id &"""><img src="""& Eshop_url &"images/button_xz.gif"" alt=""点此下载"" border='0'></a></td></tr>"
		download_info = download_info &"<tr><th>下载说明</th><td class=""list2"">"& l_content &"</td></tr>"
		download_info = download_info &"<tr><td class='list2' colspan=""2"" align='right'><a href=""javascript:history.back()"">返回上一页</a></td></tr>"
		download_info = download_info &"</table></div>"
End function

Function download()
id = request("id")
If Not IsNumeric(id) Or IsEmpty(id) Then id = 0
Set rs = conn.execute("select l_downurl,l_flag from [56770_down_list] where l_id = "& id &"")
If Not rs.eof Then
If request.cookies(cookiesname)("user_grade") ="" Then
        If InStr(rs(1),",0,")>0 Then
                response.redirect rs(0)
                response.End
        Else
                response.write "<script>alert('请登陆后下载！');document.location.href='/user/login.asp'</script>"
                response.End
        End If
Else
	if request.cookies(cookiesname)("user_grade") = 0 then response.cookies(cookiesname)("user_grade") = 1
        If InStr(rs(1),","&trim(request.cookies(cookiesname)("user_grade"))&",")>0 Then
                If Trim(rs(0)) = "" then
                response.write "<script>alert('数据文件丢失，无法下载！');javascript:history.back()</script>"
                response.End
                End if
                response.redirect rs(0)
                response.End
		Else
                response.write "<script>alert('您没有下载权限("&trim(request.cookies(cookiesname)("user_grade"))&")！\n如有疑问请联系网站工作人员！');javascript:history.back()</script>"
                response.End
		End If
End If
End If
rs.close : Set rs = Nothing
End Function
%>