<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%

server.ScriptTimeout =240
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf RegExpTest("[^A-Za-z0-9]",Request.Form ("username")) Then
	ef=True
	ec="用户名中有非法字符！"
ElseIf Request.Form ("newusername")<>"" and RegExpTest("[^A-Za-z0-9]",Request.Form ("newusername")) Then
	ef=True
	ec="转移用户名中有非法字符！"
Elseif Request.Form ("Submit")="马上转移" and Request.Form ("newusername")="" then
	ef=True
	ec="请输入转移用户名！"
elseIf session("canadmhostset")="" Then

if Request.Form ("Submit")="马上转移" and session("canadmhostch")="" then
	ef=True
	ec="您没有此操作的权限。"
end If

If Request.Form ("Submit")="主机管理" and session("canadmhostset")="" Then
	ef=True
	ec="您没有此操作的权限。"
end If

if (Request.Form ("Submit")="允许绑定子目录" or Request.Form ("Submit")="关闭绑定子目录绑定") and session("canadmhostmidsub")="" then
	ef=True
	ec="您没有此操作的权限。"
end If

if Request.Form ("Submit")="更改允许的域名绑定数量" and session("canadmhostmiddomain")="" then
	ef=True
	ec="您没有此操作的权限。"
end If

if (Request.Form ("Submit")="设置流量及CPU" Or Request.Form ("Submit")="将当前的流量及CPU清0") and session("canadmhostmidcpu")="" then
	ef=True
	ec="您没有此操作的权限。"
end If

if (Request.Form ("Submit")="单独设置续费价格" Or Request.Form ("Submit")="取消单独价格") and session("canadmhostmidrepay")="" then
	ef=True
	ec="您没有此操作的权限。"
end If

if (Request.Form ("Submit")="重设FTP密码" or Request.Form ("Submit")="回收池" or Request.Form ("Submit")="暂停"  or Request.Form ("Submit")="停止"  or Request.Form ("Submit")="恢复"  or Request.Form ("Submit")="临时恢复"  or Request.Form ("Submit")="提取日志"  or Request.Form ("Submit")="提取旧日志"  or Request.Form ("Submit")="启用详细出错信息"  or Request.Form ("Submit")="停止详细出错信息"  or Request.Form ("Submit")="设置拒绝IP"  or Request.Form ("Submit")="设置此目录只有htm权限"  or Request.Form ("Submit")="恢复此目录" or Request.Form ("Submit")="RAR还原" or Request.Form ("Submit")="RAR打包"  or Request.Form ("Submit")="关闭写入权限"  or Request.Form ("Submit")="恢复写入权限"  or Request.Form ("Submit")="马上重开此用户"  or Request.Form ("Submit")="停止这个主机的FTP读写权限"  or Request.Form ("Submit")="恢复这个主机的FTP读写权限"  or Request.Form ("Submit")="关闭此网站的FSO权限"  or Request.Form ("Submit")="打开此网站的FSO权限"  or Request.Form ("Submit")="允许查看日志/CPU"  or Request.Form ("Submit")="不允许查看日志/CPU"  or Request.Form ("Submit")="允许打包还原"  or Request.Form ("Submit")="不允许打包还原"  or Request.Form ("Submit")="允许备份还原"  or Request.Form ("Submit")="不允许备份还原"  or Request.Form ("Submit")="重新计算此用户的实际占用空间" or Request.Form ("Submit")="重新恢复此用户的权限结构" or Request.Form ("Submit")="更改主机的备注信息" or Request.Form ("Submit")="清空数据" or Request.Form ("Submit")="删除旧主机并更换服务器" )and session("canadmhostoth")="" then
	ef=True
	ec="您没有此操作的权限。"
end If

If session("canadmhostmidcpu")="" Then
if Request.Form ("Submit")="设置资源"  then
	ef=True
	ec="您没有此操作的权限。"
end If
end If

if Request.Form ("Submit")="删除" and session("canadmhostdel")="" then
	ef=True
	ec="您没有此操作的权限。"
