<!--#INCLUDE FILE="setup.asp" -->
<!--#include file="checkuser.asp"-->
<!--#include file="include/encrypt.asp"-->
<%
select case Request("Action")
case "chkLogin"
	Call chklogin()
case "logout"
	Call logout()
case Else
	Call main()
End select

Call endconnection()


Sub chklogin()

	dim username,userpwd
	dim ip,Adminsql,AdminRs

	username=trim(Request.form("adminname"))
	userpwd=trim(Request.form("adminpwd"))
	if membername="" then
		'Errmsg=Errmsg+"<br>"+"<li>您还没有在前台登陆。"
		'Call disperrs(ErrMsg)
	elseif username="" or userpwd="" Then
		'Errmsg=Errmsg+"<br>"+"<li>请输入您的用户名或密码。"
		'Call disperrs(ErrMsg)
	else
		username=replace(username,"'","")
		userpwd=md5(userpwd)
		Adminsql="select A.userid,A.userpwd from admin A inner join student S on A.adminid=S.studid where A.userid='"&username&"' and A.userpwd='"&userpwd&"' and S.userid='"&membername&"' and S.locked>1"
		set AdminRs=conn.execute(Adminsql)
		if AdminRs.eof and AdminRs.bof Then
			Errmsg=Errmsg+"<br>"+"<li>您输入的用户名和密码不正确或者您不是系统管理员。<br>"&_
				"<li>请<a href=sysadm_login.asp target=_top>重新登录</a>。"
			Call disperrs(ErrMsg)
		else
			ip=Request.ServerVariables("REMOTE_ADDR")
			conn.execute("update admin set lastlogin=now(),ip='"&ip&"' where userid='"&username&"'")
			session("adminlogin")="0K"
			session.timeout=20
			server.transfer "Superindex.asp"
		end if
		Set AdminRs=Nothing
	end if

End Sub


Sub logout()
	session("adminlogin")=""
	server.transfer "../manage/Admin_logout.asp"
End Sub


Sub main()%>

<title><%=StrVar(1)%>--管理页面</title>
<link href="css.asp" rel="stylesheet" type="text/css">
<!--#include file=theme.css-->
<body alink=#333333 vlink=#333333 link=#333333 topmargin=0>
<BR><BR>
<form action="SysAdm_Login.asp" method="post"> 
<input type=hidden name=Action value=chkLogin>
<table cellpadding=0 cellspacing=0 border=0 width=600 Class=TableBorder align=center>
<tr>    
	<td>
		<table cellpadding=5 cellspacing=1 border=0 width=100%>
	    <tr>
			<th valign=middle colspan=2 align=center><b>系统管理员登陆</b></th>
		</tr>
	    <tr Class=LightTableBody>
			<td valign=middle align=center>管理员帐号</font></td>
		    <td valign=middle>&nbsp;&nbsp;<INPUT name=adminname type=text maxlength=12></td>
		</tr>
	    <tr Class=LightTableBody>
			<td valign=middle  align=center>管理员密码</font></td>
		    <td valign=middle>&nbsp;&nbsp;<INPUT name=adminpwd type=password maxlength=12 autocomplete=off></td>
		</tr>
	    <tr>
			<td Class=DarkTableBody valign=middle colspan=2 align=center>
			<input type=submit name="submit" value="登 陆" class=button style="width:75px"></td>
		</tr>
		</table>
	</td>
</tr>
</table>
</form>

<%End Sub


Sub disperrs(errormsg)
%>
<html><head>
<title><%=StrVar(1)%>——错误提示</title>
<link href="css.asp" rel="stylesheet" type="text/css">
<!--#include file=theme.css-->
<body alink=#333333 vlink=#333333 link=#333333 topmargin=0>
<br><br>
    <table cellpadding=0 cellspacing=0 border=0 width=90% Class=TableBorder align=center>
        <tr>
            <td>
                <table cellpadding=5 cellspacing=1 border=0 width=100%>
    <tr align="center"> 
      <th width="100%"><b>同学录错误信息</b></th>
    </tr>
    <tr> 
      <td width="100%" Class=LightTableBody><br><b>产生错误的可能原因：</b><br><br>
<li>您是否仔细阅读了<a href=help.asp>帮助文件</a>
<%=errormsg%><br><br>
      </td>
    </tr>
    <tr align="center"> 
      <td width="100%" Class=DarkTableBody>
<a href="javascript:history.go(-1)"><< 返回上一页</a>
      </td>
    </tr>  
    </table>   </td></tr></table>
<%
End Sub

%>
