CMXX - Firmware improvement

This commit is contained in:
“VeLiTi”
2024-10-09 15:08:57 +02:00
parent 9ffb1e41a9
commit 34b1ee1600
5 changed files with 241 additions and 1 deletions

View File

@@ -41,6 +41,23 @@ if (isset($_GET['rowID'])) {
if ($update_allowed === 1){
if (isset($_POST['submit'])) {
//CHECK FOR FIRMWARE FILE
$firmware_file = $_FILES["fileToUpload"]["name"] ?? '';
if($firmware_file !='' || !empty($firmware_file)){
//READ FILE
$contents = file_get_contents($_FILES["fileToUpload"]["tmp_name"]);
//firmwarename
$firmware_name = pathinfo($_FILES["fileToUpload"]["name"], PATHINFO_FILENAME);
//Filename
$target_dir = dirname(__FILE__)."/firmware/";
$input_file = $target_dir . $firmware_name.'.HEX';
//store firmware file
file_put_contents($input_file, $contents);
//Use firmwarefile name as software version
$_POST['software'] = $firmware_name;
}
//GET ALL POST DATA
$data = json_encode($_POST, JSON_UNESCAPED_UNICODE);
//Secure data
@@ -78,6 +95,25 @@ if (isset($_GET['rowID'])) {
} else {
// Create a new product
if (isset($_POST['submit']) && $create_allowed === 1) {
//CHECK FOR FIRMWARE FILE
$firmware_file = $_FILES["fileToUpload"]["name"] ?? '';
//FIRMWARE FILE UPLOADED
if($firmware_file !='' || !empty($firmware_file)){
//READ FILE
$contents = file_get_contents($_FILES["fileToUpload"]["tmp_name"]);
//firmwarename
$firmware_name = pathinfo($_FILES["fileToUpload"]["name"], PATHINFO_FILENAME);
//Filename
$target_dir = dirname(__FILE__)."/firmware/";
$input_file = $target_dir . $firmware_name.'.HEX';
//store firmware file
file_put_contents($input_file, $contents);
//Use firmwarefile name as software version
$_POST['software'] = $firmware_name.'.HEX';
}
//GET ALL POST DATA
$data = json_encode($_POST , JSON_UNESCAPED_UNICODE);
//Secure data
@@ -97,7 +133,7 @@ if (isset($_GET['rowID'])) {
template_header('Products versions', 'products_versions', 'manage');
$view ='
<form action="" method="post">
<form action="" method="post" enctype="multipart/form-data">
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
<h2 class="responsive-width-100">'.$product_version_version.'</h2>
<a href="index.php?page=product&rowID='.$productrowid.'" class="btn alt mar-right-2">'.$button_cancel.'</a>
@@ -130,6 +166,11 @@ $view .= '<div class="content-block tab-content active">
<label for=""><i class="required">*</i>'.$product_version_software.'</label>
<input id="name" type="text" name="software" placeholder="'.$product_version_software.'" value="'.$products_versions['software'].'" required>
<label for=""></label>
<input type="file" name="fileToUpload" id="fileToUpload" accept=".hex, .HEX" style="width: 30%;padding: 50px 0 0 0;height: 10px;">
';
if (isset($_GET['rowID']) && $_GET['rowID'] !='' && !empty($products_versions['measurement'])){