Merge branch 'remastering' of https://git.steelants.cz/SImple-Home/PHP_SMART_HOME_V3 into remastering
This commit is contained in:
commit
366f1c4db4
@ -76,7 +76,7 @@ class EndpointsApi extends ApiController{
|
|||||||
|
|
||||||
//Log Data Save
|
//Log Data Save
|
||||||
if (isset($obj['logs'])){
|
if (isset($obj['logs'])){
|
||||||
foreach ($deviceLogs as $log) {
|
foreach ($obj['logs'] as $log) {
|
||||||
$logManager = new LogManager('../logs/devices/'. date("Y-m-d").'.log');
|
$logManager = new LogManager('../logs/devices/'. date("Y-m-d").'.log');
|
||||||
$logManager->setLevel(LOGLEVEL);
|
$logManager->setLevel(LOGLEVEL);
|
||||||
$logManager->write("[Device Log Msg] Device_ID " . $deviceId . "->" . $log, LogRecordTypes::ERROR);
|
$logManager->write("[Device Log Msg] Device_ID " . $deviceId . "->" . $log, LogRecordTypes::ERROR);
|
||||||
|
@ -1,23 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
if (!empty ($_POST)){
|
if (!empty ($_POST)){
|
||||||
if (!empty ($_FILES['deviceFirmware']) && !empty ($_FILES['deviceFirmware']['tmp_name']) && !empty ($_POST['deviceId'])) {
|
|
||||||
$deviceManager = new DeviceManager ();
|
$deviceManager = new DeviceManager ();
|
||||||
|
if (!empty ($_FILES['deviceFirmware']) && !empty ($_FILES['deviceFirmware']['tmp_name']) && !empty ($_POST['deviceId'])) {
|
||||||
$file = $_FILES['deviceFirmware'];
|
$file = $_FILES['deviceFirmware'];
|
||||||
$deviceMac = $deviceManager->getDeviceById ($_POST['deviceId'])['mac'];
|
$deviceMac = $deviceManager->getDeviceById ($_POST['deviceId'])['mac'];
|
||||||
$fileName = (!empty ($deviceMac) ? str_replace (":", "", $deviceMac) . ".bin" : "");
|
$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 != "") {
|
if ($fileName != "") {
|
||||||
copy ($file['tmp_name'], "../app/updater/" . $fileName);
|
copy ($file['tmp_name'], "../updater/" . $fileName);
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset ($_POST['deviceCommand']) && !empty ($_POST['deviceId'])) {
|
if (isset ($_POST['deviceCommand']) && !empty ($_POST['deviceId'])) {
|
||||||
$deviceManager = new DeviceManager ();
|
|
||||||
$deviceManager->edit ($_POST['deviceId'], array ('command' => $_POST['deviceCommand']));
|
$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();
|
die();
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ class LogManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function __destruct(){
|
public function __destruct(){
|
||||||
if (isset($this->logFile)) {
|
if (isset($this->logFile) && $this->logFile != "Unable to open file!") {
|
||||||
fclose($this->logFile);
|
fclose($this->logFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> 5cb6f0b... Some Fixes
|
|
||||||
<head>
|
<head>
|
||||||
<?php
|
<?php
|
||||||
$partial = new Partial('head');
|
$partial = new Partial('head');
|
||||||
@ -12,10 +8,6 @@
|
|||||||
?>
|
?>
|
||||||
<title><?php echo $TITLE ?></title>
|
<title><?php echo $TITLE ?></title>
|
||||||
</head>
|
</head>
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> 5cb6f0b... Some Fixes
|
|
||||||
<body class="no-transitions">
|
<body class="no-transitions">
|
||||||
<div class="row no-gutters main">
|
<div class="row no-gutters main">
|
||||||
<div class="col-md-3 d-sm-none"></div>
|
<div class="col-md-3 d-sm-none"></div>
|
||||||
@ -37,7 +29,12 @@
|
|||||||
<th>Room</th>
|
<th>Room</th>
|
||||||
<th>Firmware</th>
|
<th>Firmware</th>
|
||||||
<th>IP Address<br>(Mac)</th>
|
<th>IP Address<br>(Mac)</th>
|
||||||
<th>Action</th>
|
<th>Action
|
||||||
|
<form method="post" action="">
|
||||||
|
<button class="fa custom-file-input" type="submit" name="deviceCommand" value="reset" title="Reset All"><b></b></button>
|
||||||
|
<div style="float: clear;"></div>
|
||||||
|
</form>
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -50,10 +47,11 @@
|
|||||||
<td>
|
<td>
|
||||||
<?php if (!empty($device['mac'])) : ?>
|
<?php if (!empty($device['mac'])) : ?>
|
||||||
<i class="fa <?php echo (!empty($device['firmware_hash']) ? ($device['firmware_hash'] != "need" ? "fa-check-circle" : "fa-circle") : "fa-times-circle"); ?>" style="float: center; <?php echo (!empty($device['firmware_hash']) ? ($device['firmware_hash'] != "need" ? "color: green;" : "color: yellow;") : "color: red;"); ?>"></i>
|
<i class="fa <?php echo (!empty($device['firmware_hash']) ? ($device['firmware_hash'] != "need" ? "fa-check-circle" : "fa-circle") : "fa-times-circle"); ?>" style="float: center; <?php echo (!empty($device['firmware_hash']) ? ($device['firmware_hash'] != "need" ? "color: green;" : "color: yellow;") : "color: red;"); ?>"></i>
|
||||||
<button class="fa custom-file-input" type="button" onclick="document.getElementById('deviceFirmware').click();"></button>
|
<?php echo $device['firmware_hash'] ?>
|
||||||
|
<button class="fa custom-file-input" type="button" onclick="document.getElementById('deviceFirmware-<?php echo $device['device_id']?>').click();"></button>
|
||||||
<form style="display: none;" method="post" action="" enctype="multipart/form-data">
|
<form style="display: none;" method="post" action="" enctype="multipart/form-data">
|
||||||
<input type="hidden" name="deviceId" value="<?php echo (!empty($device['device_id']) ? $device['device_id'] : ""); ?>">
|
<input type="hidden" name="deviceId" value="<?php echo (!empty($device['device_id']) ? $device['device_id'] : ""); ?>">
|
||||||
<input type="file" onchange="this.form.submit();" name="deviceFirmware" id="deviceFirmware" value="">
|
<input type="file" onchange="this.form.submit();" name="deviceFirmware" id="deviceFirmware-<?php echo $device['device_id']?>" value="">
|
||||||
</form>
|
</form>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div type="float: clear;"></div>
|
<div type="float: clear;"></div>
|
||||||
|
Loading…
Reference in New Issue
Block a user