<!--#INCLUDE FILE="conn.asp" -->
<!--#include file="Class_Checkuser.asp"-->
<!--#include file="Class_Top.asp"-->
<!--#include file="inc/Md5.asp"-->
<!--#include file="inc/UpiConfig.asp"--><%'-----恒浪整合文件---%>
<%
Dim Locat,Act
Locat="同学录登陆"

Dim RemoveUser
if Request("action")="logout" Then
	response.cookies("fenglingtxl_520")("username")=""
	response.cookies("fenglingtxl_520")("password")=""
	response.cookies("fenglingtxl_520")("visitedclasses")=""
	response.cookies("fenglingtxl_520")("logintime")=""
	Response.Cookies("fenglingtxl_520")("usercookies")=""
	RemoveUser="delete from online where userid='"&membername&"'"
	Conn.Execute RemoveUser
	
    '//==恒浪整合退出开始==By Howave.Net & SeaShell 2007/06/08==
	  Call Howave_Logout()	
    '//==恒浪整合退出结束====
	response.redirect "main.asp"
	'Server.Transfer "main.asp"
ElseIf Request("action")="CheckLogin" Then

	%>
	<!--#include file="inc/validate.asp"-->
	<%
	Call chklogin()
Else
	Call top(1,1)
	Call loginform()
End if

Sub loginform()
%>
<BR><form action="Class_Login.asp" method="post"> 
<input type=hidden name=action value=CheckLogin>
<table cellpadding=0 cellspacing=0 border=0 width=700 Class=TableBorder align=center>
    <tr>    
        <td>
        <table cellpadding=5 cellspacing=1 border=0 width=100%>
    <tr >
    <th colspan=2 align=center>
    <b>同学录登陆</b></th></tr>
    <tr Class=LightTableBody>
            <td>
              <div align="right">请输入您的用户名：</div></td>
    <td><INPUT name=username type=text value="<%if Request("name")<>"" Then Response.Write  Request("name") Else 'Response.Write htmlencode(Request.cookies("txl")("username"))%>" maxlength=12> &nbsp; <a href="Class_Register.asp">没有注册？</a></td></tr>
    <tr Class=LightTableBody>
            <td>
              <div align="right">请输入您的密码：</div></td>
    <td><INPUT name=password type=password maxlength=12> &nbsp; <a href="Class_GetPasswd.asp" style="cursor:help">忘记密码？</a></td></tr>
	<tr Class=LightTableBody>
            <td>
              <div align="right">请选择登陆设置：</div></td>
    <td><SELECT name=CookieDate>
                          <option value="0">- 不 保 存 -</option>
                          <option value="1">保 存 一 天</option>
                          <option value="2">保 存 一 月</option>
                          <option value="3">保 存 一 年</option>
                        </SELECT></td></tr>
	<input type=hidden name=comeurl value="<%=Request.ServerVariables("HTTP_REFERER")%>">
    <tr Class=DarkTableBody>
    <td colspan=2 align=center><input type=submit name="submit" value="登陆(L)" accesskey="l" class=button style="width:70px"></td></tr></table></td></tr></table>
</form>
<%End Sub


