<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostEmail.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
Dim CDNret
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("canadmhostset")="" Then
	ef=True
	ec="您没有此操作的权限。"
ElseIf Request.Form ("id")="" Then
	ef=True
	ec="请选择产品！"
ElseIf Instr(1, Request.Form ("id"), "'", 1)>0 then
	ef=True
	ec="非法产品ID！"
ElseIf not IsNumeric(Request.Form ("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
ElseIf not IsNumeric(Request.Form ("hosttypeAuto"))  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.Form ("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="host不存在！"
end if
end if

if not ef then
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username='"&dsph("username")&"'"
		ds.Open Sql,conn,1,3
if ds.eof then
	ef=True
	ec="用户不存在!"
end if
end if


if not ef then
	Set dshostold = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_hostProductlist where hosttype='"&dsph ("hosttype")&"'"
	dshostold.Open Sql,conn,1,1
if dshostold.Eof 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
'	ostype=dsserver("ostype")'linux
'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
    netby=dsserver("netby")
	ip=dsserver("ip")
	hostip=dsserver("ip")
	ftpdomain=dsserver("ftpdomain")
	ostype=dsserver("ostype")
hostip=dsserver("ip")
isuseCDN=dsserver("isuseCDN")	
usecdn1=dsserver("usecdn1")
usecdn2=dsserver("usecdn2")
usecdn3=dsserver("usecdn3")
usecdn4=dsserver("usecdn4")
usecdn5=dsserver("usecdn5")
CDNORIport=dsserver("port")
end if
end if

if not ef then
if isuseCDN=true then
	Set dsCDNserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerCDNlist where id='"&dsserver ("usecdn1")&"'"
	dsCDNserver.Open Sql,conn,1,3
if dsCDNserver.Eof then
	ef=True
	ec="CDN服务器不存在！"
end if
end if
end if

if not ef Then
	Set dshost = Server.CreateObject("ADODB.Recordset")	
	'新产品类别
	Sql="Select * from FreeHost.FreeHost_hostProductlist where id='"&Request.Form ("hosttypeAuto")&"'"
	dshost.Open Sql,conn,1,1
if dshost.Eof then
	ef=True
	ec="新的产品类型不存在！"
Else
packagename=dshost("packagename")'linux
newhosttype=dshost("hosttype")
NewtypePrice=dshost("usermoney")'新产品价格
End If
End If

if not ef then
if dshost("ostype")<>dshostold("ostype") then
	ef=True
	ec="产品只能在一样的操作系统类型中升级！您现在的操作系统类型为："&dshostold("ostype")
end if
end If

if not ef Then
olduser_money=ds("usermoney")
oldtime=dsph ("endtime")
starttime=dsph ("endtime")
pdtype=dsph("hosttype")

moneych=0
oldtime=dsph ("endtime")


If dsph ("hosttype")<>newhosttype Then'类型变更

'response.write "类型变"

typechange=true
pdtype="原类型："&dsph ("hosttype")&" 新类型："&Request.Form ("hosttype")
FreeHost_oplog session("admusername"),"信息","管理员修改虚拟主机，("&dsph ("ftpname")&")原类型:"&dsph ("hosttype")&"新类型:"&Request.Form ("hosttype")
dsph ("hosttype")=newhosttype
dsph.update
If Request.Form ("chmoneyauto")<>"" Then
'变更金额
if Request.Form ("usermoneyauto")<>"" then'手工指定变更金额
ds("usermoney")=ds("usermoney")-Request.Form ("usermoneyauto")
moneych=-Request.Form ("usermoneyauto")
'response.write "---手工设置"
else'计算差价

daytoend=DateDiff("d",NOW,dsph("endtime"))
if daytoend<0 Then daytoend=0
if dsph("istest")="y" then  daytoend=0
oldusermoneyleft=dshostold("usermoney")/365*daytoend
if oldusermoneyleft<0 then oldusermoneyleft=0'防止出现特殊情况
newtypeusemoneyforuser=NewtypePrice/365*daytoend'计算新产品价格
oldusermoneytake=newtypeusemoneyforuser-oldusermoneyleft
ds("usermoney") =ds("usermoney")-Fix(oldusermoneytake)
moneych=-Fix(oldusermoneytake)

end if
end if

end if

newuser_money=ds("usermoney")
'moneych=newuser_money-olduser_money
temptime=dsph ("endtime")
ds.update

if Request.Form ("istestch1")="y" then
dsph("status")="正常"
dsph("istest")="n"
dsph.update
FreeHost_oplog session("admusername"),"信息","管理员修改虚拟主机，("&dsph ("ftpname")&") 将试用的改成正式的"
end If




'更新产品类别
dsph ("hosttype")=dshost("hosttype")


dsph("status")="正常"
starttime=dsph ("endtime")
temptime=dsph ("endtime")
dsph.update

isadd="y"
If newuser_money<olduser_money Then isadd="n"

If moneych<>0 Then FreeHost_moneyNewlog conn,"y","n","y","n",isadd,isAgnHostSer,abs(moneych),dsph ("username"),session("admusername"),dsph ("username"),olduser_money,newuser_money,agnusername,agnStmoney,agnEndmoney,session("admusername"),"管理员修改虚拟主机(ftp名"&dsph ("ftpname")&")","管理员修改虚拟主机(ftp名"&dsph ("ftpname")&")","虚拟主机",dsph("id"),pingzheng,type1,bank,haveget,havecheck

FreeHost_oplog session("admusername"),"信息","管理员完成修改虚拟主机操作,ftp用户名，("&dsph ("ftpname")&")"



if dshost("isbydomain")="y" then
'送域名
	Set dspre = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Preopen_Product where byid='"&dsph("id")&"'"
	dspre.Open Sql,conn,1,3
if dspre.eof then
dspre.addnew
dspre("username")=ds("username")
dspre("haveget")="n"
dspre("byid")=dsph("id")
dspre("type1")=dshost("Domaintype")
dspre("whichProduct")="虚拟主机"
dspre("attime")=now
dspre("agent1")=ds("agent1")
dspre.update
dspre.close
set dspre=nothing
end if
end if


starttime=now
'开通邮箱
	Set dsemailpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_EmailProductlist where Hosttype='"&dshost("Hosttype")&"' and isbyhost='y'"
	dsemailpdlist.Open Sql,conn,1,1
if not dsemailpdlist.Eof then

'2008-2-14修改bug
ServerlistID=dsemailpdlist ("ServerlistID")
	Set dsemailserver = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Serveremaillist where netby='"&netby&"' and agent1='n'"

		dsemailserver.Open Sql,conn,1,1
while not dsemailserver.Eof
 if (dsemailpdlist ("ServerlistID")=dsemailserver("id") or dsemailpdlist ("ServerlistID2")=dsemailserver("id")  or dsemailpdlist ("ServerlistID3")=dsemailserver("id") or dsemailpdlist ("ServerlistID4")=dsemailserver("id") or dsemailpdlist ("ServerlistID5")=dsemailserver("id")) then
 ServerlistID=dsemailserver("id")'优先选择可选机房中的同机房
 end if
 dsemailserver.movenext
wend
dsemailserver.Requery
while not dsemailserver.Eof
 if ip=dsemailserver("ip") and (dsemailpdlist ("ServerlistID")=dsemailserver("id") or dsemailpdlist ("ServerlistID2")=dsemailserver("id")  or dsemailpdlist ("ServerlistID3")=dsemailserver("id") or dsemailpdlist ("ServerlistID4")=dsemailserver("id") or dsemailpdlist ("ServerlistID5")=dsemailserver("id")) then
 ServerlistID=dsemailserver("id")'优先选择可选机房中的同一IP
 end if
  dsemailserver.movenext
wend
dsemailserver.close


	Set agnserverid = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_EmailProductlist_AGN where id='"&dsemailpdlist ("id")&"' and agent1='"&ds("agent1")&"'"
	agnserverid.Open Sql,conn,1,1
if not agnserverid.Eof then
if  agnserverid ("ServerlistID")<>0 then ServerlistID=agnserverid ("ServerlistID")
end if

Set dsphemail = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Email where byhost='"&dsph ("id")&"'"
	dsphemail.Open Sql,conn,1,3
if dsphemail.eof then
dsphemail.addnew
dsphemail("username")=ds("username")
dsphemail("ServerlistID")=ServerlistID
dsphemail("Emailtype")=dsemailpdlist("Emailtype")

dsphemail("starttime")=starttime
dsphemail("endtime")=temptime
dsphemail("byhost")=dsph("id")
dsphemail("istest")="n"
dsphemail("emailcount")=dsemailpdlist("emailcount")
dsphemail("userspacelimt")=dsemailpdlist("userspacelimt")
dsphemail("domainspacelimt")=dsemailpdlist("domainspacelimt")
dsphemail("domainmustsame")=dsemailpdlist("domainmustsame")
dsphemail("status")="正常"
if ds("agent1")<>"n" then
dsphemail("agent1")=ds("agent1")
else
dsphemail("agent1")="n"
end if
dsphemail.update
dsphemail.close

'log
	Set dsphemail = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Email where starttime='"&starttime&"' and username='"&ds("username")&"'"
	dsphemail.Open Sql,conn,1,1
FreeHost_oplog session("admusername"),"信息","管理员升级虚拟主机("&dsph ("Ftpname")&")赠送邮箱ID:"&dsphemail("id")
retemail="赠送的邮箱产品已开通"
else

dsphemail("username")=ds("username")
'dsphemail("ServerlistID")=dsemailpdlist("ServerlistID")
ServerlistID=dsphemail("ServerlistID")
dsphemail("Emailtype")=dsemailpdlist("Emailtype")

'dsphemail("starttime")=starttime'不用改升级时间
dsphemail("endtime")=temptime
dsphemail("byhost")=dsph("id")
dsphemail("istest")="n"
dsphemail("emailcount")=dsemailpdlist("emailcount")
dsphemail("userspacelimt")=dsemailpdlist("userspacelimt")
dsphemail("domainspacelimt")=dsemailpdlist("domainspacelimt")
dsphemail("domainmustsame")=dsemailpdlist("domainmustsame")
dsphemail("status")="正常"
if ds("agent1")<>"n" then
dsphemail("agent1")=ds("agent1")
else
dsphemail("agent1")="n"
end if
dsphemail.update

FreeHost_oplog session("admusername"),"信息","管理员升级虚拟主机("&dsph ("Ftpname")&")邮箱产品同步升级,ID:"&dsphemail("id")

'dsphemail.close
Set dspdallemail = Server.CreateObject("ADODB.Recordset")	
		Sql="Select top 1 * from FreeHost.FreeHost_Product_ALLEmail where username='"&ds ("username")&"' and PdEID='"&dsphemail ("id")&"'"
		dspdallemail.Open Sql,conn,1,3
if not dspdallemail.Eof then
emailname=trim(dspdallemail("emailname"))
emailarry=split(emailname,"@")
name1=emailarry(0)
domain=lcase(trim(emailarry(1)))
op=0
'temp2=PauseEmail(dsph ("ServerlistID"),dspdallemail("emailname"),op)

Set dsphemaillist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_EmailProductlist where Emailtype='"&dsphemail ("Emailtype")&"'"
	dsphemaillist.Open Sql,conn,1,1
tem=ModAdmEmail(ServerlistID,trim(dspdallemail("emailname")),domain,dsphemail ("emailcount"),dsphemail ("domainspacelimt")*1024)'maxuser
end if

end if
end if







'SQL
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")


dim softtype,MySQLver,MSSQLver

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'当已有SQL附属于这个主机时
'检查新产品有没有送的库,如果有,就更新库大小
Set dsphSql = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_Sql where byhost='"&dsph ("id")&"'"
	dsphSql.Open Sql,conn,1,3
while Not dsphSql.eof
	Set dsserverSQL = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerSqllist where id='"&dsphSql ("ServerlistID")&"'"
	dsserverSQL.Open Sql,conn,1,1
if not dsserverSQL.Eof Then
	
	Set dsSqlpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_SqlProductlist where Hosttype='"&dshost("Hosttype")&"' and isbyhost='y'"
'response.write sql
'response.end
	dsSqlpdlist.Open Sql,conn,1,1
while not dsSqlpdlist.Eof
	Set dsserverSQLold = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerSqllist where (id='"&dsSqlpdlist ("ServerlistID")&"' or id='"&dsSqlpdlist ("ServerlistID2")&"' or id='"&dsSqlpdlist ("ServerlistID3")&"' or id='"&dsSqlpdlist ("ServerlistID4")&"' or id='"&dsSqlpdlist ("ServerlistID5")&"') and softtype='"&dsserverSQL("softtype")&"'"
	dsserverSQLold.Open Sql,conn,1,1
if not dsserverSQLold.Eof Then


dsphSql ("Sqltype")=dsSqlpdlist("Sqltype")
dsphSql ("userspacelimt")=dsSqlpdlist("userspacelimt")
dsphSql ("logspacelimt")=dsSqlpdlist("logspacelimt")
if dsphSql("istest")="y" then
dsphSql("istest")="n"
end if
dsphSql("status")="正常"
dsphSql ("endtime")=temptime
dsphSql.update




URL=dsserverSQL("site")
FreeHostsharekey=dsserverSQL("FreeHostsharekey")
userid=dsserverSQL ("admname")
pwd=dsserverSQL("admpass")
homedir=dsserverSQL("homedir")
ip=dsserverSQL("ip")
port=dsserverSQL("port")
userspacelimt=dsphSql("userspacelimt")
logspacelimt=dsphSql("logspacelimt")
sqlname=dsphSql("sqlname")

softtype=dsserverSQL("softtype")
MySQLver=dsserverSQL("MySQLver")
MSSQLver=dsserverSQL("MSSQLver")

if softtype="SQL2000" then
retsql=SqlModify(URL,FreeHostsharekey,userid,pwd,userspacelimt,logspacelimt,sqlname)
end If

FreeHost_oplog session("admusername"),"信息","管理员升级虚拟主机("&dsph ("Ftpname")&")据库产品同步升级,数据库名:"&sqlname&" ID:"&dsphSql("id")&"返回信息："&retsql



End if'存在同样类型的数据库
dsSqlpdlist.movenext
Wend
End if'有这个服务器定义
dsphSql.movenext
wend

else'当没有SQL附属于这个主机时
	Set dsSqlpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_SqlProductlist where Hosttype='"&dshost("Hosttype")&"' and isbyhost='y'"
If IsNumeric(Request.Form ("dsSqlpdlistID"&Request.Form ("Hostlistid"))) And Request.Form ("dsSqlpdlistID"&Request.Form ("Hostlistid"))<>"" Then Sql="Select * from FreeHost.FreeHost_SqlProductlist where Hosttype='"&dshost("Hosttype")&"' and id='"&Request.Form ("dsSqlpdlistID"&Request.Form ("Hostlistid"))&"' and isbyhost='y'"

'response.write sql
'response.end
'If canselectdb Then '只能选一个库

	dsSqlpdlist.Open Sql,conn,1,1
'if not dsSqlpdlist.Eof then
while not dsSqlpdlist.Eof


'2008-2-14修改bug
ServerlistID=dsSqlpdlist ("ServerlistID")
	Set dsSqlserver = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Serversqllist where netby='"&netby&"' and agent1='n'"

		dsSqlserver.Open Sql,conn,1,1
while not dsSqlserver.Eof
 if (dsSqlpdlist ("ServerlistID")=dsSqlserver("id") or dsSqlpdlist ("ServerlistID2")=dsSqlserver("id")  or dsSqlpdlist ("ServerlistID3")=dsSqlserver("id") or dsSqlpdlist ("ServerlistID4")=dsSqlserver("id") or dsSqlpdlist ("ServerlistID5")=dsSqlserver("id")) then
 ServerlistID=dsSqlserver("id")'优先选择可选机房中的同机房
 end if
 dsSqlserver.movenext
wend
dsSqlserver.Requery
while not dsSqlserver.Eof
 if ip=dsSqlserver("ip") and (dsSqlpdlist ("ServerlistID")=dsSqlserver("id") or dsSqlpdlist ("ServerlistID2")=dsSqlserver("id")  or dsSqlpdlist ("ServerlistID3")=dsSqlserver("id") or dsSqlpdlist ("ServerlistID4")=dsSqlserver("id") or dsSqlpdlist ("ServerlistID5")=dsSqlserver("id")) then
 ServerlistID=dsSqlserver("id")'优先选择可选机房中的同一IP
 end if
  dsSqlserver.movenext
wend
dsSqlserver.close

	Set agnserverid = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_SqlProductlist_AGN where id='"&dsSqlpdlist("id")&"' and agent1='"&ds("agent1")&"'"
	agnserverid.Open Sql,conn,1,1
if not agnserverid.Eof then
if  agnserverid ("ServerlistID")<>0 then ServerlistID=agnserverid ("ServerlistID")
end if

	Set dsserverSQL = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerSqllist where id='"&ServerlistID&"'"
	dsserverSQL.Open Sql,conn,1,1
if not dsserverSQL.Eof then

'dim softtype
Set dsphSql = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_Sql where byhost='"&dsph ("id")&"' and ( ServerlistID='"&dsSqlpdlist ("ServerlistID")&"' or ServerlistID='"&dsSqlpdlist ("ServerlistID2")&"' or ServerlistID='"&dsSqlpdlist ("ServerlistID3")&"' or ServerlistID='"&dsSqlpdlist ("ServerlistID4")&"' or ServerlistID='"&dsSqlpdlist ("ServerlistID5")&"' )"
	dsphSql.Open Sql,conn,1,3

if dsphSql.eof then

dsphSql.addnew
dsphSql("username")=ds("username")
dsphSql("ServerlistID")=ServerlistID
dsphSql("Sqltype")=dsSqlpdlist("Sqltype")
dsphSql("starttime")=starttime
dsphSql("endtime")=temptime
dsphSql("byhost")=dsph("id")
dsphSql("istest")="n"

Randomize
id=id&Int((10 - 0 + 1) * Rnd + 0)
sqlname="a"&right("00"& month(Now),2)& right("00" & day(Now),2)& right("00" & hour(Now),2)& right("00"& Minute(Now),2)& right( "00"& second(Now),2)&id
Randomize
id=id&Int((10 - 0 + 1) * Rnd + 0)
sqlpassword="a"&right("00"& month(Now),2)& right("00" & day(Now),2)& right("00" & hour(Now),2)& right("00"& Minute(Now),2)& right( "00"& second(Now),2)&id
'dsphSql("Sqlcount")=dsSqlpdlist("Sqlcount")
dsphSql("userspacelimt")=dsSqlpdlist("userspacelimt")
dsphSql("logspacelimt")=dsSqlpdlist("logspacelimt")
dsphSql("sqlname")=sqlname
dsphSql("sqlpassword")=sqlpassword
dsphSql("status")="等待开通"
if ds("agent1")<>"n" then
dsphSql("agent1")=ds("agent1")
else
dsphSql("agent1")="n"
end if
dsphSql.update

URL=dsserverSQL("site")
FreeHostsharekey=dsserverSQL("FreeHostsharekey")
userid=dsserverSQL ("admname")
pwd=dsserverSQL("admpass")
homedir=dsserverSQL("homedir")
ip=dsserverSQL("ip")
port=dsserverSQL("port")
userspacelimt=dsphSql("userspacelimt")
logspacelimt=dsphSql("logspacelimt")
sqlname=dsphSql("sqlname")
sqlpassword=dsphSql("sqlpassword")
'ret=SqlAdd(URL,userid,pwd,homedir,userspacelimt,logspacelimt,sqlname,sqlpassword)
'response.write ret

softtype=dsserverSQL("softtype")
MySQLver=dsserverSQL("MySQLver")
MSSQLver=dsserverSQL("MSSQLver")

if softtype="SQL2000" then
retsql=SqlAdd(URL,FreeHostsharekey,userid,pwd,homedir,userspacelimt,logspacelimt,sqlname,sqlpassword)
else
retsql=SqlAddmysql(URL,FreeHostsharekey,userid,pwd,homedir,userspacelimt,logspacelimt,sqlname,sqlpassword)
end if

dsphSql.close


'log
	Set dsphSql = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Sql where sqlname='"&sqlname&"' and username='"&ds("username")&"'"
	dsphSql.Open Sql,conn,1,3
	dsphSql("status")="正常"
	dsphSql.update
FreeHost_oplog session("admusername"),"信息","管理员升级虚拟主机("&dsph ("Ftpname")&")赠送数据库,数据库名:"&sqlname&"类型"&softtype&" ID:"&dsphSql("id")&"返回信息："&retsql

'dim Subject,body
EmailUserSQLOpen
ret=Send2Mail(conn,ds("username"),Subject,body)
'如果是从没有数据库升级到有数据库
else
'原来有数据库
'更新产品类别
while not dsphSql.Eof
dsphSql ("Sqltype")=dsSqlpdlist("Sqltype")
dsphSql ("userspacelimt")=dsSqlpdlist("userspacelimt")
dsphSql ("logspacelimt")=dsSqlpdlist("logspacelimt")
if dsphSql("istest")="y" then
dsphSql("istest")="n"
end if
dsphSql("status")="正常"
dsphSql ("endtime")=temptime
dsphSql.update


URL=dsserverSQL("site")
FreeHostsharekey=dsserverSQL("FreeHostsharekey")
userid=dsserverSQL ("admname")
pwd=dsserverSQL("admpass")
homedir=dsserverSQL("homedir")
ip=dsserverSQL("ip")
port=dsserverSQL("port")
userspacelimt=dsphSql("userspacelimt")
logspacelimt=dsphSql("logspacelimt")
sqlname=dsphSql("sqlname")

softtype=dsserverSQL("softtype")
MySQLver=dsserverSQL("MySQLver")
MSSQLver=dsserverSQL("MSSQLver")

if softtype="SQL2000" then
retsql=SqlModify(URL,FreeHostsharekey,userid,pwd,userspacelimt,logspacelimt,sqlname)
end if
dsphSql.movenext
Wend
FreeHost_oplog session("admusername"),"信息","管理员升级虚拟主机("&dsph ("Ftpname")&")据库产品同步升级,数据库名:"&sqlname&"类型"&softtype&" ID:"&dsphSql("id")&"返回信息："&retsql
'完成更新
end if

end If

dsSqlpdlist.movenext
wend
end if'有与没有都处理完



URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
ftpname=dsph ("ftpname")
username=dsph ("username")
homedir=dsserver("homedir")
starttime=dsph("starttime")
endtime=dsph("endtime")
type1=dsph("hosttype")







%>
<!--#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="90" align="center" valign="middle" background="img/r3.jpg" id="tableTop1" style="Cursor:hand"><a href="admhost.asp"><font color="#FFFFFF"><strong>虚拟主机管理</strong></font></a></td>
            <td width="5" background="img/midtop2.gif">&nbsp;</td>
          </tr>
      </table></TD>
      <TD width="83">&nbsp;</TD>
      <TD width="83" align="left">&nbsp;</TD>
      <TD align="left">&nbsp;</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">	  <table width="65%"  border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><br>
              </td>
        </tr>
      </table>
        <br>
        <table width="65%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><br>
<DIV class="tableborder"><br>
<br>
受控端返回信息：
<%
'调用开通function

hostname=dsph("hostname")
'dsph("hostname")=hostname
'dsph.update

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 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") 
dsph("netver")=netver
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 dshost("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")
username=dsph ("Ftpname")
password=dsph("Ftppassword")
comment=dsph ("username")
'homedir=Request.Form("homedir")

homedir=dsserver("homedir")

If typechange Then
spacelimit=dshost ("spacelimt")'类型变更'---------------------------------------
MaxConnections=dshost("MaxConnections")
EnumAppsInPool=dshost ("AppPoolnum")
MaxBandwidth=dshost("MaxBandwidth")
end if

starttime=dsph("starttime")
endtime=dsph("endtime")
type1=dsph("Hosttype")
email=ds("email")
host=dsph("hostname")
hostcomment_arry=Split(dsph("hostname"), ",")
hostcomment=Replace(hostcomment_arry(0),":80:","")&"_"&username&"_"&dsph ("username")


DefaultDoc=Request.Form ("DefaultDoc")
if trim(Request.Form ("ScriptMaps"))<>"" then
ScriptMaps=trim(Request.Form ("ScriptMaps"))&"|"&dsserver("infosafe")
ScriptMaps=trim(replace(ScriptMaps,"||","|"))
end if

AccessFlags=Request.Form ("AccessFlags")
LogFileDirectory=Request.Form ("LogFileDirectory")
HttpErrors=Request.Form ("HttpErrors")



If Request.Form ("Submit")<>"" Then
if Request.Form ("spacelimit")<>"" and not (Request.Form ("istestch1")="y" or Request.Form ("istestch2")="y") then spacelimit=Request.Form  ("spacelimit")
if Request.Form ("MaxConnections")<>"" and not (Request.Form ("istestch1")="y" or Request.Form ("istestch2")="y") then MaxConnections=Request.Form  ("MaxConnections")
if Request.Form ("AppPoolnum")<>"" then EnumAppsInPool=Request.Form  ("AppPoolnum")
if Request.Form ("MaxBandwidth")<>"" and not (Request.Form ("istestch1")="y" or Request.Form ("istestch2")="y") then MaxBandwidth=Request.Form ("MaxBandwidth")
end if
hostname=host
 
hostnamestr=replace(hostname, ":80:","")
hostname_arry=Split(hostnamestr, ",")
for i=0 to ubound(hostname_arry)
hostname_arry(i)=ComX.idntoac_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)
dsph("hostname")=hostname
dsph.update
host=hostname


if Request.Form ("istestch1")="y" then
MaxConnections=dshost ("MaxConnections")
spacelimit=dshost ("spacelimt")
MaxBandwidth=dshost("MaxBandwidth")
end if

dsph("spacelimt")=spacelimit
dsph("MaxConnections")=MaxConnections
dsph("MaxBandwidth")=MaxBandwidth
dsph("AppPoolnum")=EnumAppsInPool

dsph("Maxbytes")=dshost("Maxbytes")
dsph("MaxCPU")=dshost("MaxCPU")

If dsph("allowsub")="n" then
dsph("allowsub")=dshost("allowsub")
dsph("subweb")=dshost("subweb")
dsph("useper")=100
Else
dsph("subweb")=dshost("subweb")
End if

dsph("canseelog")=dshost("canseelog")
dsph("canrar")=dshost("canrar")
dsph("canback")=dshost("canback")
dsph("canrecypool")=dshost("canrecypool")
dsph("canchnetver")=dshost("canchnetver")
dsph("notuserar")=dshost("notuserar")

if dsserver("iisver")>6 Then
hostnamestr=replace(host, ":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)
host=hostname
End if

if Application("hostoneip")=true then
If request("ipid")<>"" then
 conn.Execute "update FreeHost.FreeHost_Product_Host_IP set HostID=0 where HostID="&dsph("id")
 conn.Execute "update FreeHost.FreeHost_Product_Host_IP set HostID="&dsph("id")&" where ID="&request("ipid")
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:")
'特有内容:
host=Replace(host,dsX("IP")&":80:"&dsX("IP")&",","")
host=dsX("IP")&":80:"&dsX("IP")&","&host
End if
End If

If Request("nullhead")="1" Then
dsph("nullhead")=1
host=dsX("IP")&":80:,"&host
Else
dsph("nullhead")=0
End If

If Request("iphead")="1" Then
dsph("iphead")=1
host=dsX("IP")&":80:,"&host
Else
dsph("iphead")=0
End If

End if

 dsph("AppPoolnum")=EnumAppsInPool
If EnumAppsInPool="" Then dsph("AppPoolnum")=dshost("AppPoolnum")'2011
dsph.update


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 isuseCDN=true Then host=Replace(host,":80:",":"&CDNORIport&":")
If Not IsNull(dsph("CurPoolname")) Then
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)
else
outtemp=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 Replace(replace(outtemp,",:","<br>:"),host,"成功")
'Response.Write replace(outtemp,",","<br>")


'处理子目录绑定
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")
'op=0
'Response.Write PauseSiteSub(URL,FreeHostsharekey,IISID,tourl,op)
'dsphsub("status")="正常"
dsphsub("endtime")=temptime
dsphsub.update
dsphsub.movenext
wend
dsphsub.close

CDNrefreshDomain'更新CDN
response.write CDNret

%><br>
<br>

</div>
                <DIV class="tableborder">
                  <table width="100%"  border="0" align="center" cellpadding="2" cellspacing="1">
                    <tr align="center" bordercolor="#000000" bgcolor="#999999">
                      <td height="24" colspan="4" background="img/tablebg.gif"><font color="#990000"><font color="#FFFFFF">虚拟主机升级成功，以下是相关的资料</font></font></td>
                    </tr>
                    <tr bordercolor="#000000" bgcolor="#E4EAF2">
                      <td width="53%" height="30"><font color="#000000"> 　　　 用户的原金额：</font></td>
                      <td width="47%" colspan="3"><%=olduser_money%> 元</td>
                    </tr>
                    <tr bordercolor="#000000" bgcolor="#E4EAF2">
                      <td height="41"><font color="#000000">　　　 用户的金额变化：</font></td>
                      <td colspan="3"><font color=red><%=moneych%> 元</font></td>
                    </tr>
                    <tr bordercolor="#000000" bgcolor="#E4EAF2">
                      <td height="39"><font color="#000000">　　　 用户的新金额：</font></td>
                      <td colspan="3"><font color="#000000"><%=newuser_money%> 元</font></td>
                    </tr>
                    <tr bordercolor="#000000" bgcolor="#E4EAF2">
                      <td height="37"><font color="#000000"> 　　　 新产品类型是:</font></td>
                      <td colspan="3"><%=newhosttype%></td>
                    </tr>
                    <tr bordercolor="#000000" bgcolor="#E4EAF2">
                      <td height="37"><font color="#000000"> 　　　 现在的到期时间是:</font></td>
                      <td colspan="3"><%=temptime%></td>
                    </tr>
                    <tr bordercolor="#000000" bgcolor="#E4EAF2">
                      <td height="37" colspan="4" align="right" bgcolor="#E4EAF2"><font color="#000000"> 　　　</font><a href="#top"><font color="#6B9EDE" face="Arial, Helvetica, sans-serif">Top↑</font></a> </td>
                    </tr>
                  </table>
                </div>
                
            </td>
          </tr>
        </table></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%>
