<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<%
If session("HOSTAUID")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request("id")="" Then
	ef=True
	ec="请输入产品ID！"
ElseIf Instr(1, Request("id"), "'", 1)>0 then
	ef=True
	ec="非法产品ID！"
ElseIf not IsNumeric(Request("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
ElseIf not IsNumeric(Request("d"))  Then
	ef=True
	ec="D应该是数字！"
end if

if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where id='"&session("HOSTAUID")&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsph.Open Sql,conn,1,1
if dsph.Eof then
	ef=True
	ec="不存在的虚拟主机ID！"
end if
end if

if not ef then
if dsph("canback")="n" then
	ef=True
	ec="很抱歉，您的虚拟主机不允许使用本功能！"
end if
end if

if not ef then
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Serverlist where id='"&dsph ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
if dsserver.Eof then
	ef=True
	ec="服务器不存在！"
end if
end if

if not ef then
if not dsserver("backupyes")="y" then
	ef=True
	ec="很抱歉，产品所在的服务器不支持此功能！"
end if
end if

if not ef then
if Clng(Request("d"))>dsserver("backupsave")-1 then
	ef=True
	ec="还原的日期超出服务器允许范围！"
end if
end if

if not ef then
if DateDiff("s",Application("canrar"&dsserver("id")&"optime"),NOW )<180 and Application("canrar"&dsserver("id"))=true then
	ef=True
	ec="系统繁忙，前一个RAR操作尚未处理完，请您稍等三分钟后再试，谢谢您的支持。"
end if
end if

if not ef then'time
Application.lock
Application("canrar"&dsserver("id")&"optime")=now
Application("canrar"&dsserver("id"))=true
Application.unlock
end if

if not ef then
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
dir=dsserver("backupdir")
username=dsph("ftpname")
homedir=dsserver("homedir") 
%>
<!--#include virtual="/inc-freehost-function/template-hostadm-top.asp"-->
　虚拟主机自助管理


<br>

<TABLE 
            width="100%" border=1 align=center cellPadding=0 cellSpacing=0 borderColorLight=#cccccc borderColorDark=#fbfbfb>
  <TBODY>
    <TR align="center">
      <TD height="35" colspan="2" vAlign=middle bgColor=#494949>&nbsp; <font color="#FFFFFF">数据还原：</font></TD>
    </TR>
    <TR align="left">
      <TD height="89" colspan="2" vAlign=middle bgColor=#FFFFFF><p>　
	  <%

	  tn1=Weekday(now)
	  tn2=-(7-dsserver("backupday")+tn1)+1
	  if tn2<-7 then  tn2=tn2+7
	  if tn2=-7 then
	  tn2=0
	  end if
	  nowtimeori=dateadd("d",tn2,now)
	  
	  ib=Request("d")

  	  nowtime=dateadd("d",Clng("-"&ib*7),nowtimeori)
	  nowtime=dateadd("d",-1,nowtime)
	  txm=year(nowtime)&"-"&month(nowtime)&"-"&(day(nowtime))
	  dir=dsserver("backupdir")
	  dir=replace(dir&"\"&txm&"\"&lcase(dsph("ftpname"))&".rar","\\","\")

	
frompath=dir
'pathDIR=replace(homedir&"\"&username&"\"&Request.Form ("dirname")&"\","\\","\")
toDIR=replace(homedir&"\"&username&"\","\\","\")
RARcon=" x -ibck -inul -y "&frompath&" "&toDIR
rbsvar="-r -v "&username&" "&toDIR&"*.*"

	  %>
	  <%=RAROPadm(URL,FreeHostsharekey,RARcon)%>
	  <%=RBSop(URL,FreeHostsharekey,rbsvar)%>
  
	  还原工作已提交给自动任务，它将会在两分钟后开始执行，1小时内完成，请您耐心等候。 <br>
      </p>
      </TD>
    </TR>

  </TBODY>
</TABLE>


　<a href="selfhostmodify.asp?id=<%=Request("id")%>"><font color="#000000">[返回上一页]</font></a>
<!--#include virtual="/inc-freehost-function/template-hostadm-end.asp"-->
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>