<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
server.ScriptTimeout =240
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("canadmemailset")="" 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='"&Request.Form ("id")&"'"
	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 ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username='"&dsph("username")&"'"
		ds.Open Sql,conn,1,3
if ds.eof then
	ef=True
	ec="用户不存在!"
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='"&dspdl ("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 username='"&ds ("username")&"' and PdEID='"&dsph ("id")&"'"
		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 username='"&ds ("username")&"' and PdEID='"&dsph ("id")&"'"
    conn.Execute Sql
 dspdallemail.addnew
dspdallemail("emailname")=emailname
dspdallemail("username")=ds ("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/htmlwrite.asp"--><%=htmlwrite("html8")%>
<%=htmlwrite("html9")%>
<TABLE width="100%" border=0 cellPadding=0 cellSpacing=0 background="img/midtop4.gif">
  <TBODY>
    <TR>
      <TD width=53 align="left" background="img/midtop1.gif"><strong> 　 </strong><font color="#FFFFFF">─<strong>&gt;</strong></font> </TD>
      <TD align="left"><table height="59"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="7" background="img/midtop.gif">&nbsp;</td>
            <td width="90" align="center" valign="middle" background="img/r3.jpg" id="tableTop1" style="Cursor:hand"><a href="admemail.asp"><font color="#FFFFFF"><strong>邮箱管理</strong></font></a></td>
            <td width="5" background="img/midtop2.gif">&nbsp;</td>
          </tr>
      </table></TD>
      <TD width="83">&nbsp;</TD>
      <TD width="83" align="left">&nbsp;</TD>
      <TD align="left">&nbsp;</TD>
      <TD width=23 align="right"><IMG height=59 
                  src="img/rtop4.jpg" 
                  width=19></TD>
    </TR>
  </TBODY>
</TABLE>
<TABLE width="100%" border=0 cellPadding=0 cellSpacing=0>
  <TBODY>
    <TR>
      <TD width=19 background="img/midlef.gif" id=rightid>&nbsp;</TD>
      <TD height="300" align="center" vAlign=top bgcolor="#FFFFFF">
	  
	  <DIV class="tableborder" id="t4">      <br>
<%=tem%><%=tem2%>
<br>
保存成功.      </div>
	  
	  
      </TD>
      <TD width=18 background="img/midri.gif">&nbsp;</TD>
    </TR>
  </TBODY>
</TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
    <TR>
      <TD width=30><IMG height=19 
                  src="img/rb1.jpg" 
                  width=30></TD>
      <TD 
                background=img/rb2.jpg>&nbsp;</TD>
      <TD width=30><IMG height=19 
                  src="img/rb3.jpg" 
                  width=30></TD>
    </TR>
  </TBODY>
</TABLE>
<%=htmlwrite("html10")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
