Commit a2b76548 authored by Ad Schellevis's avatar Ad Schellevis

move new classes to comply with PSR1/2 style guides, still a lot todo here...

parent a8641315
...@@ -54,14 +54,14 @@ require_once("script/load_phalcon.php"); ...@@ -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 // TODO : restructure code / gui, for now we try to maintain gui compatibility by not breaking the old callbacks
// //
function captiveportal_passthrumac_configure_entry($macent) { function captiveportal_passthrumac_configure_entry($macent) {
$cpc = new Captiveportal\CPClient(); $cpc = new OPNsense\CaptivePortal\CPClient();
$cpc->update(); $cpc->update();
return "" ; return "" ;
} }
function captiveportal_passthrumac_delete_entry($macent) { function captiveportal_passthrumac_delete_entry($macent) {
$cpc = new Captiveportal\CPClient(); $cpc = new OPNsense\CaptivePortal\CPClient();
$cpc->update(); $cpc->update();
return "" ; return "" ;
...@@ -72,7 +72,7 @@ function captiveportal_passthrumac_configure($lock = false) { ...@@ -72,7 +72,7 @@ function captiveportal_passthrumac_configure($lock = false) {
} }
function captiveportal_allowedip_configure_entry($ipent, $ishostname = false) { function captiveportal_allowedip_configure_entry($ipent, $ishostname = false) {
$cpc = new Captiveportal\CPClient(); $cpc = new OPNsense\CaptivePortal\CPClient();
$cpc->update(); $cpc->update();
return "" ; return "" ;
...@@ -86,7 +86,7 @@ function captiveportal_allowedip_configure() { ...@@ -86,7 +86,7 @@ function captiveportal_allowedip_configure() {
function captiveportal_disconnect_client($sessionid, $term_cause = 1, $logoutReason = "LOGOUT") { function captiveportal_disconnect_client($sessionid, $term_cause = 1, $logoutReason = "LOGOUT") {
global $cpzone; global $cpzone;
$cpc = new Captiveportal\CPClient(); $cpc = new OPNsense\CaptivePortal\CPClient();
$cpc->disconnect($cpzone,$sessionid); $cpc->disconnect($cpzone,$sessionid);
} }
...@@ -96,7 +96,7 @@ function captiveportal_remove_entries($remove) { ...@@ -96,7 +96,7 @@ function captiveportal_remove_entries($remove) {
if (!is_array($remove) || empty($remove)) if (!is_array($remove) || empty($remove))
return; return;
$cpc = new Captiveportal\CPClient(); $cpc = new OPNsense\CaptivePortal\CPClient();
$cpc->disconnect($cpzone,$remove); $cpc->disconnect($cpzone,$remove);
} }
...@@ -120,7 +120,7 @@ function portal_allow($clientip,$clientmac,$username,$password = null, $attribut ...@@ -120,7 +120,7 @@ function portal_allow($clientip,$clientmac,$username,$password = null, $attribut
if (is_null($radiusctx)) if (is_null($radiusctx))
$radiusctx = 'first'; $radiusctx = 'first';
$cpc = new Captiveportal\CPClient(); $cpc = new OPNsense\CaptivePortal\CPClient();
$sessionid = $cpc->portal_allow($cpzone,$clientip,$clientmac,$username,$password,$bw_up,$bw_down,$radiusctx,$session_timeout,$idle_timeout,$session_terminate_time,$interim_interval); $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])) { if (isset($config['captiveportal'][$cpzone]['radacct_enable']) && !empty($radiusservers[$radiusctx])) {
...@@ -199,7 +199,7 @@ function captiveportal_init_rules($reinit = false) { ...@@ -199,7 +199,7 @@ function captiveportal_init_rules($reinit = false) {
// //
if ( $reinit ) { if ( $reinit ) {
$cpc = new Captiveportal\CPClient(); $cpc = new OPNsense\CaptivePortal\CPClient();
$cpc->reconfigure(); $cpc->reconfigure();
unset($cpc); unset($cpc);
} }
...@@ -651,7 +651,7 @@ function captiveportal_prune_old() { ...@@ -651,7 +651,7 @@ function captiveportal_prune_old() {
if (empty($cpzone)) if (empty($cpzone))
return; return;
$cpc = new Captiveportal\CPClient(); $cpc = new OPNsense\CaptivePortal\CPClient();
$cpcfg = $config['captiveportal'][$cpzone]; $cpcfg = $config['captiveportal'][$cpzone];
if ( !isset($cpcfg['radacct_enable'])) { if ( !isset($cpcfg['radacct_enable'])) {
...@@ -841,7 +841,7 @@ function captiveportal_radius_stop_all() { ...@@ -841,7 +841,7 @@ function captiveportal_radius_stop_all() {
$radiusservers = captiveportal_get_radius_servers(); $radiusservers = captiveportal_get_radius_servers();
if (!empty($radiusservers)) { if (!empty($radiusservers)) {
$cpdb = new Captiveportal\DB($cpzone); $cpdb = new OPNsense\Captiveportal\DB($cpzone);
$clients = $cpdb->listClients(array()); $clients = $cpdb->listClients(array());
......
...@@ -218,8 +218,8 @@ EOF; ...@@ -218,8 +218,8 @@ EOF;
function voucher_expire($voucher_received) { function voucher_expire($voucher_received) {
global $g, $config, $cpzone; global $g, $config, $cpzone;
$cpdb = new Captiveportal\DB($cpzone); $cpdb = new OPNsense\CaptivePortal\DB($cpzone);
$cpc = new Captiveportal\CPClient(); $cpc = new OPNsense\CaptivePortal\CPClient();
// XMLRPC Call over to the master Voucher node // XMLRPC Call over to the master Voucher node
if(!empty($config['voucher'][$cpzone]['vouchersyncdbip'])) { if(!empty($config['voucher'][$cpzone]['vouchersyncdbip'])) {
......
...@@ -30,12 +30,12 @@ ...@@ -30,12 +30,12 @@
function: provides access to the systems ARP table function: provides access to the systems ARP table
*/ */
namespace OPNsense\CaptivePortal;
use \OPNsense\Core;
namespace Captiveportal; class ARP
{
class ARP {
/** /**
* pointer to shell object * pointer to shell object
...@@ -46,9 +46,9 @@ class ARP { ...@@ -46,9 +46,9 @@ class ARP {
/** /**
* construct new ARP table handlers * 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 { ...@@ -56,10 +56,13 @@ class ARP {
* @param $ipaddress hosts ipaddress * @param $ipaddress hosts ipaddress
* @param $mac hosts physical address * @param $mac hosts physical address
*/ */
function setStatic($ipaddress,$mac){ public function setStatic($ipaddress, $mac)
{
// validate input, only set static entries for valid addresses // 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 (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 ( filter_var($ipaddress , FILTER_VALIDATE_IP, FILTER_FLAG_IPV4|FILTER_FLAG_IPV6) )
{
$this->shell->exec("/usr/sbin/arp -s ".trim($ipaddress)." ".trim($mac)); $this->shell->exec("/usr/sbin/arp -s ".trim($ipaddress)." ".trim($mac));
} }
} }
......
...@@ -32,12 +32,14 @@ ...@@ -32,12 +32,14 @@
*/ */
namespace Captiveportal; namespace OPNsense\CaptivePortal;
use \OPNsense\Core;
/** /**
* Class CPClient * Class CPClient
* // TODO: CARP interfaces are probably not handled correctly * // TODO: CARP interfaces are probably not handled correctly
* @package Captiveportal * @package CaptivePortal
*/ */
class CPClient { class CPClient {
...@@ -50,7 +52,7 @@ class CPClient { ...@@ -50,7 +52,7 @@ class CPClient {
/** /**
* ipfw rule object * ipfw rule object
* @var \Captiveportal\Rules * @var \CaptivePortal\Rules
*/ */
private $rules = null; private $rules = null;
...@@ -227,9 +229,9 @@ class CPClient { ...@@ -227,9 +229,9 @@ class CPClient {
// Request handle to configuration // Request handle to configuration
$this->config = \Core\Config::getInstance(); $this->config = \Core\Config::getInstance();
// generate new ruleset // generate new ruleset
$this->rules = new \Captiveportal\Rules(); $this->rules = new Rules();
// keep a link to the shell object // keep a link to the shell object
$this->shell = new \Core\Shell(); $this->shell = new Core\Shell();
} }
/** /**
...@@ -581,7 +583,7 @@ class CPClient { ...@@ -581,7 +583,7 @@ class CPClient {
*/ */
function flush($zone=null){ function flush($zone=null){
if ( $zone == null ) { if ( $zone == null ) {
$shell = new \Core\Shell(); $shell = new Core\Shell();
$shell->exec("/sbin/ipfw -f table all flush"); $shell->exec("/sbin/ipfw -f table all flush");
} }
else{ else{
......
...@@ -31,11 +31,11 @@ ...@@ -31,11 +31,11 @@
*/ */
namespace Captiveportal; namespace OPNsense\CaptivePortal;
/** /**
* Class DB, handles captive portal zone's adminstration * Class DB, handles captive portal zone's adminstration
* @package Captiveportal * @package CaptivePortal
*/ */
class DB { class DB {
......
...@@ -31,12 +31,12 @@ ...@@ -31,12 +31,12 @@
*/ */
namespace Captiveportal; namespace OPNsense\CaptivePortal;
/** /**
* Class Rules * Class Rules
* @package Captiveportal * @package CaptivePortal
*/ */
class Rules { class Rules {
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
*/ */
namespace Core; namespace OPNsense\Core;
/** /**
* Class ConfigException * Class ConfigException
...@@ -44,7 +44,7 @@ class ConfigException extends \Exception { } ...@@ -44,7 +44,7 @@ class ConfigException extends \Exception { }
* Class Config * Class Config
* @package Core * @package Core
*/ */
class Config extends \Core\Singleton { class Config extends Singleton {
/** /**
* config file location ( path + name ) * config file location ( path + name )
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
*/ */
namespace Core; namespace OPNsense\Core;
class Shell class Shell
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
*/ */
namespace Core; namespace OPNsense\Core;
/** /**
......
...@@ -2,9 +2,14 @@ ...@@ -2,9 +2,14 @@
require_once("script/load_phalcon.php"); require_once("script/load_phalcon.php");
$cpc = new Captiveportal\CPClient(); $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->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->reconfigure();
//$cpc->refresh_allowed_mac(); //$cpc->refresh_allowed_mac();
......
...@@ -94,7 +94,7 @@ $main_buttons = array( ...@@ -94,7 +94,7 @@ $main_buttons = array(
</td> </td>
<td class="listr" ondblclick="document.location='services_captiveportal.php?zone=<?=$cpzone;?>';"> <td class="listr" ondblclick="document.location='services_captiveportal.php?zone=<?=$cpzone;?>';">
<?php <?php
$cpdb = new Captiveportal\DB($cpzone) ; $cpdb = new OPNsense\CaptivePortal\DB($cpzone) ;
echo $cpdb->countClients() ; echo $cpdb->countClients() ;
?> ?>
</td> </td>
......
...@@ -80,7 +80,7 @@ function clientcmp($a, $b) { ...@@ -80,7 +80,7 @@ function clientcmp($a, $b) {
} }
if (!empty($cpzone)) { if (!empty($cpzone)) {
$cpdb_handle = new Captiveportal\DB($cpzone); $cpdb_handle = new OPNsense\CaptivePortal\DB($cpzone);
$order = ""; $order = "";
if ($_GET['order']) { if ($_GET['order']) {
......
...@@ -63,7 +63,7 @@ $a_cp =& $config['captiveportal']; ...@@ -63,7 +63,7 @@ $a_cp =& $config['captiveportal'];
$cpdb_all = array(); $cpdb_all = array();
foreach ($a_cp as $cpzone => $cp) { foreach ($a_cp as $cpzone => $cp) {
$cpdb_handle = new Captiveportal\DB($cpzone); $cpdb_handle = new OPNsense\CaptivePortal\DB($cpzone);
$order = ""; $order = "";
if ($_GET['order']) { if ($_GET['order']) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment