-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathte_count_active_users.asp
More file actions
102 lines (87 loc) · 4.06 KB
/
te_count_active_users.asp
File metadata and controls
102 lines (87 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<%
'==============================================================
' TableEditoR 0.81 Beta
' http://www.2enetworx.com/dev/projects/tableeditor.asp
'--------------------------------------------------------------
' File: te_count_active_users.asp
' Description: Counts active TableEditoR users
' Initiated By Rami Kattan on Apr 10, 2002
'--------------------------------------------------------------
' Copyright (c) 2002, 2eNetWorX/dev.
'
' TableEditoR is distributed with General Public License.
' Any derivatives of this software must remain OpenSource and
' must be distributed at no charge.
' (See license.txt for additional information)
'
' See Credits.txt for the list of contributors.
'
' Change Log:
'--------------------------------------------------------------
'==============================================================
%>
<%
if not instr(request.ServerVariables("SCRIPT_NAME"), "index.asp") > 0 AND bActiveUsers then
' ON ERROR RESUME NEXT
set my_Conn = Server.CreateObject("ADODB.Connection")
my_Conn.Open arrConn(0)
'// FIND OUT WHAT PAGE THEY ARE VIEWING
strActiveUsersPathHost = Request.ServerVariables("HTTP_HOST")
strActiveUsersPathInfo = Request.ServerVariables("PATH_INFO")
strUserID = session("teUserName")
strTableName = request("tablename")
if strUserID = "" then strUserID = "Guest"
strActiveUsersQueryString = Request.QueryString
If strActiveUsersQueryString <> "" Then
strActiveUsersQueryString = "?" & strActiveUsersQueryString
End If
strActiveUsersPageViewing = "http://" & strActiveUsersPathHost & strActiveUsersPathInfo & strActiveUsersQueryString
'// GET THE USERS IP ADDRESS
strActiveUsersIPAddress = Request.ServerVariables("REMOTE_ADDR")
'// ENCODE THIS INFO FOR SQL SERVER
' strActiveUsersPageViewing = ActiveUsersSQLencode(strActiveUsersPageViewing)
'// FIND CURRENT DATE AND TIME
strActiveUsersCurrentDate = Now
'// SET CHECK OUT TIME FOR 11 MINUTES OF INACTIVITY
strActiveUsersCheckOutTime = DATEADD("s", -660, strActiveUsersCurrentDate)
'// LETS DELETE ALL INACTIVE USERS
strSQL = "DELETE FROM Active_Users WHERE LastCheckedIn < #" & strActiveUsersCheckOutTime & "#"
my_Conn.Execute (strSQL)
strSQL = "SELECT * FROM Active_Users WHERE Active_Users.UserID='" & strUserID & "'"
set rs1 = my_Conn.Execute (strSQL)
if rs1.eof or rs1.bof then
'// THEY ARE NOT IN THE DATABASE SO LETS ADD THEM
strSQL = "INSERT INTO Active_Users (UserID,UserIP,CheckedIn,LastCheckedIn,PageViewing) VALUES ('" & strUserID & "','"
strSQL = strSQL & strActiveUsersIPAddress & "','" & strActiveUsersCurrentDate & "','" & strActiveUsersCurrentDate & "','" & strActiveUsersPageViewing & "')"
my_Conn.Execute (strSQL)
else
'// THEY ARE IN THE DATABASE SO LETS UPDATE THERE STUFF
'// FIRST LETS MAKE SURE THEY ARE NOT SUPOSED TO BE TIMED OUT
strSQL = "SELECT Active_Users.LastCheckedIn "
strSQL = strSQL & "FROM Active_Users "
strSQL = strSQL & "WHERE Active_Users.UserID = '" & strUserID & "' "
strSQL = strSQL & "AND Active_Users.LastCheckedIn < #" & strActiveUsersCheckOutTime & "# "
set rs2 = my_Conn.Execute (strSQL)
if rs2.eof or rs2.bof then
'// NOW LETS UPDATE THEM SINCE THEY ARE NOT SUPOSED TO BE TIMED OUT
strSQL = "UPDATE Active_Users SET Active_Users.PageViewing='" & strActiveUsersPageViewing & "' , Active_Users.LastCheckedIn='" & strActiveUsersCurrentDate & "' WHERE Active_Users.UserID='" & strUserID & "'"
my_Conn.Execute (strSQL)
else
'// DELETE THEM
strSQL = "DELETE FROM Active_Users "
strSQL = strSQL & "WHERE Active_Users.UserID = '" & strUserID & "' "
strSQL = strSQL & "AND Active_Users.LastCheckedIn < #" & strActiveUsersCurrentDate & "# "
my_Conn.Execute (strSQL)
strSQL = "INSERT INTO Active_Users (UserID,UserIP,CheckedIn,LastCheckedIn,PageViewing) VALUES ('" & strUserID & "','"
strSQL = strSQL & strActiveUsersIPAddress & "','" & strActiveUsersCurrentDate & "','" & strActiveUsersCurrentDate & "','" & strActiveUsersPageViewing & "')"
my_Conn.Execute (strSQL)
end if
rs2.close
set rs2 = nothing
end if
rs1.close
my_Conn.close
set rs1 = nothing
set my_Conn = nothing
end if
%>