Commit b08d5827 authored by Franco Fichtner's avatar Franco Fichtner

src/opnsense: apply style here too

parent c91304c9
......@@ -35,6 +35,7 @@ require_once("config.inc");
require_once("certs.inc");
require_once("legacy_bindings.inc");
use OPNsense\Core\Config;
global $config;
// traverse captive portal zones
......@@ -48,17 +49,26 @@ if (isset($configObj->OPNsense->captiveportal->zones)) {
foreach ($configObj->cert as $cert) {
if ($cert_refid == (string)$cert->refid) {
// generate cert pem file
$pem_content = trim(str_replace("\n\n", "\n", str_replace("\r", "", base64_decode((string)$cert->crt))));
$pem_content = trim(str_replace("\n\n", "\n", str_replace(
"\r",
"",
base64_decode((string)$cert->crt)
)));
$pem_content .= "\n";
$pem_content .= trim(str_replace("\n\n", "\n", str_replace("\r", "", base64_decode((string)$cert->prv))));
$pem_content .= trim(str_replace(
"\n\n",
"\n",
str_replace("\r", "", base64_decode((string)$cert->prv))
));
$pem_content .= "\n";
$output_pem_filename = "/var/etc/cert-cp-zone" . $zone_id . ".pem" ;
$output_pem_filename = "/var/etc/cert-cp-zone" . $zone_id . ".pem";
file_put_contents($output_pem_filename, $pem_content);
chmod($output_pem_filename, 0600);
echo "certificate generated " .$output_pem_filename . "\n";
// generate ca pem file
if (!empty($cert->caref)) {
$output_pem_filename = "/var/etc/ca-cp-zone" . $zone_id . ".pem" ;
$output_pem_filename = "/var/etc/ca-cp-zone" . $zone_id . ".pem";
$cert = (array)$cert;
$ca = ca_chain($cert);
file_put_contents($output_pem_filename, $ca);
......
......@@ -55,7 +55,7 @@ $result = $db->query('
// process all sessions
if ($result !== false) {
while($row = $result->fetchArray(SQLITE3_ASSOC) ){
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
$authFactory = new OPNsense\Auth\AuthenticationFactory();
$authenticator = $authFactory->get($row['authenticated_via']);
if ($authenticator != null) {
......@@ -66,11 +66,11 @@ if ($result !== false) {
$stmt->bindParam(':zoneid', $row['zoneid']);
$stmt->bindParam(':sessionid', $row['sessionid']);
$stmt->execute();
if (method_exists($authenticator,'startAccounting')) {
if (method_exists($authenticator, 'startAccounting')) {
// send start accounting event
$authenticator->startAccounting($row['username'], $row['sessionid']);
}
} elseif ($row['deleted'] == 1 && $row['state'] != 'STOPPED') {
} elseif ($row['deleted'] == 1 && $row['state'] != 'STOPPED') {
// stop accounting, send stop event (if applicable)
$stmt = $db->prepare('update accounting_state
set state = \'STOPPED\'
......@@ -79,13 +79,13 @@ if ($result !== false) {
$stmt->bindParam(':zoneid', $row['zoneid']);
$stmt->bindParam(':sessionid', $row['sessionid']);
$stmt->execute();
if (method_exists($authenticator,'startAccounting')) {
if (method_exists($authenticator, 'startAccounting')) {
$time_spend = time() - $row['created'];
$authenticator->stopAccounting($row['username'], $row['sessionid'], $time_spend);
}
} elseif ($row['state'] != 'STOPPED') {
// send interim updates (if applicable)
if (method_exists($authenticator,'updateAccounting')) {
if (method_exists($authenticator, 'updateAccounting')) {
// send interim update event
$time_spend = time() - $row['created'];
$authenticator->updateAccounting($row['username'], $row['sessionid'], $time_spend);
......
......@@ -34,6 +34,7 @@ require_once("config.inc");
require_once("certs.inc");
require_once("legacy_bindings.inc");
use OPNsense\Core\Config;
global $config;
// Our template systems stores the ca certid into /usr/local/etc/squid/ca.pem.id
......
#!/usr/local/bin/php
<?
<?php
/**
* Backup to Google Drive (if configured)
*/
......
......@@ -24,7 +24,6 @@ try {
$application = new \Phalcon\Mvc\Application($di);
echo $application->handle()->getContent();
} catch (\Exception $e) {
$response = array();
$response['errorMessage'] = $e->getMessage();
......
......@@ -24,7 +24,6 @@ try {
$application = new \Phalcon\Mvc\Application($di);
echo $application->handle()->getContent();
} catch (\Exception $e) {
echo $e->getMessage();
}
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