<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("agentusername")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf not IsNumeric(Request.QueryString ("id"))  Then
	ef=True
	ec="ID应该是数字！"
ElseIf RegExpTest("[^A-Za-z0-9]",Request("username")) Then
	ef=True
	ec="用户名中有非法字符！"
ElseIf RegExpTest("[^A-Za-z0-9]",Request("vpsname")) Then
	ef=True
	ec="VPS名中有非法字符！"	
ElseIf Request.QueryString("ip")<>"" and not IsNumeric(Replace(Request.QueryString("ip"),".",""))  Then
	ef=True
	ec="IP不对！"
'ElseIf RegExpTest("[^A-Za-z0-9]",Request("hostname")) Then
'	ef=True
'	ec="主机名中有非法字符！"
'ElseIf RegExpTest("[^A-Za-z0-9]",Request("ftpname")) Then
	'ef=True
	'ec="FTP名中有非法字符！"
ElseIf not IsNumeric(Request("ServerlistID"))  Then
	ef=True
	ec="服务器ID应该是数字！"
ElseIf RegExpTest("[^A-Za-z0-9]",Request("VPStype")) Then
	ef=True
	ec="类型中有非法字符！"
ElseIf RegExpTest("[^A-Za-z0-9]",Request("beianstatus")) Then
	ef=True
	ec="beianstatus中有非法字符！"
