<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("VPSAUID")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request.Form ("id")="" Then
	ef=True
	ec="请输入产品ID！"
ElseIf Request.Form ("newpassword")="" Then
	ef=True
	ec="新密码为空！"
ElseIf Request.Form ("newpassword")<>Request.Form ("renewpassword") Then
	ef=True
	ec="密码不一致！"
ElseIf RegExpTest("[^A-Za-z0-9]",Request.Form ("newpassword")) Then
	ef=True
	ec="密码中有非法字符！"
ElseIf not IsNumeric(session("VPSAUID"))  Then
	ef=True
	ec="vpsid应该是数字！"
end if

if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsphVPS = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_VPS where id='"&session("VPSAUID")&"'"
	dsphVPS.Open Sql,conn,1,3
if dsphVPS.Eof then
	ef=True
	ec="不存在的数据库产品ID！"
end if
end If

if not ef Then
If dsphVPS("endtime")<Now Then
	ef=True
	ec="产品已过期,不能再操作！"
End If
end if

if not ef then
	Set dsVPSpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_VPSProductlist where VPStype='"&dsphVPS("VPStype")&"'"
	if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsVPSpdlist.Open Sql,conn,1,1
if dsVPSpdlist.Eof then
	ef=True
	ec="产品不存在！"
end if
end if

if not ef then
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerVPSlist where id='"&dsphVPS ("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
Set dsVPSip = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_VPS_IP where ipbyid=0 and VPSID="&dsphVPS("id")
		dsVPSip.Open Sql,conn,1,1
If  not dsVPSip.eof then
IP=dsVPSip("IP")
IPmask=dsVPSip("IPmask")
IPgateway=dsVPSip("IPgateway")
IPdns1=dsVPSip("IPdns1")
IPdns2=dsVPSip("IPdns2")
'dsVPSip.close
Else
	ef=True
	ec="这个VPS没有分配IP资源,请联系管理员处理！"
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 DateDiff("s",Application("canrar"&dsserver("id")&"optime"),NOW )<1500 and Application("canrar"&dsserver("id"))=true then
'	ef=True
'	ec="系统繁忙，前一个预装的操作尚未处理完，请您稍等25分钟后再试，谢谢您的支持。"
'end if
'end if

'if not ef then'time
'Application.lock
'Application("canrar"&dsserver("id")&"optime")=now
'Application("canrar"&dsserver("id"))=true
'Application.unlock
'end If

if not ef then
%>
<!--#include virtual="/inc-freehost-function/template-vpsadm-top.asp"-->
　
<p>云服务器自助管理


  <br>
  <br>
  <br>
预装操作系统
 
<br>
<br>
<br>
<%


URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
username=dsphVPS("username")
vpsname=dsphVPS("vpsname")
'oridir=dsserver("osfile"&Request.Form ("osid"))
'homedir=dsserver("homedir")
todir=dsphVPS("vhdpath")
MAXspace=dsphVPS("MAXspace")
'IP=dsVPSip("IP")
'IPmask=dsVPSip("IPmask")
'IPgateway=dsVPSip("IPgateway")
'IPdns1=dsVPSip("IPdns1")
'IPdns2=dsVPSip("IPdns2")
EndIP=IP
VPSpassword=dsphVPS("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

Set dsVPSip = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_VPS_IP where VPSID="&dsphVPS("id")&" order by SwitchName asc"
		dsVPSip.Open Sql,conn,1,1
IParycon=""'前面是IP，后面是MAC，网卡代号，虚拟交换机名
while not dsVPSip.eof
SwitchName=dsserver("SwitchName")
MAC=dsphVPS("MAC")
If dsVPSip("SwitchName")=2 Then SwitchName=dsserver("SwitchName2")
If dsVPSip("SwitchName")=2 Then MAC=dsphVPS("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


oridir="X:\setipby7i24"
todir=oridir
VPSpassword=Request.Form ("newpassword")
if len(oridir)>3 Then

FreeHost_oplog dsphVPS("username"),"信息","用户更改云服务器管理员密码:"&dsphVPS ("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的操作结果："

'dsphVPS("status")="正常"
dsphVPS("VPSpassword")=VPSpassword
dsphVPS.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

Else
Response.Write "管理员没定义原始的操作系统文件,请联系管理员处理."
End If


%>
  <br>
  <br>
  <br>
  　<a href="selfvpsmodify.asp?id=<%=Request("id")%>"><font color="#000000">[返回]</font></a>
  <!--#include virtual="/inc-freehost-function/template-vpsadm-end.asp"-->
  <%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
</p>
