<!--#INCLUDE FILE="conn.asp" -->
<!--#include file="admin_Checkuser.asp"-->
<!--#include file="inc/md5.asp"-->
<style type=text/css>
body { background:#CAD7F7; font-size: 12px; margin-top:0px;
SCROLLBAR-FACE-COLOR: #799AE1; SCROLLBAR-HIGHLIGHT-COLOR: #799AE1; 
SCROLLBAR-SHADOW-COLOR: #799AE1; SCROLLBAR-DARKSHADOW-COLOR: #799AE1; 
SCROLLBAR-3DLIGHT-COLOR: #799AE1; SCROLLBAR-ARROW-COLOR: #FFFFFF;
SCROLLBAR-TRACK-COLOR: #AABFEC;
}
TD {
	FONT-SIZE: 12px
}
INPUT {
	BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 12px; BORDER-BOTTOM-WIDTH: 1px; BORDER-RIGHT-WIDTH: 1px
}
TEXTAREA {
	BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 12px; BORDER-BOTTOM-WIDTH: 1px; BORDER-RIGHT-WIDTH: 1px
}
SELECT {
	BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 12px; BORDER-BOTTOM-WIDTH: 1px; BORDER-RIGHT-WIDTH: 1px
}
SPAN {
	FONT-SIZE: 12px; POSITION: static
}
A:link {
	COLOR: #000000; TEXT-DECORATION: none
}
A:visited {
	COLOR: #000000; TEXT-DECORATION: none
}
a:hover  { color:#428EFF;text-decoration:underline; }
A.highlight:link {
	COLOR: red; TEXT-DECORATION: none
}
A.highlight:visited {
	COLOR: red; TEXT-DECORATION: none
}
A.highlight:hover {
	COLOR: red
}
A.thisclass:link {
	FONT-WEIGHT: bold; TEXT-DECORATION: none
}
A.thisclass:visited {
	FONT-WEIGHT: bold; TEXT-DECORATION: none
}
A.thisclass:hover {
	FONT-WEIGHT: bold
}
A.navlink:link {
	COLOR: #000000; TEXT-DECORATION: none
}
A.navlink:visited {
	COLOR: #000000; TEXT-DECORATION: none
}
A.navlink:hover {
	COLOR: #003399; TEXT-DECORATION: none
}
.twidth {
	WIDTH: 760px
}
.content {
	FONT-SIZE: 14px; MARGIN: 5px 20px; LINE-HEIGHT: 140%; FONT-FAMILY: Tahoma,宋体
}
.aTitle {
	FONT-WEIGHT: bold; FONT-SIZE: 15px
}
TD.forumHeaderBackgroundAlternate {
	BACKGROUND-IMAGE: url(images/manage/admin_top_bg.gif); COLOR: #000000; BACKGROUND-COLOR: #799ae1
}
#TableTitleLink A:link {
	COLOR: #ffffff; TEXT-DECORATION: none
}
#TableTitleLink A:visited {
	COLOR: #ffffff; TEXT-DECORATION: none
}
#TableTitleLink A:active {
	COLOR: #ffffff; TEXT-DECORATION: none
}
#TableTitleLink A:hover {
	COLOR: #ffffff; TEXT-DECORATION: underline
}
TD.forumRow {
	PADDING-RIGHT: 3px; PADDING-LEFT: 3px; BACKGROUND: #F1F3F5; PADDING-BOTTOM: 3px; PADDING-TOP: 3px
}
TH {
	FONT-WEIGHT: bold; FONT-SIZE: 12px; BACKGROUND-IMAGE: url(images/manage/admin_bg_1.gif); COLOR: white; BACKGROUND-COLOR: #4455aa
}
TD.bodytitle {
	BACKGROUND-IMAGE: url(images/manage/admin_bg_2.gif)
}
TD.bodytitle1 {
	BACKGROUND-IMAGE: url(images/manage/admin_bg_3.gif)
}
TD.tablebody1 {
	PADDING-RIGHT: 3px; PADDING-LEFT: 3px; BACKGROUND: #bebbdb; PADDING-BOTTOM: 3px; PADDING-TOP: 3px
}
TD.forumRowHighlight {
	PADDING-RIGHT: 3px; PADDING-LEFT: 3px; BACKGROUND: #E4EDF9; PADDING-BOTTOM: 3px; PADDING-TOP: 3px
}
.tableBorder {
	BORDER-RIGHT: #183789 1px solid; BORDER-TOP: #183789 1px solid; BORDER-LEFT: #183789 1px solid; WIDTH: 98%; BORDER-BOTTOM: #183789 1px solid; BACKGROUND-COLOR: #ffffff
}
.tableBorder1 {WIDTH: 98%; }
.helplink {
	FONT: 10px verdana,arial,helvetica,sans-serif; CURSOR: help; TEXT-DECORATION: none
}
.copyright {
	PADDING-RIGHT: 1px; BORDER-TOP: #6595d6 1px dashed; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; FONT: 11px verdana,arial,helvetica,sans-serif; COLOR: #4455aa; PADDING-TOP: 1px; TEXT-DECORATION: none
}
</style>
<%
select case Request("Action")
case "chkLogin"
	Call chklogin()
