<%
Dim arrAdminFlag

Sub CheckLogin()
	Dim AdminId,AdminName,AdminPass,UserType
	AdminId = Session("AdminId")
	AdminName = Session("AdminName")
	AdminPass = Session("AdminPass")
	UserType = Session("UserType")
	
	If AdminId = "" Or IsNull(AdminId) Or AdminName = "" Or IsNull(AdminName) Or AdminPass = "" Or IsNull(AdminPass) Or UserType <> "Master" Or IsNull(UserType) Then
		ToLogin()
		Exit Sub
	End If
	
	Set Rs = Conn.Execute("select * from AdminTbl where AdminId = "& AdminId &" and AdminName = '"& AdminName &"' and IsLock = '0'")
	If Rs.Eof Then
		ToLogin()
		Exit Sub
	Else
		If Cstr(Rs("AdminPass")) <> Cstr(AdminPass) Then
			ToLogin()
			Exit Sub
		End If
	End If
	Set Rs = Nothing
End Sub

Sub ToLogin()
	Dim GoPath
	If InStr(PagePath , "../") > 0 Then
		GoPath = Right(PagePath , Len(PagePath) - Len("../"))
	Else
		GoPath = PagePath
	End If
	Response.Write("<script language=""javascript"">top.location.href='"& GoPath &"Login.asp';</script>")
	Response.End()
End Sub

Sub AdminFlag_Check()
	Dim strAdminFlag
	Dim arri,arrj
	
	Set Rs = Conn.Execute("select * from AdminTbl where AdminId = "& Session("AdminId"))
	If Rs.Eof Then
		strAdminFlag = ""
	Else
		strAdminFlag = Rs("AdminFlag")
	End If
	Set Rs = Nothing
	
	If InStr(strAdminFlag , "$") <= 0 Or InStr(strAdminFlag , "|") <= 0 Then
		strAdminFlag = "9|0|0|0|0|0|0|0|0|0|0$9|0|0|0|0|0|0|0|0|0|0$9|0|0|0|0|0|0|0|0|0|0$9|0|0|0|0|0|0|0|0|0|0$9|0|0|0|0|0|0|0|0|0|0$9|0|0|0|0|0|0|0|0|0|0$9|0|0|0|0|0|0|0|0|0|0$9|0|0|0|0|0|0|0|0|0|0$9|0|0|0|0|0|0|0|0|0|0$9|0|0|0|0|0|0|0|0|0|0"
	End If
	
	strAdminFlag = Split(strAdminFlag , "$")
	arri = Ubound(strAdminFlag)
	For i = 0 To Ubound(strAdminFlag)
		strAdminFlag(i) = Split(strAdminFlag(i) , "|")
		If i = 0 Then
			arrj = Ubound(strAdminFlag(i))
		Else
			If arrj < Ubound(strAdminFlag(i)) Then
				arrj = Ubound(strAdminFlag(i))
			End If
		End If
	Next
	
	ReDim arrAdminFlag(arri , arrj)
	
	For i = 0 To arri
		For j = 0 To arrj
			arrAdminFlag(i , j) = strAdminFlag(i)(j)
		Next
	Next
End Sub

CheckLogin()
AdminFlag_Check()
%>