<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="admin.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/function.asp"-->
<%
If Request("act")=5 Then
   Call Cw_jmailyzm(Request("e"))
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>邮箱管理 - <%=cf_name%></title>
<link href="images/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="images/us.js"></script>
<script type="text/javascript" src="../inc/jquery.js"></script>
</head>

<body>
<!--#include file="top.asp"-->
<div class="con bian">
   <div class="bd_l"><!--#include file="left.asp"--></div>
   <div class="bd_r">
      <div class="title">邮箱管理</div>
	  <%
	  If Request("act")=1 Then
	   Call cw_yz(180)'发送间隔60S
	     If isjmail=1 then
		 e_rnd=Cw_rnd(19)
		 e_email=Request("e")
		 e_tit=cf_name&"-邮箱验证"
		 e_con="亲爱的<b>"&session("user")&"</b><br />你正在使用"&cf_name&"邮箱验证，<br />请点击以下链接对您的E-mail邮箱进行验证：<br /><a href='"&cf_host&cf_root&"user/cw_email.asp?key="&e_rnd&"&act=2' target='_blank'>"&cf_host&cf_root&"user/Cw_email.asp?key="&e_rnd&"&act=2</a>" 
		 Conn.Execute("update cw_user set repass="&e_rnd&" where id="&session("userid"))		 
		 jm=Cw_jmail(cf_smtp,cf_email,cf_name,cf_jmailUser,cf_jmailPass,e_email,e_tit,e_con)
	     Select Case jm
	     Case 0
		   conn.execute("update cw_user set repass='"&e_rnd&"' where id="&session("userid"))
	       Response.Write("<script>alert('验证邮件发送成功！');location.href='cw_email.asp';</script>")
	     Case 1
	       Response.Write("<script>alert('验证邮件发送失败！');location.href='cw_email.asp';</script>")
	     Case 2
	       Response.Write("<script>alert('验证邮件发送失败！');location.href='cw_email.asp';</script>")
	      End Select
	    Else
	       Response.Write("<script>alert('对不起，系统暂不支持邮箱验证！');history.back();</script>")
	    End If
	  End If
	  
	  If Request("act")=2 and Request("key")<>"" Then
	     Set rm=Server.CreateObject("adodb.recordset")
		 rmq="select * from cw_user where id="&session("userid")
		 rm.Open rmq,conn,1,3
		 if not rm.eof then
		   key=rm("repass")
		   If key=Request("key") Then
		     rm("repass")=""
			 rm("ismail")=1
			 rm.Update
			 Response.Write("<script>alert('恭喜您，邮箱验证成功！');location.href='cw_email.asp';</script>")
		   Else
		     Response.Write("<script>alert('非法操作，您己被记录！');history.back();</script>")
		   End If
		 end if
		 rm.Close
		 Set rm=Nothing
	  End If
	  
	  If Request("act")=4 Then	     
		 If Request("yzm")<>session("email_yzm") Then
		    Response.Write("<script>alert('验证码错误！');history.back();</script>")
			Response.End()
		 End If
		 e_rnd=Cw_rnd(19)
		 e_tit=cf_name&"-邮箱验证"
		 e_con="亲爱的<b>"&session("user")&"</b><br />您的邮箱己成功修改，为了您的帐户安全及密码遗忘找回密码等，<br />请点击以下链接对您的新E-mail邮箱进行验证：<br /><a href='"&cf_host&cf_root&"user/cw_email.asp?key="&e_rnd&"&act=2' target='_blank'>"&cf_host&cf_root&"user/Cw_email.asp?key="&e_rnd&"&act=2</a>" 
		 e_email=Trim(Request("newemail"))
		 Set re=Server.CreateObject("adodb.recordset")
		 req="select * from cw_user where email='"&e_email&"'"
		 re.open req,conn,1,1
		 if not re.eof then
		   Response.Write("<script>alert('此邮箱己被其他用户绑定，请更换邮箱！');history.back();</script>")
		   Response.End()
		 end if
		 re.close
		 set re=nothing
		 Conn.Execute("Update cw_user set email='"&e_email&"',ismail=0,repass='"&e_rnd&"' where id="&session("userid"))
		 If isjmail=1 Then
			jm=Cw_jmail(cf_smtp,cf_email,cf_name,cf_jmailUser,cf_jmailPass,e_email,e_tit,e_con)
			Select Case jm
			Case 0
			  Response.Write("<script>alert('邮箱修改成功，验证邮件己发送！');location.href='cw_email.asp';</script>")
			Case 1
			  Response.Write("<script>alert('邮箱修改成功！');location.href='cw_email.asp';</script>")
			Case 2
			  Response.Write("<script>alert('邮箱修改成功！');location.href='cw_email.asp';</script>")
			End Select
		 Else
			Response.Write("<script>alert('邮箱修改成功！');location.href='cw_email.asp';</script>")
		 End if		 
	  End If
	  
	  If Request("act")=6 Then
	     Call Cw_yzm()
	     e_rnd=Cw_rnd(19)
		 e_email=Trim(Request("email"))
		 e_tit=cf_name&"-邮箱验证"
		 e_con="亲爱的<b>"&session("user")&"</b><br />您刚刚设置了邮箱地址，为了您的帐户安全及密码遗忘找回密码等，<br />请点击以下链接对您的E-mail邮箱进行验证：<br /><a href='"&cf_host&cf_root&"user/cw_email.asp?key="&e_rnd&"&act=2' target='_blank'>"&cf_host&cf_root&"user/Cw_email.asp?key="&e_rnd&"&act=2</a>"
	     Set re=Server.CreateObject("adodb.recordset")
		 req="select email from cw_user where email='"&e_email&"'"
		 re.open req,conn,1,1
		 if not re.eof then
		   Response.Write("<script>alert('此邮箱己被其他用户绑定，请更换邮箱！');history.back();</script>")
		   Response.End()
		 end if
		 re.close
		 set re=nothing
	     conn.execute("update cw_user set email='"&e_email&"' where id="&session("userid"))
		If isjmail=1 then 
		 jm=Cw_jmail(cf_smtp,cf_email,cf_name,cf_jmailUser,cf_jmailPass,e_email,e_tit,e_con)
	     Select Case jm
	     Case 0
		   conn.execute("update cw_user set repass='"&e_rnd&"' where id="&session("userid"))
	       Response.Write("<script>alert('邮箱设置成功，请尽快登录邮箱进行验证！');location.href='cw_email.asp';</script>")
	     Case 1
	       Response.Write("<script>alert('邮箱设置成功，邮箱验证邮件发送失败！');location.href='cw_email.asp';</script>")
	     Case 2
	       Response.Write("<script>alert('邮箱设置成功，邮箱验证邮件发送失败！');location.href='cw_email.asp';</script>")
	      End Select
	    Else
	       Response.Write("<script>alert('邮箱设置成功，系统自动跳转！');location.href='cw_email.asp';;</script>")
	    End If
	  End If
	  