case "txllogin"
    call txllogin()
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)
	ElseIf isValidstring(username)<>"" Then
		ErrMsg=ErrMsg+"<br>"+"<li>您输入的用户名非法！</a>！"
		Call disperrs(ErrMsg)
	elseif request("verifycode")="" then
		Errmsg=Errmsg+"<br>"+"<li>请返回输入确认码。<br><br><li><b>返回后请刷新登录页面后重新输入正确的信息。</b>"
		Call disperrs(ErrMsg)
	elseif session("getcode")="9999" then
		session("getcode")=""
	elseif session("getcode")="" then
	    Errmsg=Errmsg+"<br>"+"<li>请不要重复提交，如需重新登录请返回登录页面。<br><br><li><b>返回后请刷新登录页面后重新输入正确的信息。</b>"
		Call disperrs(ErrMsg)
	elseif cstr(session("getcode"))<>cstr(trim(request("verifycode"))) then
	Errmsg=Errmsg+"<br>"+"<li>您输入的确认码和系统产生的不一致，请重新输入。<br><br><li><b>返回后请刷新登录页面后重新输入正确的信息。</b>"
		Call disperrs(ErrMsg)
	else
	    session("getcode")=""
		username=replace(username,"'","")
		userpwd=md5(userpwd)
		Adminsql="select A.username,A.[password] from admin A inner join student S on A.managerid=S.studid where A.username='"&username&"' and A.[password]='"&userpwd&"' and S.userid='"&membername&"'"
		set AdminRs=conn.execute(Adminsql)
		if AdminRs.eof and AdminRs.bof Then
			Errmsg=Errmsg+"<br>"+"<li>您输入的用户名和密码不正确或者您不是系统管理员。<br><br>"&_
				"<li>请<a href=admin_logon.asp target=_top>重新登录</a>。"
			Call disperrs(ErrMsg)
		else
			ip=Request.ServerVariables("REMOTE_ADDR")
			conn.execute("update admin set lastlogin=getdate(),ip='"&ip&"' where username='"&username&"'")
			session("adminlogin")="0K"
			session.timeout=20
			server.transfer "admin_index.asp"
		end if
		Set AdminRs=Nothing
	end if

End Sub


Sub logout()
	session("adminlogin")=""
	'server.transfer "../main.asp"
	response.redirect "../main.asp"
End Sub

