<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<%
domain=trim(LCASE(Request("domain")))
emailname="webmaster@"&domain
If session("username")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
If session("HOSTAUID")<>"" Then ec="主机面板中不能操作用户区的内容，请您先登陆用户区。"
If session("EmailAUID")<>"" Then ec="邮箱面板中不能操作用户区的内容，请您先登陆用户区。"
If session("SQLAUID")<>"" Then ec="数据库面板中不能操作用户区的内容，请您先登陆用户区。"
elseif Request("domain")<>"" and IsValidEmail(emailname)=false then
	ef=True
	ec="存在无效邮箱名称！请检查域名是否正确。"
end if
if not ef then
%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html2")%>
邮箱管理
<%=htmlwrite("html3")%>
<br>
<%Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
if Request("domain")<>"" then	
	Set dspdallemail = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_ALLEmail where username='"&session ("username")&"' and emailname like '%"&Request("domain")&"%'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		dspdallemail.Open Sql,conn,1,1
		if  not dspdallemail.eof then
		havefind=true
		end if
end if
Set dsphemail = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Email where username='"&session("username")&"' order by endtime desc"
if Request("domain")<>"" and havefind then
Sql="Select * from FreeHost.FreeHost_Product_Email where username='"&session("username")&"' and  id="&dspdallemail("PdEID")&""
elseif Request("domain")<>"" and not havefind then
Sql="Select * from FreeHost.FreeHost_Product_Email where username='"&session("username")&"' and  id=0"
end if
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsphemail.PageSize = 25
	dsphemail.Open Sql,conn,1,1
if dsphemail.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 dsphemail.RecordCount <> 0 Then dsphemail.AbsolutePage = CLng(pn)  
    if clng(pn)<=10 then
    begini=1
      if dsphemail.PageCount<=10 then
       endini=dsphemail.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>页 
        　共<%=dsphemail.PageCount%>页　<%end if%><%If Clng(pn)>1 Then%><a href="?<%=ask(0)%>&pn=<%=pn-1%>">上一页</a><%End If%>|<%If Clng(pn)<dsphemail.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 dsphemail.PageSize 
					If dsphemail.RecordCount=0 Then Exit For
%>
<%
	Emailtype=dsphemail("Emailtype")
	Set ori_email_name = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_EmailProductlist where Emailtype='"&dsphemail("Emailtype")&"'"
		ori_email_name.Open Sql,conn,1,1
		if not ori_email_name.eof then
Set newname_email = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_EmailProductlist_AGN where agent1='"&session("agentname")&"' and id='"&ori_email_name("id")&"'"
		newname_email.Open Sql,conn,1,1
if not newname_email.eof then
Emailtype=newname_email("Emailtype")
end if
		end if

	%>
  <tr align="center" bgcolor="#FFFFFF">
    <td height="30">
<%=Emailtype%>
</td>
    <td><%
	Set dspdallemail = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_ALLEmail where username='"&session ("username")&"' and  PdEID='"&dsphemail ("id")&"' order by emailname"
		dspdallemail.Open Sql,conn,1,1
		if not dspdallemail.eof then%><%
		if not isnull(dspdallemail("emailname")) then
		%><%= replace(dspdallemail("emailname"),Application("admmailname")&"@","")%><%
		end if
		end if%></td>
    <td>
	<%
	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Host where id='"&dsphemail("byhost")&"' and username='"&session("username")&"'"
	dsph.Open Sql,conn,1,1
if not dsph.Eof then
nohost=false%>
<a href="/user/hostadm2.asp?id=<%=dsphemail("byhost")%>&go=a"><font color="black">虚拟主机(<%=dsph("ftpname")%>)</font></a>
<%else
nohost=true
end if%>
<%
Set dsdm = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_Product_Domain where username='"&session ("username")&"' and id ='"&dsphemail("bydomain")&"'"
	dsdm.Open Sql,conn,1,1
if not dsdm.Eof then
nodomain=false%>
<a href="/user/listmydomain.asp?id=<%=dsphemail("bydomain")%>"><font color="black">域名(<%=dsdm("domain")%>)</font></a>
<%else
nodomain=true
end if
if nohost and nodomain then%>
无
<%end if%>

	</td>
    <td><%
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Serveremaillist where id='"&dsphemail ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
%><%=dsserver("ip")%><%dsserver.close%></td>
    <td><%=formatdatetime(dsphemail("starttime"),1)%></td>
    <td><%=formatdatetime(dsphemail("endtime"),1)%></td>
    <td><a href="emailadm2.asp?id=<%=dsphemail("id")%>&go=c"><font color="#000000">延期</font></a></td>
    <td><a href="emailadm2.asp?id=<%=dsphemail("id")%>&go=d"><font color="#000000">升级</font></a></td>
    <td><%if dsphemail("endtime")>NOW then%>
      <%if dsphemail("istest")="y" then%>
      <font color="#FF0000">试用</font><%else%>
      <%=dsphemail("status")%>
      <%end if%>
      <%else%>
      <font color="#FF0000">过期</font>
      <%if dsphemail("status")="暂停" then%>
      <br>
      <font color="#FF0000">暂停</font>
      <%end if%>
      <%end if%></td>
    <td bgcolor="#FFFFFF"><a href="emailadm2.asp?id=<%=dsphemail("id")%>&go=a"><font color="#000000">管理</font></a></td>
  </tr>
<%
If clng(pn)=dsphemail.PageCount Then
I = dsphemail.RecordCount - (dsphemail.PageCount-1) * dsphemail.PageSize
If N=I Then Exit For
End If
dsphemail.movenext
Next%>
</table>
<%dsphemail.close
set dsphemail=nothing
end if
%>
<br><br>
<br>
<form action="mailadm.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="domain" type="text" id="domain">
          <input type="submit" name="Submit" value="查找">
      </p></td>
    </tr>
  </table>
</form>
<br>
<%=htmlwrite("html4")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
