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
eea2a96c
Commit
eea2a96c
authored
Jul 09, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(legacy) cleanups voucher.inc
parent
e225795a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
27 deletions
+31
-27
voucher.inc
src/etc/inc/voucher.inc
+1
-27
services_captiveportal_vouchers.php
src/www/services_captiveportal_vouchers.php
+9
-0
status_captiveportal_voucher_rolls.php
src/www/status_captiveportal_voucher_rolls.php
+21
-0
No files found.
src/etc/inc/voucher.inc
View file @
eea2a96c
...
...
@@ -276,7 +276,7 @@ function voucher_configure($sync = false)
$ret
=
true
;
if
(
!
is_array
(
$config
[
'voucher'
]))
{
if
(
!
is
set
(
$config
[
'voucher'
])
||
!
is
_array
(
$config
[
'voucher'
]))
{
return
$ret
;
}
...
...
@@ -427,25 +427,6 @@ function voucher_write_active_db($roll, $active) {
}
}
/* return how many vouchers are marked used on a roll */
function
voucher_used_count
(
$roll
)
{
global
$g
,
$cpzone
;
$bitstring
=
voucher_read_used_db
(
$roll
);
$max
=
strlen
(
$bitstring
)
*
8
;
$used
=
0
;
for
(
$i
=
1
;
$i
<=
$max
;
$i
++
)
{
// check if ticket already used or not.
$pos
=
$i
>>
3
;
// divide by 8 -> octet
$mask
=
1
<<
(
$i
%
8
);
// mask to test bit in octet
if
(
ord
(
$bitstring
[
$pos
])
&
$mask
)
$used
++
;
}
unset
(
$bitstring
);
return
$used
;
}
function
voucher_read_used_db
(
$roll
)
{
global
$cpzone
;
...
...
@@ -464,13 +445,6 @@ function voucher_read_used_db($roll)
return
base64_decode
(
$vdb
);
}
function
voucher_unlink_db
(
$roll
)
{
global
$cpzone
;
@
unlink
(
"/var/db/voucher_
{
$cpzone
}
_used_
{
$roll
}
.db"
);
@
unlink
(
"/var/db/voucher_
{
$cpzone
}
_active_
{
$roll
}
.db"
);
}
/* we share the log with captiveportal for now */
function
voucher_log
(
$priority
,
$message
)
...
...
src/www/services_captiveportal_vouchers.php
View file @
eea2a96c
...
...
@@ -37,6 +37,15 @@ require_once('filter.inc');
require_once
(
'captiveportal.inc'
);
require_once
(
'voucher.inc'
);
function
voucher_unlink_db
(
$roll
)
{
global
$cpzone
;
@
unlink
(
"/var/db/voucher_
{
$cpzone
}
_used_
{
$roll
}
.db"
);
@
unlink
(
"/var/db/voucher_
{
$cpzone
}
_active_
{
$roll
}
.db"
);
}
$referer
=
(
isset
(
$_SERVER
[
'HTTP_REFERER'
])
?
$_SERVER
[
'HTTP_REFERER'
]
:
'/services_captiveportal_vouchers.php'
);
$cpzone
=
$_GET
[
'zone'
];
...
...
src/www/status_captiveportal_voucher_rolls.php
View file @
eea2a96c
...
...
@@ -33,6 +33,27 @@ require_once("filter.inc");
require_once
(
"captiveportal.inc"
);
require_once
(
"voucher.inc"
);
/* return how many vouchers are marked used on a roll */
function
voucher_used_count
(
$roll
)
{
global
$g
,
$cpzone
;
$bitstring
=
voucher_read_used_db
(
$roll
);
$max
=
strlen
(
$bitstring
)
*
8
;
$used
=
0
;
for
(
$i
=
1
;
$i
<=
$max
;
$i
++
)
{
// check if ticket already used or not.
$pos
=
$i
>>
3
;
// divide by 8 -> octet
$mask
=
1
<<
(
$i
%
8
);
// mask to test bit in octet
if
(
ord
(
$bitstring
[
$pos
])
&
$mask
)
$used
++
;
}
unset
(
$bitstring
);
return
$used
;
}
$cpzone
=
$_GET
[
'zone'
];
if
(
isset
(
$_POST
[
'zone'
]))
{
$cpzone
=
$_POST
[
'zone'
];
...
...
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