 <!--#include file="conn.asp"-->
<%
'检查访问的来源是否合法
call checkPrePage()
	
'恢复文件
'-------------------------------------------------------------------------------------
	strSQL="Select * From EditFile Where id=" & Clng(request.QueryString("id"))
	Set rsSub=Server.CreateObject("ADODB.RecordSet")
	rsSub.open strSQL,conn,1,1
	if rsSub.recordcount>0 then
		strFile=Trim(rsSub("e_file"))
		strContent=Trim(rsSub("e_html"))
		strEditTime=rsSub("e_edittime")
		'开始替换文件
		Set fs = Server.CreateObject( Const_ScriptFileSystem )
			DiyFolder = "home/" & Trim(Session("UserName")) & "/"
			DiyFolder = Server.MapPath( DiyFolder )

			if fs.FolderExists( DiyFolder )=false then
				'On Error Resume Next
				fs.CreateFolder( DiyFolder )
			end if
			EditFile = DiyFolder & "\" & strFile
			
			Set fp = fs.CreateTextFile( EditFile )
				'On Error Resume Next
				fp.Write strContent
			fp.close
		Set fs = nothing
		strMsg="文件还原成功！\n\n文件名："  & strFile & "\n上次全站编辑时间：" & strEditTime & "　\n"
		response.Write("<script>")
		response.Write("alert('" & strMsg & "');")
		response.Write("</script>")
	Else
		strMsg="  文件还原失败！未能发现上次编辑的数据！"
		response.Write("<script>")
		response.Write("alert('" & strMsg & "');")
		response.Write("</script>")
	end if
	rsSub.close
	Set rsSub=nothing
%>