<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<%
If session("HOSTAUID")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request.Form ("id")="" Then
	ef=True
	ec="请输入产品ID！"
ElseIf Instr(1, Request.Form ("id"), "'", 1)>0 then
	ef=True
	ec="非法产品ID！"
ElseIf not IsNumeric(Request("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
ElseIf not IsNumeric(Request("copyid"))  Then
	ef=True
	ec="copyid应该是数字！"
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,3
if dsph.Eof then
	ef=True
	ec="不存在的虚拟主机ID！"
end if
end if

if not ef then
	Set dsHostpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_HostProductlist where Hosttype='"&dsph("Hosttype")&"'"
	if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsHostpdlist.Open Sql,conn,1,1
if dsHostpdlist.Eof 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="服务器不存在！"
Else
	ostype=dsserver("ostype")'linux
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="系统繁忙，前一个复制网站的操作尚未处理完，请您稍等三分钟后再试，谢谢您的支持。"
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")
username=dsph("ftpname")

%>
<!--#include virtual="/inc-freehost-function/template-hostadm-top.asp"-->
 　预装网站
 
<br>
<br>
<br>
<%


oridir=dsHostpdlist("UAcopydir"&Request.Form ("copyid"))
oridir=Replace(oridir,"$ftpname",dsph("ftpname"))
homedir=dsserver("homedir")
'todir=replace(homedir&"\web","\\","\")
todir=replace(homedir&"\"&dsph("ftpname")&"\web","\\","\")
if len(oridir)>3 then temp=COPYDIR(URL,FreeHostsharekey,oridir,todir)



Response.Write "装入网站"&dsHostpdlist("UAcopyName"&Request.Form ("copyid"))&"操作结果："

If	InStr(temp,"会复制目录中") Then
Response.Write "2分钟后开始复制."
Else
Response.Write temp
End If

toDIR=replace(homedir&"\"&username&"\","\\","\")
rbsvar="-r -v "&username&" "&toDIR&"*.*"
Response.Write RBSop(URL,FreeHostsharekey,rbsvar)




%>
<br>
<br>
<br>
　<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%>