<%@ 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 Request.Form ("password")="" or RegExpTest("[^A-Za-z0-9]",Request.Form ("password")) Then
	ef=True
	ec="密码没填或有特殊字符！"
ElseIf Request.Form ("password")<>Request.Form ("repassword") Then
	ef=True
	ec="重复输入的密码不一致！"
ElseIf len(Request.Form ("password"))<6 Then
	ef=True
	ec="密码过于简单(不能小于6位数)！"
ElseIf Request.Form ("password")="123456" or Request.Form ("password")="888888" Then
	ef=True
	ec="密码过于简单(不能小于6位数)！"
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="服务器不存在！"
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)))
if (name1<>Application("admmailname")) then
starttime=dspdallemail("starttime")
'删除旧的
sql="delete from FreeHost.FreeHost_Product_ALLEmail where PdEID='"&dsph ("id")&"'"
    conn.Execute Sql
 dspdallemail.addnew
dspdallemail("emailname")=emailname
dspdallemail("username")=dsph ("username")
dspdallemail("PdEID")=dsph ("id")
dspdallemail("Emailtype")=dsph ("Emailtype")
if starttime<>"" then
dspdallemail("starttime")=starttime
else
dspdallemail("starttime")=now
end if
dspdallemail("endtime")=dsph ("endtime")
dspdallemail("istest")=dsph ("istest")
dspdallemail("status")=dsph ("status")
dspdallemail("userspacelimt")=dsph ("userspacelimt")
dspdallemail("domainspacelimt")=dsph ("domainspacelimt")
end if
dspdallemail("emailpass")=Request.Form ("password")
dspdallemail.update
'dim websize
'websize=dspdl ("userspacelimt")*1024
tem=ChpassEmail(dsph ("ServerlistID"),name1,domain,Request.Form ("password"))
tem2=ModAdmEmail(dsph ("ServerlistID"),trim(dspdallemail("emailname")),domain,dsph ("emailcount"),dsph ("domainspacelimt")*1024)'maxuser
dim websize
websize=dspdl ("userspacelimt")*1024
tem=ChpassEmail(dsph ("ServerlistID"),name1,domain,Request.Form ("password"))
end if

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

<br>
<br>
保存成功。请用管理邮箱名：<%=dspdallemail("emailname")%>及您刚才修改的密码<br><br>

登陆：<a href="<%=dsserver("webdomain")%>"><font color="#000000"><%=dsserver("webdomain")%></font></a>，可以管理您名下的邮箱用户。您也可以将　mail.域名　解析到邮箱服务器IP上<br>
<br>
<a href="<%=dsserver("webdomain")%>"><font color="#000000"></font></a>您就可以用 http://mail.域名 来直接访问<br>
<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%>