Security | Strategy 2 Menu Management
Menu management mainly includes two parts, the editing and maintenance of menu items and the generation of menus according to the rights of the current landing user.
The edit and maintenance of the menu refers to the maintenance of the menu table. Because it is relatively simple, do not make detailed instructions here, just pay attention to the following three questions:
First, the generation of menu number and the number of permission digits. Because menu items can be deleted, if the new menu item gets the number and the number of permission digits only adds 1 to the maximum number, must lead to the waste of coding resources, especially the number of permission digits, only 100 digits, if because of the jump number and lead to the waste of coding resources, will inevitably lead to new functional modules have no encoded resources available. So, in adding a new menu item you have to solve the jump number problem. Take a look at the following statement with number and permission digits:
Select min (cdbh) +1 from CDB where cdbh+1 isn't in (select Cdbh from CDB)
Select min (qxws) +1 from CDB where qxws+1 isn't in (select Qxws from CDB)
As long as we ensure that the menu maintenance itself this function module assigned to it the menu number 1, the number of permissions to 1, you can ensure that in any case, the menu number and the number of permission digits will not jump, the encoding resources can be fully utilized. Because menu maintenance itself, this menu item will not be deleted under normal circumstances.
Second, the entry path is to enter the function module of the first page of the connection address, please pay attention to the path of the relative problem.
Third, the related file refers to the completion of the functional module of the page combination. Under normal circumstances, a menu item to connect a functional module, to complete the functionality of the module may require several ASP pages. For example, the entry path for menu item 1 is ... /menu1.asp, the following three pages, menu11.asp, menu12.asp, menu13.asp, the contents of the relevant documents refers to Meunu1.asp, menu11.asp,menu12.asp, Menu13.asp This string sequence example. The main role of this item is to set up for security checks, that is, the page in the system registration process.
There is a key session variable for menu generation based on the permissions of the currently logged on user ("Yhqx"), which is generated during a security review that is to be described later, until the user exits the system or the session timeout expires. The content inside is the 100-bit permission string for the currently logged in user. The process of generating a menu based on this variable is as follows:
<% sql= "SELECT * from CDB where fcdbh=0 order by CDBH"
Set Rs=conn.execute (SQL)
' Get all the parent menus in the menu table with submenus
' Traverse the parent menu
Do as not rs.eof
Submenunum=0
Sql= "Select Qxws from CDB where fcdbh=" &rs ("CDBH") & "ORDER by CDBH"
Set Rs1=conn.execute (SQL)
' Get all the submenus under the current parent menu
' Traverse the submenu under the Current parent menu
Do as not rs1.eof
If Mid (Session ("YHQX"), Rs1 ("Qxws"), 1 =1 Then
Submenunum=submenunum+1
' If the current user has the current submenu's permissions, then the number of submenus plus 1
End If
Rs1.movenext
Loop
Rs1.close
Set rs1=nothing
If Submenunum>0 Then
' Generates the parent menu if the current user's current parent menu has more than Zero submenu number
If Rs.bof then Firstmenu=rs ("CDBH") End If
Menunum=rs ("CDBH")
Parentname=rs ("CDMC")
Response.Write "<!--" &ParentName& "parent menu-->"
%>
<menu class=parent name=<%=parentname%> url=<%=rs ("Rklj")%> target= >
The form and style of the menu are tailored to suit your needs.
<%
Response.Write "<!--" &ParentName& "submenu-->"
Sql= ' select * from CDB where fcdbh= ' &MenuNum& ' ORDER by CDBH '
Set Rs1=conn.execute (SQL)
' Find all submenus under this parent menu
Do as not rs1.eof
If Mid (Session ("YHQX"), Rs1 ("yhqx"), 1 =1 Then
%>
<menu class=child name=<%=rs ("CDMC")%> url=<%=rs ("Rklj")%> target= ><br>
The form and style of the menu are tailored to suit your needs.
<%
End If
Rs1.movenext
Loop
Rs1.close
Set rs1=nothing
End If
Rs.movenext
Loop
Rs.close
Set rs=nothing
%>
Since this system has only level two menus, there is no question about the generation of menu recursive calls. If it is to be implemented, the menu generation process must be defined as a function form in order to make a recursive call, without detailed discussion.
3 Permission Assignment
The assignment of permissions consists of two parts, the user group rights assignment and the user's permission assignment. Is the process of associating a specific menu with a user group or user.
First look at the user group's add interface as follows:
<form name= "Zjyhz" method= "post" action= "yhzbmb_zj.asp" onsubmit= "return Checkinput (This)" > <!--call the input validation function. and generates a permission string-->
<input type= "hidden" name= "action" value= "Zjyhz" >
<table cellpadding= "0" cellspacing= "0" width= "100%" >
<tr>
<td><fieldset align= "Center" ><legend> Add user Group
</legend>
<input type= "hidden" name= "DQDWDM" value= "<%=DQDWDM%>" ><!--is passed in from the previous page and the current unit is encoded-->
User group name: <input type= "text" name= "YHZMC" size= "maxlength=" ><br><br>
Set User group Permissions:<br>
<table width= "100%" border= "0" cellpadding= "0" Cellspac