<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
server.ScriptTimeout =2400
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request.QueryString ("pn")="" Then
	ef=True
	ec="请输入页号！"
ElseIf Instr(1, Request.QueryString ("pn"), "'", 1)>0 then
	ef=True
	ec="产品类型有非法字符！"
ElseIf not IsNumeric(Request("ServerlistID")) Then
	ef=True
	ec="编号必须是数字"
elseIf session("canrebuild")="" Then
	ef=True
	ec="您没有此操作的权限。"
end If

if not ef then
if DateDiff("s", Application("hostoptime"),NOW )<180 and Application("hostoplock")=true then
	ef=True
	ec="系统繁忙，前一个网站开通操作尚未处理完，请您稍等两分钟后再试，谢谢您的支持。"
end if
end if

if not ef Then
 
pn=Request.QueryString ("pn")
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsph = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_Product_Host where serverlistid='"&Request.QueryString("ServerlistID")&"' and hosttype<>'子目录绑定'  order by id desc"
	dsph.PageSize = 50
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="此服务器并没有开通虚拟主机！"
else
	If dsph.RecordCount <> 0 Then dsph.AbsolutePage = CLng(pn) 
end if
end If


if not ef Then
Dim EnumAppsInPool
%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html8")%>
<%=htmlwrite("html9")%>
<TABLE width="100%" border=0 cellPadding=0 cellSpacing=0 background="img/midtop4.gif">
  <TBODY>
    <TR>
      <TD width=53 align="left" background="img/midtop1.gif"><strong> 　 </strong><font color="#FFFFFF">─<strong>&gt;</strong></font> </TD>
      <TD align="left"><table height="59"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="7" background="img/midtop.gif">&nbsp;</td>
            <td width="80" align="center" valign="middle" background="img/r3.jpg" id="tableTop1" style="Cursor:hand"><a href="rebuild.asp"><font color="#FFFFFF">重建用户</font></a><a href="serverlist.asp"></a></td>
            <td width="5" background="img/midtop2.gif">&nbsp;</td>
          </tr>
      </table></TD>
      <TD width=23 align="right"><IMG height=59 
                  src="img/rtop4.jpg" 
                  width=19></TD>
    </TR>
  </TBODY>
</TABLE>
<TABLE width="100%" border=0 cellPadding=0 cellSpacing=0>
  <TBODY>
    <TR>
      <TD width=19 background="img/midlef.gif" id=rightid>&nbsp;</TD>
      <TD height="300" align="center" vAlign=top bgcolor="#FFFFFF"><br>
<br>

<DIV class="tableborder"><br>
<br>
<br>
<%

For N=1 To dsph.PageSize 
					If dsph.RecordCount=0 Then Exit For

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 dshost = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_HostProductlist where Hosttype='"&dsph ("Hosttype")&"'"
	dshost.Open Sql,conn,1,1
if not dshost.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

isuseCDN=dsserver("isuseCDN")	
usecdn1=dsserver("usecdn1")
usecdn2=dsserver("usecdn2")
usecdn3=dsserver("usecdn3")
usecdn4=dsserver("usecdn4")
usecdn5=dsserver("usecdn5")
CDNORIport=dsserver("port")

packagename=dshost("packagename")'linux
	ostype=dsserver("ostype")'linux
'调用开通function
AccessFlags=1
if dshost("asp")="y" then
AccessFlags=513
ScriptMaps=dsserver("asp") 
end if

if dshost("aspx")="y" then
AccessFlags=513
netver=dsserver("netver")
If Not IsNull(dshost("netver")) Then netver=dshost("netver")
If Not IsNull(dsph("netver")) Then netver=dsph("netver")
If netver="1.1" Then ScriptMaps=ScriptMaps&"|"&dsserver("aspx") 
If netver="2.0" Then ScriptMaps=ScriptMaps&"|"&dsserver("aspx2") 
If netver="4.0" Then ScriptMaps=ScriptMaps&"|"&dsserver("aspx4") 
end If

