<!--#include file="Include/Conn.asp"-->
<!-- #include file="inc/UPIConfig.asp" -->
<!--#include file="inc/md5.asp"-->

<%
'完整调用形式：
'<script src="Interface.asp?action=操作类型&name=用户名&Md5Info=验证串&pass=密码&lock=是否锁定&question=提示问题&answer=答案&email=电子邮件&sex=性别&save=Cookies保存选项"
'action、name、Md5Info是必填参数
'删除用户时不需要其它参数
'更新资料时，提供所要更新的信息即可
'注意：这里传递的用户密码为32位MD5加密
Dim Action,useremail,username,userpassword,question,answer,babynam,babybirth


Dim PEMd5Info

UpiMd5Info = UCase(Trim(Request("Md5Info")))
Action = Trim(Request("action"))
username = Trim(Request("name"))
userpassword = Trim(Request("pass"))
If Len(userpassword) = 32 Then userpassword = Mid(userpassword,9,16)
question = Trim(Request("question"))
answer = Trim(Request("answer"))
UpiUserSex = Trim(Request("sex"))
if(UpiUserSex="1") Then
UpiUserSex="先生"
else
UpiUserSex="女士"
end if
useremail = Trim(Request("email"))

usertype = Request("usertype")
If usertype="" then
usertype=session("usertype")
End if

If Not (Action = "" or username = "" or UpiMd5Info = "") Then
	PEMd5Info = MD5(username&SecurityKey,32)
	If UpiMd5Info = UCase(PEMd5Info) Then

		Select Case Action
		Case "AddUser"
			Call AddUser()
		Case "LoginUser"
			Call LoginUser()
		Case "LogoutUser"
			Call LogoutUser()
		Case "ModifyInfo"
			Call ModifyUserInfo()
	    Case "ModifyPsw"
			Call ModifyUserPsw()
		Case "DelUser"
			Call DelUser()
		End Select
    End If
End If


Sub AddUser()
dim zhmail
 zhmail="欢迎您注册人才热线,请尽快发布您的招聘信息或求职简历以完成您的注册!"
zhmail=zhmail&"在您成功注册之后,您便能享受到本站完善的求职招聘服务,目前主要功能有："
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;1、个人在线添加求职简历"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;2、个在线上传个人相片"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;3、首页显示最新新闻信息10条"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;4、首页显示最新招聘信息8条"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;5、首页显示最新求职信息8条"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;6、注册用户可在线发送求职/招聘意向邮件"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;7、企业可发布多条招聘信息"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;8、企业自己删除招聘信息"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;9、个人/企业帐号注销"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;10、首页页尾导航采用数据库形式方便随时更改"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;11、首页所有广告及链接图片均为数据库形式更新更轻松"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;12、站内基本信息统计"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;13、在线人才新闻系统"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;14、在线政策法规发布系统"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;15、在线人事代理信息发布系统"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;16、企业营业执照图片在线上传"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;17、企业信息和招聘信息独立分开，更便于查看"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;18、院校用户注册功能（暂不提供）"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;19、培训机构注册（暂不提供）"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;20、猎头服务（暂不提供）"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;21、个业职位库"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;22、企业人才库"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;23、个人/企业站内信箱可实现站内招聘/求职"
zhmail=zhmail&"<br>&nbsp;"
zhmail=zhmail&"最后祝您在本站找到合适的工作招到合适的人才!"
zhmail=zhmail&"<br>&nbsp;"
zhmail=zhmail&"<br>&nbsp;&nbsp;&nbsp;&nbsp;P.S.(此信为系统所发,请勿回复,谢谢!)"

If usertype="" then
usertype="person"
End if

If usertype="person" then
Call personReg()
Call personLogin()
Elseif  usertype="company" then
Call companyReg()
Call companyLogin()
Else
Call personReg()
Call personLogin()
End if

End Sub '注册新用户


Sub LoginUser()

If usertype="person" then
Call personLogin()
Elseif  usertype="company" then
Call companyLogin()
Else
Call personLogin()
Call companyLogin()
End if

End Sub '会员登陆

Sub LogoutUser()
session("puid")=""
session("cuid")=""
session.Abandon
End Sub

Sub ModifyUserInfo()
Dim tempSQL
On Error Resume Next
	tempSQL = "UPDATE person Set "
	If username <> "" and Len(username) = 16 Then
		tempSQL = tempSQL & "pwd='" & userpassword & "'"
	End If
	If useremail <> "" Then
		tempSQL = tempSQL & ",email='" & useremail & "'"
	End If
	tempSQL = tempSQL & " WHERE uname='" & username & "'"
	conn.Execute(TempSQL)
	
	tempSQL = "UPDATE company Set "
	If username <> "" and Len(username) = 16 Then
		tempSQL = tempSQL & "pwd='" & userpassword & "'"
	End If
	If useremail <> "" Then
		tempSQL = tempSQL & ",email='" & useremail & "'"
	End If
	tempSQL = tempSQL & " WHERE uname='" & username & "'"
	conn.Execute(TempSQL)
End Sub

Sub ModifyUserPsw()
'If not IsObject(conn) then Link_DataBase
'if usertype="person" then
    set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from person where uname='"&username&"'",conn,1,3
	if not rs.eof and not rs.bof then
		rs("pwd")=userpassword
		rs.update
		rs.close
		set rs=nothing
     end if
        rs.close
		set rs=nothing
'elseif usertype="company" then
	set rs=server.CreateObject("adodb.recordset")
	rs.open "select * from company where uname='"&username&"'",conn,1,3
	  if not rs.eof and not rs.bof then
		rs("pwd")=userpassword
		rs.update
		rs.close
		set rs=nothing
     end if
'end if
End Sub 


Sub DelUser()
conn.execute("delete * from person where uname='"&username&"'")
conn.execute("delete * from company where uname='"&username&"'")
End Sub
''''--------------个人注册---------------------------
Sub personReg()
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from person"
rs.open sql,conn,1,3
rs.addnew
rs("uname")=username
rs("pwd")=userpassword
rs("email")=useremail
rs.update
rs.close

sql="select * from pmailbox"
rs.open sql,conn,1,3
rs.addnew
rs("reid")=username
rs("senduid")="sysop"
rs("title")="恭喜您注册成功！"
rs("sendname")="系统管理员"
rs("sdate")=now()
rs("mailtext")=zhmail
rs.update
rs.close
session("puid")=username
End sub
''''--------------个人注册---------------------------
''''--------------企业注册---------------------------
Sub companyReg()
set rs=server.createobject("adodb.recordset")
sql="select * from company"
rs.open sql,conn,1,3
rs.addnew
rs("uname")=username
rs("pwd")=userpassword
rs("email")=useremail
rs.update
rs.close
set rs=nothing
End Sub
'''--------------企业注册---------------------------
'''--------------个人登陆---------------------------
Sub personLogin()
   set rs=server.createobject("adodb.recordset")
   sql="select * from person where uname='"&username&"' and pwd='"&userpassword&"'"
   rs.open sql,conn,1,1
   if not rs.bof or not rs.eof then
   session("puid")=username
   session("usertype")="person"
   End if
End Sub
 ''--------------个人登陆---------------------------
 '''--------------企业登陆---------------------------
Sub companyLogin()
   set rs=server.createobject("adodb.recordset")
   sql="select * from company where uname='"&username&"' and pwd='"&userpassword&"'"
   rs.open sql,conn,1,1
   if not rs.bof or not rs.eof then
   session("cuid")=username
   session("usertype")="company"
   End if
End Sub
 ''--------------企业登陆---------------------------
 
%>