mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 09:04:39 +00:00
move new classes to comply with PSR1/2 style guides, still a lot todo here...
This commit is contained in:
parent
a8641315f3
commit
a2b765486d
@ -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 Captiveportal\CPClient();
|
||||
$cpc = new OPNsense\CaptivePortal\CPClient();
|
||||
$cpc->update();
|
||||
|
||||
return "" ;
|
||||
}
|
||||
|
||||
function captiveportal_passthrumac_delete_entry($macent) {
|
||||
$cpc = new Captiveportal\CPClient();
|
||||
$cpc = new OPNsense\CaptivePortal\CPClient();
|
||||
$cpc->update();
|
||||
|
||||
return "" ;
|
||||
@ -72,7 +72,7 @@ function captiveportal_passthrumac_configure($lock = false) {
|
||||
}
|
||||
|
||||
function captiveportal_allowedip_configure_entry($ipent, $ishostname = false) {
|
||||
$cpc = new Captiveportal\CPClient();
|
||||
$cpc = new OPNsense\CaptivePortal\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 Captiveportal\CPClient();
|
||||
$cpc = new OPNsense\CaptivePortal\CPClient();
|
||||
$cpc->disconnect($cpzone,$sessionid);
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ function captiveportal_remove_entries($remove) {
|
||||
if (!is_array($remove) || empty($remove))
|
||||
return;
|
||||
|
||||
$cpc = new Captiveportal\CPClient();
|
||||
$cpc = new OPNsense\CaptivePortal\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 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);
|
||||
|
||||
if (isset($config['captiveportal'][$cpzone]['radacct_enable']) && !empty($radiusservers[$radiusctx])) {
|
||||
@ -199,7 +199,7 @@ function captiveportal_init_rules($reinit = false) {
|
||||
|
||||
//
|
||||
if ( $reinit ) {
|
||||
$cpc = new Captiveportal\CPClient();
|
||||
$cpc = new OPNsense\CaptivePortal\CPClient();
|
||||
$cpc->reconfigure();
|
||||
unset($cpc);
|
||||
}
|
||||
@ -651,7 +651,7 @@ function captiveportal_prune_old() {
|
||||
if (empty($cpzone))
|
||||
return;
|
||||
|
||||
$cpc = new Captiveportal\CPClient();
|
||||
$cpc = new OPNsense\CaptivePortal\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());
|
||||
|
||||
|
||||
@ -218,8 +218,8 @@ EOF;
|
||||
function voucher_expire($voucher_received) {
|
||||
global $g, $config, $cpzone;
|
||||
|
||||
$cpdb = new Captiveportal\DB($cpzone);
|
||||
$cpc = new Captiveportal\CPClient();
|
||||
$cpdb = new OPNsense\CaptivePortal\DB($cpzone);
|
||||
$cpc = new OPNsense\CaptivePortal\CPClient();
|
||||
|
||||
// XMLRPC Call over to the master Voucher node
|
||||
if(!empty($config['voucher'][$cpzone]['vouchersyncdbip'])) {
|
||||
|
||||
@ -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 {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -32,12 +32,14 @@
|
||||
*/
|
||||
|
||||
|
||||
namespace Captiveportal;
|
||||
namespace OPNsense\CaptivePortal;
|
||||
|
||||
use \OPNsense\Core;
|
||||
|
||||
/**
|
||||
* Class CPClient
|
||||
* // TODO: CARP interfaces are probably not handled correctly
|
||||
* @package Captiveportal
|
||||
* @package CaptivePortal
|
||||
*/
|
||||
class CPClient {
|
||||
|
||||
@ -50,7 +52,7 @@ class CPClient {
|
||||
|
||||
/**
|
||||
* ipfw rule object
|
||||
* @var \Captiveportal\Rules
|
||||
* @var \CaptivePortal\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{
|
||||
@ -31,11 +31,11 @@
|
||||
|
||||
*/
|
||||
|
||||
namespace Captiveportal;
|
||||
namespace OPNsense\CaptivePortal;
|
||||
|
||||
/**
|
||||
* Class DB, handles captive portal zone's adminstration
|
||||
* @package Captiveportal
|
||||
* @package CaptivePortal
|
||||
*/
|
||||
class DB {
|
||||
|
||||
@ -31,12 +31,12 @@
|
||||
|
||||
*/
|
||||
|
||||
namespace Captiveportal;
|
||||
namespace OPNsense\CaptivePortal;
|
||||
|
||||
|
||||
/**
|
||||
* Class Rules
|
||||
* @package Captiveportal
|
||||
* @package CaptivePortal
|
||||
*/
|
||||
class Rules {
|
||||
|
||||
@ -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 )
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
*/
|
||||
|
||||
namespace Core;
|
||||
namespace OPNsense\Core;
|
||||
|
||||
|
||||
class Shell
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
*/
|
||||
|
||||
namespace Core;
|
||||
namespace OPNsense\Core;
|
||||
|
||||
|
||||
/**
|
||||
@ -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();
|
||||
|
||||
@ -94,7 +94,7 @@ $main_buttons = array(
|
||||
</td>
|
||||
<td class="listr" ondblclick="document.location='services_captiveportal.php?zone=<?=$cpzone;?>';">
|
||||
<?php
|
||||
$cpdb = new Captiveportal\DB($cpzone) ;
|
||||
$cpdb = new OPNsense\CaptivePortal\DB($cpzone) ;
|
||||
echo $cpdb->countClients() ;
|
||||
?>
|
||||
</td>
|
||||
|
||||
@ -80,7 +80,7 @@ function clientcmp($a, $b) {
|
||||
}
|
||||
|
||||
if (!empty($cpzone)) {
|
||||
$cpdb_handle = new Captiveportal\DB($cpzone);
|
||||
$cpdb_handle = new OPNsense\CaptivePortal\DB($cpzone);
|
||||
|
||||
$order = "";
|
||||
if ($_GET['order']) {
|
||||
|
||||
@ -63,7 +63,7 @@ $a_cp =& $config['captiveportal'];
|
||||
$cpdb_all = array();
|
||||
|
||||
foreach ($a_cp as $cpzone => $cp) {
|
||||
$cpdb_handle = new Captiveportal\DB($cpzone);
|
||||
$cpdb_handle = new OPNsense\CaptivePortal\DB($cpzone);
|
||||
|
||||
$order = "";
|
||||
if ($_GET['order']) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user