if dshost("cgi")="y" then
AccessFlags=517
ScriptMaps=ScriptMaps&"|"&dsserver("cgi") 
end if
if dshost("php")="y" then
AccessFlags=513
ScriptMaps=ScriptMaps&"|"&dsserver("php") 
end If
if dsph("notuserar")="y" then
ScriptMaps=ScriptMaps&"|"&dsserver("notuserar") 
end if
if dsserver("infosafe")<>"" And AccessFlags>1 then
ScriptMaps=ScriptMaps&"|"&dsserver("infosafe") 
end if
ScriptMaps=trim(replace(ScriptMaps,"||","|"))

URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
ostype=dsserver("ostype")'linux
username=dsph ("Ftpname")
password=dsph("Ftppassword")
comment=dsph ("username")
homedir=dsserver("homedir")
spacelimit=dshost ("spacelimt")
starttime=dsph("starttime")
endtime=dsph("endtime")
type1=dsph("Hosttype")
email=ds("email")
host=dsph("hostname")
hostcomment_arry=Split(host, ",")
hostcomment=Replace(hostcomment_arry(0),":80:","")&"_"&username&"_"&dsph ("username")
MaxConnections=dshost ("MaxConnections")
EnumAppsInPool=dshost ("AppPoolnum")
MaxBandwidth=dshost ("MaxBandwidth")
'DefaultDoc=""'dshost ("DefaultDoc")
ScriptMaps=ScriptMaps
AccessFlags=AccessFlags
'LogFileDirectory=""'dsserver ("LogFileDirectory")
'HttpErrors=""'Request.Form ("HttpErrors")
if not isnull(dsph("spacelimt")) then  spacelimit=dsph("spacelimt")
if not isnull(dsph("MaxConnections")) then  MaxConnections=dsph("MaxConnections")
if not isnull(dsph("MaxBandwidth")) then  MaxBandwidth=dsph("MaxBandwidth")
if not isnull(dsph("AppPoolnum")) then  EnumAppsInPool=dsph("AppPoolnum")
If EnumAppsInPool="" Then EnumAppsInPool=dshost ("AppPoolnum")

If IsNull(MaxBandwidth) Then MaxBandwidth=4294967295
If IsNull(MaxConnections) Then MaxConnections=4294967295
If MaxBandwidth="" Then MaxBandwidth=4294967295
If MaxConnections="" Then MaxConnections=4294967295
ALLMaxConnections=Cdbl(MaxConnections)'为子目录站准备
ALLMaxBandwidth=Cdbl(MaxBandwidth)'为子目录站准备

'检查有没有子目录站，分配主站资源
useper=100
Set dsphsub = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where Hosttype='子目录绑定' and allowsubbyid='"&dsph("id")&"' order by endtime desc"
dsphsub.Open Sql,conn,1,3
While Not dsphsub.eof
useper=useper-dsphsub("useper")'分配资源
dsphsub.movenext
wend
dsphsub.close
if ALLMaxBandwidth<32727000 and ALLMaxBandwidth>0 then
MaxBandwidth=Cdbl(ALLMaxBandwidth*useper/100)
else
MaxBandwidth=4294967295
end If
if ALLMaxConnections>-1 and ALLMaxConnections<500000 then
MaxConnections=Cdbl(ALLMaxConnections*useper/100)
else
MaxConnections=-1
end If

hostname=host
if dsserver("iisver")>6 Then
hostnamestr=replace(hostname, ":80:","")
hostname_arry=Split(hostnamestr, ",")
for i=0 to ubound(hostname_arry)
hostname_arry(i)=ComX.actoidc_7i24_com(cstr(hostname_arry(i)))
next
hostname=""
for i=0 to ubound(hostname_arry)
hostname=hostname&":80:"&replace(replace(hostname_arry(i), " ",""),":80:","")&","
next
if right(hostname,1)="," then hostname=left(hostname,len(hostname)-1)
End If
host=hostname

if Application("hostoneip")=true then
Set dsX = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_Host_IP where HostID="&dsph("id")
		dsX.Open Sql,conn,1,1
If not dsX.Eof Then
host=Replace(host,":80:",dsX("IP")&":80:")
If dsph("iphead")=true then host=dsX("IP")&":80:"&dsX("IP")&","&host
If dsph("nullhead")=true Then host=dsX("IP")&":80:,"&host
End if
End If

