<!--#include file="te_config.asp"-->
<%
if request("comebackto") <> "" then
	sReferer = request("comebackto")
	sGoBackTo = "?" & request.querystring
end if

sub AskForLogin(sText)
%>
<p class="smallheader">

	<%
		sMsg = sText
		if request("comebackto") <> "" then
			sMsg = sMsg & "<br>请再次登陆."
			if sText <> "" then
				%><!--#include file="te_header.asp"--><%
			end if
		else
			if sText = "" then 
				sMsg = sMsg & "请登录"
			else
				%><!--#include file="te_header.asp"--><%
			end if
		end if
		response.write sMsg
	%>
</p>
<form action="index.asp<%=sGoBackTo%>" method="post">
  <table cellspacing="0">
    <tr>
      <td background="images/bg.gif" class="smallerheader">超管名</td>
      <td background="images/bg.gif"> 
        <input name="txtUserName" type="text" class="tbflat" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: 1px double; BORDER-LEFT: 1px double; BORDER-RIGHT: 1px double; BORDER-TOP: 1px double; COLOR: #666666; TEXT-ALIGN: center" onMouseOver="this.style.color='#000000'" onMouseOut="this.style.color='#eeeeee'" size="30"></td>
	</tr>
	<tr>
      <td background="images/bg.gif" class="smallerheader">密&nbsp;&nbsp;码</td>
      <td background="images/bg.gif"> 
        <input name="txtPassword" type="password" class="tbflat" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: 1px double; BORDER-LEFT: 1px double; BORDER-RIGHT: 1px double; BORDER-TOP: 1px double; COLOR: #666666; TEXT-ALIGN: center" onMouseOver="this.style.color='#000000'" onMouseOut="this.style.color='#eeeeee'" size="30"></td>
	</tr>
	<tr>
      <td background="images/bg.gif"></td>
      <td background="images/bg.gif"> 
        
        <div align="center">
          <input type="submit" name="cmdLogin" class="cmdflat" style="BACKGROUND-COLOR: #cccfff; BORDER-BOTTOM: 1px double; BORDER-LEFT: 1px double; BORDER-RIGHT: 1px double; BORDER-TOP: 1px double; COLOR: #ffffff; TEXT-ALIGN: center" onMouseOver="this.style.color='#0000ff'" onMouseOut="this.style.color='#ff9966'" value=" 登录 ">
        </div></td>
	</tr>
	<tr>
	  <td background="images/bg.gif"></td>
	  <td background="images/bg.gif"class="smallerheader">默认用户名和密码为admin，为安全请及时修改。</td>
    </tr>
</table>

</form>
<%
	if sText = "" then
	else
		%><!--#include file="te_footer.asp"--><%
	end if
end sub

	if request("cmdLogin") <> "" then
		'User provided the user name and password
		
		'Open the connections and create the recordset object
		OpenRS arrConn(0)
		
		sUserName = request("txtUserName")
		sPassword = request("txtPassword")

		sSQL = "SELECT * FROM Users WHERE UserName = '" & sUserName & "'"
		rs.Open sSQL, , , adCmdTable
		if not (rs.bof or rs.eof) then
			if rs("Password") = sPassword then
				'Login succeeded
				'Store info into session
				session("teUserName") = sUserName
				session("teFullName") = rs("FullName")
				session("rAdmin") = rs("rAdmin")
				session("rRecAdd") = rs("rRecAdd")
				session("rRecEdit") = rs("rRecEdit")
				session("rRecDel") = rs("rRecDel")
				session("rQueryExec") = rs("rQueryExec")
				session("rSQLExec") = rs("rSQLExec")
				session("rTableAdd") = rs("rTableAdd")
				session("rTableEdit") = rs("rTableEdit")
				session("rTableDel") = rs("rTableDel")
				session("rFldAdd") = rs("rFieldAdd")
				session("rFldEdit") = rs("rFieldEdit")
				session("rFldDel") = rs("rFieldDel")
				
				if sReferer = "" then
					response.redirect "te_admin.asp"
				else
					response.redirect sReferer
				end if
			else
				'登录失败 - 密码错误
				AskForLogin "登录失败 - 密码错误"
			end if
		else
			'用户未找到
			AskForLogin "登录失败 - 用户未找到"
		end if
		
		CloseRS
		
	else
%>
<!--#include file="te_header.asp"-->
<%
		if bProtected then
		'If protection is ON, ask for login
			AskForLogin ""
		else
		'if protection is OFF, display a warning
%>
	<p class="smallheader">
		你没有使用保护!
	</p>
	任何知道“数据库编辑”文件精确位置的访问者都可以看到或改变你数据库里的信息。<br>
	要使用保护, 打开 <strong>te_config.asp</strong> 文件并选择 <strong>bProtected = True</strong>.<br><br>
	你现在可以进入 <a href="te_admin.asp" style="color: #0000FF;">管理页面</a> 

<%		end if
%><!--#include file="te_footer.asp"--><%
	end if
%>
 

