<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<%'aspnet_regiis.exe -norestart -s W3SVC/997936427
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应该是数字！"
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 dshost = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_HostProductlist where Hosttype='"&dsph("Hosttype")&"'"
	if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dshost.Open Sql,conn,1,1
if dshost.Eof then
	ef=True
	ec="产品不存在！"
end if
end If

if not ef then
if not (dsph("status")="用户停止" or dsph("status")="正常") 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
canpool="n"
if dshost("AppPoolnum")=1 then canpool="y"
if not isnull(dsph("AppPoolnum")) then
if dsph("AppPoolnum")=1 then canpool="y"
end If
canchnetver="n"
If canpool="y" then
if dshost("aspx")="y" then canchnetver="y"
end If
if canchnetver="n" then
'	ef=True
'	ec="您所在的池不允许这项操作！"
end if
end If

if not ef then
if Not dsph("canchnetver")="y" Then
If Not session("canchnetver")="y" then
	ef=True
	ec="此产品不允许切换.Net版本！"
end If
End if
end If

if not ef Then
if dshost("aspx")<>"y" Then
	ef=True
	ec="不支持asp.net的虚拟主机不能用这个功能"
End If
end If


if not ef Then

If Request.Form ("Submit")="切换成1.1版本" then
dsph("netver")="1.1"
Else
dsph("netver")="2.0"
End If
If Request.Form ("Submit")="切换成4.0/4.5版本" Then dsph("netver")="4.0"
dsph.update

session("netver")=dsph("netver")

'if not isnull(dsph("AppPoolnum")) then  AppPoolnum=dsph("AppPoolnum")
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
username=dsph("ftpname")
'returnstr = ShowUser2(URL,FreeHostsharekey,username)
'if (instr(1,returnstr,"用户不存在！")>0) then 
'Response.Write returnstr
'Response.End 
'end if 
'if Not instr(returnstr,"用户名：")>1 then 
'Response.Write "这台受控服务器自检没有通过，请在站点管理，虚拟主机中自检来分析原因。"
'Response.End 
'end if 
'PoolName=GETvalue(returnstr,",;应用程序池名：",";默认首页：")
'PoolName=trim(PoolName)
'if Left(PoolName,2)<>"1_" Then
'	ef=True
'	ec="您所在的池不允许这项操作！"
'End if
'End If

'if not ef then

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,"||","|"))


EnumAppsInPool=dshost ("AppPoolnum")
'if not isnull(dsph("AppPoolnum")) then  EnumAppsInPool=dsph("AppPoolnum")

if not isnull(dsph("AppPoolnum")) Then
If dsph("AppPoolnum")=1 then
EnumAppsInPool=1
End if
End if

'EnumAppsInPoolOLD=EnumAppsInPool
netver=dsserver("netver")
If Not IsNull(dshost("netver")) Then netver=dshost("netver")
If netver<>dsph("netver") then'当产品默认.net不等于要换的
If EnumAppsInPool>1 And dshost("AppPoolnum")>1 then
If dsph("netver")="1.1" Then EnumAppsInPool=EnumAppsInPool+1
If dsph("netver")="2.0" Then EnumAppsInPool=EnumAppsInPool+2
If dsph("netver")="4.0" Then EnumAppsInPool=EnumAppsInPool+4
dsph("AppPoolnum")=EnumAppsInPool
dsph.update
End if
End If

'原代码
'if EnumAppsInPool=1 then  EnumAppsInPool=""
'outtemp=ModifyUser2(URL,FreeHostsharekey,username,comment,homedir,spacelimit,starttime,endtime,type1,type2,type3,email,host,hostcomment,MaxConnections,EnumAppsInPool,DefaultDoc,ScriptMaps,AccessFlags,LogFileDirectory,HttpErrors,MaxBandwidth)



dsph("AppPoolnum")=EnumAppsInPool'不保存的
'If Not IsNull(dsph("CurPoolname")) Then
'dsph("CurPoolname")=Null
'dsph.update
'新的受控
CurPoolname=dsph("AppPoolnum")&"_FreeHost_1"
Curpoolid=1
haneemptypool=False
	Set dsPooldist = Server.CreateObject("ADODB.Recordset")	
Sql="Select distinct CurPoolname from FreeHost.FreeHost_Product_Host where serverlistid='"&dsph("ServerlistID")&"' and hosttype<>'子目录绑定' and AppPoolnum='"&EnumAppsInPool&"' and CurPoolname is not null and CurPoolname like '"&EnumAppsInPool&"_F%' order by CurPoolname Asc"
	dsPooldist.Open Sql,conn,1,1
'	response.write sql
If dsPooldist.Eof Then haneemptypool=true'一个这样的池也没有
Do Until dsPooldist.Eof
CurPoolname=dsPooldist("CurPoolname")
If CInt(Replace(CurPoolname,dsph("AppPoolnum")&"_FreeHost_",""))>Curpoolid Then Curpoolid=CInt(Replace(CurPoolname,dsph("AppPoolnum")&"_FreeHost_",""))
'response.write "<br>"&CurPoolname&"<br>"
Set dsCurPcount = Server.CreateObject("ADODB.Recordset")	
Sql="Select count(*) from FreeHost.FreeHost_Product_Host where serverlistid='"&dsph("ServerlistID")&"' and hosttype<>'子目录绑定' and CurPoolname='"&CurPoolname&"'"
	dsCurPcount.Open Sql,conn,1,1
'	response.write dsCurPcount(0)&"<br>"
	If dsCurPcount(0)<CInt(EnumAppsInPool) Then'池没装完
	If dsCurPcount(0)>0 Then CurPoolname=dsPooldist("CurPoolname")'池名不变
	haneemptypool=true
	Exit do
	End if
	dsCurPcount.close
dsPooldist.movenext
loop
dsPooldist.close
if haneemptypool=False Then CurPoolname=EnumAppsInPool&"_FreeHost_"&CStr(Curpoolid+1)
dsph("CurPoolname")=CurPoolname'不保存
'dsph.update

'End If

if EnumAppsInPool=1 then  EnumAppsInPool=""


outpoolname=dsph("CurPoolname")
op=1
outtemp="新受控"&ModifyUser3(URL,FreeHostsharekey,username,comment,homedir,spacelimit,starttime,endtime,type1,type2,type3,email,host,hostcomment,MaxConnections,EnumAppsInPool,DefaultDoc,ScriptMaps,AccessFlags,LogFileDirectory,HttpErrors,MaxBandwidth,outpoolname,op)



'处理子目录绑定
if dsph("Hosttype")<>"子目录绑定" then
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
dsphsub("netver")=dsph("netver")
IISID=dsphsub("IISID")
temp="子目录站同步操作："&ModifyUserSub(URL,FreeHostsharekey,username,password,IISID,comment,homedir,spacelimit,starttime,endtime,type1,type2,type3,email,host,hostcomment,MaxConnections,EnumAppsInPool,DefaultDoc,ScriptMaps,AccessFlags,LogFileDirectory,HttpErrors,MaxBandwidth)

dsphsub.update
dsphsub.movenext
wend
dsphsub.close
end if



%>
<!--#include virtual="/inc-freehost-function/template-hostadm-top.asp"-->
 　更改.Net版本号
 
<br>
<br>
<br>
<%=outtemp%><%=temp%>
<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%>