<!-- #include file="conn.asp" -->
<!-- #include file="cls_main.asp" -->
<!-- #include file="cls_regExp.asp" -->
<% dim obj,Mesky
set obj = New ViewDownInfo
	obj.AspInit()
set obj = nothing

class ViewDownInfo
	Private strSQL,q
	Private Sub Class_Initialize()
		Set Mesky = New Cls_Main
	End Sub
	Private Sub Class_Terminate()
		Set Mesky = Nothing
	End Sub
	Public Sub AspInit()
		Call Mesky.LoadSetting()
		if Request.QueryString("ID") = "" then
			Mesky.strMsg = "非法操作，ID 参数不能为空。"
			call Mesky.SystemMsg()
			exit sub
		Else
			call show_Down_Info(clng(Trim(Request.QueryString("ID"))))
		End If
	End Sub
	Public Sub show_Down_Info(ID)
	
		Dim arrPage, arrMainPage, Rs, s, tempStr
		If ID = "" Then Exit Sub
		Set Rs = Mesky.Execute("select * from Mesky_Down_Resource where ID=" & ID)
		If (Rs.EOF And Rs.BOF) Then
			Set Rs = Nothing
			Exit Sub
		End If
		arrPage = Split(Mesky.ReadStylePage("Style_Down_Info"), "<!--|||-->")
		arrMainPage = Split(Mesky.ReadStylePage("Style_Down_Main"), "<!--|||-->")
		tempStr = Replace(arrPage(0), "{$site_nav}", Mesky.site_nav(Rs("catalogID"), "Mesky_Down_catalog", Rs("ResName") & " " & Rs("ResVer"), ""))
		
		s = Replace(arrPage(1), "{$id}", ID)
		s = Replace(s, "{$softname}", Rs("ResName"))
		s = Replace(s, "{$softver}", Rs("ResVer"))
		s = Replace(s, "{$softsize}", Rs("ResSize"))
		s = Replace(s, "{$softlanguage}", Rs("ResLanguage"))
		s = Replace(s, "{$softtype}", Rs("ResType"))
		s = Replace(s, "{$softlicence}", Rs("ResLicence"))
		s = Replace(s, "{$catalogid}", Rs("catalogID"))
		s = Replace(s, "{$catalogname}", Rs("catalogname"))
		s = Replace(s, "{$system}", Rs("system"))
		If Rs("previewimg") <> "" Then
			s = Replace(s, "{$previewimg}", "<B>界面预览：</B><a href=""../Viewimg.asp?p=" & Rs("Previewimg") & """ target=""_blank""><img src=""../images/screen.gif""  border=""0"" align=""absmiddle""></a><br>")
		Else
			s = Replace(s, "{$previewimg}", "")
		End If
		If Rs("SmallImg") <> "" And (Not IsNull(Rs("SmallImg"))) Then
			s = Replace(s, "{$smallimg}", "<img src=""../" & Rs("SmallImg") &""">")
		Else
			s = Replace(s, "{$smallimg}", "")
		End If
		s = Replace(s, "{$dateandtime}", Rs("dateandtime"))
		s = Replace(s, "{$updatetime}", Rs("updatetime"))
		s = Replace(s, "{$username}", Rs("username"))
		s = Replace(s, "{$softrank}", Rs("resrank"))
		s = Replace(s, "{$userclass}", Split(Mesky.Setting(140), ",")(Rs("UserClass")))
		If Rs("RegUrl") <> "" Then
			s = Replace(s, "{$regurl}", "<B>软件注册：</B><a href=""" & Rs("regurl") & """ target=""_blank"">" & Rs("regurl") & "</a><br>")
		Else
			s = Replace(s, "{$regurl}", "")
		End If
		If Rs("authoremail") <> "" Then
			s = Replace(s, "{$authoremail}", "<B>联 系 人：</B><a href=""mailto:" & Rs("authoremail") & """>" & Rs("authoremail") & "</a><br>")
		Else
			s = Replace(s, "{$authoremail}", "")
		End If
		If Rs("AuthorUrl") <> "" Then
			s = Replace(s, "{$authorurl}", "<B>开 发 商：</B><a href=""" & Rs("authorurl") & """ target=""_blank"">" & Mesky.cutStr(Rs("authorurl"),25) & "</a><br>")
		Else
			s = Replace(s, "{$authorurl}", "")
		End If
		s = Replace(s, "{$hitstoday}", Rs("hitstoday"))
		s = Replace(s, "{$hitsweek}", Rs("hitsweek"))
		s = Replace(s, "{$hitsmonth}", Rs("HitsMonth"))
		s = Replace(s, "{$hitstotal}", Rs("hitstotal"))
		s = Replace(s, "{$content}", Rs("content"))
		
		If Rs("UserClass") = 0 Then
			If Mesky.setting(82) = "1" then
				s = Replace(s, "{$downaddress}", "<img src=""images/d_download.gif"" align=""absmiddle"" border=""0""><a onclick='window.open(""ViewDownloadUrl.asp?ID=" & ID & """)' href=""javascript:"">点击打开下载页面(Download Now) </a><br>")
			Else
				If Mesky.Setting(80) = 1 Then
					s = Replace(s, "{$downaddress}", showDownloadAddress(Rs("ID"), Mesky.Setting(81), 1))
				Else
					s = Replace(s, "{$downaddress}", showDownloadAddress(Rs("ID"), Mesky.Setting(81), 0))
				End If
			End If
		Else
			s = Replace(s, "{$downaddress}", "<img src=""images/d_download.gif"" align=""absmiddle"" border=""0""><a onclick='window.open(""VipDownload.asp?ID=" & ID & """)' href=""javascript:"">点此进入会员下载页面</a><br>")
		End If
		tempStr = Replace(arrMainPage(0), "{$page_title}", Mesky.Setting(0) & " - " & Rs("ResName") & " " & Rs("ResVer")) & arrMainPage(1) & arrMainPage(2) & tempStr & s
		s = Null
		
		
		'相关软件
		If Rs("mutualitydown") <> "" Then
			tempStr = tempStr & Replace(arrPage(2), "{$mutualitydown}", Mesky.showMutualityDownRes(Rs("mutualitydown"),45))
		End If
		
		'相关文章
		If Rs("mutualitycms") <> "" Then
			tempStr = tempStr & Replace(arrPage(3), "{$mutualitycms}", Mesky.showMutualityCmsRes(Rs("mutualitycms"),45))
		End If
		
		'用户评论
		If Mesky.Setting(88) Then
			s = Replace(arrPage(5), "{$comment}", comment_down(ID, Rs("commentNum"), Rs("Grade")))
		Else
			s = Replace(arrPage(5), "{$comment}", "")
		End If
		tempStr = tempStr & Replace(arrPage(4), "{$softname}", Rs("ResName")) & s
		s = Null
		
		tempStr = tempStr & arrPage(6) & arrMainPage(5)
		arrPage = Null
		arrMainPage = Null
		
		
		tempStr = regExp_showDownRes(tempStr)
		
		Set Rs = Nothing
		Response.Write Replace(tempStr,"../","")
		tempStr = Null		
	End Sub
	'下载地址
	Private Function showDownloadAddress(ID, brNum, show)
		Dim sRs, aRs, s, arrDownloadName, arrDownloadURL, i
		Set sRs = Mesky.Execute("select * from Mesky_Down_Address where ResourceID=" & ID & "")
		If Not (sRs.EOF And sRs.BOF) Then
			Do While Not sRs.EOF
			If sRs("SiteID") > 0 Then '使用预定义
				's = s & "<a href=""Download.asp"""
				Set aRs = Mesky.Execute("select ID,DownloadName,DownloadURL,isLB from Mesky_Down_SiteSetting where ID = " & sRs("SiteID"))
				arrDownloadName = Split(aRs(1), ",")
				arrDownloadURL = Split(aRs(2), ",")
				If aRs(3) Then '显示全部分站
					s = s & ("<img src=""../images/d_download.gif"" align=""absmiddle"" border=""0""> <b>下载“" & sRs("Name") & "”</b><br>")
					For i = 0 To UBound(arrDownloadName)
						If show Then
							s = s & "·<a href=""../Download.asp?ID=" & sRs("ID") & "&URL=" & arrDownloadURL(i) & sRs("URL") & """>" & arrDownloadName(i) & "</a>　"
						Else
							s = s & "·<a href=""../Download.asp?ID=" & sRs("ID") & "&sID=" & i & """>" & arrDownloadName(i) & "</a>　"
						End If
						If ((i + 1) Mod brNum) = 0 Then s = s & "<br>"
					Next
				Else
					If show Then '在明文显示下载地址是强制显示全部分站
						For i = 0 To UBound(arrDownloadName)
							s = s & "·<a href=""../Download.asp?ID=" & sRs("ID") & "&URL=" & arrDownloadURL(i) & sRs("URL") & """>" & arrDownloadName(i) & "</a>　"
						's = s & "<img src=""images/d_download.gif"" align=""absmiddle"" border=""0""> <a href=""Download.asp?ID=" & sRs("ID") & " & sID=" & sRs("SiteID") & " & URL=" & sRs("URL") & """>" & sRs("Name") & "</a><br>"
						If ((i + 1) Mod brNum) = 0 Then s = s & "<br>"
						Next
					Else
						s = s & "<img src=""../images/d_download.gif"" align=""absmiddle"" border=""0""> <a href=""../Download.asp?ID=" & sRs("ID") & """>" & sRs("Name") & "</a><br>"
					End If
				End If
				Set aRs = Nothing
			Else '不使用预定义
				If show Then
					s = s & "<img src=""../images/d_download.gif"" align=""absmiddle"" border=""0""> <a href=""../Download.asp?ID=" & sRs("ID") & "&URL=" & sRs("URL") & """>" & sRs("Name") & "</a><br>"
				Else
					s = s & "<img src=""../images/d_download.gif"" align=""absmiddle"" border=""0""> <a href=""../Download.asp?ID=" & sRs("ID") & """>" & sRs("Name") & "</a><br>"
				End If
			End If
			sRs.MoveNext
			Loop
			End If
		Set sRs = Nothing
		showDownloadAddress = s
		s = Null
	End Function
	Private Function comment_down(ID, commentNum, Grade)
		Dim reval, commentRs, i
		i = commentNum
		reval = reval & "<TABLE width=""100%"" border=""0"" cellPadding=""2"" cellSpacing=""1"" bgColor=""#cccccc"" style=""FONT-SIZE: 9pt"">" & vbCrLf
		reval = reval & "              <TR>" & vbCrLf
		reval = reval & "                <TD width=""80"" align=""middle"" bgColor=""#efefef""><input type=""submit"" name=""Submit"" value=""发表评论"" onclick=""spanComment.style.display=''; comment.content.focus(); return false;""></TD>" & vbCrLf
		reval = reval & "                <TD noWrap align=""center"" bgColor=""#efefef"">评论人</TD>" & vbCrLf
		reval = reval & "                <TD noWrap align=middle bgColor=""#efefef"">评论内容摘要(共 <FONT color=red>" & commentNum & "</FONT> 条，<A href=""../comment_down.asp?id=" & ID & """><FONT " & vbCrLf
		reval = reval & "color=#3366cc>查看完整内容</FONT></A>) 得分 <FONT color=red>" & Grade & "</FONT> 分</TD>" & vbCrLf
		reval = reval & "                <TD align=middle bgColor=#efefef>发表时间</TD>" & vbCrLf
		reval = reval & "              </TR>" & vbCrLf
		If commentNum <> 0 And commentNum <> "" Then
			Set commentRs = Mesky.Execute("select top 7 ID,Content,UserName,Email,dateandtime,Graded from Mesky_Down_Comment where ResourceID=" & ID & " order by dateandtime desc")
			If Not (commentRs.EOF And commentRs.BOF) Then
				Do While Not commentRs.EOF
				reval = reval & "              <TR bgColor=#ffffff>" & vbCrLf
				reval = reval & "                <TD width=""80"" align=right noWrap><NOBR><FONT color=red>" & i & "</FONT> 楼</NOBR> <NOBR>[<A " & vbCrLf
				reval = reval & "onclick=""spanComment.style.display=''; comment.content.focus(); comment.content.value='回复 " & i & " 楼(" & commentRs(2) & ")：'; return false;"" href=""javascript:""><FONT color=#3366cc>回复</FONT></A>]</NOBR><BR></TD>" & vbCrLf
				reval = reval & "                <TD style=""WORD-BREAK: break-all; WORD-WRAP: break-word"" align=center width=50><FONT color=green>" & commentRs(2) & "</FONT></TD>" & vbCrLf
				reval = reval & "                <TD style=""WORD-BREAK: break-all; WORD-WRAP: break-word"">" & Mesky.cutStr(commentRs(1), 180) & "</TD>" & vbCrLf
				reval = reval & "                <TD noWrap align=middle><A style=""BORDER-BOTTOM: #3399cc 1px dotted"" href=""../comment_down.asp?id=" & ID & "#commentID" & commentRs(0) & """><FONT color=#3366cc>" & Mesky.FormatMyDate(commentRs(4), "{m}-{d} {h}:{mi}") & "</FONT></A></TD>" & vbCrLf
				reval = reval & "              </TR>" & vbCrLf
				i = i - 1
				commentRs.MoveNext
				Loop
			End If
			Set commentRs = Nothing
		End If
		reval = reval & "              <TR bgcolor=""#FFFFFF"" id=""spanComment"" style=""display:none"">" & vbCrLf
		reval = reval & "                <TD colSpan=4><script language=""javascript"" src=""../js/comment.js""></script>" & vbCrLf
		reval = reval & "               <script language=""javascript"">show_commentForm(" & ID & ")</script>" & vbCrLf
		reval = reval & "               </TD>" & vbCrLf
		reval = reval & "              </TR>" & vbCrLf
		reval = reval & "</TABLE>" & vbCrLf
		comment_down = reval
		reval = Null
	End Function

End Class
%>