<%
'下载列表 调用方法：DownList(分类ID,分类路径)
Function DownList(ID, SortPath)
    Dim rs, sql,StringText
    Dim HideSort
	StringText=""   
    If ID = "" Then SortPath = "0,"
    
    Dim idCount
    Dim pages
    pages = DownInfo
    Dim pagec
    Dim page
    page = CLng(request("Page"))
    Dim pagenc
    pagenc = 5
    Dim pagenmax
    Dim pagenmin
    Dim pageprevious
    Dim pagenext
    'datafrom = ""&Datapre&"_DownLoad"
    Dim datawhere
    datawhere = "where ViewFlag and Instr(SortPath,'"&SortPath&"')>0 "&HideSort& " "
    Dim sqlid
    Dim Myself, PATH_INFO, QUERY_STRING
    PATH_INFO = request.servervariables("PATH_INFO")
    QUERY_STRING = request.ServerVariables("QUERY_STRING")
    If QUERY_STRING = "" Then
        Myself = PATH_INFO & "?"
    ElseIf InStr(PATH_INFO & "?" & QUERY_STRING, "Page=") = 0 Then
        Myself = PATH_INFO & "?" & QUERY_STRING & "&"
    Else
        Myself = Left(PATH_INFO & "?" & QUERY_STRING, InStr(PATH_INFO & "?" & QUERY_STRING, "Page=") -1)
    End If
    Dim taxis
    taxis = "order by id desc "
    Dim i
    sql = "select count(ID) as idCount from ["&Datapre&"_DownLoad]" & datawhere
    Set rs = db(sql,4)
    idCount = rs("idCount")
    If(idcount>0) Then
    If(idcount Mod pages = 0)Then
    pagec = Int(idcount / pages)
Else
    pagec = Int(idcount / pages) + 1
End If
sql = "select id from ["&Datapre&"_DownLoad] " & datawhere & taxis
Set rs = db(sql,2)
rs.pagesize = pages
If page < 1 Then page = 1
If page > pagec Then page = pagec
If pagec > 0 Then rs.absolutepage = page
For i = 1 To rs.pagesize
    If rs.EOF Then Exit For
    If(i = 1)Then
    sqlid = rs("id")
Else
    sqlid = sqlid &","&rs("id")
End If
rs.movenext
Next
End If
If(idcount>0 And sqlid<>"") Then
sql = "select ID,DownName,AddTime,FileSize from ["&Datapre&"_DownLoad] where id in("& sqlid &") "&taxis
Set rs = db(sql,4)
StringText=StringText&"<table border=""0"" align=""center"">"&vbCrLf
StringText=StringText&"<tr><th class=""Down-time"">日期</th><th class=""Down-title"" style='text-align:left;text-indent:1em;'>资料标题</th><th>文件大小</th></tr>"&vbCrLf
Dim AutoLink
While Not rs.EOF
    If ISHTML = 1 Then
        AutoLink = ""&DownNameDiy&""&Separated&""&rs("ID")&"."&HTMLName&""
    Else
        AutoLink = "DownView.Asp?ID="&rs("ID")&""
    End If
StringText=StringText&"<tr><td class=""time-list""><span>"&FormatDate(rs("Addtime"), 13)&"</span></td><td><a title="""&rs("DownName")&""" href="""&AutoLink&""">"&rs("DownName")&"</a></td><td>"&rs("filesize")&"M</td></tr>"&vbCrLf
    rs.movenext
Wend
StringText=StringText&"</table>"&vbCrLf
Else
StringText=StringText&"<center>暂无相关信息</center>"
    Exit Function
End If
StringText=StringText&"<div class=""page_list"">"&vbcrlf
StringText=StringText&"<div class=""list_info"">共"&idcount&"条&nbsp;&nbsp;"&pages&"条/页&nbsp;&nbsp;<span class=""disabled"">&nbsp;"&vbcrlf

pagenmin = page - pagenc
pagenmax = page+pagenc
If(pagenmin<1) Then pagenmin = 1
If ISHTML = 1 Then
    If ID = "" Then
        If(page>1) Then StringText=StringText&"<span><a href="""&DownSortName&""&Separated&"1."&HTMLName&""" title=""回到第一页"">&nbsp;&lt;&lt;&nbsp;</a></span>"
    Else
        If(page>1) Then StringText=StringText&"<span><a href="""&DownSortName&""&Separated&""&ID&""&Separated&"1."&HTMLName&""" title=""回到第一页"">&nbsp;&lt;&lt;&nbsp;</a></span> "
    End If
Else
    If(page>1) Then StringText=StringText&"<span><a href="""& myself &"Page=1"" title=""回到第一页"">&nbsp;&lt;&lt;&nbsp;</a> </span>"