if isuseCDN=true Then host=Replace(host,":80:",":"&CDNORIport&":")
Application.lock
Application("hostoptime")=now
Application("hostoplock")=true
Application.unlock
'Application.lock
If request("havebuildpool")="true" And Not IsNull(dsph("CurPoolname")) Then
siteID=dsph("id")&"000"
outpoolname=dsph("CurPoolname")
op=0
response.write "新受控建立主站FTP名："&username&"信息："&AddUser3(URL,FreeHostsharekey,username,password,comment,homedir,spacelimit,starttime,endtime,type1,type2,type3,email,host,hostcomment,MaxConnections,EnumAppsInPool,DefaultDoc,ScriptMaps,AccessFlags,LogFileDirectory,HttpErrors,MaxBandwidth,siteID,outpoolname,op)
else
response.write "建立主站FTP名："&username&"信息："&AddUser2(URL,FreeHostsharekey,username,password,comment,homedir,spacelimit,starttime,endtime,type1,type2,type3,email,host,hostcomment,MaxConnections,EnumAppsInPool,DefaultDoc,ScriptMaps,AccessFlags,LogFileDirectory,HttpErrors,MaxBandwidth)
End if
'Application.unlock
Application.lock
Application("hostoplock")=false
Application.unlock

response.write tem
'response.flush
tourl=dsserver("pauseweb3")
if dsph("pausereason")=1 Then tourl=dsserver("pauseweb")
if dsph("pausereason")=2 Then tourl=dsserver("pauseweb2")
if dsph("pausereason")=3 Then tourl=dsserver("pauseweb3")
if dsph("pausereason")=4 Then tourl=dsserver("pauseweb4")

if dsph ("status")="暂停" then
op=1
if dsph("Hosttype")="子目录绑定" then
Response.Write PauseSiteSub(URL,FreeHostsharekey,IISID,tourl,op)
else
Response.Write PauseSite(URL,FreeHostsharekey,username,tourl,op)
end if
end If

if dsph ("status")="停止" then
op=1
if dsph("Hosttype")="子目录绑定" then
Response.Write OPSiteSub(URL,FreeHostsharekey,IISID,op)
else
Response.Write OPSite(URL,FreeHostsharekey,username,op)
end If
end if

'if instr(1,tem,"用户已存在！")<1 then
'rbsone="rbs.exe -r -v "&username&" "&homedir&"\"&"*.*"
'rbsone=replace(rbsone,"\\","")
'rbs=rbs+"</br>"+rbsone
'end if
%>
网址为：</font><font color="#000000"><a href="http://<%=Replace(hostcomment_arry(0),":80:","")%>" target=_blank><font color="#000000">http://<%=Replace(hostcomment_arry(0),":80:","")%></font></a></font>
<br><br>

<%

'处理子目录
havesubsite=false
Set dsphsub = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where Hosttype='子目录绑定' and allowsubbyid='"&dsph("id")&"' order by endtime desc"
dsphsub.Open Sql,conn,1,3
While Not dsphsub.eof
havesubsite=true
hostname=dsphsub("hostname")
hostname=replace(hostname, ":80:","")
hostname_arry=Split(hostname, ",")

%>
子目录网站：
<%for idname=0 to ubound(hostname_arry)%><a href="http://<%=hostname_arry(idname)%>" target="_blank"><%=hostname_arry(idname)%></a> <%next%>子目录：<%=dsphsub("dirname")%>的开通信息：
<%
IISID=dsphsub("IISID")
returnstr=ShowUserSub(URL,FreeHostsharekey,IISID)
if instr(Replace(returnstr,",",""),Replace(dsphsub("hostname"),",",""))<2 then 
'不存在的的子站才可以建立。
homedir=dsserver("homedir")
type1=dsphsub("Hosttype")
email="子目录绑定"
host=dsphsub("hostname")
hostcomment_arry=Split(host, ",")
hostcomment="Sub_"&username&"_"&Replace(hostcomment_arry(0),":80:","")&"_"&dsphsub("username")
MaxConnections=5'----------------------
'EnumAppsInPool=50'----------------------2009-6-21

