<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<%
Function buildaclclosewrite(URL,FreeHostsharekey,var)
Set MaintoCSCom=Server.CreateObject("www.7i24.com")
body=URLEncoding("var="&var)
RetInfo=MaintoCSCom.DOHTTPSSL(Url&"?buildaclclosewrite",FreeHostsharekey,body,FreeHost_t1,FreeHost_t2,FreeHost_t3,FreeHost_t4)
Set MaintoCSCom =Nothing
buildaclclosewrite=RetInfo
End Function

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

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 Instr(1, Request.Form ("htmdir"), "\", 1)>0 or Instr(1, Request.Form ("htmdir"), "..", 1)>0 then
	ef=True
	ec="只允许设一级目录，不要用\或..符号"
ElseIf RegExpTest("[^A-Za-z0-9]",Replace(Replace(Replace(Request.Form ("htmdir"),"_",""),"#",""),"$","")) Then
	ef=True
	ec="目录名中有非法字符！"
ElseIf Request.Form ("htmdir")="" and ( Request.Form ("Submit")="关闭此目录的写入权限" or Request.Form ("Submit")="打开此目录的写入权限" )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,3
if dsph.Eof then
	ef=True
	ec="不存在的虚拟主机ID！"
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
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
username=dsph("ftpname")
homedir=dsserver("homedir") 
%>
<!--#include virtual="/inc-freehost-function/template-hostadm-top.asp"-->
 　写入权限设置
 
<br>
<br>
<br>
<%
'on error resume next

'opdir=replace(Request.Form ("opdir"),"\\","\")
opdir=trim(Request.Form ("htmdir"))
username=dsph ("Ftpname")
homedir=dsserver("homedir")
homedir=homedir&"\"&username
homedir=homedir&"\web"
if opdir<>"" then homedir=homedir&"\"&opdir
homedir=replace(homedir,"\\","\")
rbsone=username&" "&homedir
var=replace(rbsone,"\\","\")

if Request.Form ("Submit")="关闭此网站的写入权限" or Request.Form ("Submit")="关闭此目录的写入权限" then
Response.Write buildaclclosewrite(URL,FreeHostsharekey,var)
end if

if Request.Form ("Submit")="打开此网站的写入权限" or Request.Form ("Submit")="打开此目录的写入权限" then
if opdir<>"" then
Response.Write buildaclopenwrite(URL,FreeHostsharekey,var)
else
homedir=dsserver("homedir")
homedir=homedir&"\"&username
homedir=replace(homedir,"\\","\")
rbsone=username&" "&homedir
var=replace(rbsone,"\\","\")
Response.Write BUILDACL(URL,FreeHostsharekey,var)
end if
end if


'dsph.update
dsph.close

%>命令在五分钟后开始执行。
<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%>