Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
d6d7a0d4
Commit
d6d7a0d4
authored
Oct 06, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(captiveportal, new) work in progress script base
parent
acc319f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
4 deletions
+3
-4
db.py
src/opnsense/scripts/OPNsense/CaptivePortal/lib/db.py
+3
-4
No files found.
src/opnsense/scripts/OPNsense/CaptivePortal/lib/db.py
View file @
d6d7a0d4
...
@@ -78,7 +78,6 @@ class DB(object):
...
@@ -78,7 +78,6 @@ class DB(object):
response
[
'ipAddress'
]
=
ip_address
response
[
'ipAddress'
]
=
ip_address
response
[
'macAddress'
]
=
mac_address
response
[
'macAddress'
]
=
mac_address
response
[
'startTime'
]
=
time
.
time
()
# record creation = sign-in time
response
[
'startTime'
]
=
time
.
time
()
# record creation = sign-in time
response
[
'last_accessed'
]
=
time
.
time
()
# last accessed_time = sign-in time
response
[
'sessionId'
]
=
base64
.
b64encode
(
os
.
urandom
(
16
))
# generate a new random session id
response
[
'sessionId'
]
=
base64
.
b64encode
(
os
.
urandom
(
16
))
# generate a new random session id
cur
=
self
.
_connection
.
cursor
()
cur
=
self
.
_connection
.
cursor
()
...
@@ -90,8 +89,8 @@ class DB(object):
...
@@ -90,8 +89,8 @@ class DB(object):
"""
,
response
)
"""
,
response
)
# add new session
# add new session
cur
.
execute
(
"""INSERT INTO cp_clients(zoneid, authenticated_via, sessionid, username, ip_address, mac_address, created
, last_accessed
)
cur
.
execute
(
"""INSERT INTO cp_clients(zoneid, authenticated_via, sessionid, username, ip_address, mac_address, created)
VALUES (:zoneid, :authenticated_via, :sessionId, :userName, :ipAddress, :macAddress, :startTime
, :last_accessed
)
VALUES (:zoneid, :authenticated_via, :sessionId, :userName, :ipAddress, :macAddress, :startTime)
"""
,
response
)
"""
,
response
)
self
.
_connection
.
commit
()
self
.
_connection
.
commit
()
...
@@ -144,7 +143,7 @@ class DB(object):
...
@@ -144,7 +143,7 @@ class DB(object):
, CASE WHEN si.packets_out IS NULL THEN 0 ELSE si.packets_out END packets_out
, CASE WHEN si.packets_out IS NULL THEN 0 ELSE si.packets_out END packets_out
, CASE WHEN si.bytes_in IS NULL THEN 0 ELSE si.bytes_in END bytes_in
, CASE WHEN si.bytes_in IS NULL THEN 0 ELSE si.bytes_in END bytes_in
, CASE WHEN si.bytes_out IS NULL THEN 0 ELSE si.bytes_out END bytes_out
, CASE WHEN si.bytes_out IS NULL THEN 0 ELSE si.bytes_out END bytes_out
, CASE WHEN si.last_accessed IS NULL THEN
0
ELSE si.last_accessed END last_accessed
, CASE WHEN si.last_accessed IS NULL THEN
cc.created
ELSE si.last_accessed END last_accessed
FROM cp_clients cc
FROM cp_clients cc
LEFT JOIN session_info si ON si.zoneid = cc.zoneid AND si.sessionid = cc.sessionid
LEFT JOIN session_info si ON si.zoneid = cc.zoneid AND si.sessionid = cc.sessionid
WHERE cc.zoneid = :zoneid
WHERE cc.zoneid = :zoneid
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment