<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
server.ScriptTimeout =240
If session("EmailAUID")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request.Form ("id")="" Then
	ef=True
	ec="请输入产品ID！"
ElseIf not IsNumeric(Request.Form ("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
ElseIf  RegExpTest("[^A-Za-z0-9\.\-]",replace(Request.Form ("ali"),",","")) 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
	Set dspdl = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_EmailProductlist where Emailtype='"&dsph ("Emailtype")&"'"
		dspdl.Open Sql,conn,1,1
If dspdl.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="服务器不存在！"
else
URL=dsserver("site")
FreeHostsharekey=dsserver("FreeHostsharekey")
end if
end if

if not ef then
Set dspdallemail = Server.CreateObject("ADODB.Recordset")	
Sql="Select top 1 * from FreeHost.FreeHost_Product_ALLEmail where PdEID='"&dsph ("id")&"' and emailname is not null"
		dspdallemail.Open Sql,conn,1,3
if dspdallemail.Eof then
	ef=True
	ec="管理邮箱不存在！请先绑定域。"
end if
end if


if not ef then
email=trim(dspdallemail("emailname"))
emailarry=split(email,"@")
name1=emailarry(0)
domain=lcase(trim(emailarry(1)))


keyvalue=trim(lcase(Request.Form ("ali")))

regpath=domain
key="Address"
retvlue=replace(Regimailop(URL,FreeHostsharekey,regpath,key,keyvalue,3),"操作成功，数值为：","")
regpath=retvlue

if Request.Form ("del")="mod" Then
key="Aliases"
tem=Regimailop(URL,FreeHostsharekey,regpath,key,keyvalue,4)
end if


end if

if not ef then%>
<!--#include virtual="/inc-freehost-function/template-emailadm-top.asp"--> 邮箱管理

<br>
<br>
保存成功：<%=tem%>　<!--<%=retvlue%>--> <br><br>
<br>
<br>
　<a href="adm.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%>