<%

Dim membername,memberpwd
'Dim userno

membername=replace(Request.cookies("fytxl")("fystud"),"'","")
memberpwd=replace(Request.cookies("fytxl")("fypasswd"),"'","")

Dim SysAdmin,AdmSQL,AdmRs
SysAdmin=False

if membername<>"" Then
	if chkuserlogin(membername,memberpwd)<>"" Then
		response.cookies("fytxl")("fystud")=""
		response.cookies("fytxl")("fypasswd")=""
		response.cookies("fytxl")("visitedclasses")=""
		response.cookies("fytxl")("logintime")=""
		membername=""
	Else
		AdmSQL="select A.* from admin A inner join student S "&_
		"on A.adminid=S.studid where S.userid='"&membername&"' and S.locked>1"
		Set AdmRs=Conn.Execute(AdmSQL)
		if Not (AdmRs.eof and AdmRs.bof) Then
			SysAdmin=True
		End if
		set AdmRs=nothing
	End if
End if


Function chkjoinclass(byval myClassID)

	Dim ClassRs,JoinRs
	Dim ErrMsg,FoundErr
	chkjoinclass=""

	if not isNumeric(myClassID) Then
		ErrMsg=ErrMsg+"<br>"+"<li>操作失败，您没有选择加入的班级！"
		chkjoinclass=ErrMsg
		Exit Function
	End if

	myClassID=Clng(myClassID)

	Set ClassRs=Conn.Execute("select classname from class where classid="&myClassID)
	if ClassRs.eof and ClassRs.bof Then
		ErrMsg=ErrMsg+"<br>"+"<li>操作失败！您要访问的班级不存在或已被删除。"
		chkjoinclass=ErrMsg
		Exit Function
	Else
		ClassName=ClassRs(0)
	End if
	Set ClassRs=Nothing


	Set JoinRs=Conn.Execute("Select isauditing,degree from joinclass where userid='"&membername&"' and classid="&myClassID)
	if JoinRs.eof and JoinRs.bof Then
		if sysadmin Then
			Degree=9
		Else
			ErrMsg=ErrMsg+"<br>"+"<li>对不起，您还没有加入这个班级！"
			FoundErr=True
		End if
	Else
		if JoinRs(0)=True Then
			ErrMsg=ErrMsg+"<br>"+"<li>操作失败！您还没有通过班级管理员的审核。"
			FoundErr=True
		Else
			Degree=JoinRs(1)
		End if
	End if
	Set JoinRs=Nothing


	if FoundErr Then
		chkjoinclass=ErrMsg
	Else
		chkjoinclass=""
	End if

End Function



Function ChkRights(MgrItem)

	Dim Rights
	Cmt=Degree

	if sysadmin or Degree>6 Then 
		ChkRights=True
	ElseIf Cmt=1 Then
		ChkRights=False
	Else
		Set Rights=Conn.Execute("Select rights from class where classid="&ClsID)
		if mid(Rights(0),(6-Cmt)*7+MgrItem,1)="1" Then
			ChkRights=True
		Else
			ChkRights=False
		End if
		Set Rights=Nothing
	End if

End Function


Function chkUserLogin(byval txluser,byval txlpwd)

	Dim tmprs
	Dim founderr,errormsg

	chkuserlogin=""

	Set tmprs =Conn.Execute("Select userpwd,locked from student where userid='"&txluser&"'")

	if tmprs.EOF and tmprs.bof Then
		Errormsg=Errormsg+"<br>"+"<li>对不起，您还没有<a href=register.asp>注册</a>！"
		founderr=True
	ElseIf txlpwd<>tmprs(0) Then
		Errormsg=Errormsg+"<br>"+"<li>密码错误！请重新<a href=login.asp>登陆</a>！！"
		founderr=True
	ElseIf tmprs(1)=1 Then
		Errormsg=Errormsg+"<br>"+"<li>对不起，您的同学录帐号已被锁定，若有任何问题，请与<a href=mailto:"&StrVar(2)&">系统管理员联系</a>！"
		founderr=True
	End if

	Set tmprs=Nothing

	if founderr=True Then
		chkuserlogin=errormsg
	End if

End Function

%>

