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
a2b76548
Commit
a2b76548
authored
Dec 28, 2014
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move new classes to comply with PSR1/2 style guides, still a lot todo here...
parent
a8641315
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
49 additions
and
39 deletions
+49
-39
captiveportal.inc
src/etc/inc/captiveportal.inc
+9
-9
voucher.inc
src/etc/inc/voucher.inc
+2
-2
ARP.php
src/opnsense/mvc/app/models/OPNsense/CaptivePortal/ARP.php
+13
-10
CPClient.php
...nsense/mvc/app/models/OPNsense/CaptivePortal/CPClient.php
+8
-6
DB.php
src/opnsense/mvc/app/models/OPNsense/CaptivePortal/DB.php
+2
-2
Rules.php
src/opnsense/mvc/app/models/OPNsense/CaptivePortal/Rules.php
+2
-2
Config.php
src/opnsense/mvc/app/models/OPNsense/Core/Config.php
+2
-2
Shell.php
src/opnsense/mvc/app/models/OPNsense/Core/Shell.php
+1
-1
Singleton.php
src/opnsense/mvc/app/models/OPNsense/Core/Singleton.php
+1
-1
test.php
src/opnsense/mvc/script/test.php
+6
-1
services_captiveportal_zones.php
src/www/services_captiveportal_zones.php
+1
-1
status_captiveportal.php
src/www/status_captiveportal.php
+1
-1
captive_portal_status.widget.php
src/www/widgets/widgets/captive_portal_status.widget.php
+1
-1
No files found.
src/etc/inc/captiveportal.inc
View file @
a2b76548
...
...
@@ -54,14 +54,14 @@ require_once("script/load_phalcon.php");
// TODO : restructure code / gui, for now we try to maintain gui compatibility by not breaking the old callbacks
//
function
captiveportal_passthrumac_configure_entry
(
$macent
)
{
$cpc
=
new
Captivep
ortal\CPClient
();
$cpc
=
new
OPNsense\CaptiveP
ortal\CPClient
();
$cpc
->
update
();
return
""
;
}
function
captiveportal_passthrumac_delete_entry
(
$macent
)
{
$cpc
=
new
Captivep
ortal\CPClient
();
$cpc
=
new
OPNsense\CaptiveP
ortal\CPClient
();
$cpc
->
update
();
return
""
;
...
...
@@ -72,7 +72,7 @@ function captiveportal_passthrumac_configure($lock = false) {
}
function
captiveportal_allowedip_configure_entry
(
$ipent
,
$ishostname
=
false
)
{
$cpc
=
new
Captivep
ortal\CPClient
();
$cpc
=
new
OPNsense\CaptiveP
ortal\CPClient
();
$cpc
->
update
();
return
""
;
...
...
@@ -86,7 +86,7 @@ function captiveportal_allowedip_configure() {
function
captiveportal_disconnect_client
(
$sessionid
,
$term_cause
=
1
,
$logoutReason
=
"LOGOUT"
)
{
global
$cpzone
;
$cpc
=
new
Captivep
ortal\CPClient
();
$cpc
=
new
OPNsense\CaptiveP
ortal\CPClient
();
$cpc
->
disconnect
(
$cpzone
,
$sessionid
);
}
...
...
@@ -96,7 +96,7 @@ function captiveportal_remove_entries($remove) {
if
(
!
is_array
(
$remove
)
||
empty
(
$remove
))
return
;
$cpc
=
new
Captivep
ortal\CPClient
();
$cpc
=
new
OPNsense\CaptiveP
ortal\CPClient
();
$cpc
->
disconnect
(
$cpzone
,
$remove
);
}
...
...
@@ -120,7 +120,7 @@ function portal_allow($clientip,$clientmac,$username,$password = null, $attribut
if
(
is_null
(
$radiusctx
))
$radiusctx
=
'first'
;
$cpc
=
new
Captivep
ortal\CPClient
();
$cpc
=
new
OPNsense\CaptiveP
ortal\CPClient
();
$sessionid
=
$cpc
->
portal_allow
(
$cpzone
,
$clientip
,
$clientmac
,
$username
,
$password
,
$bw_up
,
$bw_down
,
$radiusctx
,
$session_timeout
,
$idle_timeout
,
$session_terminate_time
,
$interim_interval
);
if
(
isset
(
$config
[
'captiveportal'
][
$cpzone
][
'radacct_enable'
])
&&
!
empty
(
$radiusservers
[
$radiusctx
]))
{
...
...
@@ -199,7 +199,7 @@ function captiveportal_init_rules($reinit = false) {
//
if
(
$reinit
)
{
$cpc
=
new
Captivep
ortal\CPClient
();
$cpc
=
new
OPNsense\CaptiveP
ortal\CPClient
();
$cpc
->
reconfigure
();
unset
(
$cpc
);
}
...
...
@@ -651,7 +651,7 @@ function captiveportal_prune_old() {
if
(
empty
(
$cpzone
))
return
;
$cpc
=
new
Captivep
ortal\CPClient
();
$cpc
=
new
OPNsense\CaptiveP
ortal\CPClient
();
$cpcfg
=
$config
[
'captiveportal'
][
$cpzone
];
if
(
!
isset
(
$cpcfg
[
'radacct_enable'
]))
{
...
...
@@ -841,7 +841,7 @@ function captiveportal_radius_stop_all() {
$radiusservers
=
captiveportal_get_radius_servers
();
if
(
!
empty
(
$radiusservers
))
{
$cpdb
=
new
Captiveportal\DB
(
$cpzone
);
$cpdb
=
new
OPNsense\
Captiveportal\DB
(
$cpzone
);
$clients
=
$cpdb
->
listClients
(
array
());
...
...
src/etc/inc/voucher.inc
View file @
a2b76548
...
...
@@ -218,8 +218,8 @@ EOF;
function
voucher_expire
(
$voucher_received
)
{
global
$g
,
$config
,
$cpzone
;
$cpdb
=
new
Captivep
ortal\DB
(
$cpzone
);
$cpc
=
new
Captivep
ortal\CPClient
();
$cpdb
=
new
OPNsense\CaptiveP
ortal\DB
(
$cpzone
);
$cpc
=
new
OPNsense\CaptiveP
ortal\CPClient
();
// XMLRPC Call over to the master Voucher node
if
(
!
empty
(
$config
[
'voucher'
][
$cpzone
][
'vouchersyncdbip'
]))
{
...
...
src/opnsense/mvc/app/models/
Captivep
ortal/ARP.php
→
src/opnsense/mvc/app/models/
OPNsense/CaptiveP
ortal/ARP.php
View file @
a2b76548
...
...
@@ -30,12 +30,12 @@
function: provides access to the systems ARP table
*/
namespace
OPNsense\CaptivePortal
;
use
\OPNsense\Core
;
namespace
Captiveportal
;
class
ARP
{
class
ARP
{
/**
* pointer to shell object
...
...
@@ -46,9 +46,9 @@ class ARP {
/**
* construct new ARP table handlers
*/
function
__construct
()
public
function
__construct
()
{
$this
->
shell
=
new
\
Core\Shell
();
$this
->
shell
=
new
Core\Shell
();
}
/**
...
...
@@ -56,10 +56,13 @@ class ARP {
* @param $ipaddress hosts ipaddress
* @param $mac hosts physical address
*/
function
setStatic
(
$ipaddress
,
$mac
){
public
function
setStatic
(
$ipaddress
,
$mac
)
{
// validate input, only set static entries for valid addresses
if
(
preg_match
(
'/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/'
,
trim
(
$mac
))){
if
(
filter_var
(
$ipaddress
,
FILTER_VALIDATE_IP
,
FILTER_FLAG_IPV4
|
FILTER_FLAG_IPV6
)
){
if
(
preg_match
(
'/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/'
,
trim
(
$mac
)))
{
if
(
filter_var
(
$ipaddress
,
FILTER_VALIDATE_IP
,
FILTER_FLAG_IPV4
|
FILTER_FLAG_IPV6
)
)
{
$this
->
shell
->
exec
(
"/usr/sbin/arp -s "
.
trim
(
$ipaddress
)
.
" "
.
trim
(
$mac
));
}
}
...
...
@@ -106,4 +109,4 @@ class ARP {
}
}
\ No newline at end of file
}
\ No newline at end of file
src/opnsense/mvc/app/models/
Captivep
ortal/CPClient.php
→
src/opnsense/mvc/app/models/
OPNsense/CaptiveP
ortal/CPClient.php
View file @
a2b76548
...
...
@@ -32,12 +32,14 @@
*/
namespace
Captiveportal
;
namespace
OPNsense\CaptivePortal
;
use
\OPNsense\Core
;
/**
* Class CPClient
* // TODO: CARP interfaces are probably not handled correctly
* @package Captive
p
ortal
* @package Captive
P
ortal
*/
class
CPClient
{
...
...
@@ -50,7 +52,7 @@ class CPClient {
/**
* ipfw rule object
* @var \Captive
p
ortal\Rules
* @var \Captive
P
ortal\Rules
*/
private
$rules
=
null
;
...
...
@@ -227,9 +229,9 @@ class CPClient {
// Request handle to configuration
$this
->
config
=
\Core\Config
::
getInstance
();
// generate new ruleset
$this
->
rules
=
new
\Captiveportal\
Rules
();
$this
->
rules
=
new
Rules
();
// keep a link to the shell object
$this
->
shell
=
new
\
Core\Shell
();
$this
->
shell
=
new
Core\Shell
();
}
/**
...
...
@@ -581,7 +583,7 @@ class CPClient {
*/
function
flush
(
$zone
=
null
){
if
(
$zone
==
null
)
{
$shell
=
new
\
Core\Shell
();
$shell
=
new
Core\Shell
();
$shell
->
exec
(
"/sbin/ipfw -f table all flush"
);
}
else
{
...
...
src/opnsense/mvc/app/models/
Captivep
ortal/DB.php
→
src/opnsense/mvc/app/models/
OPNsense/CaptiveP
ortal/DB.php
View file @
a2b76548
...
...
@@ -31,11 +31,11 @@
*/
namespace
Captivep
ortal
;
namespace
OPNsense\CaptiveP
ortal
;
/**
* Class DB, handles captive portal zone's adminstration
* @package Captive
p
ortal
* @package Captive
P
ortal
*/
class
DB
{
...
...
src/opnsense/mvc/app/models/
Captivep
ortal/Rules.php
→
src/opnsense/mvc/app/models/
OPNsense/CaptiveP
ortal/Rules.php
View file @
a2b76548
...
...
@@ -31,12 +31,12 @@
*/
namespace
Captivep
ortal
;
namespace
OPNsense\CaptiveP
ortal
;
/**
* Class Rules
* @package Captive
p
ortal
* @package Captive
P
ortal
*/
class
Rules
{
...
...
src/opnsense/mvc/app/models/Core/Config.php
→
src/opnsense/mvc/app/models/
OPNsense/
Core/Config.php
View file @
a2b76548
...
...
@@ -32,7 +32,7 @@
*/
namespace
Core
;
namespace
OPNsense\
Core
;
/**
* Class ConfigException
...
...
@@ -44,7 +44,7 @@ class ConfigException extends \Exception { }
* Class Config
* @package Core
*/
class
Config
extends
\Core\
Singleton
{
class
Config
extends
Singleton
{
/**
* config file location ( path + name )
...
...
src/opnsense/mvc/app/models/Core/Shell.php
→
src/opnsense/mvc/app/models/
OPNsense/
Core/Shell.php
View file @
a2b76548
...
...
@@ -31,7 +31,7 @@
*/
namespace
Core
;
namespace
OPNsense\
Core
;
class
Shell
...
...
src/opnsense/mvc/app/models/Core/Singleton.php
→
src/opnsense/mvc/app/models/
OPNsense/
Core/Singleton.php
View file @
a2b76548
...
...
@@ -31,7 +31,7 @@
*/
namespace
Core
;
namespace
OPNsense\
Core
;
/**
...
...
src/opnsense/mvc/script/test.php
View file @
a2b76548
...
...
@@ -2,9 +2,14 @@
require_once
(
"script/load_phalcon.php"
);
$cpc
=
new
Captiveportal\CPClient
();
$acc_list
=
$cpc
->
list_accounting
();
print_r
(
$acc_list
);
//$cpc->portal_allow("test","10.211.55.101","00:1C:42:49:B7:B2","Fritsx");
$cpc
->
disconnect
(
"test"
,
array
(
"5489714eba263"
,
"gdsajhgadsjhg"
));
//
$cpc->disconnect("test",array("5489714eba263","gdsajhgadsjhg"));
//$cpc->reconfigure();
//$cpc->refresh_allowed_mac();
...
...
src/www/services_captiveportal_zones.php
View file @
a2b76548
...
...
@@ -94,7 +94,7 @@ $main_buttons = array(
</td>
<td
class=
"listr"
ondblclick=
"document.location='services_captiveportal.php?zone=
<?=
$cpzone
;
?>
';"
>
<?php
$cpdb
=
new
Captivep
ortal\DB
(
$cpzone
)
;
$cpdb
=
new
OPNsense\CaptiveP
ortal\DB
(
$cpzone
)
;
echo
$cpdb
->
countClients
()
;
?>
</td>
...
...
src/www/status_captiveportal.php
View file @
a2b76548
...
...
@@ -80,7 +80,7 @@ function clientcmp($a, $b) {
}
if
(
!
empty
(
$cpzone
))
{
$cpdb_handle
=
new
Captivep
ortal\DB
(
$cpzone
);
$cpdb_handle
=
new
OPNsense\CaptiveP
ortal\DB
(
$cpzone
);
$order
=
""
;
if
(
$_GET
[
'order'
])
{
...
...
src/www/widgets/widgets/captive_portal_status.widget.php
View file @
a2b76548
...
...
@@ -63,7 +63,7 @@ $a_cp =& $config['captiveportal'];
$cpdb_all
=
array
();
foreach
(
$a_cp
as
$cpzone
=>
$cp
)
{
$cpdb_handle
=
new
Captivep
ortal\DB
(
$cpzone
);
$cpdb_handle
=
new
OPNsense\CaptiveP
ortal\DB
(
$cpzone
);
$order
=
""
;
if
(
$_GET
[
'order'
])
{
...
...
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