diff --git a/net/haproxy/src/opnsense/mvc/app/controllers/OPNsense/HAProxy/Api/SettingsController.php b/net/haproxy/src/opnsense/mvc/app/controllers/OPNsense/HAProxy/Api/SettingsController.php index d63cf323f..588a480e3 100644 --- a/net/haproxy/src/opnsense/mvc/app/controllers/OPNsense/HAProxy/Api/SettingsController.php +++ b/net/haproxy/src/opnsense/mvc/app/controllers/OPNsense/HAProxy/Api/SettingsController.php @@ -121,7 +121,6 @@ class SettingsController extends ApiControllerBase $cnf->save(); $result["result"] = "saved"; } - } return $result; @@ -143,7 +142,7 @@ class SettingsController extends ApiControllerBase } } else { // generate new node, but don't save to disc - $node = $mdlCP->frontends->frontend->add() ; + $node = $mdlCP->frontends->frontend->add(); return array("frontend" => $node->getNodes()); } return array(); @@ -273,7 +272,7 @@ class SettingsController extends ApiControllerBase } } else { // generate new node, but don't save to disc - $node = $mdlCP->backends->backend->add() ; + $node = $mdlCP->backends->backend->add(); return array("backend" => $node->getNodes()); } return array(); @@ -403,7 +402,7 @@ class SettingsController extends ApiControllerBase } } else { // generate new node, but don't save to disc - $node = $mdlCP->servers->server->add() ; + $node = $mdlCP->servers->server->add(); return array("server" => $node->getNodes()); } return array(); @@ -501,7 +500,7 @@ class SettingsController extends ApiControllerBase } } else { // generate new node, but don't save to disc - $node = $mdlCP->healthchecks->healthcheck->add() ; + $node = $mdlCP->healthchecks->healthcheck->add(); return array("healthcheck" => $node->getNodes()); } return array(); @@ -599,7 +598,7 @@ class SettingsController extends ApiControllerBase } } else { // generate new node, but don't save to disc - $node = $mdlCP->acls->acl->add() ; + $node = $mdlCP->acls->acl->add(); return array("acl" => $node->getNodes()); } return array(); @@ -697,7 +696,7 @@ class SettingsController extends ApiControllerBase } } else { // generate new node, but don't save to disc - $node = $mdlCP->actions->action->add() ; + $node = $mdlCP->actions->action->add(); return array("action" => $node->getNodes()); } return array(); @@ -795,7 +794,7 @@ class SettingsController extends ApiControllerBase } } else { // generate new node, but don't save to disc - $node = $mdlCP->luas->lua->add() ; + $node = $mdlCP->luas->lua->add(); return array("lua" => $node->getNodes()); } return array(); @@ -925,7 +924,7 @@ class SettingsController extends ApiControllerBase } } else { // generate new node, but don't save to disc - $node = $mdlCP->errorfiles->errorfile->add() ; + $node = $mdlCP->errorfiles->errorfile->add(); return array("errorfile" => $node->getNodes()); } return array(); diff --git a/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.php b/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.php index 742303782..ab3e2a460 100644 --- a/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.php +++ b/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.php @@ -42,7 +42,7 @@ class HAProxy extends BaseModel * @param $checkFrontends bool enable in-depth check (1 or more active frontends) * @return bool is the HAProxy service enabled */ - public function isEnabled($checkFrontends=true) + public function isEnabled($checkFrontends = true) { if ((string)$this->general->enabled === "1") { if ($checkFrontends === true) { @@ -267,7 +267,7 @@ class HAProxy extends BaseModel // Check if the ACL is already linked to the Action. $linkedAcls = (string)$action->linkedAcls; if (!empty($linkedAcls) and !($replace)) { - if (strpos($linkedAcls,$acl_uuid) !== false) { + if (strpos($linkedAcls, $acl_uuid) !== false) { // Match! Nothing to do. return $acl_uuid; } else { @@ -307,7 +307,7 @@ class HAProxy extends BaseModel // Check if the server is already linked to the backend. $linkedServers = (string)$backend->linkedServers; if (!empty($linkedServers) and !($replace)) { - if (strpos($linkedServers,$server_uuid) !== false) { + if (strpos($linkedServers, $server_uuid) !== false) { // Match! Nothing to do. return $server_uuid; } else { @@ -347,7 +347,7 @@ class HAProxy extends BaseModel // Check if the action is already linked to the frontend. $linkedActions = (string)$frontend->linkedActions; if (!empty($linkedActions) and !($replace)) { - if (strpos($linkedActions,$action_uuid) !== false) { + if (strpos($linkedActions, $action_uuid) !== false) { // Match! Nothing to do. return $action_uuid; } else { diff --git a/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/exportCerts.php b/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/exportCerts.php index 02e70a1f7..be70a6a70 100755 --- a/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/exportCerts.php +++ b/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/exportCerts.php @@ -35,6 +35,7 @@ require_once("config.inc"); require_once("certs.inc"); require_once("legacy_bindings.inc"); use OPNsense\Core\Config; + global $config; // configure ssl elements @@ -65,7 +66,7 @@ foreach ($configNodes as $key => $value) { if ($cert_refid == (string)$cert->refid) { $pem_content = ''; // CRLs require special export - if ( $type == 'crl' ) { + if ($type == 'crl') { $crl =& lookup_crl($cert_refid); crl_update($crl); $pem_content = base64_decode($crl['text']); @@ -74,7 +75,7 @@ foreach ($configNodes as $key => $value) { $pem_content .= "\n" . str_replace("\n\n", "\n", str_replace("\r", "", base64_decode((string)$cert->prv))); } // generate pem file - $output_pem_filename = "/var/etc/haproxy/ssl/" . $cert_refid . ".pem" ; + $output_pem_filename = "/var/etc/haproxy/ssl/" . $cert_refid . ".pem"; file_put_contents($output_pem_filename, $pem_content); chmod($output_pem_filename, 0600); echo "exported $type to " . $output_pem_filename . "\n"; diff --git a/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/exportErrorFiles.php b/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/exportErrorFiles.php index ce82cf8c0..48c843c8b 100755 --- a/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/exportErrorFiles.php +++ b/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/exportErrorFiles.php @@ -35,6 +35,7 @@ require_once("config.inc"); require_once("certs.inc"); require_once("legacy_bindings.inc"); use OPNsense\Core\Config; + global $config; // traverse HAProxy error files @@ -45,7 +46,7 @@ if (isset($configObj->OPNsense->HAProxy->errorfiles)) { $ef_id = (string)$errorfile->id; if ($ef_id != "") { $ef_content = htmlspecialchars_decode(str_replace("\r", "", (string)$errorfile->content)); - $ef_filename = "/var/etc/haproxy/errorfiles/" . $ef_id . ".txt" ; + $ef_filename = "/var/etc/haproxy/errorfiles/" . $ef_id . ".txt"; file_put_contents($ef_filename, $ef_content); chmod($ef_filename, 0600); echo "error file exported to " . $ef_filename . "\n"; diff --git a/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/exportLuaScripts.php b/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/exportLuaScripts.php index 04ac6aaca..b4bc1ebc4 100755 --- a/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/exportLuaScripts.php +++ b/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/exportLuaScripts.php @@ -35,6 +35,7 @@ require_once("config.inc"); require_once("certs.inc"); require_once("legacy_bindings.inc"); use OPNsense\Core\Config; + global $config; // traverse HAProxy Lua scripts @@ -48,7 +49,7 @@ if (isset($configObj->OPNsense->HAProxy->luas)) { $lua_id = (string)$lua->id; if ($lua_id != "") { $lua_content = htmlspecialchars_decode(str_replace("\r", "", (string)$lua->content)); - $lua_filename = "/var/etc/haproxy/lua/" . $lua_id . ".lua" ; + $lua_filename = "/var/etc/haproxy/lua/" . $lua_id . ".lua"; file_put_contents($lua_filename, $lua_content); chmod($lua_filename, 0600); echo "lua script exported to " . $lua_filename . "\n"; diff --git a/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/queryStats.php b/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/queryStats.php index 0a37868c6..a9b9a47d1 100755 --- a/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/queryStats.php +++ b/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/queryStats.php @@ -31,7 +31,8 @@ $haproxy_socket = '/var/run/haproxy.socket'; -function socketCmd($command) { +function socketCmd($command) +{ global $haproxy_socket; $data = array(); if (!file_exists($haproxy_socket)) { @@ -52,22 +53,28 @@ function socketCmd($command) { return $data; } -function showInfo() { +function showInfo() +{ $data = array(); $show_info = socketCmd('show info'); - foreach ($show_info as $line ) { - if (empty(trim($line))) continue; + foreach ($show_info as $line) { + if (empty(trim($line))) { + continue; + } $values = explode(':', $line); $data[trim($values[0])] = trim($values[1]); } return $data; } -function showTable() { +function showTable() +{ $data = array(); $show_table = socketCmd('show table'); foreach ($show_table as $line) { - if (empty(trim($line))) continue; + if (empty(trim($line))) { + continue; + } $line = preg_replace('/#/', '', $line); $values = explode(',', $line); $items = array(); @@ -80,18 +87,21 @@ function showTable() { return $data; } -function showStat() { +function showStat() +{ $show_stat = socketCmd('show stat'); // output is a list of CSV $stat_csv = array_map('str_getcsv', $show_stat); - array_walk($stat_csv, function(&$a) use ($stat_csv) { + array_walk($stat_csv, function (&$a) use ($stat_csv) { // XXX: Ignore empty/incomplete entries. - if (count($a) > 1) $a = array_combine($stat_csv[0], $a); + if (count($a) > 1) { + $a = array_combine($stat_csv[0], $a); + } }); array_shift($stat_csv); # remove column header foreach ($stat_csv as &$value) { // Add unique identifier. - if ( ! empty($value['pxname']) and $value['pxname'] != null ) { + if (! empty($value['pxname']) and $value['pxname'] != null) { $value['id'] = $value['pxname'] . '/' . $value['svname']; } } diff --git a/net/wol/src/etc/inc/plugins.inc.d/wol.inc b/net/wol/src/etc/inc/plugins.inc.d/wol.inc index b4af53934..b42a2b123 100644 --- a/net/wol/src/etc/inc/plugins.inc.d/wol.inc +++ b/net/wol/src/etc/inc/plugins.inc.d/wol.inc @@ -38,4 +38,3 @@ function wol_xmlrpc_sync() return $result; } - diff --git a/security/acme-client/src/etc/inc/plugins.inc.d/acmeclient.inc b/security/acme-client/src/etc/inc/plugins.inc.d/acmeclient.inc index 52f93a5f5..0dc25a115 100644 --- a/security/acme-client/src/etc/inc/plugins.inc.d/acmeclient.inc +++ b/security/acme-client/src/etc/inc/plugins.inc.d/acmeclient.inc @@ -31,7 +31,7 @@ function acmeclient_enabled() global $config; return isset($config['OPNsense']['AcmeClient']['settings']['enabled']) && - $config['OPNsense']['AcmeClient']['settings']['enabled'] == 1; + $config['OPNsense']['AcmeClient']['settings']['enabled'] == 1; } function acmeclient_firewall($fw) diff --git a/security/acme-client/src/opnsense/mvc/app/controllers/OPNsense/AcmeClient/Api/SettingsController.php b/security/acme-client/src/opnsense/mvc/app/controllers/OPNsense/AcmeClient/Api/SettingsController.php index b62ce4f80..ea5083510 100644 --- a/security/acme-client/src/opnsense/mvc/app/controllers/OPNsense/AcmeClient/Api/SettingsController.php +++ b/security/acme-client/src/opnsense/mvc/app/controllers/OPNsense/AcmeClient/Api/SettingsController.php @@ -307,11 +307,11 @@ class SettingsController extends ApiMutableModelControllerBase $mdlAcme->settings->haproxyBackendRef = $backend_uuid; // Link new ACL to HAProxy action - $link_acl_result = $mdlHAProxy->linkAclToAction($acl_uuid,$action_uuid); + $link_acl_result = $mdlHAProxy->linkAclToAction($acl_uuid, $action_uuid); //$this->getLogger()->error("LE link acl result: ${link_acl_result}"); // Link new server to HAProxy backend - $link_server_result = $mdlHAProxy->linkServerToBackend($server_uuid,$backend_uuid); + $link_server_result = $mdlHAProxy->linkServerToBackend($server_uuid, $backend_uuid); //$this->getLogger()->error("LE link server result: ${link_server_result}"); } @@ -331,7 +331,7 @@ class SettingsController extends ApiMutableModelControllerBase if (!empty((string)$frontend->id)) { // Check if the HAProxy ACME Action is linked to this frontend. $_actions = $frontend->linkedActions; - if (strpos($_actions,$action_ref) !== false) { + if (strpos($_actions, $action_ref) !== false) { // Match! Nothing to do. } else { // Link to ACME Action is currently missing: add it! @@ -368,7 +368,6 @@ class SettingsController extends ApiMutableModelControllerBase $backend->configdRun('template reload OPNsense/HAProxy'); $response = $backend->configdRun("haproxy restart"); } - } else { // NOTE: HAProxy integration is NOT removed if the user disables it, because // we might destroy changes made by the user when doing so. diff --git a/security/acme-client/src/opnsense/mvc/app/models/OPNsense/AcmeClient/AcmeClient.php b/security/acme-client/src/opnsense/mvc/app/models/OPNsense/AcmeClient/AcmeClient.php index 16452ee88..09a07e485 100644 --- a/security/acme-client/src/opnsense/mvc/app/models/OPNsense/AcmeClient/AcmeClient.php +++ b/security/acme-client/src/opnsense/mvc/app/models/OPNsense/AcmeClient/AcmeClient.php @@ -58,7 +58,7 @@ class AcmeClient extends BaseModel * @param $checkCertificates bool enable in-depth check (1 or more active certificates) * @return bool is the AcmeClient service enabled */ - public function isEnabled($checkCertificates=false) + public function isEnabled($checkCertificates = false) { if ((string)$this->settings->enabled === "1") { if ($checkCertificates === true) { diff --git a/security/acme-client/src/opnsense/scripts/OPNsense/AcmeClient/certhelper.php b/security/acme-client/src/opnsense/scripts/OPNsense/AcmeClient/certhelper.php index 6c4c6aa0a..f6c417c4e 100755 --- a/security/acme-client/src/opnsense/scripts/OPNsense/AcmeClient/certhelper.php +++ b/security/acme-client/src/opnsense/scripts/OPNsense/AcmeClient/certhelper.php @@ -115,7 +115,7 @@ function cert_action_validator($opt_cert_id) $modelObj = new OPNsense\AcmeClient\AcmeClient; // Store certs here after successful issue/renewal. Required for restart actions. - $restart_certs = Array(); + $restart_certs = array(); // Search for cert ID in configuration $configObj = Config::getInstance()->object(); @@ -874,7 +874,7 @@ function run_restart_actions($certlist, $modelObj) $return = 0; // NOTE: Do NOT run any restart action twice, collect duplicates first. - $restart_actions = Array(); + $restart_actions = array(); // Check if there's something to do. if (!empty($certlist) and is_array($certlist)) { @@ -889,7 +889,7 @@ function run_restart_actions($certlist, $modelObj) $_actions = explode(',', $certObj->restartActions); // Walk through all linked restart actions. $_actions = explode(',', $certObj->restartActions); - foreach ($_actions as $_action ) { + foreach ($_actions as $_action) { // Extract restart action $action = $modelObj->getByActionID($_action); // Make sure the object is functional. @@ -965,14 +965,12 @@ function run_restart_actions($certlist, $modelObj) fclose($proc_pipes[0]); // Wait until process terminates normally - while(is_resource($proc)) - { + while (is_resource($proc)) { $proc_stdout .= stream_get_contents($proc_pipes[1]); $proc_stderr .= stream_get_contents($proc_pipes[2]); // Check if timeout is reached - if(($timeout !== false) and ((time() - $starttime) > $timeout)) - { + if (($timeout !== false) and ((time() - $starttime) > $timeout)) { // Terminate process if timeout is reached log_error("AcmeClient: timeout running restart action: " . $action->name); proc_terminate($proc, 9); @@ -982,8 +980,7 @@ function run_restart_actions($certlist, $modelObj) // Check if process terminated normally $status = proc_get_status($proc); - if(!$status['running']) - { + if (!$status['running']) { fclose($proc_pipes[1]); fclose($proc_pipes[2]); proc_close($proc);