ElseIf not IsNumeric(Request("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
ElseIf not IsDate(Request("starttime")) and Request("starttime")<>""  Then
	ef=True
	ec="请输入合法的日期！"
ElseIf not IsDate(Request("endtime")) and Request("endtime")<>""  Then
	ef=True
	ec="请输入合法的日期！"
ElseIf not IsDate(Request("starttime1")) and Request("starttime1")<>""  Then
	ef=True
	ec="请输入合法的日期！"
ElseIf not IsDate(Request("endtime1")) and Request("endtime1")<>""  Then
	ef=True
	ec="请输入合法的日期！"
ElseIf not IsDate(Request("starttime2")) and Request("starttime2")<>""  Then
	ef=True
	ec="请输入合法的日期！"
ElseIf not IsDate(Request("endtime2")) and Request("endtime2")<>""  Then
	ef=True
	ec="请输入合法的日期！"
end If


if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
  Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_AGENT where username='"&session("agentusername")&"'"
		dsagent.Open Sql,conn,1,1
If dsagent.Eof Then
	ef=True
	ec="代理不存在!"
end if
end If

if not ef Then
If Request.QueryString("ip")<>""  Then
	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_VPS_IP where ip='"&Request.QueryString ("ip")&"' and vpsid>0"
	dsph.Open Sql,conn,1,1
if dsph.Eof Then
	ef=True
	ec="IP不存在！"
	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_VPS where AgnUpIP like '%"&Request.QueryString ("ip")&"%'"
	dsph.Open Sql,conn,1,1
if dsph.Eof Then
	ef=True
	ec="IP不存在！"
Else
	ef=False
vpsid=dsph("id")
dsph.close
'Response.redirect "handvps1agn.asp?vpsname="&dsph("vpsname")
End if
Else
vpsid=dsph("vpsid")
dsph.close
End If
End if
End If


if not ef then%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html5")%>
　云服务器管理
<%=htmlwrite("html6")%>
<br>
<form action="admvps-cloud.asp" method="get" name="form1">
<DIV class="tableborder" id="table1" <%if Request.QueryString ("op")<>"" then%> style="display:"<%end if%>><table width="100%"  border="0" cellspacing="1">
        <tr >
          <td height="24" colspan="2" align="center" background="img/tablebg.gif"><font color="#FFFFFF">开通新的弹性云服务器</font></td>
        </tr>
        <tr bgcolor="#E4EAF2">
          <td width="9%" height="40" align="right" bgcolor="#E4EAF2">&nbsp;</td>
          <td width="91%" align="left">　用户名：
              <input name="username" type="text" id="username" size="10" maxlength="14">
              <input name="Submit" type="submit" id="Submit" value="下一步"></td>
        </tr>
      </table>
  </div>
</form>

<form action="admvps2.asp" method="get" name="form1">
<DIV class="tableborder" id="table1" <%if Request.QueryString ("op")<>"" then%> style="display:"<%end if%>><table width="100%"  border="0" cellspacing="1">
        <tr >
          <td height="24" colspan="2" align="center" background="img/tablebg.gif"><font color="#FFFFFF">开通新的固定云服务器</font></td>
        </tr>
        <tr bgcolor="#E4EAF2">
          <td width="9%" height="40" align="right" bgcolor="#E4EAF2">&nbsp;</td>
          <td width="91%" align="left">　用户名：
              <input name="username" type="text" id="username" size="10" maxlength="14">
云服务器产品：
<%
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_VPSProductlist where cancloud=0 and canbyagn='y' and (onlyusebyagn is null or onlyusebyagn='"&session("agentusername")&"') order by id asc"
		ds.Open Sql,conn,1,1
If ds.Eof Then%>
云服务器产品列表为空.
<%else%>
<select name="id" id="id">
  <%while not ds.Eof
	vpstype=ds("vpstype")
	Set newname_VPS = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_VPSProductlist_AGN where agent1='"&session("agentusername")&"' and id='"&ds("id")&"'"
		newname_VPS.Open Sql,conn,1,1
if not newname_VPS.eof then
'info=newname_VPS("info")
vpstype=newname_VPS("vpstype")
end if  
newname_VPS.close
  %>
  <option value="<%=ds("id")%>"><%=vpstype%></option>
  <%
ds.movenext
wend%>
</select>
<%end if%>
<input name="Submit" type="submit" id="Submit" value="下一步"></td>
        </tr>
      </table>
  </div>
</form>

<form action="admvps.asp" method="get" name="form1">
  <DIV class="tableborder"  id="table2" <%if Request.QueryString ("op")<>"" then%> style="display:"<%end if%>>
    <table width="100%"  border="0" cellspacing="1">
      <tr >
        <td height="24" colspan="2" align="center" background="img/tablebg.gif"><font color="#FFFFFF">查找云服务器</font></td>
      </tr>
      <tr bgcolor="#E4EAF2">
        <td width="9%" height="40" align="right" bgcolor="#E4EAF2">&nbsp;</td>
        <td width="91%" align="left">　用户名：
          <input name="username" type="text" id="username" size="10" maxlength="14">
          或云服务器名：
<input name="vpsname" type="text" id="vpsname" size="10" maxlength="14">
        或IP：
          <input name="IP" type="text" value="" size="15" maxlength="30">		<input name="Submit" type="submit" id="Submit" value="下一步"></td>
      </tr>
    </table>
  </div>
</form>

<%if Request.QueryString ("op")<>"" then%><DIV class="tableborder" id="table3"  style="display:"><%else%><DIV class="tableborder" id="table3"  style="display:none"><%end if%>
<table width="100%"  border="0" cellspacing="1">
      <tr >
        <td height="24" colspan="2" align="center" background="img/tablebg.gif"><font color="#FFFFFF">虚拟主机到期处理</font></td>
      </tr>
      <tr bgcolor="#E4EAF2">
        <td width="9%" height="130" align="right" bgcolor="#E4EAF2">&nbsp;</td>
        <td width="91%" align="left">
            　<a href="gemail.asp?type=host&da=30"><font color="#000000">群发邮件给一个月后到期的用户>>></font> </a> <br>
            　<a href="gemail.asp?type=host&da=7"><font color="#000000">群发邮件给一周后到期的用户>>></font> </a> <br>            <br></td>
      </tr>
  </table>
</div>

<%
	Set dsph = Server.CreateObject("ADODB.Recordset")
SQL="Select * from FreeHost.FreeHost_Product_VPS where "

if Request.QueryString ("username")<>"" then Sql=Sql+"username= '"&trim(Request.QueryString ("username"))&"' and "
if Request.QueryString ("id")<>"" then Sql=Sql+"id= '"&trim(Request.QueryString ("id"))&"' and "
if Request.QueryString ("vpsname")<>"" then Sql=Sql+"vpsname= '"&trim(Request.QueryString ("vpsname"))&"' and "
'if Request.QueryString ("hostname")<>"" then Sql=Sql+"hostname like '%"&ComX.idntoac_7i24_com(cstr(hostname))&"%' and "
'if Request.QueryString ("ftpname")<>"" then Sql=Sql+"ftpname like '%"&trim(Request.QueryString ("ftpname"))&"%' and "
'if Request.QueryString ("ServerlistID")<>"" then Sql=Sql+"ServerlistID = '"&trim(Request.QueryString ("ServerlistID"))&"' and "
'if Request.QueryString ("VPStype")<>"" then Sql=Sql+"VPStype = '"&trim(Request.QueryString ("VPStype"))&"' and "

if Request.QueryString ("status")<>"" then
if Request.QueryString ("status")="过期暂停" then
Sql=Sql+"istest = 'n' and endtime < '"&now&"' and status = '暂停' and "
elseif Request.QueryString ("status")="过期未暂停" then
Sql=Sql+"istest = 'n' and endtime < '"&now&"' and status = '正常' and "
elseif Request.QueryString ("status")="试用过期未暂停" then
Sql=Sql+"endtime < '"&now&"' and istest = 'y' and status = '正常' and "
elseif Request.QueryString ("status")="试用过期已暂停" then
Sql=Sql+"endtime < '"&now&"' and istest = 'y' and status = '暂停' and "
elseif Request.QueryString ("status")="试用过期" then
Sql=Sql+"endtime < '"&now&"' and istest = 'y' and "
elseif Request.QueryString ("status")="试用" then
Sql=Sql+"endtime > '"&now&"' and istest = 'y' and "
else
'Sql=Sql+"istest = 'n' and status = '"&trim(Request.QueryString ("status"))&"' and "
end if
end if

'if Request.QueryString ("beianstatus")<>"" and Request.QueryString ("beianstatus")<>"没有备案" then Sql=Sql+"beianstatus = '"&trim(Request.QueryString ("beianstatus"))&"' and "
'if Request.QueryString ("beianstatus")="没有备案" then Sql=Sql+"beianstatus is null and "
if Request.QueryString ("starttime2") <>"" then  Sql=Sql+"starttime>'"&Request.QUERYSTRING ("starttime1")&"' and starttime<'"&Request.QUERYSTRING ("starttime2")&"' and "
if Request.QueryString ("endtime2") <>"" then  Sql=Sql+"endtime>'"&Request.QUERYSTRING ("endtime1")&"' and endtime<'"&Request.QUERYSTRING ("endtime2")&"' and "
if Request.QueryString ("starttime") <>"" then  Sql=Sql+"starttime>'"&Request.QUERYSTRING ("starttime")&"' and "
if Request.QueryString ("endtime") <>"" then  Sql=Sql+"endtime<'"&Request.QUERYSTRING ("endtime")&"' and "
if right(sql,5)=" and " then sql=left(sql,len(sql)-5)&" and (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"') order by id desc"
if right(SQL,6)="where " then  SQL="Select * from FreeHost.FreeHost_Product_VPS where (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"') order by id desc"

if Request.QueryString ("op") ="all" then Sql="Select * from FreeHost.FreeHost_Product_VPS where (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"') order by id desc"
if Request.QueryString ("op") ="pause" then Sql="Select * from FreeHost.FreeHost_Product_VPS where VPStype<>'子目录绑定' and endtime<'"&now&"' and (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"') order by endtime desc"
if Request.QueryString ("op") ="del" then Sql="Select * from FreeHost.FreeHost_Product_VPS where VPStype<>'子目录绑定' and endtime<'"&dateadd("d",-30,now)&"'  and (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"') order by endtime desc"
if Request.QueryString ("op") ="willpause" then Sql="Select * from FreeHost.FreeHost_Product_VPS where VPStype<>'子目录绑定' and endtime<'"&dateadd("d",30,now)&"' and (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"') order by endtime desc "
if Request.QueryString ("space")<>"" then Sql="Select * from FreeHost.FreeHost_Product_VPS where (userspacelimtReal >userspacelimt or logspacelimtReal>logspacelimt) and (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"') order by userspacelimtReal desc"

if Request.QueryString ("ip") <>"" then Sql="Select * from FreeHost.FreeHost_Product_VPS where id='"&vpsid&"' and (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"') order by id desc"

'Response.Write sql
if Instr(1,sql, ";", 1)>0 or Instr(1,replace(sql,"xn--",""), "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsph.PageSize = 25
        dsph.Open Sql,conn,1,1
if not dsph.eof then
if Request.ServerVariables("QUERY_STRING")<>"" then
ask=Split(Request.ServerVariables("QUERY_STRING"), chr(38)&"pn")
else
ask=Split("freehost=1", "")
ask(0)="freehost=lsoft"
end if
	pn=1
if Request.QueryString ("pn")<>"" then pn=Request.QueryString ("pn")
If dsph.RecordCount <> 0 Then dsph.AbsolutePage = CLng(pn)  
    if clng(pn)<=10 then
    begini=1
      if dsph.PageCount<=10 then
       endini=dsph.PageCount 
       else
       endini=10
      end if
    end if
%>

<%if clng(pn)<=10 then%>最新 <%for i=begini to endini
    if clng(pn)=i then%><font color=red>[<%=i%>]</font><%else%><a href="?<%=ask(0)%>&pn=<%=i%>"><font color="#000000">[<%=i%>]</font></a><%end if%>　<%next%> 
        <%else%>　<a href="?<%=ask(0)%>&pn=1"><font color="#000000">最新[1]--[10]</font></a>　　现在是第<font color=red>[<%=pn%>]</font>页 
        　共<%=dsph.PageCount%>页　<%end if%><%If Clng(pn)>1 Then%><a href="?<%=ask(0)%>&pn=<%=pn-1%>">上一页</a><%End If%>|<%If Clng(pn)<dsph.PageCount Then%><a href="?<%=ask(0)%>&pn=<%=pn+1%>">下一页</a><%End If%>
<%if Request.QueryString ("op") ="" then%>
<a href="admvps.asp?starttime=<%=formatdatetime(now,2)%>"><font color="#000000">今天新开通</font></a> | <a href="admvps.asp?starttime=<%=formatdatetime(dateadd("d",-7,now),2)%>"><font color="#000000">一周新开通</font></a> | <a href="admvps.asp?endtime=<%=formatdatetime(dateadd("d",7,now),2)%>"><font color="#000000">一周到期</font></a> | <a href="admvps.asp?endtime=<%=formatdatetime(dateadd("d",30,now),2)%>"><font color="#000000">30天到期</font></a>
|<a href="admvps.asp"><font color="#000000">全部</font></a>

<%end if%>
<DIV class="tableborder">
<table width="100%" border="0" cellspacing="1" cellpadding="2" align="center">
  <tr bgcolor="#C1BFBF" align="center">
    <td width="13%" background="img/tablebg.gif"><font color="#FFFFFF">云服务器名</font></td>
    <td width="15%" background="img/tablebg.gif"><font color="#FFFFFF">产品类型</font></td>
    <td width="13%" height="24" background="img/tablebg.gif"><font color="#FFFFFF">用户名</font></td>
    <td width="16%" height="24" background="img/tablebg.gif"><font color="#FFFFFF">IP 地址</font></td>
    <td width="13%" height="24" background="img/tablebg.gif"><font color="#FFFFFF">开通/到期</font></td>
    <td width="8%" background="img/tablebg.gif"><font color="#FFFFFF">状态</font></td>
    <td width="4%" height="24" background="img/tablebg.gif"><font color="#FFFFFF">操作</font></td>
    </tr>
<%
For N=1 To dsph.PageSize 
					If dsph.RecordCount=0 Then Exit For
%>
<%

	vpstype=dsph("vpstype")
	Set ori_host_name = Server.CreateObject("ADODB.Recordset")	
		Sql="Select id from FreeHost.FreeHost_VPSProductlist where vpstype='"&dsph("vpstype")&"'"
		ori_host_name.Open Sql,conn,1,1
		if not ori_host_name.eof then
Set newname_host = Server.CreateObject("ADODB.Recordset")	
Sql="Select vpstype from FreeHost.FreeHost_VPSProductlist_AGN where agent1='"&session("agentusername")&"' and id='"&ori_host_name("id")&"'"
		newname_host.Open Sql,conn,1,1
if not newname_host.eof then vpstype=newname_host("vpstype")
end if%>
  <tr align="center" bgcolor="#E4EAF2" onmouseover=this.bgColor='#cccccc'; onmouseout=this.bgColor='#E4EAF2';>
    <td width="13%"><%=dsph("vpsname")%><br>
    </td>
    <td><%=vpstype%></td>
    <td width="13%" height="30"><a href="searchuser.asp?username=<%=dsph("username")%>"><%=dsph("username")%></a></td>
    <td><%
	if dsph("isagentpd")=true then%>
      <%if not isnull(dsph("AgnUpIP")) then%><%=replace(dsph("AgnUpIP"),"|","<br>")%><%end if%>
      <%
	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

Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerVPSlist where id='"&dsph ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
isONEip=dsserver("isONEip")	

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,1%>
      <%=dsPORTserver("IP")%>(公网)<br>
      <%end if	

end if
dsX.movenext
wend
end if
%><%
if not isnull(dsph("ADSLName")) then
%>拨号资源(手工录入)：<%=dsph("ADSLName")%>/<%=dsph("ADSLpass")%><br>
<%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%>
   拨号资源：<%=dsADSL("ADSLName")%>/<%=dsADSL("ADSLpass")%><br>
<%		
dsADSL.movenext
wend
end if%></td>
    <td width="13%"><%=formatdatetime(dsph("starttime"),1)%><br>
      <%=formatdatetime(dsph("endtime"),1)%>      <br>      </td>
    <td width="8%"><%if dsph("endtime")>NOW then%>
        <%if dsph("istest")="y" then%>
        <font color="#FF0000">试用</font>
        <%else%>
        <%=dsph("status")%>
        <%end if%>
        <%else%>
        <font color="#FF0000">过期</font>
        <%if dsph("status")="暂停" then%>
        <br>
        <font color="#FF0000">暂停</font>
        <%end if%>
        <%end if%></td>
    <td><%
	if dsph("isagentpd")=true then%><a href="vpsadmrepay1.asp?id=<%=dsph("id")%>"><font color="#000000">延期升级</font></a> <%end if%><a href="vpsadm2.asp?id=<%=dsph("id")%>&go=a"><font color="#000000">管理</font></a></td>
    </tr>
<%
If clng(pn)=dsph.PageCount Then
I = dsph.RecordCount - (dsph.PageCount-1) * dsph.PageSize
If N=I Then Exit For
End If
dsph.movenext
Next%></table>
</div>
<%dsph.close
set dsph=nothing
else%>
<DIV class="tableborder"><br>
<br>
没有相关的记录。<br>
<br>
</div>
<%end if%><br>


<form action="admvps.asp" method="get" name="form1">
  <DIV class="tableborder"  id="table2" <%if Request.QueryString ("op")<>"" then%> style="display:"<%end if%>>
    <table width="100%"  border="0" cellspacing="1">
      <tr >
        <td height="24" colspan="2" align="center" background="img/tablebg.gif"><font color="#FFFFFF">按开通时间找云服务器：</font></td>
      </tr>
      <tr bgcolor="#E4EAF2">
        <td width="9%" height="40" align="right" bgcolor="#E4EAF2">&nbsp;</td>
        <td width="91%" align="left">　开始时间：
              <input name="starttime1" type="text" id="starttime1" value="<%=formatdatetime(now,2)%>" size="19" maxlength="19">
结束时间：
<input name="starttime2" type="text" value="<%=formatdatetime(dateadd("d",1,now),2)%>" size="19" maxlength="19">
<input name="Submit" type="submit" id="Submit" value="下一步"></td>
      </tr>
    </table>
  </div>
</form>
<form action="admvps.asp" method="get" name="form1">
  <DIV class="tableborder"  id="table2" <%if Request.QueryString ("op")<>"" then%> style="display:"<%end if%>>
    <table width="100%"  border="0" cellspacing="1">
      <tr >
        <td height="24" colspan="2" align="center" background="img/tablebg.gif"><font color="#FFFFFF">按到期时间找云服务器：</font></td>
      </tr>
      <tr bgcolor="#E4EAF2">
        <td width="9%" height="40" align="right" bgcolor="#E4EAF2">&nbsp;</td>
        <td width="91%" align="left">　开始时间：
              <input name="endtime1" type="text" id="starttime" value="<%=formatdatetime(now,2)%>" size="19" maxlength="19">
结束时间：
<input name="endtime2" type="text" value="<%=formatdatetime(dateadd("d",1,now),2)%>" size="19" maxlength="19">
<input name="Submit" type="submit" id="Submit" value="下一步"></td>
      </tr>
    </table>
  </div>
</form>

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