<%
Response.Buffer = EW_RESPONSE_BUFFER
%>
<!--#include file="ewcfg7.asp"-->
<!--#include file="zlogininfo.asp"-->
<!--#include file="aspfn7.asp"-->
<!--#include file="userfn7.asp"-->
<% Session.Timeout = 900 %>
<%
Response.Expires = 0
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "pragma", "no-cache"
Response.AddHeader "cache-control", "private, no-cache, no-store, must-revalidate"
%>
<%

' Define page object
Dim login
Set login = New clogin
Set Page = login

' Page init processing
Call login.Page_Init()

' Page main processing
Call login.Page_Main()
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>网站后台管理</title>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.6.0/build/container/assets/skins/sam/container.css">
<link rel="stylesheet" type="text/css" href="yousiteadmin.css">
<meta name="generator" content="ASPMaker v7.1.0.0">
</style>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body class="yui-skin-sam">
<script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/utilities/utilities.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/container/container-min.js"></script>
<script type="text/javascript">
<!--
var EW_DATE_SEPARATOR = "-"; 
if (EW_DATE_SEPARATOR == "") EW_DATE_SEPARATOR = "/"; // Default date separator
var EW_UPLOAD_ALLOWED_FILE_EXT = "gif,jpg,jpeg,bmp,png,doc,xls,pdf,zip"; // Allowed upload file extension
var EW_FIELD_SEP = ", "; // Default field separator
// Ajax settings
var EW_RECORD_DELIMITER = "\r";
var EW_FIELD_DELIMITER = "|";
var EW_LOOKUP_FILE_NAME = "ewlookup7.asp"; // lookup file name
//var EW_ADD_OPTION_FILE_NAME = ""; // add option file name
var EW_BUTTON_SUBMIT_TEXT = "    增加    ";
var EW_BUTTON_CANCEL_TEXT = "    取消    ";
//-->
</script>
<script type="text/javascript" src="js/ew7.js"></script>
<script type="text/javascript" src="js/ewvalidator.js"></script>
<script type="text/javascript" src="js/userfn7.js"></script>
<script language="JavaScript" type="text/javascript">
<!--
// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js");
//-->
</script>



				
<script language="JavaScript" type="text/javascript">
<!--
// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->
</script>
<script type="text/javascript">
<!--
var login = new ew_Page("login");
// extend page with ValidateForm function
login.ValidateForm = function(fobj)
{
	if (!this.ValidateRequired)
		return true; // ignore validation
	if (!ew_HasValue(fobj.username))
		return ew_OnError(this, fobj.username, "请输入用户 ID");
	if (!ew_HasValue(fobj.password))
		return ew_OnError(this, fobj.password, "请输入密码");
	// Call Form Custom Validate event
	if (!this.Form_CustomValidate(fobj)) return false;
	return true;
}
// extend page with Form_CustomValidate function
login.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!
 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
// requires js validation
<% If EW_CLIENT_VALIDATE Then %>
login.ValidateRequired = true;
<% Else %>
login.ValidateRequired = false;
<% End If %>
//-->
</script>


<table width="431" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-top:180px;">
  <tr>
    <td width="187" height="200" valign="top"><img src="images/logo.jpg" width="160" height="76" style="margin-top:50px"><br>
      　MY网站信息管理系统</td>
    <td width="21" align="center"><img src="images/login_line.gif" width="21" height="264"></td>
    <td width="223"><form action="<%= ew_CurrentPage %>" method="post" onsubmit="return login.ValidateForm(this);">
    <input type="hidden" value="a" name="rememberme" id="rememberme">
      <table border="0" align="center" cellpadding="4" cellspacing="0">
        <tr>
          <td><span class="aspmaker">用户名</span></td>
          <td><span class="aspmaker">
            <input type="text" name="username" id="username" size="20" value="<%= login.sUsername %>" style="width:150px; height:18px; border:1px solid #CCC">
          </span></td>
        </tr>
        <tr>
          <td><span class="aspmaker">密码</span></td>
          <td><span class="aspmaker">
            <input type="password" name="password" id="password" size="20" style="width:150px; height:18px; border:1px solid #CCC">
          </span></td>
        </tr>
       
        <tr>
          <td align="center">&nbsp;</td>
          <td><span class="aspmaker">
            <input type="submit" name="submit" id="submit" value="    登录    ">
          </span></td>
        </tr>
        <tr>
          <td colspan="2" align="center"><% login.ShowMessage %></td>
        </tr>
      </table>
    </form></td>
  </tr>
