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