<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<%
If session("agentusername")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request("ip1")<>"" And not IsNumeric(replace(Request("ip1"),".","")) Then
	ef=True
	ec="ip1不对"
ElseIf Request("ip2")<>"" And not IsNumeric(replace(Request("ip2"),".","")) Then
	ef=True
	ec="ip2不对"
end if
if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsph = Server.CreateObject("ADODB.Recordset")	
if Request.QueryString ("op") ="all" then Sql="Select * from FreeHost.FreeHost_Product_Sql where (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"') order by id desc"
if Request.QueryString ("op") ="pause" then Sql="Select * from FreeHost.FreeHost_Product_Sql where (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"') and endtime<'"&now&"' order by endtime desc"
if Request.QueryString ("op") ="del" then Sql="Select * from FreeHost.FreeHost_Product_Sql where (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"') and endtime<'"&dateadd("d",-30,now)&"' order by endtime desc"
	dsph.PageSize = 25
	dsph.Open Sql,conn,1,3
if dsph.Eof then
	ef=True
	ec="此类数据库不存在！"
end if
end if

if not ef then
ask=Split(Request.ServerVariables("QUERY_STRING"), chr(38)&"pn")
	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
%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html5")%> 数据库管理
<%=htmlwrite("html6")%>
<%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%>">[<%=i%>]</a><%end if%>　<%next%> 
        <%else%>　<a href="?<%=ask(0)%>&pn=1">最新[1]--[10]</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%>
<%while not dsph.Eof%>
<table width="100%"  border="0" cellspacing="1" bgcolor="#000000">
  <tr>
    <td width="3%" rowspan="2" align="center" bgcolor="#FFCC66"><%=dsph("id")%>
    <td width="76%" bgcolor="#FFCC66">产品类型：<%=dsph("Sqltype")%> 用户名:<%=dsph("username")%> 
    <td width="14%" rowspan="2" align="center" bgcolor="#FFCC66"><%if dsph("endtime")>NOW then%>
        <%if dsph("istest")="y" then%>
        <strong><font color=#000099>目前处于试用期!</font></strong>
        <%else%>
        <font color="#FFFFFF"><%=dsph("status")%></font>
        <%end if%>
        <%else%>
        <font color="#FFFFFF"><strong>已过期！</strong></font>
        <%if dsph("status")="暂停" then%>
        <br>
        <font color="#FFFFFF">并且已暂停!</font>
        <%end if%>
        <%end if%>
    </td>
    <td width="7%" rowspan="2" align="center" bgcolor="#FFCC66"><a href="handSql1.asp?username=<%=dsph("username")%>&id=<%=dsph("id")%>" target="_blank">管理</a>
        <%if Request.QueryString ("op") ="del" then%>
        <br>
        <br>
        <a href="handhosthanddel.asp?username=<%=dsph("username")%>&id=<%=dsph("id")%>">删除</a><br>
        <br>
        <%end if%>
    </td>
  </tr>
  <tr>
    <td bgcolor="#CCCCCC">开通时间:<%=dsph("starttime")%>　到期时间:<%=dsph("endtime")%> </td>
  </tr>
</table>
<table width="100%"  border="0" cellspacing="1" bgcolor="#000000">
  <tr>
    <td bgcolor="#F7F7F7">
      <font color="#FF0000">
      <%
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerSqllist where id='"&dsph ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
if dsserver.Eof then%>
此数据库服务器在数据库中不存在！
<%else
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
userid=dsserver ("admname")
pwd=dsserver("admpass")
sqlname=dsph("sqlname")
sqlpassword=dsph("sqlpassword")

if Request.QueryString ("op") ="pause" then
op=1
ret=PauseSQL(URL,FreeHostsharekey,userid,pwd,sqlname,sqlpassword,op)
Response.Write ret
dsph("status")="暂停"
dsph.update
end if

if Request.QueryString ("op") ="del" then
op=2
ret=PauseSQL(URL,FreeHostsharekey,userid,pwd,sqlname,sqlpassword,op)

ret=ret&"删除成功"
homedir=dsserver("homedir")
username=dsph("ftpname")
ftpdir=homedir&"\backup\"&sqlname&"_"&dsph("randir")
varcon=" /E /T /R "&username
todeluser=1
delacl=1
todelftp=1
if not isnull(dsph("ftpendtime")) then
ret = ret&"删除这个库的备份FTP："&DelFTP(URL,FreeHostsharekey,username,ftpdir,varcon,todeluser,delacl,todelftp)
end if
if not isnull(dsph("randir")) then
ret = ret&"删除这个库的备份目录："&DelDir(URL,FreeHostsharekey,ftpdir)
end if

opport=dsserver("port")
for iipsec=1 to 2
if not isnull(dsph("ip"&iipsec)) then
	Set dsphip = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Sql where (ip1='"&dsph("ip"&iipsec)&"' or ip2='"&dsph("ip"&iipsec)&"') and id<>'"&dsph ("id")&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsphip.Open Sql,conn,1,3
if dsphip.Eof then
opvar="del"
ret=ret&OPIpsec(URL,FreeHostsharekey,opvar,dsph("ip"&iipsec),opport)
response.write "删除允许的IP："&dsph("ip"&iipsec)&"<br>"
end if
dsphip.close
end if
next

FreeHost_clientlog conn,dsph ("username"),session("admusername"),"超级管理员操作","数据库产品",dsph ("id"),"删除","","",ret
dsph.delete
response.write ret
end if

%>
      </font>
<%end if%>
</td>
  </tr>
</table>
<%
dsph.movenext
wend
dsph.close
set dsph=nothing
%>
<%=htmlwrite("html7")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