Sub chklogin()

	Dim DefaultURL,Rtitle,Rmsg
	Dim userid,userpwd
	Dim ErrMsg,FoundErr
	Dim chkstat
	Dim LoginSQL
	Dim lastip
	Dim tmprs
	Dim usercookies,mypassword,comeurl

	userid=trim(Request.form("username"))
	userpwd=trim(Request.form("password"))
	usercookies=trim(request.form("CookieDate"))
	comeurl=trim(request.form("comeurl"))

	if userid="" Then
		ErrMsg=ErrMsg+"<br>"+"<li>请输入您的用户名！！"
		FoundErr=True
	ElseIf isValidstring(userid)<>"" Then
		ErrMsg=ErrMsg+"<br>"+"<li>您输入的用户名非法！！"
		FoundErr=True
	End if

	if FoundErr=True Then
		Call top(1,1)
		Call Error("Information",ErrMsg)
		Exit Sub
	End if
    mypassword=userpwd
	userpwd=md5(userpwd)

	chkstat=chkuserlogin(userid,userpwd,false)
	if chkstat<>"" Then
		Call top(1,1)
		Call Error("Information",chkstat)
		Exit Sub
	End if
	
	
	Set tmprs =Conn.Execute("Select userpwd,locked,userid from student where userid='"&userid&"'")
    if tmprs.EOF and tmprs.bof Then
	Set tmprs =Conn.Execute("Select userpwd,locked,userid from student where realname='"&userid&"'")
	end if
	userid=tmprs(2)
	Set tmprs=Nothing

	lastip = Request.ServerVariables("REMOTE_ADDR")

	LoginSQL="update student Set point=point+"&PointSet(1)&",visitcount=visitcount+1,lastlogin=now(),lastip='"&lastip&"' where userid='"&userid&"'"
	conn.execute(LoginSQL)
	If isnull(usercookies) or usercookies="" Then usercookies="0"
	select case usercookies
	case "0"
		Response.Cookies("fenglingtxl_520")("usercookies") = usercookies
	case 1
   		Response.Cookies("fenglingtxl_520").Expires=Date+1
		Response.Cookies("fenglingtxl_520")("usercookies") = usercookies
	case 2
		Response.Cookies("fenglingtxl_520").Expires=Date+31
		Response.Cookies("fenglingtxl_520")("usercookies") = usercookies
	case 3
		Response.Cookies("fenglingtxl_520").Expires=Date+365
		Response.Cookies("fenglingtxl_520")("usercookies") = usercookies
	end select
	response.cookies("fenglingtxl_520")("username")=userid
	response.cookies("fenglingtxl_520")("password")=userpwd
	response.cookies("fenglingtxl_520")("logintime")=now()
	
	'//==恒浪整合登录开始==By Howave.Net & SeaShell 2007/06/08==
		Dim H_ComeUrl
		H_ComeUrl=Request.ServerVariables("HTTP_REFERER")
		H_ComeUrl=Replace(Lcase(H_ComeUrl),"class_login.asp","")
		Howave_Login userid,MyPassword,"0",H_ComeUrl
    '//==恒浪整合登录结束====
	
	
	if instr(Request("comeurl"),"Class_Register.asp")>0 or instr(Request("comeurl"),"Class_Login.asp")>0 or trim(Request("comeurl"))="" or  instr(Request("comeurl"),"Class_GetPasswd.asp")>0 Then
		DefaultURL="main.asp"
		Rmsg="<BR><ul><li><a href="&DefaultURL&">返回同学录首页面</a></li></ul>"
	Else
		DefaultURL=Request("comeurl")
		Rmsg="<BR><ul><li><a href=main.asp>返回同学录首页面</a></li>"&_
		"<li><a href="&DefaultURL&">"&DefaultURL&"</a></li></ul>"
	End if

''''''''''''''''''''''''''''''''''
    Rmsg=Rmsg+"<ul><li><font color=red>请选择您要进入的班级</font></li>"
	tmpsql="Select C.classid,C.classname from class C inner join joinclass J on C.classid=J.classid "&_
	"where J.userid='"&userid&"'  and J.isauditing=False order by C.classname"
	Set tmprs=Conn.Execute(tmpsql)
	if tmprs.eof Then
	Rmsg=Rmsg+"<BR><BR><li><font color=red>您尚未加入任何班级</font></li>"
	Else
		do until tmprs.eof
			Rmsg=Rmsg+"<BR><BR><li><a href=Class_index.asp?ClassID="&tmprs(0)&">"&htmlencode(tmprs(1))&"</a></li>"
			tmprs.movenext
		loop		
	End if
  set tmprs=nothing
  Rmsg=Rmsg+"</ul>"
'''''''''''''''''''''''''''''''''''''
	Rtitle="登陆同学录成功"
	Call top(1,1)
	if BoolVar(1) Then	Response.Write "<bgsound src=""sound/logon.wav"" border=0>"
	Redirect 5,DefaultURL,Rtitle,Rmsg

End Sub


Call footer()
%>