useper=dsphsub("useper")'分配资源
if ALLMaxBandwidth<32727000 and ALLMaxBandwidth>0 then
MaxBandwidth=CLNG(ALLMaxBandwidth*useper/100)
else
MaxBandwidth=4294967295
end If
if ALLMaxConnections>-1 and ALLMaxConnections<500000 then
MaxConnections=CLNG(ALLMaxConnections*useper/100)
else
MaxConnections=-1
end If

hostname=host
if dsserver("iisver")>6 Then
hostnamestr=replace(hostname, ":80:","")
hostname_arry=Split(hostnamestr, ",")
for i=0 to ubound(hostname_arry)
hostname_arry(i)=ComX.actoidc_7i24_com(cstr(hostname_arry(i)))
next
hostname=""
for i=0 to ubound(hostname_arry)
hostname=hostname&":80:"&replace(replace(hostname_arry(i), " ",""),":80:","")&","
next
if right(hostname,1)="," then hostname=left(hostname,len(hostname)-1)
End If
host=hostname

if Application("hostoneip")=true then
Set dsX = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_Host_IP where HostID="&dsphsub("allowsubbyid")
		dsX.Open Sql,conn,1,1
If not dsX.Eof Then
host=Replace(host,":80:",dsX("IP")&":80:")
host=dsX("IP")&":80:"&dsX("IP")&","&host
End if
End if

if isuseCDN=true Then host=Replace(host,":80:",":"&CDNORIport&":")
Application.lock
Application("hostoptime")=now
Application("hostoplock")=true
Application.unlock
'Application.lock
temp=AddUserSubNotchek(URL,FreeHostsharekey,username,password,comment,homedir,spacelimit,starttime,endtime,type1,type2,type3,email,host,hostcomment,MaxConnections,EnumAppsInPool,DefaultDoc,ScriptMaps,AccessFlags,LogFileDirectory,HttpErrors,MaxBandwidth)
'Application.unlock
Application.lock
Application("hostoplock")=false
Application.unlock

IISID=GETvalue(temp,"此目录的虚拟主机ID为：_","_号;")
NOWIISID=IISID
dsphsub("IISID")=IISID
dsphsub.update%>
<%=temp%><br>
<%Else%>
IIS中已存在这个子目录站，不需要开通。
<%end if'完成开通这个子目录站

tourl=dsserver("pauseweb3")
if dsph("pausereason")=1 Then tourl=dsserver("pauseweb")
if dsph("pausereason")=2 Then tourl=dsserver("pauseweb2")
if dsph("pausereason")=3 Then tourl=dsserver("pauseweb3")
if dsph("pausereason")=4 Then tourl=dsserver("pauseweb4")

if dsphsub ("status")="暂停" then
op=1
Response.Write PauseSiteSub(URL,FreeHostsharekey,IISID,tourl,op)
end If
if dsphsub ("status")="停止" then
op=1
Response.Write OPSiteSub(URL,FreeHostsharekey,IISID,op)
end if

dsphsub.movenext
wend
dsphsub.close


%>

<%
end if
end if
end if
If clng(pn)=dsph.PageCount Then
I = dsph.RecordCount - (dsph.PageCount-1) * dsph.PageSize
If N=I Then Exit For
End If
dsph.movenext
Next

dsph.close
set dsph=nothing%>
<br><br>
一般的错误提示可以不用担心，但如果用户改过默认的首页，是需要用户再输入一次的。
<br><br>
	  </div>
</TD>
      <TD width=18 background="img/midri.gif">&nbsp;</TD>
    </TR>
  </TBODY>
</TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
    <TR>
      <TD width=30><IMG height=19 
                  src="img/rb1.jpg" 
                  width=30></TD>
      <TD 
                background=img/rb2.jpg>&nbsp;</TD>
      <TD width=30><IMG height=19 
                  src="img/rb3.jpg" 
                  width=30></TD>
    </TR>
  </TBODY>
</TABLE>
<%=htmlwrite("html10")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
