<!--#include file="Conn.asp" -->
<!--#include file="Comm/Site_Class.asp" -->
<!--#include file="Comm/md5.asp" -->
<%
Dim strMenu,Rs,PageTitle,j
strMenu = ""

Set Qsite = New Site_Class

Qsite.SiteConfig()
Qsite.GotoErrPage()

PageTitle = Qsite.SiteName & " - 取回密码页面"

If Not instr(1,Request.ServerVariables("http_Referer"),Request.ServerVariables ("SERVER_NAME"),1)=8 Then
	Qsite.ShowMsg "请不要非法提交数据" , "Index.asp"
End If

Set Rs = server.createobject("ADODB.Recordset")

If Request.Form <> "" Then

	Dim UserName,UserType,Email,PassWord
	Dim FromIp,TodayDate
	Dim strFromPage
	
	TodayDate = Qsite.FormatDate(Date())
	
	UserName = LCase(Qsite.chgStr(Trim(Request.Form("UserName"))))
	PassWord = LCase(Qsite.chgStr(Trim(Request.Form("PassWord"))))
	Email = LCase(Qsite.chgStr(Trim(Request.Form("Email"))))
	UserType = Qsite.chgStr(Trim(Request.Form("UserType")))
	strFromPage = Qsite.chgStr(Trim(Request.Form("strFromPage")))
	
	If UserName = "" Or IsNull(UserName) Or Email = "" Or IsNull(Email) Then
		Response.Redirect("Login.asp?msg=用户名或!邮箱错误")
		Response.End()
	End If
	If UserType <> "Company" And UserType <> "Person" Then
		Qsite.ShowMsg "请选择用户类型" , ""
	End If
	

	If UserType = "Person" Then	'个人登录
		Rs.Open "select * from PersonTbl where UserName = '"& UserName &"'" , Conn , 3 , 2
		If Rs.Eof Or Rs.Bof Then
			Session("PerId") = ""
			Session("UserName") = ""
			Session("Email") = ""
			Session("UserType") = ""
			Session("MemberType") = 0
			Qsite.ShowMsg "用户名或邮箱错误，请返回重新输入" , ""
		Else
		   Session("PerId") = Rs("PerId")
		   Session("UserName") = Rs("UserName")
		   Password=Int(899999*Rnd() +100000)
		   rs("Password")=MD5(PassWord)
		   Session("Password") = Password
		   Session("Email") = Rs("Email")
		   Session("RealName") = Rs("RealName")
		   Session("UserType") = "Person"
		   Session("MemberType") = 0
		   Rs.Update
		End If
				If InStr(strFromPage , "Person_View.asp") > 0 Or InStr(strFromPage , "Company_View.asp") > 0 Or InStr(strFromPage , "Company_Job.asp") > 0 Then
					Response.Redirect(strFromPage)
				Else
					Response.Redirect("FindPassword3.asp")
				End If
		Rs.Close
	ElseIf UserType = "Company" Then	'企业登录
		Rs.Open "select * from CompanyTbl where UserName = '"& UserName &"'" , Conn , 3 , 2
		If Rs.Eof Or Rs.Bof Then
			Session("ComId") = ""
			Session("UserName") = ""
			Session("Email") = ""
			Session("UserType") = ""
			Session("MemberType") = ""
			Qsite.ShowMsg "用户名或密码错误，请返回重新输入" , ""
		Else
		    Session("ComId") = Rs("ComId")
			Session("UserName") = Rs("UserName")
		    Password=Int(899999*Rnd() +100000)
		    rs("Password")=MD5(PassWord)
		    Session("Password") = Password
			Session("RealName") = Rs("CompanyName")
		    Session("Email") = Rs("Email")
		    Session("UserType") = "Company"
		    Session("thisMemberType") = Rs("MemberType")
		End If
				
				If InStr(strFromPage , "Person_View.asp") > 0 Or InStr(strFromPage , "Company_View.asp") > 0 Or InStr(strFromPage , "Company_Job.asp") > 0 Then
					Response.Redirect(strFromPage)
				Else
					Response.Redirect("FindPassword3.asp")
				End If
		Rs.Close
	
	Else
		Qsite.ShowMsg "用户类型不正确" , ""
	End If
	
End If
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title><%=PageTitle%> - 胶州人才网</title>
 <meta name="keywords" content="关于胶州人才网站,胶州招聘网站,胶州人力资源,胶州人才市场,胶州找工作,胶州兼职,胶州培训,胶州职业顾问,胶州职业规划,胶州人事代理">
 <meta name="description" content="胶州人才网是胶州地区内最具影响力的人才网站之一，为企业提供一站式的人才招聘服务，帮助个人求职者与企业搭建最佳互动平台，打造胶州地区权威求职招聘网站!！">
