<!--#include file="config.asp"-->
<%
Dim Rs,SQL,HtmlContent
Dim softid,SoftName,SoftSize
Dim SoftContent,SoftTime,AllHits,filesize
Dim ChannelRootDir,strInstallDir,strIndexName
Dim HtmlFileUrl,HtmlFileName,strUrl
Newasp.ReadChannel(ChannelID)
ChannelRootDir = Newasp.InstallDir & Newasp.ChannelDir
strInstallDir = Newasp.InstallDir
strIndexName = "<a href='" & ChannelRootDir & "'>" & Newasp.ChannelName & "</a>"
softid = Newasp.ChkNumeric(Request.Querystring("softid"))
If softid = 0 Then
	OutAlertScript("错误的系统参数!请输入正确的软件ID")
	Response.End
End If
Newasp.LoadTemplates ChannelID, 6, Newasp.ChannelSkin
HtmlContent = Newasp.HtmlContent
HtmlContent = Replace(HtmlContent, "{$ChannelRootDir}", ChannelRootDir)
HtmlContent = Replace(HtmlContent, "{$InstallDir}", Newasp.InstallDir)
HtmlContent = Replace(HtmlContent, "{$ChannelID}", ChannelID)
HtmlContent = Replace(HtmlContent, "{$ModuleName}", Newasp.ModuleName)
HtmlContent = Replace(HtmlContent, "{$SoftIndex}", strIndexName)
SQL = "SELECT A.softid,A.SoftName,A.SoftVer,A.Content,A.SoftSize,A.SoftTime,A.AllHits,A.HtmlFileDate,C.HtmlFileDir FROM xp90com_SoftLists A INNER JOIN [xp90com_Classify] C On A.ClassID=C.ClassID WHERE A.ChannelID="& ChannelID &" And A.isAccept <> 0 And A.SoftID=" & SoftID
Set Rs = Newasp.Execute(SQL)
If Rs.EOF And Rs.BOF Then
	OutAlertScript("对不起~！没有找到你想下载的软件。")
	Set Rs = Nothing
Else
	SoftName = Trim(Rs("SoftName") &" "& Rs("SoftVer"))
	SoftTime = Rs("SoftTime")
	AllHits = Rs("AllHits")
	SoftContent = Ubbcode(Rs("Content"))
	If CLng(Rs("SoftSize")) > 0 Then
		SoftSize = ReadSoftsize(Rs("SoftSize"))
	Else
		SoftSize = "未知大小"
	End If
	filesize = CCur(Rs("SoftSize"))
	If CInt(Newasp.IsCreateHtml) <> 0 Then
		HtmlFileUrl = ShowChannelPath(ChannelRootDir, Rs("HtmlFileDir")) & Newasp.ShowDatePath(Rs("HtmlFileDate"), Newasp.HtmlPath)
		HtmlFileName = Newasp.ReadFileName(Rs("HtmlFileDate"), Rs("softid"), Newasp.HtmlExtName, Newasp.HtmlPrefix, Newasp.HtmlForm, "")
		strUrl = HtmlFileUrl & HtmlFileName
	Else
		strUrl = ChannelRootDir & "show.asp?id="& Rs("softid")
	End If
End If
Rs.Close:Set Rs = Nothing
HtmlContent = Replace(HtmlContent, "{$PageTitle}", SoftName)
HtmlContent = Replace(HtmlContent, "{$SoftID}", softid)
HtmlContent = Replace(HtmlContent, "{$softid}", softid)
HtmlContent = Replace(HtmlContent, "{$SoftName}", SoftName)
HtmlContent = Replace(HtmlContent, "{$strUrl}", strUrl)
HtmlContent = Replace(HtmlContent, "{$Updatetime}", SoftTime)
HtmlContent = Replace(HtmlContent, "{$SoftSize}", SoftSize)
HtmlContent = Replace(HtmlContent, "{$FileSize}", FileSize)
HtmlContent = Replace(HtmlContent, "{$AllHits}", AllHits)
HtmlContent = Replace(HtmlContent, "{$SoftContent}", SoftContent)
HtmlContent = Replace(HtmlContent, "{$ShowDownAddress}", ShowDownAddress(softid))
HtmlContent = ReadClassMenu(HtmlContent)
HtmlContent = ReadClassMenubar(HtmlContent)
HtmlContent = Replace(HtmlContent, "{$SkinPath}", Newasp.SkinPath)
HtmlContent = Replace(HtmlContent,"{$InstallDir}", Newasp.InstallDir)
Response.Write HtmlContent
'================================================
'函数名：ReadSoftsize
'作  用：读取软件的大小
'================================================
Function ReadSoftsize(para)
	On Error Resume Next
	Dim strFileSize, parasize
	parasize = CCur(para)
	If parasize = 0 Then
		ReadSoftsize = "未知大小"
		Exit Function
	End If
	If parasize > 1024 * 1024 Then
		strFileSize = Round(parasize / 1024 / 1024, 2) & " GB"
	ElseIf parasize > 1024 Then
		strFileSize = Round(parasize / 1024, 2) & " MB"
	Else
		strFileSize = parasize & " KB"
	End If
	ReadSoftsize = strFileSize
