<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("username")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
If session("HOSTAUID")<>"" Then ec="主机面板中不能操作用户区的内容，请您先登陆用户区。"
If session("EmailAUID")<>"" Then ec="邮箱面板中不能操作用户区的内容，请您先登陆用户区。"
If session("SQLAUID")<>"" Then ec="数据库面板中不能操作用户区的内容，请您先登陆用户区。"
ElseIf Request("sqlname")<>"" and (RegExpTest("[^A-Za-z0-9]",Request("sqlname")) or Instr(1, Request("sqlname"), "'", 1)>0 or Instr(1, Request("sqlname"), "-", 1)>0 or Instr(1, Request("sqlname"), " ", 1)>0 or Instr(1, Request("sqlname"), "&", 1)>0 or Instr(1, Request("sqlname"), ".", 1)>0 or Instr(1, Request("sqlname"), "_", 1)>0) Then
	ef=True
	ec="数据库用户名中有非法字符！"
ElseIf Request("ftpname")<>"" and (RegExpTest("[^A-Za-z0-9]",Request("ftpname")) or Instr(1, Request("ftpname"), "'", 1)>0 or Instr(1, Request("ftpname"), "-", 1)>0 or Instr(1, Request("ftpname"), " ", 1)>0 or Instr(1, Request("ftpname"), "&", 1)>0 or Instr(1, Request("ftpname"), ".", 1)>0 or Instr(1, Request("ftpname"), "_", 1)>0) Then
	ef=True
	ec="FTP用户名中有非法字符！"
end If


if not ef Then
If trim(replace(Request("hostname"),"http://",""))<>"" then
 
hostname=trim(replace(Request("hostname"),"http://",""))
if hostname<>"" then hostname=ComX.idntoac_7i24_com(cstr(hostname))
hostnamecheck=replace(hostname,".","")
hostnamecheck=replace(hostnamecheck,"xn--","")
If RegExpTest("[^A-Za-z0-9--]",hostnamecheck) Then
	ef=True
	ec="请输入合法的域名！"
end If
end if
end if


if not ef then
%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html2")%>
SQL数据库管理
<%=htmlwrite("html3")%>

<br>
<br>
<%Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
byhost=0
if Request("ftpname")<>"" or trim(replace(Request("hostname"),"http://",""))<>"" then
Set dsph = Server.CreateObject("ADODB.Recordset")	
if Request("ftpname")<>""   then	Sql="Select * from FreeHost.FreeHost_Product_Host where username='"&session("username")&"' and Hosttype<>'子目录绑定' and  ftpname like '%"&Request("ftpname")&"%'"
if Request("hostname")<>"" then	Sql="Select * from FreeHost.FreeHost_Product_Host where username='"&session("username")&"' and Hosttype<>'子目录绑定' and  hostname like '%"&ComX.idntoac_7i24_com(cstr(hostname))&"%'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,replace(sql,"xn--",""), "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end If
'Response.write sql
	dsph.Open Sql,conn,1,1
if Not dsph.Eof Then
byhost=dsph("id")
End if
End If

Set dsphSql = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Sql where username='"&session("username")&"' order by endtime desc"
if Request("sqlname")<>"" then Sql="Select * from FreeHost.FreeHost_Product_Sql where username='"&session("username")&"' and  sqlname like '%"&Request("sqlname")&"%'"
If byhost>0 then Sql="Select * from FreeHost.FreeHost_Product_Sql where username='"&session("username")&"' and  byhost='"&byhost&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsphSql.PageSize = 25
	dsphSql.Open Sql,conn,1,1
if dsphSql.Eof then%>
没有开通的数据库产品.	
<%else%>
<%
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 dsphSql.RecordCount <> 0 Then dsphSql.AbsolutePage = CLng(pn)  
    if clng(pn)<=10 then
    begini=1
      if dsphSql.PageCount<=10 then
       endini=dsphSql.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>页 
        　共<%=dsphSql.PageCount%>页　<%end if%><%If Clng(pn)>1 Then%><a href="?<%=ask(0)%>&pn=<%=pn-1%>">上一页</a><%End If%>|<%If Clng(pn)<dsphSql.PageCount Then%><a href="?<%=ask(0)%>&pn=<%=pn+1%>"><font color="#000000">下一页</font></a>
        <%End If%>