<!--#include file="top.asp" -->
<script language="javascript">
	function CheckLogin()
	{
		if(FindForm.UserName.value == "")
		{
			alert("请输入用户名");
			FindForm.UserName.focus();
			return false;
		}
		if(FindForm.UserType[0].checked == false && FindForm.UserType[1].checked == false)
		{
			alert("请选择用户类型");
			return false;
		}
		if(FindForm.Email.value == "")
		{
			alert("请输入电子信箱");
			return false;
		}
		return true;
	}
</script>


    <table width="860" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr> 
        <td height="58" background="images/getPass_r2_c2.jpg">&nbsp;</td>
      </tr>
      <tr> 
        <td height="326" valign="top" background="images/getPass_r4_c3.jpg"  align=center> 
          <table width="800" height="41" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr> 
              <td width="90" height="41" align="center"><font color="#666666"><strong>找回密码</strong></font></td>
              <td width="710"> <table width="100%" height="1" border="0" cellpadding="0" cellspacing="0">
                  <tr height="1"> 
                    <td background="../images/ico_point.gif"></td>
                  </tr>
                </table></td>
            </tr>
          </table>
 
<BR><BR><BR><BR><BR>
<p style="font-size: 15px;font-weight: bold;color:#ff0000;">

<%
On error resume next
Dim JMail, contentId
Set JMail = Server.CreateObject("JMail.Message") 
JMail.Charset = "gb2312" ' 邮件字符集，默认为"US-ASCII"
' JMail.ISOEncodeHeaders = False ' 是否进行ISO编码，默认为True

' 发送者信息（可用变量方式赋值）
JMail.From = ""&Qsite.MailUserName&"" ' 发送者地址
JMail.FromName = "胶州人才网" ' 发送者姓名
JMail.Subject = ""&Session("RealName")&"的最新登陆密码" ' 邮件主题

' 身份验证
JMail.MailServerUserName = ""&Qsite.MailUserName&"" ' 身份验证的用户名
JMail.MailServerPassword = ""&Qsite.MailPassWord&"" ' 身份验证的密码

' 设置优先级，范围从1到5，越大的优先级越高，3为普通
JMail.Priority = 3

JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")

' 加入一个收件人【变量email：收件人地址】可以同一语句重复加入多个
JMail.AddRecipient(""&Session("Email")&"")

' 加入附件【变量filename：附件文件的绝对地址，确保用户IUSR_机器名有访问的权限】
' 【参数设置是(True)否(False)为Inline方式】
'contentId = JMail.AddAttachment (Server.MapPath("jmail.asp"), True)

' 邮件主体（HTML(注意信件内链接附件的方式)）
JMail.HTMLBody = "<html><head><META content=zh-cn http-equiv=Content-Language><meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312""><style type=text/css>A:link { FONT-SIZE: 9pt; TEXT-DECORATION: none; color: #000000}A:visited {FONT-SIZE: 9pt; TEXT-DECORATION: none; color: #666666}A:hover {COLOR: #ff6600; FONT-SIZE: 9pt; TEXT-DECORATION: underline}BODY {FONT-SIZE: 9pt} --></style></head><body><font color=red>用户名："&Session("UserName")&"</font><br><font color=green>密码是："&Session("Password")&"</font><br><br><b>请尽快登录及时更改为你容易记的密码！</b></body></html>"

' 邮件主体（文本部分）
JMail.Body = "我们的邮件采用了HTML格式，但是您的邮件查看软件可能不支持。。。"&Session("UserName")&" 你的新密码是:"&Session("Password")&",请尽快登录及时更改为你容易牢记的密码！"

' 发送【调用格式：objJMail.Send([username:password@]SMTPServerAddress[:Port])】
JMail.Send(""&Qsite.MailSmtp&"")

' 关闭并清除对象
JMail.Close()
Set JMail = Nothing

if err.number<>0 then
response.write "密码发送失败！"
else
response.write "密码已成功发送到你的邮箱！"
end if
%>	<table width="800" height="130" border="0" align="center" cellpadding="0" cellspacing="0">
<TR><TD height=100>&nbsp;</td></tr>
            <tr height="30"> 
              <td background="../images/ico_point.gif"></td>
            </tr>
 
          </table></td>
      </tr>
      <tr> 
        <td height="14" background="images/getPass_r4_c2.jpg"><img src="space.gif" height="1"></td>
      </tr>
    </table>
    <table width="990" height="8" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr height="8"> 
        <td height="8"></td>
      </tr>
    </table>
  <!--#include file="foot.asp" -->
