<%
If CmsFun.ChkNumEric(Easp.Cookie("ZjjCmsCms>AdminId")) = 0 Then
    Easp.WE Easp.JsCode("top.location.href='"& SiteAdminPath &"';")
End If
If Easp.IsN(Easp.Cookie("ZjjCmsCms>AdminName")) Then
    Dim CookieResult, FieldList, RoleName
    FieldList = "Id,RoleId,RoleType,AdminName,AdminPass,LoginTime,LoginIp,LoginNum,IsLock"
    CookieResult = Easp.db.RT(TablePrefix & "Admin", " Id = "& Easp.Cookie("ZjjCmsCms>AdminId") &" ", FieldList)
    If Easp.IsN(CookieResult) Then
        Easp.AlertUrl "参数错误!", "Admin_Login.Asp"
    Else
        RoleName = Easp.db.RT(TablePrefix & "Admin_Role", " Id = "& Result(1) &" ", "RoleName")
        Easp.SetCookie "ZjjCmsCms>AdminId", CookieResult(0), 180
        Easp.SetCookie "ZjjCmsCms>RoleId", CookieResult(1), 180
        Easp.SetCookie "ZjjCmsCms>RoleType", CookieResult(2), 180
        Easp.SetCookie "ZjjCmsCms>RoleName", RoleName, 180
        Easp.SetCookie "ZjjCmsCms>AdminName", CookieResult(3), 180
        Easp.SetCookie "ZjjCmsCms>AdminPass", CookieResult(4), 180
        Easp.SetCookie "ZjjCmsCms>LoginTime", Result(5), 180
        Easp.SetCookie "ZjjCmsCms>LoginIp", Result(6), 180
        Easp.SetCookie "ZjjCmsCms>LoginNum", Result(7), 180
        Easp.SetCookie "ZjjCmsCms>IsLock", Result(8), 180
    End If
End If

Sub ChkSysAdminLevel(ByVal ChannelName, ByVal ValType)
    Dim oRs
    Set oRs = Easp.db.GR(TablePrefix & "Admin:RoleId,RoleType:1", " Id = "& Easp.Cookie("ZjjCmsCms>AdminId") &" ", "")
    If Easp.IsN(oRs) Then
        ShowManageErrCode()
    Else
        If CmsFun.ChkNumEric(oRs(1)) = 1 Then
            Exit Sub
        Else
            If Not GetRoleSysName(oRs(0), ChannelName, ValType) Then
                ShowManageErrCode()
            End If
        End If
    End If
    Easp.C oRs
End Sub

Sub ChkChannelAdminLevel(ByVal ChannelId, ByVal ValType)
    Dim oRs
    Set oRs = Easp.db.GR(TablePrefix & "Admin:RoleId,RoleType:1", " Id = "& Easp.Cookie("ZjjCmsCms>AdminId") &" ", "")
    If Easp.IsN(oRs) Then
        ShowManageErrCode()
    Else
        If CmsFun.ChkNumEric(oRs(1)) = 1 Then
            Exit Sub
        Else
            If Not GetRoleChannel(oRs(0), ChannelName, ValType) Then
                ShowManageErrCode()
            End If
        End If
    End If
    Easp.C oRs
End Sub

Sub ShowManageErrCode()
    Dim strTemp
    strTemp = "<script>" & vbCrLf
    strTemp = strTemp & "parent.f_errorTab('错误提示', '您没有管理该页面的权限，请勿尝试非法进入！');" & vbCrLf
    strTemp = strTemp & "</script>"
    Easp.WE strTemp
End Sub

Function GetRoleSysName(ByVal RoleId, ByVal ChannelName, ByVal ValType)
    Dim oRs, TempWhere
    TempWhere = " RoleId = "& RoleId &" And ChannelName = '"& ChannelName &"' And ValType = '"& ValType &"' "
    Set oRs = Easp.db.GR(TablePrefix & "Admin_Role_Val:1", TempWhere, "")
    If Easp.IsN(oRs) Then
        GetRoleSysName = False
    Else
        GetRoleSysName = True
    End If
    Easp.C oRs
End Function

Function GetRoleChannel(ByVal RoleId, ByVal ChannelId, ByVal ValType)
    Dim oRs, TempWhere
    TempWhere = " RoleId = "& RoleId &" And ChannelId = "& ChannelId &" And ValType = '"& ValType &"' "
    Set oRs = Easp.db.GR(TablePrefix & "Admin_Role_Val:1", TempWhere, "")
    If Easp.IsN(oRs) Then
        GetRoleChannel = False
    Else
        GetRoleChannel = True
    End If
    Easp.C oRs
End Function
%>