<%@ 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")="设置资源"  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 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
if Not dsph("isagentpd")=true Then
	ef=True
	ec="不是代理上级的产品不能用这个功能！"
End If
End If



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

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

if not ef then
username=dsph("username")
vpsname=dsph("vpsname")




%>

<!--#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" >　
                <%
	if dsph("isagentpd")=true then%>
                <%=dsph("AgnUpIP")%>
                <%
	else
	Set dsX = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_VPS_IP where VPSID="&dsph("id")
		dsX.Open Sql,conn,1,1
while not dsX.eof
%>
                <%=dsX("IP")%> <br>
                <%
if dsX("portstart")>0 then

if isONEip=true then
	Set dsPORTserver = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_ServerPORTlist where id='"&useportserver&"'"
		dsPORTserver.Open Sql,conn,1,1%>
                <%=dsPORTserver("IP")%>(公网)<br>
                <%end if	

end if
dsX.movenext
wend
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("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 "不需要操作上级API,更改成功。状态为:"&dsph("status")
dsph.update
End if

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


if Request.Form ("Submit")="恢复" then
dsph("status")="正常"
dsph("pausebyagn")="n"
Response.Write "不需要操作上级API,更改成功。状态为:"&dsph("status")
dsph.update
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

dsph.delete
dsph.Update
Response.Write "VPS信息已从数据库中删除。但在上级API中并没有删除。"
'On Error Resume next'出错也处理


FreeHost_oplog session("admusername"),"信息","管理员删除(代理上级的)云服务器:"&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")="单独设置续费价格" 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")="马上重开此VPS" then
	Set dshost = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_VPSProductlist where vpstype='"&dsph("vpstype")&"'"
	dshost.Open Sql,conn,1,1

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")
varcon="makevps "&username&" "&vpsname&" "&CpuNum&" "&MAXcpu&" "&MAXRam&" "&MAXspace&" "&vhdpath&" "&StartRam
'If dsserver("OStype")="Windows Server 2012" Then varcon=varcon&" "&Minmbps8*1024*1024&" "&Maxmbps8*1024*1024


dsph("isagentpd")=dshost("isagentpd")
dsph("VPSComName")=dshost("VPSComName")
dsph("VPSApiName")=dshost("VPSApiName")
dsph("VPScpdomain")=dshost("VPScpdomain")
dsph("Agnuserid")=dshost("Agnuserid")
dsph("Domain_Agent_nonemd5_6")=dshost("Domain_Agent_nonemd5_6")
dsph("Agnidc")=dshost("Agnidc")
dsph("Agnproductid")=dshost("Agnproductid")
dsph.update

VPSApiName=dsph("VPSApiName")
userid=dsph("Agnuserid")
userstr=md5(dsph("Domain_Agent_nonemd5_6")&"7i24.com")
yearAgn=Request.Form ("year")
idc=dsph("Agnidc")
productid=dsph("Agnproductid")
attach=ds("username")
tar="http://"&VPSApiName&"/api/cloudapi.asp?userid="&userid&"&userstr="&userstr&"&year="&yearAgn&"&vpsname="&vpsname&"&VPSpassword="&dsph ("VPSpassword")&"&idc="&idc&"&productid="&productid&"&action=activate&attach="&attach
'Response.write tar
temp=ONLY_GET(tar,"")

FreeHost_oplog session("admusername"),"信息","管理区，管理员重开云服务器产品:("&vpsname&") "&temp

If InStr(temp,"et=ok") then
Sql="update FreeHost.FreeHost_Product_VPS set status='正常' where vpsname='"&vpsname&"'"
    conn.Execute Sql
response.write "操作成功，上级API返回："
Else
Sql="update FreeHost.FreeHost_Product_VPS set status='失败' where vpsname='"&vpsname&"'"
    conn.Execute Sql
'Response.Redirect "e.asp?e=调用上级API时出错，开通失败，但费用已扣，请联系管理员手工处理！出错原因为："&server.urlencode(temp)
response.write "操作失败，上级API返回原因："
End If


response.write temp
'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%>
