<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<%
If session("HOSTAUID")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request.QueryString ("id")="" Then
	ef=True
	ec="请输入产品ID！"
ElseIf not IsNumeric(Request.QueryString ("id"))  Then
	ef=True
	ec="ID应该是数字！"
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='"&Request.QueryString("id")&"'"
			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
if dsph("status")<>"正常" then
		ef=True
		ec="必须是处于正常状态的主机才能删除！"
end if
end if

if not ef then
if dsph("allowsubbyid")<> session("HOSTAUID") 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
username=dsph("Ftpname")
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
end if
end if

if not ef then'检查服务器中是否存在
IISID=dsph("IISID")
returnstr=ShowUserSub(URL,FreeHostsharekey,IISID)
if instr(1,returnstr,"用户不存在！")>0 or instr(1,returnstr,"出错！")>0 then 
dsph.delete
dsph.Update
Response.Write "服务器上不存在这个主机，因此数据记录已成功删除"
Response.End 
end if
end if

if not ef then
ALLMaxConnections=0
ALLMaxBandwidth=0

IISID=dsph("IISID")
returnstr=ShowUserSub(URL,FreeHostsharekey,IISID)
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="3" Or ALLMaxBandwidthA="1024" Then 
isnewsub=True
Else
isnewsub=False
End if

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
if Not instr(returnstr,"用户名：")>1 then 
Response.Write "这台受控服务器自检没有通过，请在站点管理，虚拟主机中自检来分析原因。"
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>"
'Response.end

if not ef then

if dsph("useper")=0 then '未分配资源的站
ALLMaxConnections=""
ALLMaxBandwidth=""'----------------------
end if

IISID=dsph("IISID")
temp=DelUserSub(URL,FreeHostsharekey,IISID)
if instr(temp,"成功删除此网站")>0 then
dsph.delete
dsph.Update
else
	ef=True
	ec=temp
end if
end if

if not ef then
MaxConnections=ALLMaxConnections
MaxBandwidth=ALLMaxBandwidth
If isnewsub=False then
temp2=ModifyUser2(URL,FreeHostsharekey,username,comment,homedir,spacelimit,starttime,endtime,type1,type2,type3,email,host,hostcomment,MaxConnections,EnumAppsInPool,DefaultDoc,ScriptMaps,AccessFlags,LogFileDirectory,HttpErrors,MaxBandwidth)
End if
'Response.Write temp
end if

if not ef then
%>
<!--#include virtual="/inc-freehost-function/template-hostadm-top.asp"-->
　虚拟主机自助管理


<br>
<br>
<form name="form1" method="post" action="delsub2.asp">
<TABLE 
            width="100%" border=1 align=center cellPadding=0 cellSpacing=0 borderColorLight=#cccccc borderColorDark=#fbfbfb>
  <TBODY>
    <TR>
      <TD width="20%" vAlign=middle bgColor=#9E9E9E>&nbsp; <font color="#FFFFFF">返回信息：</font></TD>
      <TD height="40" bgColor=#ffffff>　　</TD>
      </TR>
    <TR>
      <TD width="20%" rowspan="3" vAlign=middle bgColor=#EEEEEE>&nbsp;</TD>
    </TR>
    <TR>
      <TD height="40" align="center" bgColor=#ffffff>
<%=temp%><br>原子目录绑定所用的资源已返还给主网站。
	  </TD>
      </TR>
    <TR>
      <TD height="40" align="center" bgColor=#ffffff>
	  　<a href="selfhostmodify.asp?id=<%=Request("id")%>"><font color="#000000">[返回]</font></a>
        </TD>
    </TR>
  </TBODY>
</TABLE>
</form>
<br>
<!--#include virtual="/inc-freehost-function/template-hostadm-end.asp"-->
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>