</table>
<br>
<p><span class="aspmaker">
</span></p>
<script language="JavaScript" type="text/javascript">
<!--
// Write your startup script here
// document.write("page loaded");
//-->
</script>

<%

' Drop page object
Set login = Nothing
%>
<%

' -----------------------------------------------------------------
' Page Class
'
Class clogin

	' Page ID
	Public Property Get PageID()
		PageID = "login"
	End Property

	' Page Object Name
	Public Property Get PageObjName()
		PageObjName = "login"
	End Property

	' Page Name
	Public Property Get PageName()
		PageName = ew_CurrentPage()
	End Property

	' Page Url
	Public Property Get PageUrl()
		PageUrl = ew_CurrentPage() & "?"
	End Property

	' Message
	Public Property Get Message()
		Message = Session(EW_SESSION_MESSAGE)
	End Property

	Public Property Let Message(v)
		If Session(EW_SESSION_MESSAGE) <> "" Then ' Append
			Session(EW_SESSION_MESSAGE) = Session(EW_SESSION_MESSAGE) & "<br>" & v
		Else
			Session(EW_SESSION_MESSAGE) = v
		End If
	End Property

	' Show Message
	Public Sub ShowMessage()
		If Message <> "" Then ' Message in Session, display
			Response.Write "<p><span class=""ewMessage"">" & Message & "</span></p>"
			Session(EW_SESSION_MESSAGE) = "" ' Clear message in Session
		End If
	End Sub

	' -----------------------
	'  Validate Page request
	'
	Public Function IsPageRequest()
		IsPageRequest = True
	End Function

	' -----------------------------------------------------------------
	'  Class initialize
	'  - init objects
	'  - open ADO connection
	'
	Private Sub Class_Initialize()

		' Initialize table object
		Set zlogin = New czlogin

		' Initialize form object
		Set ObjForm = Nothing

		' Intialize page id (for backward compatibility)
		EW_PAGE_ID = "login"

		' Open connection to the database
		Set Conn = Server.CreateObject("ADODB.Connection")
		Conn.Open EW_DB_CONNECTION_STRING
	End Sub

	' -----------------------------------------------------------------
	'  Subroutine Page_Init
	'  - called before page main
	'  - check Security
	'  - set up response header
	'  - call page load events
	'
	Sub Page_Init()
		Set Security = New cAdvancedSecurity

		' Global page loading event (in userfn7.asp)
		Call Page_Loading()

		' Page load event, used in current page
		Call Page_Load()
	End Sub

	' -----------------------------------------------------------------
	'  Class terminate
	'  - clean up page object
	'
	Private Sub Class_Terminate()
		Call Page_Terminate("")
	End Sub

	' -----------------------------------------------------------------
	'  Subroutine Page_Terminate
	'  - called when exit page
	'  - clean up ADO connection and objects
	'  - if url specified, redirect to url
	'
	Sub Page_Terminate(url)

		' Page unload event, used in current page
		Call Page_Unload()

		' Global page unloaded event (in userfn60.asp)
		Call Page_Unloaded()
		If Not (Conn Is Nothing) Then Conn.Close ' Close Connection
		Set Conn = Nothing
		Set Security = Nothing

		' Go to url if specified
		If url <> "" Then
			Response.Clear
			Response.Redirect url
		End If
	End Sub

	'
	'  Subroutine Page_Terminate (End)
	' ----------------------------------------

	Dim sUsername
	Dim sLoginType

	' -----------------------------------------------------------------
	' Page main processing
	'
	Sub Page_Main()
		Dim bValidate, bValidPwd
		Dim sPassword
		Dim sLastUrl
		sLastUrl = Security.LastUrl ' Get Last Url
		If sLastUrl = "" Then sLastUrl = "default.asp"
		If Not Security.IsLoggedIn() Then Call Security.AutoLogin()
		Call Security.LoadUserLevel() ' Load user level
		If Request.Form <> "" Then

			' Setup variables
			sUsername = Request.Form("Username")
			sPassword = Request.Form("Password")
			sLoginType = LCase(Request.Form("rememberme"))
			bValidate = ValidateForm(sUsername, sPassword)
			If Not bValidate Then
				Message = gsFormError
			End If
		Else
			If Security.IsLoggedIn() Then
				If Message = "" Then Page_Terminate(sLastUrl) ' Return to last accessed page
			End If
			bValidate = False

			' Restore settings
			sUsername = Request.Cookies(EW_PROJECT_NAME)("username")
			If Request.Cookies(EW_PROJECT_NAME)("autologin") = "autologin" Then
				sLoginType = "a"
			ElseIf Request.Cookies(EW_PROJECT_NAME)("autologin") = "rememberUsername" Then
				sLoginType = "u"
			Else
				sLoginType = ""
			End If
		End If
		If bValidate Then
			bValidPwd = False

			' Call loggin in event
			bValidate = User_LoggingIn(sUsername, sPassword)
			If bValidate Then
				bValidPwd = Security.ValidateUser(sUsername, sPassword)
				If Not bValidPwd Then Message = "用户 ID 或 密码错误" ' Invalid user id/password
			Else
				If Message = "" Then Message = "取消登录" ' Login cancelled
			End If
			If bValidPwd Then

				' Write cookies
				If sLoginType = "a" Then ' Auto login
					Response.Cookies(EW_PROJECT_NAME)("autologin") = "autologin" ' Set up autologin cookies
					Response.Cookies(EW_PROJECT_NAME)("username") = sUsername ' Set up user name cookies
					Response.Cookies(EW_PROJECT_NAME)("password") = ew_Encode(TEAencrypt(sPassword, EW_RANDOM_KEY)) ' Set up password cookies
					Response.Cookies(EW_PROJECT_NAME).Expires = DateAdd("d", 365, Date) ' Change the expiry date of the cookies here
				ElseIf sLoginType = "u" Then ' Remember user name
					Response.Cookies(EW_PROJECT_NAME)("autologin") = "rememberUsername" ' Set up remember user name cookies
					Response.Cookies(EW_PROJECT_NAME)("username") = sUsername ' Set up user name cookies
					Response.Cookies(EW_PROJECT_NAME).Expires = DateAdd("d", 365, Date) ' Change the expiry date of the cookies here
				Else
					Response.Cookies(EW_PROJECT_NAME)("autologin") = "" ' Clear autologin cookies
				End If

				' Call loggedin event
				Call User_LoggedIn(sUsername)
				Call Page_Terminate(sLastUrl) ' Return to last accessed url
			Else

				' Call user login error event
				Call User_LoginError(sUsername, sPassword)
			End If
		End If
	End Sub

	' -----------------------------------------------------------------
	' Validate form
	'
	Function ValidateForm(usr, pwd)

		' Initialize
		gsFormError = ""

		' Check if validation required
		If Not EW_SERVER_VALIDATE Then
			ValidateForm = True
			Exit Function
		End If
		If usr = "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & "请输入用户 ID"
		End If
		If pwd = "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & "请输入密码"
		End If

		' Return validate result
		ValidateForm = (gsFormError = "")

		' Call Form Custom Validate event
		Dim sFormCustomError
		sFormCustomError = ""
		ValidateForm = ValidateForm And Form_CustomValidate(sFormCustomError)
		If sFormCustomError <> "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & sFormCustomError
		End If
	End Function

	' Page Load event
	Sub Page_Load()

		'Response.Write "Page Load"
	End Sub

	' Page Unload event
	Sub Page_Unload()

		'Response.Write "Page Unload"
	End Sub

	' User Logging In event
	Function User_LoggingIn(usr, pwd)
		If Not EW_DEBUG_ENABLED Then On Error Resume Next

		' Enter your code here
		' To cancel, set return value to False

		User_LoggingIn = True
	End Function

	' User Logged In event
	Sub User_LoggedIn(usr)

		' Response.Write "User Logged In"
	End Sub

	' User Login Error event
	Sub User_LoginError(usr, pwd)

		' Response.Write "User Login Error"
	End Sub

	' Form Custom Validate event
	Function Form_CustomValidate(CustomError)

		'Return error message in CustomError
		Form_CustomValidate = True
	End Function
End Class
%>