if request("act")="" then
set rr=server.CreateObject("adodb.recordset")
rq="select * from cw_user where id="&session("userid")
rr.open rq,conn,1,1
%>
<table width="99%" border="0">
  <tr>
    <td width="100" height="20" align="right">帐号：</td>
    <td><%=rr("user")%></td>
    </tr>
  <tr>
    <td height="20" align="right">邮箱：</td>
    <td><%if isnull(rr("email")) then%>您还没有设置邮箱，<a href="cw_email.asp?act=7" style="color:#FF0000">点此去设置&gt;&gt;</a><%else%><%=rr("email")%>（<%if rr("ismail")=0 then%><font color="#FF0000">未验证</font> <a href="cw_email.asp?act=1&e=<%=rr("email")%>">发送验证邮件</a><%else%><font color="#009900">己验证</font><%end if%>）【<a href="cw_email.asp?act=3" style="color:#FF6600"><u>修改邮箱</u></a>】<%end if%></td>
  </tr>
</table>
  <%
  rr.close
  set rr=nothing
end if
%>
<%if Request("act")=7 then%>
<table width="99%" border="0">
<form id="form5" name="form5" action="cw_email.asp?act=6" method="post" onsubmit="return Check_regemail(this)">
  <tr>
    <td width="100" height="20" align="right">E-mail：</td>
    <td><input type="text" name="email" id="email" value="" />
      *请填写正确能接收邮件的邮箱，否则后期无法修改邮箱</td>
    </tr>
  <tr>
    <td height="20" align="right">再次输入：</td>
    <td><input name="email2" type="text" id="email2" /></td>
  </tr>
  <tr>
    <td height="20" align="right">验证码：</td>
    <td><input name="yzm" type="text" id="yzm" size="10" /> <img src="../inc/code.asp" width="80" height="25" alt="看不清单击刷新" onclick="this.src='../inc/code.asp?' + Math.random();" style="cursor:pointer" align="absmiddle" title="单击刷新验证码" /></td>
  </tr>
  <tr>
    <td height="20" align="right">&nbsp;</td>
    <td><input type="submit" name="sub" value="设置邮箱" /></td>
  </tr>
  </form>
</table>
<%end if%>
<%
If Request("act")=3 Then
set rr=server.CreateObject("adodb.recordset")
rq="select * from cw_user where id="&session("userid")
rr.open rq,conn,1,1
%>
<table width="99%" border="0">
<form method="post" name="form2" action="cw_email.asp?act=4" onsubmit="return Check_remail(this)">  
  <tr>
    <td height="20" align="right">原邮箱：</td>
    <td><input name="oldemail" type="text" id="oldemail" value="<%=rr("email")%>" readonly="" /></td>
  </tr>
  <tr>
    <td width="100" height="20" align="right">新邮箱：</td>
    <td><input name="newemail" type="text" id="newemail" /></td>
    </tr>
  <tr>
    <td height="20" align="right">验证码：</td>
    <td><input name="yzm" type="text" id="yzm" size="10" maxlength="6" />
      <input name="yzm2" type="button" id="yzm2" onclick="Send_yzm(this.form)" value="发送邮箱验证码" />
      *验证码发送到原邮箱中，请在3分钟内进行验证！</td>
  </tr>
  <script type="text/javascript">
  setTimeout("yzm2()",180000)
  function yzm2(){
  document.getElementById("yzm2").value='重新发送！';
  document.getElementById("yzm2").disabled=false;
  }
  </script>
  <tr>
    <td height="20" align="right">&nbsp;</td>
    <td><input type="submit" name="Submit" value="修改邮箱" /></td>
  </tr>
  </form>
</table>
<%
rr.close
set rr=nothing
End if
%>
   </div>
   <div class="clear"></div>
</div>
<div class="line"></div>
<!--#include file="foot.asp"-->
<%call closes()%>
</body>
</html>
