<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<%
If session("VPSAUID")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf not IsNumeric(session("VPSAUID"))  Then
	ef=True
	ec="云服务器应该是数字！"
ElseIf not IsNumeric(request("bakid"))  Then
	ef=True
	ec="bakid应该是数字！"
end if



if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsphVPS = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_VPS where id='"&session("VPSAUID")&"'"
	dsphVPS.Open Sql,conn,1,3
if dsphVPS.Eof then
	ef=True
	ec="不存在的云服务器 ID！"
end if
end If

if not ef Then
If dsphVPS("endtime")<Now Then
	ef=True
	ec="产品已过期,不能再操作！"
End If
end if

if not ef then
if dsphVPS("Maxbak")<1 then
	ef=True
	ec="很抱歉，您的云服务器不允许使用本功能！"
end if
end if


if not ef then
	Set dsVPSpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_VPSProductlist where VPStype='"&dsphVPS("VPStype")&"'"
	if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsVPSpdlist.Open Sql,conn,1,1
if dsVPSpdlist.Eof then
	ef=True
	ec="产品不存在！"
end if
end If

if not ef then
if (Hour(now)<dsVPSpdlist("canSNAST") or Hour(now)>dsVPSpdlist("canSNAEN")) then
	ef=True
	ec="很抱歉，为了防止影响服务器的情况,本功能只能在"&dsVPSpdlist("canSNAST")&"-"&dsVPSpdlist("canSNAEN")&"点之间使用！"
end if
end if

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

if not ef then
if DateDiff("s",Application("canrar"&dsserver("id")&"optime"),NOW )<1500 and Application("canrar"&dsserver("id"))=true then
	ef=True
	ec="系统繁忙，前一个还原的操作尚未处理完，请您稍等30分钟后再试，谢谢您的支持。"
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
%>
<!--#include virtual="/inc-freehost-function/template-vpsadm-top.asp"-->
　
<p>云服务器自助管理


  <br>
  <br>
  <br>
还原已有的备份
 
<br>
<br>
<br>
<%


URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
username=dsphVPS("username")
vpsname=LCase(dsphVPS("vpsname"))
todir=dsphVPS("vhdpath")
MAXspace=dsphVPS("MAXspace")

nowvhddir=dsphVPS("vhdpath")

tobackdir=dsserver("backupdir")
timestd=dateadd("d",-((request("bakid")-1)*7),dsphVPS("lastbackuptime"))

	  If Right(dsphVPS("vhdpath"),5)=".vhdx" then
		tobackdir=replace(tobackdir&"\"&vpsname&"-"&year(timestd)&right("00"&month(timestd),2)&right("00"&day(timestd),2)&".vhdx","\\","\")
	  Else
		tobackdir=replace(tobackdir&"\"&vpsname&"-"&year(timestd)&right("00"&month(timestd),2)&right("00"&day(timestd),2)&".vhd","\\","\")
	  End if

If request("Submit")="马上还原全部硬盘数据" then
varcon="backvhd "&vpsname&" "&tobackdir&" "&nowvhddir
End If

If request("Submit")="马上还原第一硬盘(C盘)数据" then
varcon="backvhdonlyc "&vpsname&" "&tobackdir&" "&nowvhddir
End If



temp=VPSOP(URL,FreeHostsharekey,varcon,1)'0=now

'Response.Write varcon

Response.Write temp

'dsphVPS("lastbackuptime")=now
dsphVPS.update
%>
<br>
<br>
  <br>
  <br>
  <br>
  　<a href="selfvpsmodify.asp?id=<%=Request("id")%>"><font color="#000000">[返回]</font></a>
  <!--#include virtual="/inc-freehost-function/template-vpsadm-end.asp"-->
  <%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
