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
151c5914
Commit
151c5914
authored
Dec 12, 2014
by
Charlie Root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
captive portal remove captiveportal_read_db and replaced with new model
parent
e528090c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
33 deletions
+32
-33
captiveportal.inc
src/etc/inc/captiveportal.inc
+17
-21
voucher.inc
src/etc/inc/voucher.inc
+6
-10
DB.php
src/opnsense/mvc/app/models/Captiveportal/DB.php
+9
-2
No files found.
src/etc/inc/captiveportal.inc
View file @
151c5914
...
...
@@ -236,15 +236,6 @@ function captiveportal_allowedhostname_configure() {
return
$rules
;
}
/* read captive portal DB into array */
function
captiveportal_read_db
(
$query
=
""
)
{
$cpdb
=
array
();
throw
Exception
(
"TODO FIX code "
);
return
$cpdb
;
}
// Unchanged
...
...
@@ -952,21 +943,26 @@ function captiveportal_radius_stop_all() {
$radiusservers
=
captiveportal_get_radius_servers
();
if
(
!
empty
(
$radiusservers
))
{
$cpdb
=
captiveportal_read_db
();
foreach
(
$cpdb
as
$cpentry
)
{
if
(
empty
(
$cpentry
[
11
]))
$cpentry
[
11
]
=
'first'
;
if
(
!
empty
(
$radiusservers
[
$cpentry
[
11
]]))
{
RADIUS_ACCOUNTING_STOP
(
$cpentry
[
1
],
// ruleno
$cpentry
[
4
],
// username
$cpentry
[
5
],
// sessionid
$cpentry
[
0
],
// start time
$radiusservers
[
$cpentry
[
11
]],
$cpentry
[
2
],
// clientip
$cpentry
[
3
],
// clientmac
$cpdb
=
new
Captiveportal\DB
(
$cpzone
);
$clients
=
$cpdb
->
listClients
(
array
());
foreach
(
$clients
as
$cpentry
)
{
if
(
empty
(
$cpentry
->
radiusctx
))
$cpentry
->
radiusctx
=
'first'
;
if
(
!
empty
(
$radiusservers
[
$cpentry
->
radiusctx
]))
{
RADIUS_ACCOUNTING_STOP
(
$cpentry
->
pipeno_in
,
// ruleno
$cpentry
->
username
,
// username
$cpentry
->
sessionid
,
// sessionid
$cpentry
->
allow_time
,
// start time
$radiusservers
[
$cpentry
->
radiusctx
],
$cpentry
->
ip
,
// clientip
$cpentry
->
mac
,
// clientmac
7
);
// Admin Reboot
}
}
unset
(
$cpdb
);
}
}
...
...
src/etc/inc/voucher.inc
View file @
151c5914
...
...
@@ -242,7 +242,6 @@ function voucher_expire($voucher_received) {
// split into an array. Useful for multiple vouchers given
$a_vouchers_received
=
preg_split
(
"/[
\t\n\r
]+/s"
,
$voucher_received
);
$active_dirty
=
false
;
$unsetindexes
=
array
();
// go through all received vouchers, check their valid and extract
// Roll# and Ticket# using the external readvoucher binary
...
...
@@ -276,12 +275,13 @@ function voucher_expire($voucher_received) {
captiveportal_syslog
(
"
{
$voucher
}
(
{
$roll
}
/
{
$nr
}
) forced to expire"
);
/* Check if this voucher has any active sessions */
$cpentry
=
captiveportal_read_db
(
"WHERE username = '
{
$voucher
}
'"
);
if
(
!
empty
(
$cpentry
))
{
captiveportal_disconnect
(
$cpentry
,
null
,
13
);
captiveportal_logportalauth
(
$cpentry
[
4
],
$cpentry
[
3
],
$cpentry
[
2
],
"FORCLY TERMINATING VOUCHER
{
$voucher
}
SESSION"
);
$unsetindexes
[]
=
$cpentry
[
5
];
$cpdb
=
new
Captiveportal\DB
(
$cpzone
);
if
(
$db
->
countClients
(
array
(
"username"
=>
$voucher
))
>
0
)
{
captiveportal_disconnect
(
array
(
"username"
=>
$voucher
),
null
,
13
);
//TODO: fix logging (in disconnect?) captiveportal_logportalauth($cpentry[4],$cpentry[3],$cpentry[2],"FORCLY TERMINATING VOUCHER {$voucher} SESSION");
}
unset
(
$cpdb
);
}
else
captiveportal_syslog
(
"
$voucher
(
$roll
/
$nr
): not found on any registererd Roll"
);
}
else
...
...
@@ -314,10 +314,6 @@ function voucher_expire($voucher_received) {
unlock
(
$voucherlck
);
/* Write database */
if
(
!
empty
(
$unsetindexes
))
captiveportal_remove_entries
(
$unsetindexes
);
return
true
;
}
...
...
src/opnsense/mvc/app/models/Captiveportal/DB.php
View file @
151c5914
...
...
@@ -259,10 +259,17 @@ class DB {
*
* @return mixed number of connected users/clients
*/
function
countClients
(){
function
countClients
(
$qryargs
=
array
(),
$operator
=
"and"
){
$query
=
"select count(*) cnt from captiveportal "
;
$qry_tag
=
"where "
;
foreach
(
$qryargs
as
$fieldname
=>
$fieldvalue
){
if
(
array_key_exists
(
$fieldname
,
$this
->
captiveportal_types
)
){
$query
.=
$qry_tag
.
$fieldname
.
" = "
.
" :"
.
$fieldname
.
" "
;
$qry_tag
=
" "
.
$operator
.
" "
;
}
}
$resultset
=
$this
->
handle
->
query
(
$query
,
array
()
,
$this
->
captiveportal_types
);
$resultset
=
$this
->
handle
->
query
(
$query
,
$qryargs
,
$this
->
captiveportal_types
);
$resultset
->
setFetchMode
(
\Phalcon\Db
::
FETCH_OBJ
);
return
$resultset
->
fetchAll
()[
0
]
->
cnt
;
...
...
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