End If
If page - (pagenc * 2 + 1)<= 0 Then
    pageprevious = 1
Else
    pageprevious = page - (pagenc * 2 + 1)
End If
If ISHTML = 1 Then
    If ID = "" Then
        If(pagenmin>1) Then StringText=StringText&"<span><a href="""&DownSortName&""&Separated&""&pageprevious&"."&HTMLName&""" title=""第"& pageprevious &"页"">&nbsp;&lt;&nbsp;</a></span>"
    Else
        If(pagenmin>1) Then StringText=StringText&"<span><a href="""&DownSortName&""&Separated&""&ID&""&Separated&""&pageprevious&"."&HTMLName&""" title=""第"& pageprevious &"页"">&nbsp;&lt;&lt;&nbsp;</a></span>"
    End If
Else
    If(pagenmin>1) Then StringText=StringText&"<a href="""& myself &"Page="& pageprevious &""" title=""第"& pageprevious &"页"">&nbsp;&lt;&lt;&nbsp;</a> "
End If
If(pagenmax>pagec) Then pagenmax = pagec
For i = pagenmin To pagenmax
    If(i = page) Then
    StringText=StringText&"&nbsp;<span class=""current"">"& i &"</span>&nbsp;"
Else
    If ISHTML = 1 Then
        If ID = "" Then
           StringText=StringText&"<a href="""&DownSortName&""&Separated&""&i&"."&HTMLName&""">"& i &"</a>"
        Else
           StringText=StringText&"<a href="""&DownSortName&""&Separated&""&ID&""&Separated&""&i&"."&HTMLName&""">"& i &"</a>"
        End If
    Else
       StringText=StringText&"<a href="""& myself &"Page="&i&""">"& i &"</a>"
    End If
End If
Next
If page+(pagenc * 2 + 1)>= pagec Then
    pagenext = pagec
Else
    pagenext = page+(pagenc * 2 + 1)
End If
If ISHTML = 1 Then
    If ID = "" Then
        If(pagenmax<pagec) Then StringText=StringText&" <a href="""&DownSortName&""&Separated&""&pagenext&"."&HTMLName&""" title=""跳转到第"&pagenext&"页"">&nbsp;&gt;&gt;&nbsp;</a> "
        If(page<pagec) Then StringText=StringText&" <a href="""&DownSortName&""&Separated&""&pagec&"."&HTMLName&""" title=""跳转到第"&pagec&"页"">&nbsp;&gt;&gt;&nbsp;</a>"
    Else
        If(pagenmax<pagec) Then StringText=StringText&" <a href="""&DownSortName&""&Separated&""&ID&""&Separated&""&pagenext&"."&HTMLName&""" title=""跳转到第"&pagenext&"页"">&nbsp;&gt;&gt;&nbsp;</a> "
        If(page<pagec) Then StringText=StringText&" <a href="""&DownSortName&""&Separated&""&ID&""&Separated&""&pagec&"."&HTMLName&""" title=""跳转到第"&pagec&"页"">&nbsp;&gt;&gt;&nbsp;</a>"
    End If
Else
    If(pagenmax<pagec) Then StringText=StringText&" <a href="""& myself &"Page="& pagenext &""" title=""跳转到第"&pagenext&"页"">&nbsp;&gt;&gt;&nbsp;</a> "
    If(page<pagec) Then StringText=StringText&" <a href="""& myself &"Page="& pagec &""" title=""跳转到第"&pagec&"页"">&nbsp;&gt;&gt;&nbsp;</a>"
End If
StringText=StringText&"</div></div>"&vbCrLf
rs.Close
Set rs = Nothing
DownList=StringText
End Function
function DownMenu(PID)
Dim str,rs,sql,AutoUrl
if PID="" then PID=0
sql="select ID,SortName from ["&Datapre&"_DownSort] where Viewflag and ParentID="&PID&" order by ID"
set rs=db(sql,2)
if rs.eof then
PID=db("select ParentID from ["&Datapre&"_DownSort] where Viewflag and ID="&PID&"",1)(0)
rs.close:set rs=nothing
sql="select ID,SortName from ["&Datapre&"_DownSort] where Viewflag and ParentID="&PID&" order by ID"
set rs=db(sql,2)
end if
if not rs.eof then
do while not rs.eof
if IsHtml=1 then
AutoUrl=""&DownSortName&""&Separated&""&rs("ID")&"."&HTMLName&""
else
AutoUrl="DownList.asp?SortID="&rs(0)&""
end if
str=str&"<li><a href='"&AutoUrl&"'><span>"&rs(1)&"</span></a></li>"
rs.movenext
loop
end if
rs.close:set rs=nothing
DownMenu=str
end function

'下载信息
Function DownView(ID)
Dim StringText
StringText=""
If ID = "" Or Not IsNumeric(ID) Then
StringText=StringText&" <center>暂无相关信息</center>"
ElseIf conn.Execute("select * from ["&Datapre&"_Download] Where ViewFlag and  ID="&ID).EOF Then
StringText=StringText&" <center>暂无相关信息</center>"
Else
    Dim rs, sql
    
    sql = "select * from ["&Datapre&"_Download] where ViewFlag and ID="&ID
    set rs=db(sql,3)
End If

StringText=StringText&" <div class=""mm"">"
StringText=StringText&"  <table width=""98%"" border=""0"" align=""center"" cellpadding=""1"" cellspacing=""1"" bgcolor=""#E6E6E6"">"
StringText=StringText&"  <tr height=""25"" bgcolor=""#FFFFFF"">"
StringText=StringText&" <td width=""80"" align=""right"">文件名称：</td>"
StringText=StringText&"  <td style=""padding-left: 8px"">"&rs("DownName")&"</td>"
StringText=StringText&" </tr>"
StringText=StringText&" <tr height=""25"" bgcolor=""#FFFFFF"">"
StringText=StringText&" <td width=""80"" align=""right"">更新时间：</td>"
StringText=StringText&" <td style=""padding-left: 8px"">"&FormatDate(rs("UpdateTime"),13)&"</td>"
StringText=StringText&"  </tr>"
StringText=StringText&"  <tr height=""25"" bgcolor=""#FFFFFF"">"
StringText=StringText&"  <td width=""80"" align=""right"">文件大小：</td>"
StringText=StringText&" <td style=""padding-left: 8px"">"&rs("FileSize")&"M</td>"
StringText=StringText&" </tr>"
StringText=StringText&" <tr height=""25"" bgcolor=""#FFFFFF"">"
StringText=StringText&" <td width=""80"" align=""right"">浏览次数：</td>"
StringText=StringText&"  <td style=""padding-left: 8px""><script language=""javascript"" src=""HitCount.Asp?id="&rs("ID")&"&LX="&Datapre&"_Download""></script>"
StringText=StringText&" <script language=""javascript"" src=""HitCount.Asp?action=count&LX="&Datapre&"_Download&id="&rs("ID")&"""></script></td>"
StringText=StringText&"  </tr>"
StringText=StringText&" <tr height=""25"" bgcolor=""#FFFFFF"">"
StringText=StringText&"  <td width=""80"" align=""right"">下载地址：</td>"
StringText=StringText&" <td style=""padding-left: 8px""><a href="""&rs("FileUrl")&"""><img src="""&SysRootDir&templatepath&"images/Download.gif"" border=""0"" /></a></td>"
StringText=StringText&" </tr>"
StringText=StringText&" <tr height=""25"" bgcolor=""#FFFFFF"">"
StringText=StringText&"  <td width=""80"" align=""right"">相关说明：</td>"
StringText=StringText&"  <td style=""padding-left: 8px"" class=""SiteLink"">"&rs("Content")&"</td>"
StringText=StringText&" </tr>"
StringText=StringText&"  </table>"
StringText=StringText&"  </div>"

rs.update
rs.Close:Set rs = Nothing
DownView=StringText
end function 
%>