diff --git a/app/api/EndpointsApi.php b/app/api/EndpointsApi.php index 834a584..05a4558 100644 --- a/app/api/EndpointsApi.php +++ b/app/api/EndpointsApi.php @@ -76,7 +76,7 @@ class EndpointsApi extends ApiController{ //Log Data Save if (isset($obj['logs'])){ - foreach ($deviceLogs as $log) { + foreach ($obj['logs'] as $log) { $logManager = new LogManager('../logs/devices/'. date("Y-m-d").'.log'); $logManager->setLevel(LOGLEVEL); $logManager->write("[Device Log Msg] Device_ID " . $deviceId . "->" . $log, LogRecordTypes::ERROR); diff --git a/app/controllers/deviceController.php b/app/controllers/deviceController.php index 035b2ab..cb47edf 100644 --- a/app/controllers/deviceController.php +++ b/app/controllers/deviceController.php @@ -1,23 +1,26 @@ getDeviceById ($_POST['deviceId'])['mac']; $fileName = (!empty ($deviceMac) ? str_replace (":", "", $deviceMac) . ".bin" : ""); - if ($fileName != "" && file_exists ("../app/updater/" . $fileName)) { - unlink("../app/updater/" . $fileName); + + if ($fileName != "" && file_exists ("../updater/" . $fileName)) { + unlink("../updater/" . $fileName); } if ($fileName != "") { - copy ($file['tmp_name'], "../app/updater/" . $fileName); - } else { - + copy ($file['tmp_name'], "../updater/" . $fileName); } } if (isset ($_POST['deviceCommand']) && !empty ($_POST['deviceId'])) { - $deviceManager = new DeviceManager (); $deviceManager->edit ($_POST['deviceId'], array ('command' => $_POST['deviceCommand'])); + }else if (!empty ($_POST['deviceCommand'])) { + $devices = $deviceManager->getAllDevices(); + foreach ($devices as $key => $device) { + $deviceManager->edit ($device['device_id'], array ('command' => $_POST['deviceCommand'])); + } } - header('Location: ./'); + header('Location: ./device'); die(); } diff --git a/app/models/managers/LogManager.php b/app/models/managers/LogManager.php index 082c646..edae6e8 100644 --- a/app/models/managers/LogManager.php +++ b/app/models/managers/LogManager.php @@ -35,7 +35,7 @@ class LogManager } public function __destruct(){ - if (isset($this->logFile)) { + if (isset($this->logFile) && $this->logFile != "Unable to open file!") { fclose($this->logFile); } } diff --git a/app/views/templates/device.phtml b/app/views/templates/device.phtml index cccdecd..cadd925 100644 --- a/app/views/templates/device.phtml +++ b/app/views/templates/device.phtml @@ -1,9 +1,5 @@ -<<<<<<< HEAD -======= - ->>>>>>> 5cb6f0b... Some Fixes <?php echo $TITLE ?> -<<<<<<< HEAD -======= - ->>>>>>> 5cb6f0b... Some Fixes
@@ -37,7 +29,12 @@ Room Firmware IP Address
(Mac) - Action + Action +
+ +
+
+ @@ -50,10 +47,11 @@ " style="float: center; "> - + +
"> - +