end If

ElseIf Instr(1, Request.Form ("htmdir"), "\", 1)>0 or Instr(1, Request.Form ("htmdir"), "..", 1)>0 then
	ef=True
	ec="只允许设一级目录，不要用\或..符号"
end If

if not ef then
If Request.Form ("pauseweb")="" Then 
if Request.Form ("Submit")="暂停" Then
	ef=True
	ec="请先选暂停原因!"
End if
End If 
End If

if not ef Then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
idarry=split(request.form("dsphid"),",")
for dsphid=0 to ubound(idarry)
'response.write idarry(dsphid)&"<br>"&dsphid&"<br>"
If IsNumeric(idarry(dsphid))  Then



	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where id='"&idarry(dsphid)&"'"
	dsph.Open Sql,conn,1,3
if Not dsph.Eof Then
Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username='"&dsph ("username")&"'"
		ds.Open Sql,conn,1,1
if Not ds.eof then
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Serverlist where id='"&dsph ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
if Not dsserver.Eof then'存在服务器

username=dsph("Ftpname")
FreeHostsharekey=dsserver("FreeHostsharekey")
URL=dsserver("site")
If Request.Form ("pauseweb")<>"" Then tourl=dsserver(""&Request.Form ("pauseweb")&"")
password=Request.Form ("password")
homedir=dsserver("homedir") 
IISID=dsph("IISID")
ostype=dsserver("ostype")'linux
'agent
if ds("agent1")<>"n" then
  Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_AGENT where username='"&ds("agent1")&"'"
		dsagent.Open Sql,conn,1,3
If not dsagent.Eof And Request.Form ("pauseweb")<>"" Then
if len(dsagent(""&Request.Form ("pauseweb")&""))>3 then
tourl=dsagent(""&Request.Form ("pauseweb")&"")
end if
end if
end If

%>
编号：<%=dsph("id")%> FTP名：<%=dsph("ftpname")%>
原状态：          <%if dsph("endtime")>NOW then%>
                  <%if dsph("istest")="y" then%>
        试用
        <%else%>
        <%=dsph("status")%>
        <%end if%>
        <%else%>
        过期
        <%if dsph("status")="暂停" then%>
        并暂停
        <%end if%>
        <%end if%>

<%
Response.Write " 进行操作:"&Request.Form ("Submit")
Response.Write " 处理结果:"
if Request.Form ("Submit")="暂停" Then
pausereason=0
If Request.Form ("pauseweb")="pauseweb" Then pausereason=1
If Request.Form ("pauseweb")="pauseweb2" Then pausereason=2
If Request.Form ("pauseweb")="pauseweb3" Then pausereason=3
If Request.Form ("pauseweb")="pauseweb4" Then pausereason=4

op=1
if dsph("Hosttype")="子目录绑定" Then
if ostype="linux" Then
Response.write "DA面板的Linux系统不能使用此功能。"
else
Response.Write PauseSiteSub(URL,FreeHostsharekey,IISID,tourl,op)
End if
Else
Response.Write PauseSite(URL,FreeHostsharekey,username,tourl,op)
end if
dsph("status")="暂停"
dsph("pausebyagn")="a"
dsph("pausereason")=pausereason
dsph.update

'处理子目录绑定
Set dsphsub = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where allowsubbyid='"&dsph("id")&"'"
	dsphsub.Open Sql,conn,1,3
while not dsphsub.eof
IISID=dsphsub("IISID")
Response.Write PauseSiteSub(URL,FreeHostsharekey,IISID,tourl,op)
dsphsub("status")="暂停"
dsphsub("pausebyagn")="a"
dsphsub("pausereason")=pausereason
dsphsub.update
dsphsub.movenext
wend
dsphsub.close
end if

if Request.Form ("Submit")="停止" then
op=1
if dsph("Hosttype")="子目录绑定" then
Response.Write OPSiteSub(URL,FreeHostsharekey,IISID,op)
else
Response.Write OPSite(URL,FreeHostsharekey,username,op)
end if
dsph("status")="停止"
dsph("pausebyagn")="a"
dsph.update
'处理子目录绑定
Set dsphsub = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where allowsubbyid='"&dsph("id")&"'"
	dsphsub.Open Sql,conn,1,3
while not dsphsub.eof
IISID=dsphsub("IISID")
Response.Write OPSiteSub(URL,FreeHostsharekey,IISID,op)
dsphsub("status")="停止"
dsphsub("pausebyagn")="a"
dsphsub.update
dsphsub.movenext
wend
dsphsub.close
end if


if Request.Form ("Submit")="恢复" then
op=0
if dsph("Hosttype")="子目录绑定" then
Response.Write PauseSiteSub(URL,FreeHostsharekey,IISID,tourl,op)
Response.Write OPSiteSub(URL,FreeHostsharekey,IISID,op)
else
Response.Write PauseSite(URL,FreeHostsharekey,username,tourl,op)
Response.Write OPSite(URL,FreeHostsharekey,username,op)
Response.Write FTPOP(URL,FreeHostsharekey,username,0)
end if
dsph("status")="正常"
dsph("pausebyagn")="n"
dsph("pausereason")=0
dsph.update
'处理子目录绑定
Set dsphsub = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where allowsubbyid='"&dsph("id")&"'"
	dsphsub.Open Sql,conn,1,3
while not dsphsub.eof
IISID=dsphsub("IISID")
Response.Write PauseSiteSub(URL,FreeHostsharekey,IISID,tourl,op)
Response.Write OPSiteSub(URL,FreeHostsharekey,IISID,op)
dsphsub("status")="正常"
dsphsub("pausebyagn")="n"
dsphsub("pausereason")=0
dsphsub.update
dsphsub.movenext
wend
dsphsub.close
dsph.update
end If










if Request.Form ("Submit")="删除" then

'if Application("hostoneip")=true Then
Sql="update FreeHost.FreeHost_Product_Host_IP set HOSTID=0 where hostid='"&dsph("id")&"'"
conn.Execute Sql
'End if

if dsph("Hosttype")="子目录绑定" then
'查找资源
isnotdesign=false
if dsph("useper")=0 then '未分配资源的站
isnotdesign=true
end if

dsph.delete
dsph.Update
Response.Write "站点信息已从数据库中删除。"
'if not ef then
ALLMaxConnections=0
ALLMaxBandwidth=0

returnstr=ShowUserSub(URL,FreeHostsharekey,IISID)
if instr(1,returnstr,"用户不存在！")>0 or instr(1,returnstr,"出错！")>0 then 
Response.Write returnstr
Response.End 
end If
if Not instr(returnstr,"网站名")>1 then 
Response.Write "这台受控服务器自检没有通过，请在站点管理，虚拟主机中自检来分析原因。完整的返回信息是:<br><br>"&returnstr
Response.End 
end if 

ALLMaxConnectionsA=GETvalue(returnstr,";IIS连接数：",";带宽限制：")
ALLMaxBandwidthA=GETvalue(returnstr,";带宽限制：",";主机头名：")
if ALLMaxConnectionsA="-1" or ALLMaxConnectionsA="4294967295"  or ALLMaxConnections=-1 then
ALLMaxConnections=-1
else
ALLMaxConnections=ALLMaxConnections+ALLMaxConnectionsA
end if
if ALLMaxBandwidthA="4294967295" or ALLMaxBandwidthA="-1" or ALLMaxBandwidth=4294967295 then
ALLMaxBandwidth=4294967295
else
ALLMaxBandwidth=ALLMaxBandwidth+ALLMaxBandwidthA
end if

returnstr = ShowUser2(URL,FreeHostsharekey,username)
if instr(1,returnstr,"用户不存在！")>0 or instr(1,returnstr,"出错！")>0 then 
Response.Write returnstr
Response.End 
end if
ALLMaxConnectionsA=GETvalue(returnstr,";IIS连接数：",";带宽限制：")
ALLMaxBandwidthA=GETvalue(returnstr,";带宽限制：",";主机头名：")
if ALLMaxConnectionsA="-1" or ALLMaxConnectionsA="4294967295"  or ALLMaxConnections=-1 then
ALLMaxConnections=-1
else
ALLMaxConnections=ALLMaxConnections+ALLMaxConnectionsA
end if
if ALLMaxBandwidthA="4294967295" or ALLMaxBandwidthA="-1" or ALLMaxBandwidth=4294967295 then
ALLMaxBandwidth=4294967295
else
ALLMaxBandwidth=ALLMaxBandwidth+ALLMaxBandwidthA
end if

'end if

'Response.Write ALLMaxConnections&"<br>"
'Response.Write ALLMaxBandwidth&"<br>"
ret=DelUserSub(URL,FreeHostsharekey,IISID)
Response.write ret
FreeHost_oplog session("admusername"),"信息","管理员删除"&username&"子目录虚拟主机: "&ret

if isnotdesign=false then '未分配资源的站
MaxConnections=ALLMaxConnections
MaxBandwidth=ALLMaxBandwidth
temp2=ModifyUser2(URL,FreeHostsharekey,username,comment,homedir,spacelimit,starttime,endtime,type1,type2,type3,email,host,hostcomment,MaxConnections,EnumAppsInPool,DefaultDoc,ScriptMaps,AccessFlags,LogFileDirectory,HttpErrors,MaxBandwidth)
Response.Write temp
end if
'完成资源分配


Else


Set dsphemail = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Email where byhost='"&dsph ("id")&"'"
	dsphemail.Open Sql,conn,1,1
if not dsphemail.Eof then
%>
<br><a href="handemail1.asp?id=<%=dsphemail("id")%>" target="_blank"><font color=red>管理赠送的邮箱</font></a>
<%dsphemail.close
end if

Set dsphsql = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Sql where byhost='"&dsph ("id")&"'"
	dsphsql.Open Sql,conn,1,1
if not dsphsql.Eof then
%>
<br><a href="handsql1.asp?id=<%=dsphsql("id")%>" target="_blank"><font color=red>管理赠送的数据库</font></a>
<%dsphsql.close
end if

Set dsdom = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Domain where byid='"&dsph ("id")&"'"
	dsdom.Open Sql,conn,1,1
if not dsdom.Eof then
%>
<br><a href="listmydomain.asp?id=<%=dsdom("id")%>" target="_blank"><font color=red>管理赠送的域名</font></a>
<%
dsdom.close
end if

Set dspre = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Preopen_Product where byid='"&dsph ("id")&"'"
	dspre.Open Sql,conn,1,3
if not dspre.Eof then%>
<br><font color=red>赠送的未开通的域名已删除</font></a>
<%
dspre.delete
dspre.movenext
end if
dspre.close

On Error Resume next'出错也处理
'Response.end
ret=DelUser(URL,FreeHostsharekey,username)
'log
FreeHost_oplog session("admusername"),"信息","管理员删除"&username&"主虚拟主机: "&ret
Response.Write ret&"<br>"

'删除ICPDB
conn.Execute "delete from FreeHost.FreeHost_ICPDB where ftpname='"&dsph("ftpname")&"'"

'处理子目录绑定
Set dsphsub = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where allowsubbyid='"&dsph("id")&"'"
	dsphsub.Open Sql,conn,1,3
while not dsphsub.eof
IISID=dsphsub("IISID")
ret=DelUserSub(URL,FreeHostsharekey,IISID)
Response.Write ret
FreeHost_oplog session("admusername"),"信息","管理员删除"&username&"子目录虚拟主机: "&ret
dsphsub.delete
dsphsub.update
dsphsub.movenext
wend
dsphsub.close

dsph.delete
dsph.close
end if
end if












%>      <br>
<%

end if'存在服务器
end If
end If

End If'isnumeric
Next

End If





if ef then
Response.Redirect "e.asp?e="&ec
end if%>
