diff --git a/sysutils/smart/src/opnsense/mvc/app/controllers/OPNsense/Smart/Api/ServiceController.php b/sysutils/smart/src/opnsense/mvc/app/controllers/OPNsense/Smart/Api/ServiceController.php index 451a1f5b3..0af8f6728 100644 --- a/sysutils/smart/src/opnsense/mvc/app/controllers/OPNsense/Smart/Api/ServiceController.php +++ b/sysutils/smart/src/opnsense/mvc/app/controllers/OPNsense/Smart/Api/ServiceController.php @@ -34,36 +34,39 @@ use \OPNsense\Core\Backend; class ServiceController extends ApiControllerBase { - private function getDevices () + private function getDevices() { $backend = new Backend(); - $devices = preg_split ("/[\s]+/", trim($backend->configdRun("smart list"))); + $devices = preg_split("/[\s]+/", trim($backend->configdRun("smart list"))); return $devices; } - public function listAction () + public function listAction() { - if ($this->request->isPost()) - return array("devices" => $this->getDevices ()); + if ($this->request->isPost()) { + return array("devices" => $this->getDevices()); + } return array("message" => "Unable to run list action"); } - public function infoAction () + public function infoAction() { if ($this->request->isPost()) { - $device = $this->request->getPost ('device'); - $type = $this->request->getPost ('type'); + $device = $this->request->getPost('device'); + $type = $this->request->getPost('type'); - if (!in_array ($device, $this->getDevices ())) + if (!in_array($device, $this->getDevices())) { return array("message" => "Invalid device name"); + } $valid_info_types = array("i", "H", "c", "A", "a"); - if (!in_array ($type, $valid_info_types)) + if (!in_array($type, $valid_info_types)) { return array("message" => "Invalid info type"); + } $backend = new Backend(); @@ -75,19 +78,21 @@ class ServiceController extends ApiControllerBase return array("message" => "Unable to run info action"); } - public function logsAction () + public function logsAction() { if ($this->request->isPost()) { - $device = $this->request->getPost ('device'); - $type = $this->request->getPost ('type'); + $device = $this->request->getPost('device'); + $type = $this->request->getPost('type'); - if (!in_array ($device, $this->getDevices ())) + if (!in_array($device, $this->getDevices())) { return array("message" => "Invalid device name"); + } $valid_log_types = array("error", "selftest"); - if (!in_array ($type, $valid_log_types)) + if (!in_array($type, $valid_log_types)) { return array("message" => "Invalid log type"); + } $backend = new Backend(); @@ -99,19 +104,21 @@ class ServiceController extends ApiControllerBase return array("message" => "Unable to run logs action"); } - public function testAction () + public function testAction() { if ($this->request->isPost()) { - $device = $this->request->getPost ('device'); - $type = $this->request->getPost ('type'); + $device = $this->request->getPost('device'); + $type = $this->request->getPost('type'); - if (!in_array ($device, $this->getDevices ())) + if (!in_array($device, $this->getDevices())) { return array("message" => "Invalid device name"); + } $valid_test_types = array("offline", "short", "long", "conveyance"); - if (!in_array ($type, $valid_test_types)) + if (!in_array($type, $valid_test_types)) { return array("message" => "Invalid test type"); + } $backend = new Backend(); @@ -123,13 +130,14 @@ class ServiceController extends ApiControllerBase return array("message" => "Unable to run test action"); } - public function abortAction () + public function abortAction() { if ($this->request->isPost()) { - $device = $this->request->getPost ('device'); + $device = $this->request->getPost('device'); - if (!in_array ($device, $this->getDevices ())) + if (!in_array($device, $this->getDevices())) { return array("message" => "Invalid device name"); + } $backend = new Backend(); diff --git a/sysutils/smart/src/opnsense/mvc/app/controllers/OPNsense/Smart/IndexController.php b/sysutils/smart/src/opnsense/mvc/app/controllers/OPNsense/Smart/IndexController.php index b446f5475..acccc4bd9 100644 --- a/sysutils/smart/src/opnsense/mvc/app/controllers/OPNsense/Smart/IndexController.php +++ b/sysutils/smart/src/opnsense/mvc/app/controllers/OPNsense/Smart/IndexController.php @@ -28,6 +28,7 @@ */ namespace OPNsense\Smart; + class IndexController extends \OPNsense\Base\IndexController { public function indexAction() diff --git a/sysutils/smart/src/opnsense/mvc/app/views/OPNsense/Smart/index.volt b/sysutils/smart/src/opnsense/mvc/app/views/OPNsense/Smart/index.volt index 96d2d7441..331cab9c4 100644 --- a/sysutils/smart/src/opnsense/mvc/app/views/OPNsense/Smart/index.volt +++ b/sysutils/smart/src/opnsense/mvc/app/views/OPNsense/Smart/index.volt @@ -1,33 +1,31 @@ {# - -Copyright (C) 2018 Smart-Soft -Copyright (C) 2014 Deciso B.V. -Copyright (C) 2010 Jim Pingle -Copyright (C) 2006 Eric Friesen -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -#} + # Copyright (C) 2018 Smart-Soft + # Copyright (C) 2014 Deciso B.V. + # Copyright (C) 2010 Jim Pingle + # Copyright (C) 2006 Eric Friesen + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions are met: + # + # 1. Redistributions of source code must retain the above copyright notice, + # this list of conditions and the following disclaimer. + # + # 2. Redistributions in binary form must reproduce the above copyright + # notice, this list of conditions and the following disclaimer in the + # documentation and/or other materials provided with the distribution. + # + # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + # POSSIBILITY OF SUCH DAMAGE. + #}