sub txllogin()

	Dim userid,userpwd
	Dim ErrMsg,FoundErr
	Dim chkstat
	Dim LoginSQL
	Dim lastip
	Dim tmprs

	userid=trim(Request.form("username"))
	userpwd=trim(Request.form("password"))

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

	if FoundErr=True Then
		Call disperrs(ErrMsg)
		Exit Sub
	End if

	userpwd=md5(userpwd)

	chkstat=chkuserlogin(userid,userpwd)
	if chkstat<>"" Then
		Call disperrs(chkstat)
		Exit Sub
	End if
	
	LoginSQL="select A.* from admin A inner join student S on A.managerid=S.studid where S.userid='"&userid&"'"

	Set tmprs=Conn.Execute(LoginSQL)
	if tmprs.eof and tmprs.bof Then
	ErrMsg=ErrMsg+"<br>"+"<li>您不是管理员，请不要尝试非法登陆！</a>！"
	Call disperrs(ErrMsg)
		Exit Sub
	end if
	Set tmprs=Nothing

	lastip = Request.ServerVariables("REMOTE_ADDR")

	LoginSQL="update student Set point=point+"&PointSet(1)&",visitcount=visitcount+1,lastlogin=getdate(),lastip='"&lastip&"' where userid='"&userid&"'"
	conn.execute(LoginSQL)
	session("txl_Admin_name")=userid
	
	response.redirect "Admin_Logon.asp"
	end sub
	
