<%@ 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 Request.Form ("id")="" Then
	ef=True
	ec="请输入产品ID！"
ElseIf not IsNumeric(Request("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
ElseIf Request.Form ("username")="" 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 not IsNumeric(Request("newServerlistID"))  Then
	ef=True
	ec="产品ID应该是数字！"
End if

If session("canadmvpsoth")="" Then
if Request.Form ("Submit")="恢复" Or Request.Form ("Submit")="暂停" Or Request.Form ("Submit")="停止" Or Request.Form ("Submit")="启动VPS" Or Request.Form ("Submit")="关机VPS" Or Request.Form ("Submit")="重启VPS" Or Request.Form ("Submit")="重设云服务器密码" then
	ef=True
	ec="您没有此操作的权限。"
end If
End If

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

If session("canadmvpsoth")="" Then
if Request.Form ("Submit")="马上预装操作系统" then
	ef=True
	ec="您没有此操作的权限。"
end If
End If

If session("canadmvpsset")="" Then'续费升级
if trim(Request.Form ("starttime"))<>"" And trim(Request.Form ("endtime"))="" Then
	ef=True
	ec="手工指定开通时间时，必须填写到期时间及扣除金额！"
ElseIf not IsDate(Request("starttime")) and Request("starttime")<>""  Then
	ef=True
	ec="请输入合法的开始日期！"
ElseIf not IsDate(Request("endtime")) and Request("endtime")<>""  Then
	ef=True
	ec="请输入合法的到期日期！"
End If
End If


If session("canadmvpsmidcpu")="" Then
if Request.Form ("Submit")="设置资源" or Request.Form ("Submit")="设置备份还原及快照" then
	ef=True
	ec="您没有此操作的权限。"
end If
end If

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


If session("canadmvpsdel")="" Then
if Request.Form ("dodel")="删除" then
	ef=True
	ec="您没有此操作的权限。"
end If
End If


If session("canadmvpsdel")="" Then
if Request.Form ("Submit")="删除旧VPS并更换服务器" then
	ef=True
	ec="您没有此操作的权限。"
end If
if Request.Form ("Submit")="只更换所属物理机ID，不转移VHDX" then
	ef=True
	ec="您没有此操作的权限。"
end If
if Request.Form ("Submit")="更换所属物理机ID，也转移VHDX" then
	ef=True
	ec="您没有此操作的权限。"
end If
End if




if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username='"&Request.Form ("username")&"'"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		ds.Open Sql,conn,1,1
if ds.eof then
	ef=True
	ec="用户不存在!"
end if
end if

if not ef then
If Request.Form ("newusername")<>"" then
	Set dsNew = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username='"&Request.Form ("newusername")&"'"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		dsNew.Open Sql,conn,1,1
if dsNew.eof then
	ef=True
	ec="要转移的用户不存在!"
end if
end if
end if

if not ef then
	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_VPS where id='"&Request.Form ("id")&"'"
	dsph.Open Sql,conn,1,3
if dsph.Eof then
	ef=True
	ec="不存在的云服务器产品ID！"
end if
end if

if not ef then
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerVPSlist where id='"&dsph ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
if dsserver.Eof then
	ef=True
	ec="服务器不存在！"
else
isONEip=dsserver("isONEip")	
end if
end If

if not ef Then
if Request.Form ("Submit")="设置资源"  then
If dsserver("OStype")="Windows 2008R2" And Request.Form ("CpuNum")>4 Then
	ef=True
	ec="操作系统是win2012才能设置超过4个CPU！"
end If
end if
end If

if not ef Then
if isONEip=true then
	Set dsPORTserver = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_ServerPORTlist where id='"&dsserver("useportserver")&"'"
		dsPORTserver.Open Sql,conn,1,3
If dsPORTserver.Eof Then
	ef=True
	ec="PORT服务器不存在。"
Else
IPopen=dsPORTserver("ip")
end If
end If
end if

if not ef then
if Request.Form ("Submit")="马上调整" then
server.Transfer "handvps2endtime.asp"
end if
end If

if not ef then
if Request.Form ("Submit")="马上升级" then
server.Transfer "handvps2up.asp"
end if
end if

if not ef then
username=dsph("username")
vpsname=dsph("vpsname")
FreeHostsharekey=dsserver("FreeHostsharekey")
URL=dsserver("site")



%>

<!--#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 width="150"><table height="59"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="7" background="img/midtop.gif">&nbsp;</td>
            <td width="100" align="center" valign="middle" background="img/r3.jpg" id="tableTop1" style="Cursor:hand" onClick="t1.style.display='';"><a href="admvps.asp"><font color="#FFFFFF">云服务器管理</font></a></td>
            <td width="5" background="img/midtop2.gif">&nbsp;</td>
          </tr>
      </table></TD>
      <TD width="83">&nbsp;</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"><br>
 <DIV class="tableborder" id="t1"><table width="100%" border=0 cellpadding=2 cellspacing=1>
          <tr align="center" bgcolor="#EFEFEF">
            <td height="24" colspan="2" background="img/tablebg.gif"><font color="#FFFFFF">数据库记录　　<a href="#"  onClick="t1.style.display='none';"><font color="#F7F7FF">X</font></a></font></td>
          </tr>
          <tbody>
            <tr bgcolor="#E4EAF2">
              <td width="20%" height="22" align="right" >编号：</td>
              <td width="80%" height="22" align="left" >　<%=dsph("id")%></td>
            </tr>
            <tr bgcolor="#E4EAF2">
              <td height="22" align="right" >云服务器名：</td>
              <td width="80%" height="22" align="left" >　<%=dsph("vpsname")%></td>
            </tr>
            <tr bgcolor="#E4EAF2">
              <td height="22" align="right" >原云服务器密码：</td>
              <td width="80%" height="22" align="left" bgcolor="#E4EAF2" >　<%=dsph("vpspassword")%></td>
            </tr>
            <tr bgcolor="#E4EAF2">
              <td height="22" align="right" >产品类型：</td>
              <td height="22" align="left" >　<%=dsph("vpstype")%></td>
            </tr>
            <tr bgcolor="#E4EAF2">
              <td height="22" align="right" >已分配ＩＰ：</td>
              <td height="22" align="left" >　
                  <%
	Set dsVPSip = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_VPS_IP where ipbyid=0 and VPSID="&dsph("id")
		dsVPSip.Open Sql,conn,1,1
If not dsVPSip.Eof Then
'while not dsVPSip.eof
IP=dsVPSip("IP")
IPmask=dsVPSip("IPmask")
IPgateway=dsVPSip("IPgateway")
IPdns1=dsVPSip("IPdns1")
IPdns2=dsVPSip("IPdns2")
%>
                  主IP:<%=dsVPSip("IP")%>
                  <%
'dsVPSip.movenext
'wend
else%>
    无,请马上分配
    <%end if%></td>
            </tr>
            <tr bgcolor="#E4EAF2">
              <td height="22" align="right" >资源：</td>
              <td height="22" align="left" > 　　内存：<%=dsph("maxram")%>M　初始内存：<%=dsph("StartRam")%>M　CPU数量：<%=dsph("cpunum")%>　CPU上限：<%=dsph("maxcpu")%>%　硬盘：<%=dsph("maxspace")%>G　允许绑域名：<%=dsph("allowdomain")%>个(共享IP类)　流量：<%=dsph("CDNMaxMb")%>M/月(共享IP类)　带宽：<%=dsph("Maxmbps8")%>Mbps</td>
            </tr>
            <tr bgcolor="#E4EAF2">
              <td height="22" align="right" >状态：</td>
              <td height="22" align="left" >　
                <%if dsph("endtime")>NOW then%>
                  <%if dsph("istest")="y" then%>
        试用
        <%else%>
        <%=dsph("status")%>
        <%end if%>
        <%else%>
        过期
        <%if dsph("status")="暂停" then%>
        并暂停
        <%end if%>
        <%end if%>
              </td>
            </tr>
            <tr bgcolor="#E4EAF2">
              <td height="22" align="right" >开通时间：</td>
              <td height="22" align="left" >　<%=dsph("starttime")%></td>
            </tr>
            <tr bgcolor="#E4EAF2">
              <td height="22" align="right" >到期时间：</td>
              <td height="22" align="left" >　<%=dsph("endtime")%></td>
            </tr>
            <tr bgcolor="#E4EAF2">
              <td height="22" align="right" >所在服务器：</td>
              <td height="22" align="left" >　<%=dsph("ServerlistID")%></td>
            </tr>
            <tr bgcolor="#E4EAF2">
              <td height="22" align="right" >服务器IP： </td>
              <td height="22" align="left" >　
<%=dsserver("ip")%> </td>
            </tr>
			<tr bgcolor="#E4EAF2">
              <td height="22" align="right" >备注信息： </td>
              <td height="22" align="left" >　
                <%=dsph("corewhat")%></td>
            </tr>
          </tbody>
        </table>
 </div>
      <br>
<%if Request.Form ("Submit")<>"主机管理" then%>
 <DIV class="tableborder" id="t2"><table width="100%" border=0 cellpadding=2 cellspacing=1>
          <tr align="center" bgcolor="#EFEFEF">
            <td height="24" colspan="2" background="img/tablebg.gif" ><font color="#FFFFFF">受控服务器上的记录　　<a href="#"  onClick="t2.style.display='none';"><font color="#F7F7FF">X</font></a></font></td>
          </tr>
          <tbody>
            <tr bgcolor="#E4EAF2">
              <td width="20%" height="70" align="right" >返回信息：</td>
              <td width="80%" height="22" align="left" >

<%
if Request.Form ("Submit")="暂停" then
dsph("status")="暂停"
dsph("pausebyagn")="a"
Response.Write "不需要操作受控端,更改成功。状态为:"&dsph("status")
dsph.update
End if

if Request.Form ("Submit")="停止" then
dsph("status")="停止"
dsph("pausebyagn")="a"
Response.Write "不需要操作受控端,更改成功。状态为:"&dsph("status")
dsph.update
end if


if Request.Form ("Submit")="恢复" then
dsph("status")="正常"
dsph("pausebyagn")="n"
Response.Write "不需要操作受控端,更改成功。状态为:"&dsph("status")
dsph.update
end If

if Request.Form ("Submit")="启动VPS" then
action="start"
varcon="action "&vpsname&" "&action&" now"
temp=VPSOP(URL,FreeHostsharekey,varcon,0)'0=now
FreeHost_oplog session("admusername"),"信息","管理员启动VPS:"&vpsname
Response.Write temp
end If
if Request.Form ("Submit")="关机VPS" then
action="turnoff"
varcon="action "&vpsname&" "&action&" now"
temp=VPSOP(URL,FreeHostsharekey,varcon,0)'0=now
FreeHost_oplog session("admusername"),"信息","管理员关机VPS:"&vpsname
Response.Write temp
end If

if Request.Form ("Submit")="软关机VPS" then
action="shutdown"
varcon="action "&vpsname&" "&action&" now"
temp=VPSOP(URL,FreeHostsharekey,varcon,0)'0=now
FreeHost_oplog session("admusername"),"信息","管理员关机VPS:"&vpsname
Response.Write temp
end If

if Request.Form ("Submit")="重启VPS" then
action="reset"
varcon="action "&vpsname&" "&action&" now"
temp=VPSOP(URL,FreeHostsharekey,varcon,0)'0=now
FreeHost_oplog session("admusername"),"信息","管理员重启VPS:"&vpsname
Response.Write temp
end if


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

vhdpath=dsph("vhdpath")
Sql="update FreeHost.FreeHost_Product_VPS_IP set VPSID=0 where VPSID='"&dsph("id")&"'"
conn.Execute Sql

Sql="update FreeHost.FreeHost_Product_VPS_ADSL set VPSID=0 where VPSID='"&dsph("id")&"'"
conn.Execute Sql

If Not isnull(dsph("consoletime")) then
Response.Write OPIpsec(URL,FreeHostsharekey,"del",dsph("consoleip"),"2179")
varcon="DelconnectVM "&username&" "&vpsname&" "&dsph("VPSpassword")&" "&dsph("consoleip")
Response.Write VPSOP(URL,FreeHostsharekey,varcon,0)'0=now
End If

dsph.delete
dsph.Update
Response.Write "VPS信息已从数据库中删除。"
'On Error Resume next'出错也处理

action="turnoff"
varcon="action "&vpsname&" "&action&" now"
temp=VPSOP(URL,FreeHostsharekey,varcon,0)'0=now
FreeHost_oplog session("admusername"),"信息","管理员关机VPS:"&vpsname
Response.Write temp


varcon="delvps "&vpsname&" "&vhdpath&" "&dsserver("backupdir")
If dsserver("IsCluster")=true Then varcon=varcon&" "&dsserver("ClusterName")&" "&vpsname
'Response.Write varcon
temp=VPSOP(URL,FreeHostsharekey,varcon,0)'0=now
Response.Write temp
FreeHost_oplog session("admusername"),"信息","管理员删除VPS:"&vpsname
dsph.close
end if

if Request.Form ("Submit")="马上转移" Then
FreeHost_oplog session("admusername"),"信息","管理员转移"&dsph ("username")&"云服务器产品云服务器名("&dsph ("vpsname")&") 给"&Request.Form ("newusername")
dsph("username")=Request.Form ("newusername")
response.write "产品已转移到用户："&Request.Form ("newusername")&" 名下。<br>"
dsph("agent1")=dsNEW("agent1")
if dsph("agent1")<>"n" then
response.write "产品已转移到代理："&dsph("agent1")&" 名下。<br>"
end If
dsph.update
end If


if Request.Form ("Submit")="删除旧VPS并更换服务器" then

URL_OLD=URL
FreeHostsharekey_OLD=FreeHostsharekey
vhdpath_OLD=dsph("vhdpath")

	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerVPSlist where id='"&Request ("newServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
if dsserver.Eof then
	ef=True
	ec="服务器不存在！"
Else
    netby=dsserver("netby")
	serverip=dsserver("ip")
	homedir=dsserver("homedir")
isONEip=dsserver("isONEip")	
end If
if not ef Then
if isONEip=true then
	Set dsPORTserver = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_ServerPORTlist where id='"&dsserver("useportserver")&"'"
		dsPORTserver.Open Sql,conn,1,3
If dsPORTserver.Eof Then
	ef=True
	ec="PORT服务器不存在。"
Else
IPopen=dsPORTserver("ip")
end If
end If
end If

if not ef then
Set dsVPSip = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_VPS_IP where ServerlistID="&dsserver("id")&" and VPSID=0  and ipbyid=0 order by orderbyid desc"
		dsVPSip.Open Sql,conn,1,3
If dsVPSip.Eof Then
	ef=True
	ec="很抱歉,您选取的服务器的IP资源已用光,管理员尚未分配可用IP,请联系管理员处理."
Else
IP=dsVPSip("IP")
IPmask=dsVPSip("IPmask")
IPgateway=dsVPSip("IPgateway")
IPdns1=dsVPSip("IPdns1")
IPdns2=dsVPSip("IPdns2")
End If
End If
'检查内存有没有用光
if not ef then
Set dsVPSMax = Server.CreateObject("ADODB.Recordset")	
		Sql="Select sum(maxram) from FreeHost.FreeHost_Product_VPS where ServerlistID="&dsserver("id")&""
		dsVPSMax.Open Sql,conn,1,1
If (dsVPSMax(0)+dsph("MaxRAM"))>dsserver("maxram") Then
	ef=True
	ec="很抱歉,您选取的服务器的内存资源已用光,请联系管理员处理."
End If
dsVPSMax.close
End if
'检查space有没有用光
if not ef then
Set dsVPSMax = Server.CreateObject("ADODB.Recordset")	
		Sql="Select sum(Maxspace) from FreeHost.FreeHost_Product_VPS where ServerlistID="&dsserver("id")&""
		dsVPSMax.Open Sql,conn,1,1
If dsVPSMax(0)+dsph("Maxspace")>dsserver("Maxspace") Then
	ef=True
	ec="很抱歉,您选取的服务器的硬盘资源已用光,请联系管理员处理."
End If
dsVPSMax.close
End If
if not ef then
Set dsVPSMax = Server.CreateObject("ADODB.Recordset")	
		Sql="Select count(*) from FreeHost.FreeHost_Product_VPS where ServerlistID="&dsserver("id")&""
		dsVPSMax.Open Sql,conn,1,1
If dsVPSMax(0)+1>dsserver("MaxVPS") Then
	ef=True
	ec="很抱歉,您选取的服务器的VPS数量资源已用光,请联系管理员处理."
End If
dsVPSMax.close
End if

if not ef Then
Sql="update FreeHost.FreeHost_Product_VPS_IP set VPSID=0 where VPSID='"&dsph("id")&"'"
conn.Execute Sql
Response.Write "VPS原占用的IP已释放。"

Sql="update FreeHost.FreeHost_Product_VPS_ADSL set VPSID=0 where VPSID='"&dsph("id")&"'"
conn.Execute Sql
Response.Write "VPS原占用的拨号资源已释放。"

'On Error Resume next'出错也处理
'下面开始删除旧VPS
action="turnoff"
varcon="action "&vpsname&" "&action&" now"
temp=VPSOP(URL_OLD,FreeHostsharekey_OLD,varcon,0)'0=now
FreeHost_oplog session("admusername"),"信息","管理员关机VPS:"&vpsname
Response.Write temp

If Not isnull(dsph("consoletime")) then
Response.Write OPIpsec(URL,FreeHostsharekey,"del",dsph("consoleip"),"2179")
varcon="DelconnectVM "&username&" "&vpsname&" "&dsph("VPSpassword")&" "&dsph("consoleip")
Response.Write VPSOP(URL,FreeHostsharekey,varcon,0)'0=now
End If

varcon="delvps "&vpsname&" "&vhdpath_OLD&" "&dsserver("backupdir")
If dsserver("IsCluster")=true Then varcon=varcon&" "&dsserver("ClusterName")&" "&vpsname
'Response.Write varcon
temp=VPSOP(URL_OLD,FreeHostsharekey_OLD,varcon,0)'0=now
Response.Write temp
FreeHost_oplog session("admusername"),"信息","管理员更换服务器而删除VPS:"&vpsname
'dsph.close
Response.Write " 删除完成。<br>"


'删除完成
End If

if not ef Then'开始开vps
	Set dshost = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_VPSProductlist where vpstype='"&dsph("vpstype")&"'"
	dshost.Open Sql,conn,1,1
NetCardlimtype=dshost("NetCardlimtype")

if dshost("canADSL")=True then
Set dsVPSADSL = Server.CreateObject("ADODB.Recordset")	
		Sql="Select top 1 * from FreeHost.FreeHost_Product_VPS_ADSL where ServerlistID="&dsserver("id")&" and VPSID=0 order by orderbyid desc"
		dsVPSADSL.Open Sql,conn,1,3
if Not dsVPSADSL.Eof then
dsVPSADSL("VPSID")=dsph("id")
If dsVPSADSL("VLANid")>0 Then dsph("VLANid")=dsVPSADSL("VLANid")
dsVPSADSL.update
dsVPSADSL.close
End If
End if

dsph("ServerlistID")=dsserver("id")
dsph("vhdpath")=replace(dsserver("homedir")&"\"&dsph("vpsname")&"."&dsserver("vhdtype"),"\\","\")
dsVPSip("VPSID")=dsph("id")'分配ip
ip=dsVPSip("ip")
dsVPSip.update
conn.Execute "update FreeHost.FreeHost_Product_VPS_IP set VPSID='"&dsph("id")&"' where ipbyid='"&dsVPSip("ID")&"'"

URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
vpsname=dsph ("vpsname")
username=dsph ("username")
homedir=dsserver("homedir")
starttime=dsph("starttime")
endtime=dsph("endtime")
type1=dsph("VPStype")


MAXcpu=dsph("MAXCPU")
CpuNum=dsph("CpuNum")
MAXRam=dsph("MAXRam")
StartRam=dsph("StartRam")
Maxmbps8=dsph("Maxmbps8")
Minmbps8=dsph("Minmbps8")

MAXspace=dsph("MAXspace")
vhdpath=dsph("vhdpath")

EndIP=IP
VPSpassword=dsph("VPSpassword")
portstart=0
portend=0
If isONEip Then
EndIP=IPopen
portstart=dsVPSip("portstart")+4
portend=dsVPSip("portstart")+dsPORTserver("portperip")-1
End If
IP2=0
IP2mask=0
IP2gateway=0
IP2dns1=0
IP2dns2=0

Set dsVPSip2 = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_VPS_IP where ipbyid='"&dsVPSip("ID")&"' order by orderbyid desc"
		dsVPSip2.Open Sql,conn,1,1
If Not dsVPSip2.Eof Then
IP2=dsVPSip2("IP")
IP2mask=dsVPSip2("IPmask")
IP2gateway=dsVPSip2("IPgateway")
IP2dns1=dsVPSip2("IPdns1")
IP2dns2=dsVPSip2("IPdns2")
end if

todir=dsph("vhdpath")
MaxIOPS=dsph("MaxIOPS")'2014827
MaxIOPS2=dsph("MaxIOPS2")'2014827
VLANid=dsph("VLANid")

varcon="makevps "&username&" "&vpsname&" "&CpuNum&" "&MAXcpu&" "&MAXRam&" "&MAXspace&" "&vhdpath&" "&StartRam
If dsserver("OStype")="Windows Server 2012" Then varcon=varcon&" 0 "&Maxmbps8*1024*1024
If dsserver("OStype")="Windows Server 2012R2" Then varcon=varcon&" 0 "&Maxmbps8*1024*1024&" "&dsserver("SwitchName")&" "&StartRam&" "&Replace(vhdpath,".vhd","-2.vhd")&" 10 "&(MAXspace-10)&" defaultClusterNameby7i24 "&MaxIOPS&" "&MaxIOPS2&" NULLswitchname "&VLANid&" "&NetCardlimtype
If dsserver("IsCluster")=true Then varcon=Replace(varcon,"defaultClusterNameby7i24",dsserver("ClusterName"))
If Not isnull(dsserver("SwitchName2")) Then varcon=Replace(varcon,"NULLswitchname",dsserver("SwitchName2"))

temp=VPSOP(URL,FreeHostsharekey,varcon,0)

If Not isnull(dsserver("SwitchName2")) Then '处理switch
If InStr(temp,vbcrlf&vbcrlf&vbcrlf&"SwitchName : ") Then
arysw=Split(temp,vbcrlf&vbcrlf&vbcrlf&"SwitchName : ")
arysw2=Split(arysw(1),vbcrlf&vbcrlf&vbcrlf)
arysw3=Split(arysw2(0),vbcrlf)
If dsserver("SwitchName")=arysw3(0) Then
dsph("MAC")=replace(arysw3(1),"MacAddress : ","")
dsph("MAC2")=replace(arysw3(4),"MacAddress : ","")
Else
dsph("MAC")=replace(arysw3(4),"MacAddress : ","")
dsph("MAC2")=replace(arysw3(1),"MacAddress : ","")
End If
End if
End if'完成switch

response.write temp
FreeHost_oplog session("admusername"),"信息","管理员更换服务器开通云服务器产品: "&temp
'dsph("status")="等待安装操作系统"
dsph.Update

End if


end if


if Request.Form ("Submit")="只更换所属物理机ID，不转移VHDX" or Request.Form ("Submit")="更换所属物理机ID，也转移VHDX" then

	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerVPSlist where id='"&Request ("ClunewServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
if dsserver.Eof then
	ef=True
	ec="服务器不存在！"
Else
    netby=dsserver("netby")
	serverip=dsserver("ip")
	homedir=dsserver("homedir")
isONEip=dsserver("isONEip")	
end If

if not ef Then
if isONEip=true then
	ef=True
	ec="共享IP不能用这个功能。"
end If
end If

if not ef then
Set dsVPSip = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_VPS_IP where ServerlistID="&dsph("ServerlistID")&" and VPSID='"&dsph("id")&"'"
		dsVPSip.Open Sql,conn,1,3
If dsVPSip.Eof Then
	ef=True
	ec="原物理机中不存在这个IP."
Else
IP=dsVPSip("IP")
IPmask=dsVPSip("IPmask")
IPgateway=dsVPSip("IPgateway")
IPdns1=dsVPSip("IPdns1")
IPdns2=dsVPSip("IPdns2")
ipbyid=dsVPSip("ipbyid")
End If
End If


if not ef Then
dsVPSip.delete
dsVPSip.update
'Sql="delete FreeHost.FreeHost_Product_VPS_IP where VPSID='"&dsph("id")&"'"
'conn.Execute Sql
Response.Write "VPS原物理机占用的IP已在数据库中删除。"

dsVPSip.addnew
dsVPSip("IP")=IP
dsVPSip("IPmask")=IPmask
dsVPSip("IPgateway")=IPgateway
dsVPSip("IPdns1")=IPdns1
dsVPSip("IPdns2")=IPdns2
dsVPSip("VPSID")=dsph("id")
dsVPSip("ServerlistID")=dsserver("id")
dsVPSip.update
Response.Write "VPS原物理机占用的IP已自动录入到新的物理机数据库中。"

End if

if not ef Then'开始开vps
oldServerlistID=dsph("ServerlistID")
dsph("ServerlistID")=dsserver("id")
dsph("vhdpath")=replace(dsserver("homedir")&"\"&dsph("vpsname")&"."&dsserver("vhdtype"),"\\","\")
'conn.Execute "update FreeHost.FreeHost_Product_VPS_IP set VPSID='"&dsph("id")&"' where ipbyid='"&dsVPSip("ID")&"'"

'response.write temp
response.write "管理员更换群集中所属物理机："&dsph("vpsname")&" 原物理机ID:"&oldServerlistID&" 新物理机ID:"&dsph("ServerlistID")
FreeHost_oplog session("admusername"),"信息","管理员更换群集中所属物理机："&dsph("vpsname")&" 原物理机ID:"&oldServerlistID&" 新物理机ID:"&dsph("ServerlistID")
'dsph("status")="等待安装操作系统"
dsph.Update

if Request.Form ("Submit")="更换所属物理机ID，也转移VHDX" Then'物理机上操作
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
vpsname=dsph ("vpsname")
username=dsph ("username")
homedir=dsserver("homedir")
starttime=dsph("starttime")
endtime=dsph("endtime")
type1=dsph("VPStype")
MAXcpu=dsph("MAXCPU")
CpuNum=dsph("CpuNum")
MAXRam=dsph("MAXRam")
StartRam=dsph("StartRam")
Minmbps8=dsph("Minmbps8")
Maxmbps8=dsph("Maxmbps8")
vhdpath=dsph("vhdpath")
MaxIOPS=dsph("MaxIOPS")
MaxIOPS2=dsph("MaxIOPS2")
varcon="movenode "&vpsname&" "&dsserver("ClusterName")&" "&dsserver("ComputerName")
'If dsserver("OStype")="Windows Server 2012" Then varcon=varcon&" 0 "&Maxmbps8*1024*1024
'If dsserver("OStype")="Windows Server 2012R2" Then varcon=varcon&" 0 "&Maxmbps8*1024*1024&" "&dsserver("SwitchName")&" "&StartRam&" "&Replace(vhdpath,".vhd","-2.vhd")&" 10 "&(MAXspace-10)
'If dsserver("IsCluster")=true Then varcon=varcon&" "&dsserver("ClusterName")&" "&vpsname
'modi test 1 10 1024 90 c:\vps\hjkhjh.vhd 
temp=VPSOP(URL,FreeHostsharekey,varcon,0)'0=now
'Response.Write varcon
Response.Write temp
FreeHost_oplog session("admusername"),"信息","管理员更换群集中所属物理机：:"&vpsname&" 返回信息："&temp
end if
End if


end if


if Request.Form ("Submit")="设置资源" then

If Request.Form ("allowdomain")<>"" Then
If IsNumeric(Request.Form ("allowdomain")) Then
dsph("allowdomain")=Request.Form ("allowdomain")
response.write "域名绑定数量限制设置为："&Request.Form ("allowdomain")&"个 (此功能只对共享IP类VPS有效)<br>"
End If
End If

If Request.Form ("CDNMaxMb")<>"" Then
If IsNumeric(Request.Form ("CDNMaxMb")) Then
dsph("CDNMaxMb")=Request.Form ("CDNMaxMb")
response.write "流量限制设置为："&Request.Form ("CDNMaxMb")&" M/月(此功能只对共享IP类VPS有效)<br>"
End If
End If

If Request.Form ("MaxIOPS")<>"" Then
If IsNumeric(Request.Form ("MaxIOPS")) Then
dsph("MaxIOPS")=Request.Form ("MaxIOPS")
response.write "第一硬盘IOPS限制设置为："&Request.Form ("MaxIOPS")&" 次/秒(此功能只对win2012R2有效)<br>"
End If
End If
If Request.Form ("MaxIOPS2")<>"" Then
If IsNumeric(Request.Form ("MaxIOPS2")) Then
dsph("MaxIOPS2")=Request.Form ("MaxIOPS2")
response.write "第二硬盘IOPS限制设置为："&Request.Form ("MaxIOPS2")&" 次/秒(此功能只对win2012R2有效)<br>"
End If
End If

If Request.Form ("Maxram")<>"" Then
If IsNumeric(Request.Form ("Maxram")) Then
dsph("Maxram")=Request.Form ("Maxram")
response.write "内存限制设置为："&Request.Form ("Maxram")&" M<br>"
End If
End If
If Request.Form ("StartRam")<>"" Then
If IsNumeric(Request.Form ("StartRam")) Then
dsph("StartRam")=Request.Form ("StartRam")
response.write "初始内存限制设置为："&Request.Form ("StartRam")&" M<br>"
End If
End If

If Request.Form ("Maxmbps8")<>"" Then
If IsNumeric(Request.Form ("Maxmbps8")) Then
If Request.Form ("Maxmbps8")>0 then
dsph("Maxmbps8")=Fix(Request.Form ("Maxmbps8"))

If dsph("Maxmbps8")>1 Then
dsph("Minmbps8")=Fix(dsph("Maxmbps8")/2)
Else
dsph("Minmbps8")=1
End If
End if
response.write "带宽限制设置为（Windows Server 2012才支持）："&Request.Form ("Maxmbps8")&" Mbps<br>"
End If
End If

If Request.Form ("MaxCPU")<>"" Then
If IsNumeric(Request.Form ("MaxCPU")) Then
dsph("MaxCPU")=Request.Form ("MaxCPU")
response.write "CPU限制设置为："&Request.Form ("MaxCPU")&" %<br>"
End If
End If
If Request.Form ("cpunum")<>"" Then
If IsNumeric(Request.Form ("cpunum")) Then
If (Request.Form ("cpunum")=1 Or Request.Form ("cpunum")=2 Or Request.Form ("cpunum")=4 Or Request.Form ("cpunum")=8)  Then
dsph("cpunum")=Request.Form ("cpunum")
response.write "CPU个数设置为："&Request.Form ("cpunum")&" 个<br>"
Else
response.write "CPU个数只能为1,2,4,8"
End If
End If
End if

MAXspace=0
If Request.Form ("Maxspace")<>"" Then
If IsNumeric(Request.Form ("Maxspace")) Then
dsph("Maxspace")=Request.Form ("Maxspace")
MAXspace=dsph("MAXspace")
response.write "硬盘大小限制设置为："&Request.Form ("Maxspace")&" G<br>"
End If
End If

	Set dshost = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_VPSProductlist where vpstype='"&dsph("vpstype")&"'"
	dshost.Open Sql,conn,1,1
NetCardlimtype=dshost("NetCardlimtype")

URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
vpsname=dsph ("vpsname")
username=dsph ("username")
homedir=dsserver("homedir")
starttime=dsph("starttime")
endtime=dsph("endtime")
type1=dsph("VPStype")
MAXcpu=dsph("MAXCPU")
CpuNum=dsph("CpuNum")
MAXRam=dsph("MAXRam")
StartRam=dsph("StartRam")
Minmbps8=dsph("Minmbps8")
Maxmbps8=dsph("Maxmbps8")
vhdpath=dsph("vhdpath")
MaxIOPS=dsph("MaxIOPS")
MaxIOPS2=dsph("MaxIOPS2")
varcon="modi "&username&" "&vpsname&" "&CpuNum&" "&MAXcpu&" "&MAXRam&" "&MAXspace&" "&vhdpath&" "&StartRam
If dsserver("OStype")="Windows Server 2012" Then varcon=varcon&" 0 "&Maxmbps8*1024*1024
If dsserver("OStype")="Windows Server 2012R2" Or dsserver("OStype")="Windows Server 2016" Then varcon=varcon&" 0 "&Maxmbps8*1024*1024&" "&dsserver("SwitchName")&" "&StartRam&" "&Replace(vhdpath,".vhd","-2.vhd")&" 10 "&(MAXspace-10)&" defaultClusterNameby7i24 "&MaxIOPS&" "&MaxIOPS2&" "&dsHost("NetCardlimtype")&" "&dsserver("SwitchName2")
If dsserver("IsCluster")=true Then varcon=Replace(varcon,"defaultClusterNameby7i24",dsserver("ClusterName"))
temp=VPSOP(URL,FreeHostsharekey,varcon,0)'0=now
'Response.Write varcon
'Response.end
Response.Write temp
FreeHost_oplog session("admusername"),"信息","管理员调整VPS资源:"&vpsname&" 返回信息："&temp
dsph.update
end If


if Request.Form ("Submit")="设置备份还原及快照" Then
if Request.Form ("MaxBAK")>0 or Request.Form ("MaxSNA")>0 then
dsph("canbackupvhd")="y"
End If
if Request.Form ("MaxBAK")<9 or Request.Form ("MaxSNA")<9 then
dsph("MaxBAK")=Request.Form ("MaxBAK")
dsph("MaxSNA")=Request.Form ("MaxSNA")
response.write "设置备份还原及快照"
Else
response.write "备份还原及快照每项都不能超过8个"
End if
dsph.update
end If




if Request.Form ("Submit")="单独设置续费价格" and Request.Form ("repaymoney")<>"" then
if IsNumeric(Request.Form ("repaymoney")) and Request.Form ("repaymoney")>0 then
dsph ("repaymoney")=Request.Form ("repaymoney")
dsph.update
Response.Write "此产品的续费价格已单独更新为："&Request.Form ("repaymoney")&"元"
else
Response.Write "请输入大于0的价格。"
end if 
end If

if Request.Form ("Submit")="取消单独价格" then
dsph ("repaymoney")=null
dsph.update
Response.Write "此产品的续费价格已恢复为默认价格"
end if

if Request.Form ("Submit")="单独设置续费价格" and Request.Form ("repaymoney")<>"" then
if IsNumeric(Request.Form ("repaymoney")) and Request.Form ("repaymoney")>0 then
dsph ("repaymoney")=Request.Form ("repaymoney")
dsph.update
Response.Write "此产品的续费价格已单独更新为："&Request.Form ("repaymoney")&"元"
else
Response.Write "请输入大于0的价格。"
end if 
end If


if Request.Form ("Submit")="更改VPS的备注信息" then
dsph ("corewhat")=Request.Form ("corewhat")
dsph.update 
Response.Write "此产品的备注信息已更新为："&Request.Form ("corewhat")
end if







if Request.Form ("Submit")="重设云服务器密码" Then
If CStr(request("vpspassword"))="0" then
response.write "密码不变!只同步IP<br>"
Else
dsph("vpspassword")=request("vpspassword")
response.write "新密码："&dsph("vpspassword")
dsph.update
End if

URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
username=dsph("username")
vpsname=dsph("vpsname")
'oridir=dsserver("osfile"&Request.Form ("osid"))
'homedir=dsserver("homedir")
todir=dsph("vhdpath")
MAXspace=dsph("MAXspace")
'IP=dsVPSip("IP")
'IPmask=dsVPSip("IPmask")
'IPgateway=dsVPSip("IPgateway")
'IPdns1=dsVPSip("IPdns1")
'IPdns2=dsVPSip("IPdns2")
EndIP=IP
VPSpassword=dsph("VPSpassword")
portstart=0
portend=0
If isONEip Then
EndIP=IPopen
portstart=dsVPSip("portstart")+4
portend=dsVPSip("portstart")+dsPORTserver("portperip")-1
End If
IP2=0
IP2mask=0
IP2gateway=0
IP2dns1=0
IP2dns2=0

Set dsVPSip2 = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_VPS_IP where ipbyid='"&dsVPSip("ID")&"' order by orderbyid desc"
		dsVPSip2.Open Sql,conn,1,1
If Not dsVPSip2.Eof Then
IP2=dsVPSip2("IP")
IP2mask=dsVPSip2("IPmask")
IP2gateway=dsVPSip2("IPgateway")
IP2dns1=dsVPSip2("IPdns1")
IP2dns2=dsVPSip2("IPdns2")
end if

oridir="X:\setipby7i24"
todir=oridir
'VPSpassword=Request.Form ("newpassword")
if len(oridir)>3 Then
Set dsVPSip = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_VPS_IP where VPSID="&dsph("id")&" order by SwitchName asc"
		dsVPSip.Open Sql,conn,1,1
IParycon=""'前面是IP，后面是MAC，网卡代号，虚拟交换机名
while not dsVPSip.eof
SwitchName=dsserver("SwitchName")
MAC=dsph("MAC")
If dsVPSip("SwitchName")=2 Then SwitchName=dsserver("SwitchName2")
If dsVPSip("SwitchName")=2 Then MAC=dsph("MAC2")
If isnull(MAC) Then MAC="NULL"
IParycon=IParycon&""&dsVPSip("IP")&"$"&dsVPSip("IPmask")&"$"&dsVPSip("IPgateway")&"$"&dsVPSip("IPdns1")&"$"&dsVPSip("IPdns2")&"$"&MAC&"$"&SwitchName&"#"
dsVPSip.movenext
Wend
dsVPSip.close

FreeHost_oplog session("admusername"),"信息","管理员更改云服务器管理员密码"&username&" 云主机: "&vpsname

varcon="setippass "&username&" "&vpsname&" "&oridir&" "&todir&" "&IP&" "&IPmask&" "&IPgateway&" "&IPdns1&" "&IPdns2&" 1 "&MAXspace&" "&VPSpassword&" "&portstart&" "&portend&" "&IP2&" "&IP2mask&" "&IP2gateway&" "&IP2dns1&" "&IP2dns2&" 0 0 0 0 []"&iparycon
temp=VPSOP(URL,FreeHostsharekey,varcon,1)'0=now

'Response.Write varcon

Response.Write "设置密码及IP的操作结果："

'dsph("status")="正常"
'dsph.update

'If	InStr(temp,"会复制目录中") Then
'Response.Write "2分钟后开始复制."
'Else
Response.Write temp
%>
<br>
<br>
如果您的操作系统是Windows操作系统,请您
请稍等 <font color=red><b>10分钟</b></font> 后
用远程桌面连接您的云服务器：</p>
<p>IP：<%=EndIP%></p>
<%If isONEip then%>
<p>端口：<%=portstart-4%></p>
<%else%>
<p>端口：3389</p>
<%End if%>
<p>用户名：administrator</p>
<p>密码：<%=VPSpassword%><br>
  <br>
如果您的操作系统是Linux操作系统,请您
请稍等 <font color=red><b>10分钟</b></font> 后
用SSH连接您的云服务器：</p>
<p>IP：<%=EndIP%></p>
<%If isONEip then%>
<p>端口：<%=portstart-4+1%></p>
<%End if%>
<p>密码：<%=VPSpassword%><br>
  <br>
<%
End if
end If


if Request.Form ("Submit")="马上预装操作系统" then
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
username=dsph("username")
vpsname=dsph("vpsname")
oridir=dsserver("osfile"&Request.Form ("osid"))
'homedir=dsserver("homedir")
todir=dsph("vhdpath")
MAXspace=dsph("MAXspace")

EndIP=IP
VPSpassword=dsph("VPSpassword")
portstart=0
portend=0
If isONEip Then
EndIP=IPopen
portstart=dsVPSip("portstart")+4
portend=dsVPSip("portstart")+dsPORTserver("portperip")-1
End If
IP2=0
IP2mask=0
IP2gateway=0
IP2dns1=0
IP2dns2=0

Set dsVPSip2 = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_VPS_IP where ipbyid='"&dsVPSip("ID")&"' order by orderbyid desc"
		dsVPSip2.Open Sql,conn,1,1
If Not dsVPSip2.Eof Then
IP2=dsVPSip2("IP")
IP2mask=dsVPSip2("IPmask")
IP2gateway=dsVPSip2("IPgateway")
IP2dns1=dsVPSip2("IPdns1")
IP2dns2=dsVPSip2("IPdns2")
end if


if len(oridir)>3 Then

Set dsVPSip = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_VPS_IP where VPSID="&dsph("id")&" order by SwitchName asc"
		dsVPSip.Open Sql,conn,1,1
IParycon=""'前面是IP，后面是MAC，网卡代号，虚拟交换机名
while not dsVPSip.eof
SwitchName=dsserver("SwitchName")
MAC=dsph("MAC")
If dsVPSip("SwitchName")=2 Then SwitchName=dsserver("SwitchName2")
If dsVPSip("SwitchName")=2 Then MAC=dsph("MAC2")
If isnull(MAC) Then MAC="NULL"
IParycon=IParycon&""&dsVPSip("IP")&"$"&dsVPSip("IPmask")&"$"&dsVPSip("IPgateway")&"$"&dsVPSip("IPdns1")&"$"&dsVPSip("IPdns2")&"$"&MAC&"$"&SwitchName&"#"
dsVPSip.movenext
Wend
dsVPSip.close

varcon="installos "&username&" "&vpsname&" "&oridir&" "&todir&" "&IP&" "&IPmask&" "&IPgateway&" "&IPdns1&" "&IPdns2&" 1 "&MAXspace&" "&VPSpassword&" "&portstart&" "&portend&" "&IP2&" "&IP2mask&" "&IP2gateway&" "&IP2dns1&" "&IP2dns2&" NotCluster NOADSL- 0 0 []"&iparycon
If dsserver("IsCluster")=true Then varcon=Replace(varcon,"NotCluster","isCluster")

if not isnull(dsph("ADSLName")) Then
ADSLtxtInfo=dsph("ADSLName")&"/"&dsph("ADSLpass")
else
	Set dsADSL = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_VPS_ADSL where VPSID="&dsph("id")
		dsADSL.Open Sql,conn,1,1
while not dsADSL.eof
ADSLtxtInfo=dsADSL("ADSLName")&"/"&dsADSL("ADSLpass")&" "&ADSLtxtInfo
dsADSL.movenext
Wend
ADSLtxtInfo=RTrim(ADSLtxtInfo)
end If
If ADSLtxtInfo<>"" Then varcon=Replace(varcon,"NOADSL-","HAVEADSL-"&ADSLtxtInfo)
'Response.Write varcon

temp=VPSOP(URL,FreeHostsharekey,varcon,1)'0=now

Response.Write "预装操作系统"&dsserver("osname"&Request.Form ("osid"))&"操作结果："

dsph("FirstOSid")=Request.Form ("osid")'20140120
dsph("FirstIOSid")=NULL'20150306

dsph("status")="正常"
dsph.update

FreeHost_oplog session("admusername"),"信息","管理员预装操作系统"&username&" 云主机: "&vpsname

'If	InStr(temp,"会复制目录中") Then
'Response.Write "2分钟后开始复制."
'Else
Response.Write temp
%>
<%If ADSLtxtInfo<>"" then%><br><br> 拨号资源：<%=ADSLtxtInfo%><br><br><%End if%>
如果您预装的是Windows操作系统,请您
请稍等 <font color=red><b>25分钟</b></font> 后
用远程桌面连接您的云服务器：</p>
<p>IP：<%=EndIP%></p>
<%If isONEip then%>
<p>端口：<%=portstart-4%></p>
<%else%>
<p>端口：3389</p>
<%End if%>
<p>用户名：administrator</p>
<p>密码：<%=VPSpassword%><br>
  <br>
如果您预装的是Linux操作系统,请您
请稍等 <font color=red><b>25分钟</b></font> 后
用SSH连接您的云服务器：</p>
<p>IP：<%=EndIP%></p>
<%If isONEip then%>
<p>端口：<%=portstart-4+1%></p>
<%End if%>
<p>密码：<%=VPSpassword%><br>
  <br>
<%end If
end if














if Request.Form ("Submit")="马上重开此VPS" then
	Set dshost = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_VPSProductlist where vpstype='"&dsph("vpstype")&"'"
	dshost.Open Sql,conn,1,1
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
username=dsph ("username")
vpsname=dsph ("vpsname")
MAXcpu=dsph("MAXCPU")
CpuNum=dsph("CpuNum")
MAXRam=dsph("MAXRam")
StartRam=dsph("StartRam")
Minmbps8=dsph("Minmbps8")
Maxmbps8=dsph("Maxmbps8")

MAXspace=dsph("MAXspace")
vhdpath=dsph("vhdpath")
MaxIOPS=dsph("MaxIOPS")
MaxIOPS2=dsph("MaxIOPS2")
VLANid=dsph("VLANid")
NetCardlimtype=dshost("NetCardlimtype")

varcon="makevps "&username&" "&vpsname&" "&CpuNum&" "&MAXcpu&" "&MAXRam&" "&MAXspace&" "&vhdpath&" "&StartRam
If dsserver("OStype")="Windows Server 2012" Then varcon=varcon&" 0 "&Maxmbps8*1024*1024
If dsserver("OStype")="Windows Server 2012R2" Or dsserver("OStype")="Windows Server 2016" Then varcon=varcon&" 0 "&Maxmbps8*1024*1024&" "&dsserver("SwitchName")&" "&StartRam&" "&Replace(vhdpath,".vhd","-2.vhd")&" 10 "&(MAXspace-10)&" defaultClusterNameby7i24 "&MaxIOPS&" "&MaxIOPS2&" NULLswitchname "&VLANid&" "&NetCardlimtype
If dsserver("IsCluster")=true Then varcon=Replace(varcon,"defaultClusterNameby7i24",dsserver("ClusterName"))
If Not isnull(dsserver("SwitchName2")) Then varcon=Replace(varcon,"NULLswitchname",dsserver("SwitchName2"))

temp=VPSOP(URL,FreeHostsharekey,varcon,0)

If Not isnull(dsserver("SwitchName2")) Then '处理switch
If InStr(temp,vbcrlf&vbcrlf&vbcrlf&"SwitchName : ") Then
arysw=Split(temp,vbcrlf&vbcrlf&vbcrlf&"SwitchName : ")
arysw2=Split(arysw(1),vbcrlf&vbcrlf&vbcrlf)
arysw3=Split(arysw2(0),vbcrlf)
If dsserver("SwitchName")=arysw3(0) Then
dsph("MAC")=replace(arysw3(1),"MacAddress : ","")
dsph("MAC2")=replace(arysw3(4),"MacAddress : ","")
Else
dsph("MAC")=replace(arysw3(4),"MacAddress : ","")
dsph("MAC2")=replace(arysw3(1),"MacAddress : ","")
End If
End if
End if'完成switch

response.write temp'&"("&varcon&")"
if instr(temp,"失败")>1 then
response.write "出现错误."
Response.end
else
	dsph("status")="正常"
	dsph.Update
end if
dsph.close
end if











%>


			  </td>
            </tr>
            <tr align="center" bgcolor="#E4EAF2">
              <td height="30" colspan="2" align="right"><a href="#top"><font color="#6B9EDE" face="Arial, Helvetica, sans-serif">Top↑</font></a></td>
            </tr>
          </tbody>
        </table>
 </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>


 <%end if%>
<%=htmlwrite("html10")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
