<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<%
If session("EmailAUID")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request("id")="" Then
	ef=True
	ec="请输入产品ID！"
ElseIf Instr(1, Request("id"), "'", 1)>0 then
	ef=True
	ec="非法产品ID！"
ElseIf not IsNumeric(Request("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
ElseIf Instr(1, session("username"), "'", 1)>0 then
	ef=True
	ec="非法用户名！"
end if

if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsph = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_Product_Email where id='"&session("EmailAUID")&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsph.Open Sql,conn,1,1
if dsph.Eof then
	ef=True
	ec="不存在的邮箱ID！"
end if
end if

if not ef then
if dsph("istest")="y" then
'	ef=True
	ec="试用期产品不能绑定域名！"
end if
end if

if not ef then
	Set dsHostpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_EmailProductlist where Emailtype='"&dsph("Emailtype")&"'"
	if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsHostpdlist.Open Sql,conn,1,1
if dsHostpdlist.Eof then
	ef=True
	ec="产品不存在！"
end if
end if

if not ef then
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerEmaillist where id='"&dsph ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
if dsserver.Eof then
	ef=True
	ec="服务器不存在！"
end if
end if

if not ef then
Set dspdallemail = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_ALLEmail where PdEID='"&dsph ("id")&"' and emailname is not null order by emailname"
		dspdallemail.Open Sql,conn,1,3
if  not dspdallemail.eof then
emailarryX=split(dspdallemail("emailname"),"@")
domainhaveset=emailarryX(1)
else
	ef=True
	ec="请您先绑定邮箱域名！"
end if
end if

if not ef then
if isnull(dspdallemail("emailpass")) then
	ef=True
	ec="请您先设置域管理员密码！"
end if
end if


if not ef then
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")

if dsserver("softtype")="Imail" then

regpath=domainhaveset&"\users"
key="MaxSize"
op=5'1,r nun,2 w num,3 r str,4 w str,5 list
'keyvalue=20481
'Response.Write
'Response.End
returnstr=Regimailop(URL,FreeHostsharekey,regpath,key,keyvalue,op)

arrystrEmailAli=split(replace(replace(Regimailop(URL,FreeHostsharekey,domainhaveset&"\users\_aliases",key,keyvalue,6),"操作成功：",""),"postmaster@",""),"@")

arrystr=split(replace(replace(returnstr,"操作成功：",""),"_aliases@",""),"@")

if ubound(arrystr)<1 then Response.Redirect "e.asp?e=出错，这个域名没有绑定成功,请删除后重新绑定,或重新绑定一个别的域名测试。"
if not instr(returnstr,"成功")>1 then Response.Redirect "e.asp?e=出错："&returnstr

domainsize=replace(Regimailop(URL,FreeHostsharekey,domainhaveset,key,keyvalue,1),"操作成功，数值为：","")/1024/1024
key="MaxUsers"
domainmaxuser=replace(Regimailop(URL,FreeHostsharekey,domainhaveset,key,keyvalue,1),"操作成功，数值为：","")

regpath=domainhaveset
key="MaxRcv"
MaxRcv=replace(Regimailop(URL,FreeHostsharekey,regpath,key,keyvalue,1),"操作成功，数值为：","")

if domainsize=0 Then
domainsize=dsHostpdlist("domainspacelimt")'2008-当imail超过4G的域
If Not IsNull(dsph("domainspacelimt")) Then domainsize=dsph("domainspacelimt")'2008-当imail超过4G的域
End if

else

admname=dsserver("admname")
admpass=dsserver("admpass")
domain=domainhaveset
returnstr=ListDomainmail(URL,FreeHostsharekey,admname,admpass,domain)
returnstr=replace(returnstr,"授权通过 ","")
arrystrSize=split(returnstr,"#")
if ubound(arrystrSize)<1 then Response.Redirect "e.asp?e=出错，这个域名没有绑定成功,请删除后重新绑定,或重新绑定一个别的域名测试。也有可能是winwebmail邮箱软件的权限不正常造成的,请参考知识库修改权限."

domainmaxuser=arrystrSize(1)
domainsize=round(arrystrSize(2)/1024,1)
arrystr=split(arrystrSize(0),"$")
end if

%>
<!--#include virtual="/inc-freehost-function/template-emailadm-top.asp"-->
　邮箱自助管理
<%if dsserver("softtype")="Imail" then%>

  <br>
  <br>
<TABLE 
            width="100%" border=1 align=center cellPadding=0 cellSpacing=0 borderColorLight=#cccccc borderColorDark=#fbfbfb>
  <TBODY>
    <TR align="center">
      <TD height="35" colspan="6" vAlign=middle bgColor=#494949>&nbsp; <font color="#FFFFFF">修改名下邮箱设置 总可用大小：<%=domainsize%>M 允许开通的邮箱数量：<%=domainmaxuser%>个</font>　</TD>
      </TR>
<%
haveuser=0
for idformail=0 to ubound(arrystr)
arrystr(idformail)=replace(arrystr(idformail),vbcrlf,"")
if len(arrystr(idformail))>0 and arrystr(idformail)<>"root" then
regpath=domainhaveset&"\users\"&arrystr(idformail)
key="MaxSize"
retvlue=replace(Regimailop(URL,FreeHostsharekey,regpath,key,keyvalue,1),"操作成功，数值为：","")
if retvlue=0 then
retvlue=MaxRcv
end if
returnstr=round(retvlue/1024/1024,1)
haveuser=haveuser+returnstr
%>
<form action="adm2.asp" method="post" name="modhostname<%=idformail+1%>">
    <TR align="center">
      <TD width="6%" vAlign=middle bgColor=#EEEEEE><%=idformail%></TD>
      <TD width="25%" height="35" bgColor=#ffffff>　<%=arrystr(idformail)%>@<%=domainhaveset%></TD>
      <TD width="25%" height="35" bgColor=#ffffff>大小：
        <input name="size" type="text" id="size" size="4" maxlength="6" value="<%=returnstr%>">
		<input name="oldsize" type="hidden" value="<%=returnstr%>">
        M</TD>
      <TD width="22%" bgColor=#ffffff>密码：
        <input name="password" type="text" id="pass" size="6" maxlength="14">
		<input name="del" type="hidden" value="">
		<input name="id" type="hidden" value="<%=idformail+1%>">
		<input name="email" type="hidden" value="<%=arrystr(idformail)%>">
		</TD>
      <TD width="11%" bgColor=#ffffff><a href="javascript:document.modhostname<%=idformail+1%>.del.value='yes';document.modhostname<%=idformail+1%>.submit();"><font color="#000000">删除</font></a></TD>
      <TD width="11%" bgColor=#ffffff><a href="javascript:document.modhostname<%=idformail+1%>.del.value='no';document.modhostname<%=idformail+1%>.submit();"><font color="#000000">修改</font></a></TD>
    </TR>
</form>
<%
end if
next
notopenid=0
for notopenid=idformail to domainmaxuser+1
%>
<form action="adm2.asp" method="post" name="modhostname<%=notopenid+1%>">
    <TR align="center">
      <TD width="6%" vAlign=middle bgColor=#EEEEEE><%=notopenid-1%></TD>
      <TD width="25%" height="35" bgColor=#ffffff>　<input name="email" type="text" id="email" size="4" maxlength="14" >@<%=domainhaveset%></TD>
      <TD width="25%" height="35" bgColor=#ffffff>大小：
        <input name="size" type="text" id="size" size="4" maxlength="6" value="<%=round(MaxRcv/1024/1024,1)%>">
		<input name="oldsize" type="hidden" value="<%=round(MaxRcv/1024/1024,1)%>">
        M</TD>
      <TD width="22%" bgColor=#ffffff>密码：
        <input name="password" type="text" id="pass" size="6" maxlength="14">
		<input name="del" type="hidden" value="">
		<input name="id" type="hidden" value="<%=notopenid+1%>">
		</TD>
      <TD colspan="2" bgColor=#ffffff><a href="javascript:document.modhostname<%=notopenid+1%>.del.value='add';document.modhostname<%=notopenid+1%>.submit();"><font color="#000000">添加</font></a></TD>
      </TR>
</form>
<%
next
%>
    <TR align="center">
      <TD vAlign=middle bgColor=#EEEEEE>&nbsp;</TD>
      <TD height="35" bgColor=#ffffff>　</TD>
      <TD height="35" bgColor=#ffffff>已分配：
<%=haveuser%>
        M</TD>
      <TD bgColor=#ffffff>未分配： <%=domainsize-haveuser%> M </TD>
      <TD colspan="2" bgColor=#ffffff>总可用： <%=domainsize%> M</TD>
      </TR>

  </TBODY>
</TABLE><br>
<br>
<TABLE 
            width="100%" border=1 align=center cellPadding=0 cellSpacing=0 borderColorLight=#cccccc borderColorDark=#fbfbfb>
  <TBODY>
    <TR align="center">
      <TD height="35" colspan="5" vAlign=middle bgColor=#494949>&nbsp; <font color="#FFFFFF">邮箱的域别名 </font>　</TD>
      </TR>
<%
regpath=domainhaveset
regpath=replace(regpath,vbcrlf,"")'add by 2007-4-9
key="Address"
retvlue=replace(Regimailop(URL,FreeHostsharekey,regpath,key,keyvalue,3),"操作成功，数值为：","")
regpath=retvlue
regpath=replace(regpath,vbcrlf,"")'add by 2007-4-9
key="Aliases"
retvlue=replace(Regimailop(URL,FreeHostsharekey,regpath,key,keyvalue,3),"操作成功，数值为：","")
%>
<form action="admalidomain.asp" method="post" name="aliactdomain<%=idformail+1%>">
    <TR align="center">
      <TD width="6%" vAlign=middle bgColor=#EEEEEE>1</TD>
      <TD width="25%" height="35" bgColor=#ffffff>　<%=domainhaveset%></TD>
      <TD height="35" bgColor=#ffffff>域别名：
        <input name="ali" type="text" id="pass" size="20" maxlength="500" value="<%=retvlue%>">
		<input name="del" type="hidden" value="">
		<input name="id" type="hidden" value="<%=idformail+1%>">
		<input name="email" type="hidden" value="<%=idformail%>">		</TD>
      <TD width="11%" bgColor=#ffffff><a href="javascript:document.aliactdomain<%=idformail+1%>.del.value='mod';document.aliactdomain<%=idformail+1%>.ali.value='';document.aliactdomain<%=idformail+1%>.submit();"><font color="#000000">删除</font></a></TD>
      <TD width="11%" bgColor=#ffffff><a href="javascript:document.aliactdomain<%=idformail+1%>.del.value='mod';document.aliactdomain<%=idformail+1%>.submit();"><font color="#000000">修改</font></a></TD>
      </TR>
</form>
  </TBODY>
</TABLE>
<br><br>
<TABLE 
            width="100%" border=1 align=center cellPadding=0 cellSpacing=0 borderColorLight=#cccccc borderColorDark=#fbfbfb>
  <TBODY>
    <TR align="center">
      <TD height="35" colspan="5" vAlign=middle bgColor=#494949>&nbsp; <font color="#FFFFFF">邮箱别名 </font>　</TD>
      </TR>
<%
for idformail=0 to ubound(arrystrEmailAli)
arrystrEmailAli(idformail)=replace(arrystrEmailAli(idformail),vbcrlf,"")'add by 2007-4-9
if len(arrystrEmailAli(idformail))>0 and arrystrEmailAli(idformail)<>"root" then
regpath=domainhaveset&"\users\_aliases"
key=arrystrEmailAli(idformail)
retvlue=replace(Regimailop(URL,FreeHostsharekey,regpath,key,keyvalue,3),"操作成功，数值为：","")
%>
<form action="admali.asp" method="post" name="aliactname<%=idformail+1%>">
    <TR align="center">
      <TD width="6%" vAlign=middle bgColor=#EEEEEE><%=idformail+1%></TD>
      <TD width="25%" height="35" bgColor=#ffffff>　<%=arrystrEmailAli(idformail)%>@<%=domainhaveset%></TD>
      <TD height="35" bgColor=#ffffff>原始名：
        <input name="ali" type="text" id="pass" size="20" maxlength="500" value="<%=retvlue%>">
		<input name="del" type="hidden" value="">
		<input name="id" type="hidden" value="<%=idformail+1%>">
		<input name="email" type="hidden" value="<%=arrystrEmailAli(idformail)%>">		</TD>
      <TD width="11%" bgColor=#ffffff><a href="javascript:document.aliactname<%=idformail+1%>.del.value='yes';document.aliactname<%=idformail+1%>.submit();"><font color="#000000">删除</font></a></TD>
      <TD width="11%" bgColor=#ffffff><a href="javascript:document.aliactname<%=idformail+1%>.del.value='yes';document.aliactname<%=idformail+1%>.submit();"></a><a href="javascript:document.aliactname<%=idformail+1%>.del.value='mod';document.aliactname<%=idformail+1%>.submit();"><font color="#000000">修改</font></a></TD>
      </TR>
</form>
<%
end if
next
notopenid=0
for notopenid=idformail to domainmaxuser+1
if (notopenid-1)>0 then
%>
<form action="admali.asp" method="post" name="aliactname<%=notopenid+1%>">
    <TR align="center">
      <TD width="6%" vAlign=middle bgColor=#EEEEEE><%=notopenid-1%></TD>
      <TD width="25%" height="35" bgColor=#ffffff>　<input name="email" type="text" id="email" size="4" maxlength="14" >@<%=domainhaveset%></TD>
      <TD height="35" bgColor=#ffffff>原始名：
        <input name="ali" type="text" id="pass" size="20" maxlength="500">
        <input name="del" type="hidden" value="">
		<input name="op" type="hidden" value="ali">
        <input name="id" type="hidden" value="<%=idformail+1%>">
</TD>
      <TD height="35" colspan="2" bgColor=#ffffff><a href="javascript:document.aliactname<%=notopenid+1%>.del.value='add';document.aliactname<%=notopenid+1%>.submit();"><font color="#000000">添加</font></a></TD>
      </TR>
</form>
<%
end if
next
%>
  </TBODY>
</TABLE>
<%else%>





  <br>
  <br>
<TABLE 
            width="100%" border=1 align=center cellPadding=0 cellSpacing=0 borderColorLight=#cccccc borderColorDark=#fbfbfb>
  <TBODY>
    <TR align="center">
      <TD height="35" colspan="6" vAlign=middle bgColor=#494949>&nbsp; <font color="#FFFFFF">修改名下邮箱设置 总可用大小：<%=domainsize%>M 允许开通的邮箱数量：<%=domainmaxuser%>个</font>　</TD>
      </TR>
<%
haveuser=0
for idformail=0 to ubound(arrystr)
if len(arrystr(idformail))>0 and arrystr(idformail)<>"admin" then
arryemail=split(arrystr(idformail),"|")
arry2=split(arryemail(0),"@")
haveuser=haveuser+round(arryemail(1)/1024,1)
%>
<form action="adm2.asp" method="post" name="modhostname<%=idformail+1%>">
    <TR align="center">
      <TD width="6%" vAlign=middle bgColor=#EEEEEE><%=idformail+1%></TD>
      <TD width="25%" height="35" bgColor=#ffffff>　<%=arryemail(0)%></TD>
      <TD width="25%" height="35" bgColor=#ffffff>大小：
        <input name="size" type="text" id="size" size="4" maxlength="6" value="<%=round(arryemail(1)/1024,1)%>">
		<input name="oldsize" type="hidden" value="<%=round(arryemail(1)/1024,1)%>">
        M</TD>
      <TD width="22%" bgColor=#ffffff>密码：
        <input name="password" type="text" id="pass" size="6" maxlength="14">
		<input name="del" type="hidden" value="">
		<input name="id" type="hidden" value="<%=idformail+1%>">
		<input name="email" type="hidden" value="<%=arry2(0)%>">
		</TD>
      <TD width="11%" bgColor=#ffffff><a href="javascript:document.modhostname<%=idformail+1%>.del.value='yes';document.modhostname<%=idformail+1%>.submit();"><font color="#000000">删除</font></a></TD>
      <TD width="11%" bgColor=#ffffff><a href="javascript:document.modhostname<%=idformail+1%>.del.value='no';document.modhostname<%=idformail+1%>.submit();"><font color="#000000">修改</font></a></TD>
    </TR>
</form>
<%
end if
next
notopenid=0
for notopenid=idformail to domainmaxuser+1
%>
<form action="adm2.asp" method="post" name="modhostname<%=notopenid+1%>">
    <TR align="center">
      <TD width="6%" vAlign=middle bgColor=#EEEEEE><%=notopenid-1%></TD>
      <TD width="25%" height="35" bgColor=#ffffff>　<input name="email" type="text" id="email" size="4" maxlength="14" >@<%=domainhaveset%></TD>
      <TD width="25%" height="35" bgColor=#ffffff>大小：
        <input name="size" type="text" id="size" size="4" maxlength="6" value="<%=round(MaxRcv/1024/1024,1)%>">
		<input name="oldsize" type="hidden" value="<%=round(MaxRcv/1024/1024,1)%>">
        M</TD>
      <TD width="22%" bgColor=#ffffff>密码：
        <input name="password" type="text" id="pass" size="6" maxlength="14">
		<input name="del" type="hidden" value="">
		<input name="id" type="hidden" value="<%=notopenid+1%>">
		</TD>
      <TD colspan="2" bgColor=#ffffff><a href="javascript:document.modhostname<%=notopenid+1%>.del.value='add';document.modhostname<%=notopenid+1%>.submit();"><font color="#000000">添加</font></a></TD>
      </TR>
</form>
<%
next
%>

    <TR align="center">
      <TD width="6%" vAlign=middle bgColor=#EEEEEE>&nbsp;</TD>
      <TD width="25%" height="35" bgColor=#ffffff>　</TD>
      <TD width="25%" height="35" bgColor=#ffffff>已分配：
<%=haveuser%>
        M</TD>
      <TD width="22%" bgColor=#ffffff>未分配： <%=domainsize-haveuser%> M </TD>
      <TD colspan="2" bgColor=#ffffff>总可用： <%=domainsize%> M</TD>
      </TR>

  </TBODY>
</TABLE><br>
<br>




<%end if%>

<br>　<a href="selfemailmodify.asp?id=<%=Request("id")%>"><font color="#000000">[返回上一页]</font></a>
<!--#include virtual="/inc-freehost-function/template-emailadm-end.asp"-->
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>