<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/function.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<%
Server.ScriptTimeout = 999999
'on error resume next
response.Charset="GB2312"
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p19")
'''''''''''''''''''''''''''''''''''''''''''''''
dim id,rs,robotadd,TempCont,Tempdir,isexits,downurls
dim CatalogId,SoftName,SoftChar,SoftKey,SoftVersion,SoftLanguage,SoftLicense,SoftAttr,SoftSize,SoftStars,SoftOs,SoftAuthor,SoftAuthorUrl,SoftDemoUrl,SoftPhoto,SoftDesc,SoftDemons,InsertDate,ModifyDate,SoftHits,SoftSaveFile
Tempdir=server.mappath("../templet/soft_show.htm")
if not isempty(request.QueryString("id")) then 
	id=Clng(request.QueryString("id"))
else
	response.write("id is null")
	response.end()
end if

'创建文件夹
call MakeDir(server.MapPath("../soft"))
''''''''''''''''''''''''''''''''''''''''''''''''''	
Set fs=Server.CreateObject("Scripting.FileSystemObject")
'读取模板内容
If (fs.FileExists(Tempdir)) Then
	TempCont=ReadFromTextFile(Tempdir)
else
	response.Write("没有找到模板文件："&Tempdir)
	response.End()
end if
set fs=nothing
'读取软件信息
set rs=server.CreateObject("adodb.recordset")  
rs.open "select * from t_download_soft where id="&id,conn,3,1
if not rs.eof then
	CatalogId=rs("CatalogId")
	SoftName=rs("SoftName")
	SoftChar=rs("SoftChar")
	SoftKey=rs("SoftKey")
	SoftVersion=rs("SoftVersion")	
	SoftLanguage=rs("SoftLanguage")
	SoftLicense=rs("SoftLicense")
	SoftAttr=rs("SoftAttr")
	SoftSize=rs("SoftSize")
	SoftStars=rs("SoftStars")
	SoftOs=rs("SoftOs")
	SoftAuthor=rs("SoftAuthor")	
	SoftAuthorUrl=rs("SoftAuthorUrl")
	SoftDemoUrl=rs("SoftDemoUrl")
	SoftPhoto=rs("SoftPhoto")
	SoftDesc=rs("SoftDesc")
	SoftDemons=rs("SoftDemons")
	InsertDate=rs("InsertDate")
	ModifyDate=rs("ModifyDate")
	SoftHits=rs("SoftHits")
	isexits=true
else
	response.write("not find")
	isexits=false
end if
rs.close
set rs=nothing
'下载地址
set rs=server.CreateObject("adodb.recordset")
rs.open "select id,SoftId,Title,FileUrl,ServerId from t_download_file where SoftId="&id,conn,3,1
while not rs.eof
	downurls=downurls&"<li><a href="""&SiteUrl&"/soft/download.asp?id="&rs(0)&""">"&rs(2)&"</a></li>"&Chr(10)
rs.movenext
i=i+1
wend
rs.close
set rs=nothing
'模板替换
if(isexits=true) then
	TempCont=replace(TempCont,"$SoftName$",SoftName)
	TempCont=replace(TempCont,"$SoftVersion$",SoftVersion)
	TempCont=replace(TempCont,"$SoftLanguage$",SoftLanguage)
	TempCont=replace(TempCont,"$SoftLicense$",SoftLicense)
	TempCont=replace(TempCont,"$SoftAttr$",SoftAttr)
	TempCont=replace(TempCont,"$SoftSize$",SoftSize)
	TempCont=replace(TempCont,"$SoftStars$",SoftStars)
	TempCont=replace(TempCont,"$SoftOs$",SoftOs)
	TempCont=replace(TempCont,"$SoftAuthor$",SoftAuthor)
	TempCont=replace(TempCont,"$SoftAuthorUrl$",SoftAuthorUrl)
	TempCont=replace(TempCont,"$SoftDemoUrl$",SoftDemoUrl)
	TempCont=replace(TempCont,"$SoftPhoto$",SoftPhoto)
	TempCont=replace(TempCont,"$SoftDemons$",SoftDemons)
	TempCont=replace(TempCont,"$SoftDesc$",SoftDesc)
	TempCont=replace(TempCont,"$InsertDate$",InsertDate)
	TempCont=replace(TempCont,"$ModifyDate$",ModifyDate)
	TempCont=replace(TempCont,"$SoftHits$",SoftHits)
	TempCont=replace(TempCont,"$SoftId$",id)
	TempCont=replace(TempCont,"$DownUrls$",downurls)
	TempCont=replace(TempCont,"$GetRelateSoft$",GetRelateSoft(SoftKey,10))
	TempCont=ReplaceAllLabel(TempCont,CatalogId)
	'生成htm页
	SoftSaveFile=server.mappath("../soft/"&id&".htm")
	response.Write("file success save to ->:"&SoftSaveFile&"<br>")	
	call SaveTextFile(SoftSaveFile,TempCont)
end if	

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
call connclose()
%>
</body>
</html>