<%@ 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 ("dirname")="" Then
	ef=True
	ec="请设置子目录名！"
ElseIf len(Request.Form ("dirname"))>50 Then
	ef=True
	ec="目录名超过允许的长度！"
ElseIf Left(Request.Form ("dirname"),4)<>"\web" Then
	ef=True
	ec="目录名必须以\web开头！"
ElseIf RegExpTest("[^A-Za-z0-9]",replace(Request.Form ("dirname"),"\","")) Then
	ef=True
	ec="目录名中有非法字符！"
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("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")
username=dsph("ftpname")
password=dsph("Ftppassword")
homedir=dsserver("homedir") 
IISID=dsph("IISID")
%>
<!--#include virtual="/inc-freehost-function/template-hostadm-top.asp"-->
 　	网站打包
 
<br>
<br>
<br>
<%
on error resume next
	yy=year(date)
	mm=right("00"&month(date),2)
	dd=right("00"&day(date),2)
	v_ymd=yy&mm&dd
	xiaoshi=right("00"&hour(time),2)
	fenzhong=right("00"&minute(time),2)
	miao=right("00"&second(time),2)
	BillNo=v_ymd&xiaoshi&fenzhong&miao

pathRAR=replace(homedir&"\"&username&"\db\"&BillNo&".rar","\\","\")
pathDIR=replace(homedir&"\"&username&"\"&Request.Form ("dirname")&"\*.*","\\","\")
RARcon=" a -ibck -inul -m0 -ep1 -r -y "&pathRAR&" "&pathDIR
if Request.Form ("rarv")="y" then RARcon=" a -v50M -ibck -inul -m0 -ep1 -r -y "&pathRAR&" "&pathDIR
'Response.Write RARcon
'Response.Write RAROP(URL,FreeHostsharekey,RARcon,username,password)

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

Response.Write RAROPadm(URL,FreeHostsharekey,RARcon)
Response.Write RBSop(URL,FreeHostsharekey,rbsvar)



%>　系统会在十分钟后自动将<%=Request.Form ("dirname")%>目录打包在db目录的<%=BillNo&".rar"%>文件中，请您稍后用FTP下载它。
<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%>