<table width="100%" border="0" cellspacing="1" cellpadding="2" align="center" bgcolor="#CCCCCC">
  <tr bgcolor="#EEEEEE" align="center">
    <td height="21">产品类型</td>
    <td>数据库名</td>
    <td height="21">所属父产品</td>
    <td>IP 地址</td>
    <td>开通日期</td>
    <td>到期日期</td>
    <td>操作</td>
    <td>操作</td>
    <td>状态</td>
    <td>操作</td>
  </tr>
<%
For N=1 To dsphSql.PageSize 
					If dsphSql.RecordCount=0 Then Exit For
%>
<%
	Sqltype=dsphSql("Sqltype")
	Set ori_Sql_name = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_SqlProductlist where Sqltype='"&dsphSql("Sqltype")&"'"
		ori_Sql_name.Open Sql,conn,1,1
		if not ori_Sql_name.eof then
Set newname_Sql = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_SqlProductlist_AGN where agent1='"&session("agentname")&"' and id='"&ori_Sql_name("id")&"'"
		newname_Sql.Open Sql,conn,1,1
if not newname_Sql.eof then
Sqltype=newname_Sql("Sqltype")
end if
		end if

	%>
  <tr align="center" bgcolor="#FFFFFF">
    <td height="30">
<%=Sqltype%>
</td>
    <td><%=dsphSql("sqlname")%></td>
    <td>
	<%
	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where id='"&dsphSql("byhost")&"' and username='"&session("username")&"'"
	dsph.Open Sql,conn,1,1
if not dsph.Eof then
nohost=false%>
<a href="/user/hostadm2.asp?id=<%=dsphSql("byhost")%>&go=a"><font color="black">虚拟主机(<%=dsph("ftpname")%>)</font></a>
<%else%>
无
<%end if%>

	</td>
    <td><%
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Serversqllist where id='"&dsphSql ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
%><%=dsserver("ip")%><%dsserver.close%></td>
    <td><%=formatdatetime(dsphSql("starttime"),1)%></td>
    <td><%=formatdatetime(dsphSql("endtime"),1)%></td>
    <td><a href="sqladm2.asp?id=<%=dsphSql("id")%>&go=c"><font color="#000000">延期</font></a></td>
    <td><a href="sqladm2.asp?id=<%=dsphSql("id")%>&go=d"><font color="#000000">升级</font></a></td>
    <td><%if dsphSql("endtime")>NOW then%>
      <%if dsphSql("istest")="y" then%>
      <font color="#FF0000">试用</font><%else%>
      <%=dsphSql("status")%>
      <%end if%>
      <%else%>
      <font color="#FF0000">过期</font>
      <%if dsphSql("status")="暂停" then%>
      <br>
      <font color="#FF0000">暂停</font>
      <%end if%>
      <%end if%></td>
    <td bgcolor="#FFFFFF"><a href="sqladm2.asp?id=<%=dsphSql("id")%>&go=a"><font color="#000000">管理</font></a></td>
  </tr>
<%
If clng(pn)=dsphSql.PageCount Then
I = dsphSql.RecordCount - (dsphSql.PageCount-1) * dsphSql.PageSize
If N=I Then Exit For
End If
dsphSql.movenext
Next%>
</table>
<%dsphSql.close
set dsphSql=nothing
end if
%>
<br><br>
<br>
<form action="sqladm.asp" method="get" name="form1">
  <table width="100%" height="20"  border="0" cellpadding="0" cellspacing="0">
    <tr bgcolor="">
      <td>查找数据库：</td>
    </tr>
  </table>
  <table width="100%"  border="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
      <td width="9%" height="30" rowspan="2" bgcolor="#FFFFFF"><p>　数据库名：
          <input name="sqlname" type="text" id="sqlname">
          或FTP用户名：
              <input name="ftpname" type="text" id="ftpname" size="10">
              或域名
              <input name="hostname" type="text" id="hostname">
<input type="submit" name="Submit" value="查找">
      </p></td>
    </tr>
  </table>
</form>
<%=htmlwrite("html4")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
