📄 security.inc
字号:
<%
'************************************************************************************************
' 文件名: security.inc
' Copyright(c) 2001-2002 上海阿尔卡特网络支援系统有限公司
' 创建人 : 周秋舫
' 日 期 : 2002-05-29
' 修改历史 :
' ****年**月**日 ****** 修改内容:**************************************************
' 功能描述 : 有关安全方面的通用函数
' Security() : 检查用户对运行页面的权限
' 版 本 :
'************************************************************************************************
'************************************************************************************************
' 函数名 : Security
' 输 入 : (无)
' 输 出 : (无)
' 功能描述: 检查用户对所访问的页面的权限
' 首先检查用户是否已经登录,如果未登录,跳转到登录页面
' *** (现在不检查了)检查该文件是否存在于T_WebFiles表
' *** (现在不检查了)检查用户对该页是否有访问权限
' 检查用户是否在岗,如果离岗状态,则提示变成在岗状态
' 调用模块:
' 作 者 : 周秋舫
' 日 期 : 2002-05-29
' 版 本 :
'************************************************************************************************
Sub CheckSecurity()
' 先检查是否登录,如果尚未登录,跳转到登录页面
dim sError
' dim sFileName, sError
' dim crs, rs, sSQL, iHasPage
if Not IsLogin then
Server.Transfer("../common/home.asp")
exit sub
end if
' ' 获取当前被运行的ASP文件的完整虚拟路径,并检查T_WebFiles中是否有该文件
' sFileName = Request.ServerVariables("SCRIPT_NAME") ' 被运行ASP文件的完整虚拟路径
' response.write sFileName & "<br>"
' sFileName = Right(sFileName, len(sFileName)-4)
' set crs = New CRecordset
' sSQL = "select count(*) as nrows from T_WebFiles where file_name=" & ToSQL(sFileName,"Text")
' DebugStr(sSQL)
' set rs = crs.Open(dbLocal, sSQL)
' iHasPage = crs.GetValue("nrows")
' crs.Close()
' if iHasPage = 0 then
' Server.Transfer("../common/error.asp")
' exit sub
' end if
' 如果存在该页,则检查该用户对该页是否有访问权
'sSQL = "select Operation_Right from T_Rights where Role_id=" & ToSQL(GetRoleId,"Number") & " and Item_id in (select Item_id from T_WebFiles where file_name = " & ToSQL(sFileName,"Text") & ") and Operation_Right = 1"
'DebugStr(sSQL)
'set crs = New CRecordset
'set rs = crs.Open(dbLocal, sSQL)
' if rs.EOF then ' 无访问权
' sError = ToURL("对不起,您没有足够的权限!")
' Response.Redirect("../common/error.asp?error=" & sError)
' Response.end
' end if
' 检查是否为离岗状态,如果是离岗状态,提示先回到在岗状态,再进行操作
If Not IsOnline then
sError = "对不起,您现在处于离岗状态,请先回到在岗状态.........."
''Response.Redirect("../common/error.asp?error=" & ToURL(sError))
Response.Write "<script language=""javascript"">alert(""" & sError & """);</script>"
Response.Write("<script language=""javascript"">window.open(""../common/backinfor.asp"", ""wIAmBack"", ""width=350,height=124,top=300,left=300"");</script>")
Response.Write "<script language=""javascript"">history.go(-1);</script>"
exit sub
end if
End Sub
' =========================================================================================
' 函数名称:checkmenu(item_id)
' 函数功能:检查当前用户对某一个项目的操作权限,以便确定用户对与该项目对应的菜单的可见性。
' 输入参数:role_id,即当前用户在T_account中对应的role_id,
' item_id,即操作项目在T_item表中对应的item_id。
' 返回值:true/false,表示有/无对该项目的操作权限
' =========================================================================================
function checkmenu(roleid, itemid)
Dim rs
Dim item_id
Dim role_id
Dim quanxian
Dim SQLStr
role_id = roleid
item_id = itemid
SQLStr = "select * from T_Rights where role_id ="&role_id&" and item_id ='"&item_id&"'"
' response.write "aa" & SQLStr
' response.end
Set rs = cn.execute(SQLStr)
if rs.eof then
response.write "数据库T_item无"&item_id&"项目!请检查u_menu.asp!"
' response.end
else
if rs("operation_right") = 1 then
quanxian = true
else
quanxian = false
end if
end if
checkmenu = quanxian
end function
' ==================================================================
' 函数checkmenu(roleid,itemid)结束
' ==================================================================
Sub CheckSpecialPost()
Session("officer") = empty
Session("owner") = empty
Session("manager") = empty
Session("operator") = empty
'===============================
' 获取特殊用户信息 Begin
'===============================
Dim post_id, sError
sSQL = "select post_id, account_id from T_SpecialPost where account_id in (select account_id from T_Account where status = 0) order by account_id"
openrs rs, sSQL
while Not rs.EOF
post_id = GetValue(rs, "post_id")
Select Case post_id
Case 1
Session("officer") = GetValue(rs, "account_id")
Case 2
Session("owner") = GetValue(rs, "account_id")
Case 3
Session("manager") = GetValue(rs, "account_id")
Case 4
Session("operator") = GetValue(rs, "account_id")
End Select
rs.movenext
wEnd
rs.close
sError = ""
if Session("officer") = "" then sError = "办公室主任"
if Session("owner") = "" then
if sError <> "" then sError = sError & ", "
sError = sError & "与物业联系的业主人员"
end if
if Session("manager") = "" then
if sError <> "" then sError = sError & ", "
sError = sError & "物业负责人"
end if
if Session("operator") = "" then
if sError <> "" then sError = sError & "和"
sError = sError & "物业操作员"
end if
if sError <> "" then
cn.close
Session("officer") = empty
Session("owner") = empty
Session("manager") = empty
Session("operator") = empty
Response.Clear
Response.Write "<h2>error: 系统尚未指定" & sError & ",请与系统管理员联系!</h2>"
Response.end
end if
End Sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -