2020-08-31 19:23:23 +00:00
|
|
|
<?php
|
|
|
|
if (!empty ($_POST)){
|
|
|
|
if (!empty ($_FILES['deviceFirmware']) && !empty ($_FILES['deviceFirmware']['tmp_name']) && !empty ($_POST['deviceId'])) {
|
|
|
|
$deviceManager = new DeviceManager ();
|
|
|
|
$file = $_FILES['deviceFirmware'];
|
|
|
|
$deviceMac = $deviceManager->getDeviceById ($_POST['deviceId'])['mac'];
|
|
|
|
$fileName = (!empty ($deviceMac) ? str_replace (":", "", $deviceMac) . ".bin" : "");
|
2020-09-02 17:44:40 +00:00
|
|
|
|
|
|
|
if ($fileName != "" && file_exists ("../updater/" . $fileName)) {
|
|
|
|
unlink("../updater/" . $fileName);
|
2020-08-31 19:23:23 +00:00
|
|
|
}
|
|
|
|
if ($fileName != "") {
|
2020-09-02 17:44:40 +00:00
|
|
|
echo 'coping file'.$fileName .copy ($file['tmp_name'], "../updater/" . $fileName);;
|
|
|
|
|
2020-08-31 19:23:23 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset ($_POST['deviceCommand']) && !empty ($_POST['deviceId'])) {
|
|
|
|
$deviceManager = new DeviceManager ();
|
|
|
|
$deviceManager->edit ($_POST['deviceId'], array ('command' => $_POST['deviceCommand']));
|
|
|
|
}
|
2020-09-02 17:44:40 +00:00
|
|
|
//header('Location: ./');
|
|
|
|
//die();
|
2020-08-31 19:23:23 +00:00
|
|
|
}
|