Function chkUserLogin(byval txluser,byval txlpwd)

	Dim tmprs
	Dim founderr,errormsg

	chkuserlogin=""

	Set tmprs =Conn.Execute("Select userpwd,locked,userid from student where userid='"&txluser&"'")
	if tmprs.EOF and tmprs.bof Then
		Errormsg=Errormsg+"<br>"+"<li>对不起，您输入的用户名还没有<a href=../Class_Register.asp>注册</a>！！"
		founderr=True
	ElseIf txlpwd<>tmprs(0) Then
		Errormsg=Errormsg+"<br>"+"<li>密码错误！请重新<a href=../Class_Login.asp>登陆</a>！！"
		founderr=True
	ElseIf tmprs(1)=1 Then
		Errormsg=Errormsg+"<br>"+"<li>对不起，您的帐号已被锁定，若有任何问题，请与<a href=mailto:"&StrVar(2)&" title=""QQ:"&StrVar(9)&""">系统管理员联系</a>！"
		founderr=True
	End if
	Set tmprs=Nothing

	if founderr=True Then
		chkuserlogin=errormsg
	End if

End Function
Sub main()
Dim Ados,GetCode
Set Ados=Server.CreateObject("Adodb.Stream")
If Err Then
	GetCode=9999
End If
%>
<title><%=StrVar(1)%>--管理页面</title>
<BR><BR><BR><BR><BR><BR>
<%if membername="" then %>
<form action="Admin_Logon.asp" method="post"> 
<input type=hidden name=action value=txllogin>
  <table width="415" border="0" align=center cellpadding="1" cellspacing="0" style="border: outset 3px;width:0;">
    <tr>    
        <td>
         <table style="width:412" border=0 cellspacing=0 cellpadding=3 align=center>
          <tr >
    <th colspan=2 align=center class=forumRowHighlight>
    <b>校友录登陆</b></th></tr>
          <tr bgcolor="#f1f3f5" class=forumRowHighlight> 
            <td>&nbsp;&nbsp;请输入您的用户名</td>
            <td> 
              <INPUT name=username type=text maxlength=12>
            </td>
          </tr>
          <tr bgcolor="#f1f3f5" class=forumRowHighlight> 
            <td>&nbsp;&nbsp;请输入您的密码</td>
            <td> 
              <INPUT name=password type=password maxlength=12>
            </td>
          </tr>
    <tr class=forumRowHighlight>
            <td colspan=2 align=center bgcolor="#e4edf9">
<input type=submit name="submit" value="登陆(L)" accesskey="l" class=button style="width:70px"></td></tr></table></td></tr></table>
</form>
<%else%>
<TABLE height=295 cellSpacing=0 cellPadding=5 width=412 align=center 
background=images/login.gif border=0>
  <TBODY>
    <TR> 
      <TD align=left height=25>&nbsp;<FONT color=#ffffff><B><%=StrVar(1)%></B> 后台管理登陆面板</FONT></TD>
    </TR>
    <TR> 
      <TD height=70>&nbsp;<A href="http://www.717cn.com/" target=_blank><FONT 
      color=#ffffff><B>www.717cn.com</B></font></A><FONT 
      color=#ffffff> All Rights Reserved&nbsp;<BR>
        &nbsp;版本: 1.5 for SQL 版&nbsp;<BR>
        &nbsp;<B><%=StrVar(1)%></B> 后台管理登陆面板</FONT>&nbsp;<BR></TD>
    </TR>
    <TR> 
      <TD height=40></TD>
    </TR>
  <form action="admin_Logon.asp" method="post">
    <input type=hidden name=Action value=chkLogin>
    <TR> 
      <TD colSpan=2 height=30> <CENTER>
          用户名 
          <INPUT 
      style="BORDER-RIGHT: #666666 1px solid; BORDER-TOP: #666666 1px solid; BORDER-LEFT: #666666 1px solid; WIDTH: 150px; BORDER-BOTTOM: #666666 1px solid; HEIGHT: 20px" 
      maxLength=16 name="adminname" type="text" id="adminname">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </CENTER></TD>
    </TR>
    <TR> 
      <TD colSpan=2 height=15> <CENTER>
          密　码 
          <INPUT 
      style="BORDER-RIGHT: #666666 1px solid; BORDER-TOP: #666666 1px solid; BORDER-LEFT: #666666 1px solid; WIDTH: 150px; BORDER-BOTTOM: #666666 1px solid; HEIGHT: 20px" 
      maxLength=16 name="adminpwd" type="password" id="adminpwd">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </CENTER></TD>
    </TR>
    <TR> 
      <TD colSpan=2 height=15> <CENTER>
          附加码 
          <INPUT 
      style="BORDER-RIGHT: #666666 1px solid; BORDER-TOP: #666666 1px solid; BORDER-LEFT: #666666 1px solid; WIDTH: 150px; BORDER-BOTTOM: #666666 1px solid; HEIGHT: 20px" 
      maxLength=16 name="verifycode" type="text" id="verifycode">
          &nbsp;<%=getcode1()%>
        </CENTER></TD>
    </TR>
    <TR> 
      <TD height=40> <CENTER>
          <INPUT type=submit value=登陆 name=submit>
          <INPUT type=reset value=取消 name=reset>
        </CENTER></TD>
    </TR>
  </FORM>
</TABLE>
<% end if%>
<%End Sub


Sub disperrs(errormsg)
%>
<html><head>
<title><%=StrVar(1)%>——错误提示</title>
<br><br><br><br><br><br>
<table width="415" border="0" align=center cellpadding="1" cellspacing="0" style="border: outset 3px;width:0;">
  <tr>
            <td>
                <table cellpadding=5 cellspacing=1 border=0 width=412 >
        <tr align="center"> 
          <th><b><%=StrVar(1)%>错误信息</b></th>
        </tr>
        <tr> 
          <td class=forumRow><div align="center"><b>产生错误的可能原因：</b></div></td>
        </tr>
        <tr> 
          <td class=forumRow> 
            <br> 
            <li> 
              您是否仔细阅读了<a href=../Class_Help.asp>帮助文件</a> 
              <br>
              <%=errormsg%><br>
              <br>
          </td>
        </tr>
        <tr align="center"> 
          <td class=forumRowHighlight> 
            <a href="javascript:history.go(-1)"><< 
            返回上一页</a> 
          </td>
        </tr>
      </table>   </td></tr></table>
<%
End Sub
Function getcode1()
	Dim test
	On Error Resume Next
	Set test=Server.CreateObject("Adodb.Stream")
	Set test=Nothing
	If Err Then
		Dim zNum
		Randomize timer
		zNum = cint(8999*Rnd+1000)
		Session("GetCode") = zNum
		getcode1= Session("GetCode")		
	Else
		getcode1= "<img src=""Inc/code/getcode.asp"">"		
	End If
End Function
function isValidstring(para)
	on error resume next
	dim str
	dim l,i,invalidchar
	invalidchar="=%?#&;,'+<>()-:\*!/|"&chr(32)&chr(34)&chr(9)
	if isNUll(para) then 
		isValidstring=""
		exit function
	end if
	str=cstr(para)
	if trim(str)="" then
		isValidstring=""
		exit function
	end if
	l=len(str)
	for i = 1 to l
		c = Mid(str, i, 1)
		if InStr(invalidchar,c)>0 then
			isValidstring = c
			exit function
		end if
	next
	isValidstring=""
	if err.number<>0 then err.clear
end function
%>