End Function
Function ShowDownAddress(softid)
	Dim rsAddress, sqlAddress, rsDown
	Dim DownText,showdown
	Dim DownloadName, DownloadPath
	Dim DownAddress,selfont
	On Error Resume Next
	showdown = Newasp.ChkNumeric(Newasp.HtmlSetting(1))
	Set rsDown = Newasp.Execute("SELECT id,downid,DownFileName,DownText FROM [xp90com_DownAddress] WHERE softid=" & CLng(softid))
	If Not (rsDown.BOF And rsDown.EOF) Then
		Do While Not rsDown.EOF
			DownText = rsDown("DownText") & ""
			If Len(DownText) = 0 Then DownText = "立即下载"
			'---- 如果使用了下载服务器,就打开下载服务器数据表
			If rsDown("downid") > 0 Then
				sqlAddress = "SELECT downid,DownloadName,DownloadPath,IsDisp,DownPoint,UserGroup,IsOuter,selfont FROM xp90com_DownServer WHERE ChannelID=" & ChannelID & " And depth=1 And rootid =" & rsDown("downid") & " And isLock=0 ORDER BY orders ASC"
				Set rsAddress = Newasp.Execute(sqlAddress)
				If rsAddress.EOF And rsAddress.BOF Then
					DownloadPath = ""
					DownloadName = ""
				Else
					Do While Not rsAddress.EOF
						DownAddress = DownAddress & Newasp.HtmlSetting(3)
						'---- 是否直接显示软件直接的下载地址
						If rsAddress("IsDisp") <> 1 Then
							DownloadPath = "download.asp?softid=" & softid & "&downid=" & rsAddress("downid") & "&id=" & rsDown(0)
						Else
							If rsAddress("IsOuter") <> 1 Then
								DownloadPath = Trim(rsAddress("DownloadPath") & rsDown(2))
							Else
								DownloadPath = Trim(rsAddress("DownloadPath"))
							End If
						End If
						selfont = rsAddress("selfont") & ""
						If Len(selfont) < 10 Then
							DownloadName = rsAddress("DownloadName")
						Else
							DownloadName = "<span " & selfont & ">" & rsAddress("DownloadName") & "</span>"
						End If
						If rsAddress("UserGroup") > 0 Then
							DownloadName = Replace(DownloadName, "{$DownPoint}", rsAddress("DownPoint"))
						Else
							DownloadName = Replace(DownloadName, "{$DownPoint}", 0)
						End If
						DownAddress = Replace(DownAddress, "{$DownLoadUrl}", DownloadPath)
						DownAddress = Replace(DownAddress, "{$DownLoadName}", DownloadName)
						rsAddress.MoveNext
					Loop
				End If
				Set rsAddress = Nothing
			Else
				DownAddress = DownAddress & Newasp.HtmlSetting(3)
				If showdown > 0 Then
					DownloadPath = Trim(rsDown("DownFileName") & "")
				Else
					DownloadPath = "download.asp?softid=" & softid & "&downid=0&id=" & rsDown(0)
				End If
				DownAddress = Replace(DownAddress, "{$DownLoadUrl}", DownloadPath)
				DownAddress = Replace(DownAddress, "{$DownLoadName}", DownText)
			End If
			rsDown.MoveNext
		Loop
	End If
	Set rsDown = Nothing
	DownAddress = Replace(DownAddress, "{$SoftName}", SoftName)
	DownAddress = Replace(DownAddress, "{$ChannelRootDir}", ChannelRootDir)
	DownAddress = Replace(DownAddress, "{$InstallDir}", Newasp.InstallDir)
	ShowDownAddress = DownAddress
End Function
CloseConn
%>
