<%@ 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 ("ip")="" Then
	ef=True
	ec="请设置IP！"
ElseIf len(Request.Form ("ip"))>50 Then
	ef=True
	ec="ip超过允许的长度！"
ElseIf RegExpTest("[^A-Za-z0-9]",Replace(replace(Request.Form ("ip"),"-",""),".","")) Then
	ef=True
	ec="IP有非法字符！"

ElseIf Request.Form ("ftpname")="" Then
	ef=True
	ec="请设置ftp名！"
ElseIf len(Request.Form ("ftpname"))>40 Then
	ef=True
	ec="ftp名超过允许的长度！"
ElseIf RegExpTest("[^A-Za-z0-9]",Replace(Replace(Replace(Replace(Replace(Replace(replace(LCase(Request.Form ("ftpname")),"-",""),"_",""),"@",""),".",""),".net",""),".cn",""),".com","")) Then
	ef=True
	ec="ftp名中有非法字符！"'webmaster@wow-good.com
ElseIf instr(Request.Form ("ftpname"),"..") Then
	ef=True
	ec="ftp名中有非法字符！"
ElseIf Request.Form ("ftppass")="" Then
	ef=True
	ec="请设置ftp密码！"
ElseIf len(Request.Form ("ftppass"))>30 Then
	ef=True
	ec="ftp密码超过允许的长度！"
ElseIf RegExpTest("[^A-Za-z0-9]",Replace(replace(Request.Form ("ftppass"),"-",""),"_","")) Then
	ef=True
	ec="ftp密码中有非法字符！"

ElseIf Request.Form ("rdir")="" Then
	ef=True
	ec="请设置要下载的目录！"
ElseIf len(Request.Form ("rdir"))>30 Then
	ef=True
	ec="下载的目录超过允许的长度！"
ElseIf RegExpTest("[^A-Za-z0-9]",Replace(Replace(Replace(replace(Request.Form ("rdir"),"-",""),"_",""),"/",""),"\","")) Then
	ef=True
	ec="下载的目录中有非法字符！"
ElseIf Left(Request.Form ("rdir"),1)<>"/" Then
	ef=True
	ec="下载的目录名必须以/开头！"

ElseIf Request.Form ("ldir")="" Then
	ef=True
	ec="请设置保存到的目录！"
ElseIf len(Request.Form ("ldir"))>30 Then
	ef=True
	ec="保存到的目录超过允许的长度！"
ElseIf RegExpTest("[^A-Za-z0-9]",Replace(Replace(Replace(replace(Request.Form ("ldir"),"-",""),"_",""),"/",""),"\","")) Then
	ef=True
	ec="保存到的目录中有非法字符！"
ElseIf Left(Request.Form ("ldir"),5)<>"/web/" And Left(Request.Form ("ldir"),4)<>"/db/" Then
	ef=True
	ec="保存到的目录名必须以/web/或/db/开头！"

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("canrar")="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 DateDiff("s",Application("cancopy"&dsserver("id")&"optime"),NOW )<180 and Application("cancopy"&dsserver("id"))=true then
	ef=True
	ec="系统繁忙，前一个用户的搬家操作尚未处理完，请您稍等十分钟后再试，谢谢您的支持。"
end if
end if

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

if not ef then
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
username=dsph("ftpname")
password=dsph("Ftppassword")
homedir=dsserver("homedir") 
IISID=dsph("IISID")
%>
<!--#include virtual="/inc-freehost-function/template-hostadm-top.asp"-->
 　	网站搬家
 
<br>
<br>
<br>
<%

'7i24tool -F -u new8v6 -p 7i24net7i24net -R 8v6.cn C:\freehost\test\web /public_html/*.*

logpath=replace(homedir&"\"&username&"\db\ftplog.txt","\\","\")
ldir=replace(homedir&"\"&username&"\"&Replace(Request.Form ("ldir"),"/","\"),"\\","\")
'rdir=Replace(Replace(Request.Form ("rdir")&"/*.*","\","/"),"//","/")
rdir=Replace(Replace(Request.Form ("rdir")&"/.","\","/"),"//","/")
varcon=" -d "&logpath&" -F -u "&Trim(Request.Form ("ftpname"))&" -p "&Trim(Request.Form ("ftppass"))&" -R "&Trim(Request.Form ("ip"))&" "&ldir&" "&rdir

If Request.Form ("delnow")="y" Then varcon=" -d "&logpath&" -DD -F -u "&Trim(Request.Form ("ftpname"))&" -p "&Trim(Request.Form ("ftppass"))&" -R "&Trim(Request.Form ("ip"))&" "&ldir&" "&rdir

'Response.Write varcon
'Response.end

returnstr = Sitecopy(URL,FreeHostsharekey,varcon)



if (instr(1,returnstr,"NOT IMPLEMENTED")>0) then 
Response.Write "网站搬家功能最要2009-4-19后的受控端才能支持,请您联系管理员先升级受控端" 
Response.End 
end if 
Response.Write returnstr

toDIR=replace(homedir&"\"&username&"\","\\","\")
rbsvar="-r -v "&username&" "&toDIR&"*.*"


Response.Write RBSop(URL,FreeHostsharekey,rbsvar)



%>　系统会在两分钟后自动开始帮您将网站搬家,需要的时间由网络情况决定,一般在半小时左右。搬家过程中,您可以在/db/ftplog.txt文件中看到整个搬家的命令操作过程.
<br>
<br>
<br>
　<a href="selfhostmodify.asp?id=<%=session("HOSTAUID")%>"><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

Function Sitecopy(URL,FreeHostsharekey,varcon)
Set MaintoCSCom=Server.CreateObject("www.7i24.com")
body=URLEncoding("varcon="&varcon)
RetInfo=MaintoCSCom.DOHTTPSSL(Url&"?Sitecopy",FreeHostsharekey,body,FreeHost_t1,FreeHost_t2,FreeHost_t3,FreeHost_t4)
Set MaintoCSCom =Nothing
Sitecopy=RetInfo
End Function
%>