1, I want to achieve:
I want to set up a JSP program, as long as there is a user landing site (admin or illegal), regardless of the login success or failure of the landing of the user name (login information, the implementation page) recorded to the database, as well as the site after the landing of the changes to make a record, such as modified the news, delete messages, Modified site configuration and so on have records, does not require recoverable, can record seven days, or 1000 records so it can be. Multiple records can be deleted automatically .... How to implement a similar feature.
———— ideas:
A, write a common function:
function Dorecordlog (username, action, content)
' Internal implementation of this function to record user action log function
End Function
b, each page needs to log the operation to call this function.
———— Idea 2:
Four ways:
A. Each page generates a different session, and if the page ends, the value is paid to the variable passed to the database save.
B. Set a new date for each record, date modified, saved in the database, displayed on the admin page, and if you see which record is newly modified, it will be the new date, and the new date will not change.
C. Place an Access Statistics page, statistics each backstage manager visited the path, I useful access statistics, can check to see each of the footprints, and each other's IP, but used in the foreground, of course, backstage can also be used.
D. If you want to control the manager's operational rights, you can set up multiple administrative groups, set different administrative permissions for different groups, like Windows, have administrator rights and guest permissions, so that some users can only see and can not modify.
I've been using the second approach to check for updates.
CREATE TABLE EventLog (
CID int PRIMARY key NOT NULL,
Csort varchar (m) NULL,
Cusername varchar (m) NULL,
CTime datetime,
CDO varchar () NULL,
CIP varchar (20)
)
Program
Call the database First
And then
<%
Function Events (CSORT,CUSERNAME,CDO)
CIP = Request.ServerVariables ("Http_x_forwarded_for")
If CIP = "" Then
CIP = Request.ServerVariables ("REMOTE_ADDR")
End If
Ctime=now ()
Safesql= "SELECT * from Tb_eventlog"
Set Rsyss=server. CreateObject ("Adodb.recordset")
Rsyss.open safesql,con,1,3
Rsyss.addnew
Rsyss ("Csort") =csort
Rsyss ("Cusername") =cusername
Rsyss ("CDO") =CDO
Rsyss ("CTime") =ctime
Rsyss ("CIP") =cip
Rsyss.update
Rsyss.close
End Function
%>
Don't just write a diary.
Generally more reasonable approach is to first in the operation of a flash format.
For example: An administrator to make some adjustments to the database, he deleted a user, then delete the user should be recorded in the log.
This must be the admin, first it's landed, then you can use the session ("UserID") to save its landing state, while taking out the value, to the diary database records, so that the first to achieve the purpose of positioning people, of course, this operation is in the deletion of users, then can be noted in the action. So the establishment of the database is clear:
UserID datetime Active
The UserID is the one who did the storage.
DateTime is used to store the action when
Active is used to indicate an action, such as deleting a user and so on text storage
The data table can be expanded if necessary.
When the administrator deletes the user, the action is written to the journal database before the action to delete the user is started. This completely records the actions of the administrator.
Access to the Web page can be done after landing.
For example, there is a Web page abc.asp
So at the beginning of the abc.asp test session ("userid") if it exists, insert a record into the journal database, userid Insert the session ("UserID"), insert the current time into DateTime, and "Access the ABC Web page" Inserted into active so that you can take out the record and see that a user has visited the ABC Web page at some point. Of course, if you visit too many pages, you can write this section out and import it into each page. It's OK.
As for how to control the beginning of the Web page, this is a redirection problem.
For example, if you write a page in the background that closes a Web site, you can use a application ("Vis") variable to control it. When you click Close, an event is executed, application ("Vis") = "false", and conversely, the value is true to open or close the Application-start event first.
When you run the Web page, you go to the value of application ("Vis"), and if true, the page is displayed without action, and if False, the page is directed to another hint page.
Of course, I am here to application as an example, in fact, you can also be stored in the database, so stored as a configuration. This will not be lost even if you restart the server. But the principle here is this.
Simple No. It's no different from writing regular pages. The so-called backstage is only the administrator landing. In fact, for the development of the front desk is not part of the background. This noun is just a distinguishing feature of Web pages.
Called when an action is performed or a page is entered
<% ' such as when a user logs on
Events "User Login", Session ("username"), "Successful Login background management"
' When the information is modified
Events "Enterprise Honor", Session ("username"), "Modify the Honor category name"
%>, it's okay.
The second one doesn't understand what you mean.
Then you can put a judge in front of the page.
Set a table first
Page face value (0/1)
On each page
Use
If Request.ServerVariables ("Server_port") <> "then"
Userurl = "http://" &request.servervariables ("SERVER_NAME") & ":" & Request.ServerVariables ("SERVER_PORT" ) & Request.ServerVariables ("URL")
Else
Userurl = "http://" &request.servervariables ("SERVER_NAME") & Request.ServerVariables ("URL")
End If
Pick up your website.
Userurl=right (Userurl,instrrev (Userurl, "/") +1) take the name of the page in your website
And then
Read your table page name the same in the judge if the value of 0 is closed if the value of 1 can be seen
You're doing a page backstage to control whether the page is closed.
—————————— Action Log ————————
A, the log will probably record: who at what time and where did what the operation
So write a similar process where Addlog (user,time,place,operate) can be called where records are needed.
For example to record the landing process, then log in after the completion of the login, the user name, time, (here can not be recorded, because there should be only a landing point bar), the operation is landing.
Other places like this call to record.
b, I was placed in a separate log file, named by date
Procedure Writetotxt (content:string);
Var
F:textfile;
path,name:string;
Begin
Name:=formatdatetime (' Yyyy-mm-dd ', now);/Date Acquired
Path:=extractfilepath (application.exename) + ' log/' + name+ '. txt ';//log access Path
AssignFile (F,path);
If FileExists (path) =false Then
ReWrite (F);
Append (F);
Writeln (F, ' [' +datetimetostr (now ()) + ']: ' +content '; Write to log file
CloseFile (F);
End
It's OK to call after the specific operation.
In an OA project, you need to record what the user has done, including additions, deletions, and modifications that you want to record in a format similar to the following:
User xxx added a product category XXX in 2007 x month x day
User xxx deleted a user xxx in 2007 x month x day
Now ask everyone, in addition to adding and deleting changes in the other run a stored procedure to record this information, there is no more simple way ah, thank you ~ ~ Thank you for participating ~
—————— Answer:
Record with a text file, append text my practice is to create a log table in the database.
Then write some methods that trigger when the user makes a search for additional deletions.
Add data to a table
can be considered unified processing through HttpModule,
However, you have to consider how to capture what the user is doing