plugins: style sweep

This commit is contained in:
Franco Fichtner
2019-03-19 08:20:18 +01:00
parent a2b4dab129
commit 0498c2247f
5 changed files with 25 additions and 22 deletions
@@ -34,6 +34,6 @@ use OPNsense\Base\ApiMutableModelControllerBase;
class GeneralController extends ApiMutableModelControllerBase
{
static protected $internalModelClass = '\OPNsense\Zabbixproxy\General';
static protected $internalModelName = 'general';
protected static $internalModelClass = '\OPNsense\Zabbixproxy\General';
protected static $internalModelName = 'general';
}
@@ -40,8 +40,8 @@ use OPNsense\Zabbixproxy\General;
*/
class ServiceController extends ApiMutableServiceControllerBase
{
static protected $internalServiceClass = '\OPNsense\Zabbixproxy\General';
static protected $internalServiceTemplate = 'OPNsense/Zabbixproxy';
static protected $internalServiceEnabled = 'enabled';
static protected $internalServiceName = 'zabbixproxy';
protected static $internalServiceClass = '\OPNsense\Zabbixproxy\General';
protected static $internalServiceTemplate = 'OPNsense/Zabbixproxy';
protected static $internalServiceEnabled = 'enabled';
protected static $internalServiceName = 'zabbixproxy';
}
@@ -34,8 +34,8 @@ use \OPNsense\Base\ApiMutableModelControllerBase;
class DhcpController extends ApiMutableModelControllerBase
{
static protected $internalModelName = 'dhcp';
static protected $internalModelClass = '\OPNsense\Freeradius\Dhcp';
protected static $internalModelName = 'dhcp';
protected static $internalModelClass = '\OPNsense\Freeradius\Dhcp';
public function searchDhcpAction()
{
@@ -34,8 +34,8 @@ use \OPNsense\Base\ApiMutableModelControllerBase;
class LeaseController extends ApiMutableModelControllerBase
{
static protected $internalModelName = 'lease';
static protected $internalModelClass = '\OPNsense\Freeradius\Lease';
protected static $internalModelName = 'lease';
protected static $internalModelClass = '\OPNsense\Freeradius\Lease';
public function searchLeaseAction()
{
@@ -39,7 +39,8 @@ use OPNsense\AcmeClient\AcmeClient;
$HIGHWINDS_API_URL = 'https://striketracker.highwinds.com/api/v1/accounts';
function find_certificate($acme_cert_id) {
function find_certificate($acme_cert_id)
{
$modelObj = new OPNsense\AcmeClient\AcmeClient;
$configObj = Config::getInstance()->object();
if (isset($configObj->OPNsense->AcmeClient->certificates) && $configObj->OPNsense->AcmeClient->certificates->count() > 0) {
@@ -66,7 +67,8 @@ function find_certificate($acme_cert_id) {
}
}
function export_certificate($cert_refid) {
function export_certificate($cert_refid)
{
$configObj = Config::getInstance()->object();
foreach ($configObj->cert as $cert) {
if ($cert_refid == (string)$cert->refid) {
@@ -74,9 +76,9 @@ function export_certificate($cert_refid) {
$key_content = str_replace("\n\n", "\n", str_replace("\r", "", base64_decode((string)$cert->prv)));
// check if a CA is linked
if (!empty((string)$cert->caref)) {
$cert = (array)$cert;
$ca = ca_chain($cert);
$ca_content = $ca;
$cert = (array)$cert;
$ca = ca_chain($cert);
$ca_content = $ca;
}
$result = array();
$result['cert'] = $cert_content;
@@ -89,7 +91,8 @@ function export_certificate($cert_refid) {
return None;
}
function upload_certificate($cert_name,$cert_refid,$acme_cert_id,$acme_automation_id) {
function upload_certificate($cert_name, $cert_refid, $acme_cert_id, $acme_automation_id)
{
$modelObj = new OPNsense\AcmeClient\AcmeClient;
$configObj = Config::getInstance()->object();
if (isset($configObj->OPNsense->AcmeClient->actions) && $configObj->OPNsense->AcmeClient->actions->count() > 0) {
@@ -105,7 +108,7 @@ function upload_certificate($cert_name,$cert_refid,$acme_cert_id,$acme_automatio
$hw_access_token = (string)$automObj->highwinds_access_token;
$cert_data = export_certificate($cert_refid);
if ($cert_data !== None) {
$hw_result = hw_upload_certificate($hw_account_hash,$hw_access_token,$cert_name,$cert_data);
$hw_result = hw_upload_certificate($hw_account_hash, $hw_access_token, $cert_name, $cert_data);
if ($hw_result !== None) {
return true;
}
@@ -120,7 +123,7 @@ function upload_certificate($cert_name,$cert_refid,$acme_cert_id,$acme_automatio
}
}
function hw_list_certificates($account_hash,$access_token)
function hw_list_certificates($account_hash, $access_token)
{
global $HIGHWINDS_API_URL;
$curl = curl_init();
@@ -150,9 +153,9 @@ function hw_list_certificates($account_hash,$access_token)
return json_decode($response);
}
function hw_get_certificate($account_hash,$access_token,$cert_name)
function hw_get_certificate($account_hash, $access_token, $cert_name)
{
$certificates = hw_list_certificates($account_hash,$access_token);
$certificates = hw_list_certificates($account_hash, $access_token);
if ($certificates !== None) {
foreach ($certificates->list as $cert) {
if ($cert->commonName == $cert_name) {
@@ -163,11 +166,11 @@ function hw_get_certificate($account_hash,$access_token,$cert_name)
return None;
}
function hw_upload_certificate($account_hash,$access_token,$cert_name,$cert_data)
function hw_upload_certificate($account_hash, $access_token, $cert_name, $cert_data)
{
global $HIGHWINDS_API_URL;
// Check current status of certificate at Highwinds
$hw_cert = hw_get_certificate($account_hash,$access_token,$cert_name);
$hw_cert = hw_get_certificate($account_hash, $access_token, $cert_name);
$hw_url = 'certificates';
if ($hw_cert == None) {
log_error("AcmeClient: cert for ${cert_name} not found in Highwinds API, starting upload...");