CMXX - Updated products_software
This commit is contained in:
@@ -24,7 +24,6 @@ if(isset($get_content) && $get_content!=''){
|
||||
//check if productcode and product_version are send
|
||||
if (isset($criterias['productcode']) && $criterias['productcode'] != '' && isset($criterias['version'])){
|
||||
|
||||
|
||||
//Connect to DB
|
||||
$pdo = dbConnect($dbname);
|
||||
|
||||
@@ -39,14 +38,21 @@ $messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach ($messages as $message){
|
||||
|
||||
//CHECK IF FIRMWARE FILE IS AVAILABLE
|
||||
$software_file = dirname(__FILE__,4)."/firmware/".$message['software'].'.HEX';
|
||||
if (file_exists($software_file)){
|
||||
$software_file = dirname(__FILE__,4)."/firmware/".$message['software'];
|
||||
$file = glob($software_file, GLOB_BRACE);
|
||||
|
||||
if (!empty($file)){
|
||||
//GET FILE EXTENTION
|
||||
$ext = strtolower(pathinfo($file[0], PATHINFO_EXTENSION));
|
||||
if ($ext == 'hex'){
|
||||
//GET SOURCE CODE
|
||||
$file_contents = file_get_contents($software_file);
|
||||
//REMOVE RETURN \R
|
||||
$file_contents = str_replace("\r", '',$file_contents);
|
||||
} else {
|
||||
$file_contents = '';
|
||||
}
|
||||
else {
|
||||
//PROVIDE URL TO FILE
|
||||
$file_contents = 'https://'.$_SERVER['SERVER_NAME'].'/firmware'.'/'.$message['software'];
|
||||
}
|
||||
|
||||
$output = array("hw_version"=> $message['version'], "HEX_FW"=> $message['software'], "Firmware" => $file_contents);
|
||||
@@ -59,7 +65,7 @@ foreach ($messages as $message){
|
||||
//Send results
|
||||
echo $output;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
http_response_code(404);
|
||||
|
||||
@@ -44,16 +44,28 @@ if (isset($_GET['rowID'])) {
|
||||
|
||||
//CHECK FOR FIRMWARE FILE
|
||||
$firmware_file = $_FILES["fileToUpload"]["name"] ?? '';
|
||||
|
||||
if($firmware_file !='' || !empty($firmware_file)){
|
||||
|
||||
$extension = strtolower(pathinfo($firmware_file, PATHINFO_EXTENSION));
|
||||
$target_dir = dirname(__FILE__)."/firmware/";
|
||||
|
||||
if ($extension == 'hex'){
|
||||
//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);
|
||||
|
||||
} else {
|
||||
$target_file = $target_dir . $firmware_file;
|
||||
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file);
|
||||
$firmware_name = $firmware_file;
|
||||
}
|
||||
|
||||
//Use firmwarefile name as software version
|
||||
$_POST['software'] = $firmware_name;
|
||||
}
|
||||
@@ -99,19 +111,31 @@ if (isset($_GET['rowID'])) {
|
||||
//CHECK FOR FIRMWARE FILE
|
||||
$firmware_file = $_FILES["fileToUpload"]["name"] ?? '';
|
||||
|
||||
//FIRMWARE FILE UPLOADED
|
||||
if($firmware_file !='' || !empty($firmware_file)){
|
||||
|
||||
$extension = strtolower(pathinfo($firmware_file, PATHINFO_EXTENSION));
|
||||
$target_dir = dirname(__FILE__)."/firmware/";
|
||||
|
||||
if ($extension == 'hex'){
|
||||
//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);
|
||||
|
||||
$firmware_name = $firmware_name.'.HEX';
|
||||
|
||||
} else {
|
||||
$target_file = $target_dir . $firmware_file;
|
||||
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file);
|
||||
$firmware_name = $firmware_file;
|
||||
}
|
||||
|
||||
//Use firmwarefile name as software version
|
||||
$_POST['software'] = $firmware_name.'.HEX';
|
||||
$_POST['software'] = $firmware_name;
|
||||
}
|
||||
|
||||
//GET ALL POST DATA
|
||||
@@ -165,10 +189,10 @@ $view .= '<div class="content-block tab-content active">
|
||||
<input id="name" type="text" name="version" placeholder="'.$product_version_version.'" value="'.$products_versions['version'].'" required>
|
||||
|
||||
<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>
|
||||
<input id="name" type="text" name="software" placeholder="'.$product_version_software.'" value="'.$products_versions['software'].'">
|
||||
|
||||
<label for=""></label>
|
||||
<input type="file" name="fileToUpload" id="fileToUpload" accept=".hex, .HEX" style="width: 30%;padding: 50px 0 0 0;height: 10px;">
|
||||
<input type="file" name="fileToUpload" id="fileToUpload" accept=".hex, .HEX, .bin,.BIN,.exe,.EXE" style="width: 30%;padding: 50px 0 0 0;height: 10px;">
|
||||
|
||||
|
||||
';
|
||||
|
||||
@@ -7,11 +7,11 @@ error_reporting(E_ALL);
|
||||
//=================================================================
|
||||
|
||||
$service_tool_current_version = '877a739';
|
||||
$service_tool_current_filename = 'EmergencyFlasherSetup.exe';
|
||||
$software_download_url = 'https://'.$_SERVER['SERVER_NAME'].'/downloads'.'/';
|
||||
$service_tool_current_filename = 'EmergencyPlugTestKitSetup_RO-TEST.exe';
|
||||
$software_download_url = 'https://'.$_SERVER['SERVER_NAME'].'/firmware'.'/';
|
||||
|
||||
//getSoftware (legacy)
|
||||
$software_url = 'https://'.$_SERVER['SERVER_NAME'].'/downloads'.'/'.$service_tool_current_filename;
|
||||
$software_url = 'https://'.$_SERVER['SERVER_NAME'].'/firmware'.'/'.$service_tool_current_filename;
|
||||
|
||||
//=================================================================
|
||||
//SERVICE Tool initialize ===================================
|
||||
|
||||
Reference in New Issue
Block a user