CMXX - Updated products_software
This commit is contained in:
@@ -24,29 +24,35 @@ if(isset($get_content) && $get_content!=''){
|
|||||||
//check if productcode and product_version are send
|
//check if productcode and product_version are send
|
||||||
if (isset($criterias['productcode']) && $criterias['productcode'] != '' && isset($criterias['version'])){
|
if (isset($criterias['productcode']) && $criterias['productcode'] != '' && isset($criterias['version'])){
|
||||||
|
|
||||||
|
//Connect to DB
|
||||||
|
$pdo = dbConnect($dbname);
|
||||||
|
|
||||||
//Connect to DB
|
//SQL for Paging
|
||||||
$pdo = dbConnect($dbname);
|
$sql = 'SELECT * FROM products_versions pv JOIN products p ON pv.productrowid = p.rowID WHERE p.productcode = ? AND pv.version = ? AND pv.status = "1"';
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
//Excute Query
|
||||||
|
$stmt->execute([$criterias['productcode'],$criterias['version']]);
|
||||||
|
//Get results
|
||||||
|
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
//SQL for Paging
|
foreach ($messages as $message){
|
||||||
$sql = 'SELECT * FROM products_versions pv JOIN products p ON pv.productrowid = p.rowID WHERE p.productcode = ? AND pv.version = ? AND pv.status = "1"';
|
|
||||||
$stmt = $pdo->prepare($sql);
|
|
||||||
//Excute Query
|
|
||||||
$stmt->execute([$criterias['productcode'],$criterias['version']]);
|
|
||||||
//Get results
|
|
||||||
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
foreach ($messages as $message){
|
|
||||||
|
|
||||||
//CHECK IF FIRMWARE FILE IS AVAILABLE
|
//CHECK IF FIRMWARE FILE IS AVAILABLE
|
||||||
$software_file = dirname(__FILE__,4)."/firmware/".$message['software'].'.HEX';
|
$software_file = dirname(__FILE__,4)."/firmware/".$message['software'];
|
||||||
if (file_exists($software_file)){
|
$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
|
//GET SOURCE CODE
|
||||||
$file_contents = file_get_contents($software_file);
|
$file_contents = file_get_contents($software_file);
|
||||||
//REMOVE RETURN \R
|
//REMOVE RETURN \R
|
||||||
$file_contents = str_replace("\r", '',$file_contents);
|
$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);
|
$output = array("hw_version"=> $message['version'], "HEX_FW"=> $message['software'], "Firmware" => $file_contents);
|
||||||
@@ -58,8 +64,8 @@ foreach ($messages as $message){
|
|||||||
|
|
||||||
//Send results
|
//Send results
|
||||||
echo $output;
|
echo $output;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
|
|||||||
@@ -44,16 +44,28 @@ if (isset($_GET['rowID'])) {
|
|||||||
|
|
||||||
//CHECK FOR FIRMWARE FILE
|
//CHECK FOR FIRMWARE FILE
|
||||||
$firmware_file = $_FILES["fileToUpload"]["name"] ?? '';
|
$firmware_file = $_FILES["fileToUpload"]["name"] ?? '';
|
||||||
|
|
||||||
if($firmware_file !='' || !empty($firmware_file)){
|
if($firmware_file !='' || !empty($firmware_file)){
|
||||||
|
|
||||||
|
$extension = strtolower(pathinfo($firmware_file, PATHINFO_EXTENSION));
|
||||||
|
$target_dir = dirname(__FILE__)."/firmware/";
|
||||||
|
|
||||||
|
if ($extension == 'hex'){
|
||||||
//READ FILE
|
//READ FILE
|
||||||
$contents = file_get_contents($_FILES["fileToUpload"]["tmp_name"]);
|
$contents = file_get_contents($_FILES["fileToUpload"]["tmp_name"]);
|
||||||
//firmwarename
|
//firmwarename
|
||||||
$firmware_name = pathinfo($_FILES["fileToUpload"]["name"], PATHINFO_FILENAME);
|
$firmware_name = pathinfo($_FILES["fileToUpload"]["name"], PATHINFO_FILENAME);
|
||||||
//Filename
|
//Filename
|
||||||
$target_dir = dirname(__FILE__)."/firmware/";
|
|
||||||
$input_file = $target_dir . $firmware_name.'.HEX';
|
$input_file = $target_dir . $firmware_name.'.HEX';
|
||||||
//store firmware file
|
//store firmware file
|
||||||
file_put_contents($input_file, $contents);
|
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
|
//Use firmwarefile name as software version
|
||||||
$_POST['software'] = $firmware_name;
|
$_POST['software'] = $firmware_name;
|
||||||
}
|
}
|
||||||
@@ -99,19 +111,31 @@ if (isset($_GET['rowID'])) {
|
|||||||
//CHECK FOR FIRMWARE FILE
|
//CHECK FOR FIRMWARE FILE
|
||||||
$firmware_file = $_FILES["fileToUpload"]["name"] ?? '';
|
$firmware_file = $_FILES["fileToUpload"]["name"] ?? '';
|
||||||
|
|
||||||
//FIRMWARE FILE UPLOADED
|
|
||||||
if($firmware_file !='' || !empty($firmware_file)){
|
if($firmware_file !='' || !empty($firmware_file)){
|
||||||
|
|
||||||
|
$extension = strtolower(pathinfo($firmware_file, PATHINFO_EXTENSION));
|
||||||
|
$target_dir = dirname(__FILE__)."/firmware/";
|
||||||
|
|
||||||
|
if ($extension == 'hex'){
|
||||||
//READ FILE
|
//READ FILE
|
||||||
$contents = file_get_contents($_FILES["fileToUpload"]["tmp_name"]);
|
$contents = file_get_contents($_FILES["fileToUpload"]["tmp_name"]);
|
||||||
//firmwarename
|
//firmwarename
|
||||||
$firmware_name = pathinfo($_FILES["fileToUpload"]["name"], PATHINFO_FILENAME);
|
$firmware_name = pathinfo($_FILES["fileToUpload"]["name"], PATHINFO_FILENAME);
|
||||||
//Filename
|
//Filename
|
||||||
$target_dir = dirname(__FILE__)."/firmware/";
|
|
||||||
$input_file = $target_dir . $firmware_name.'.HEX';
|
$input_file = $target_dir . $firmware_name.'.HEX';
|
||||||
//store firmware file
|
//store firmware file
|
||||||
file_put_contents($input_file, $contents);
|
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
|
//Use firmwarefile name as software version
|
||||||
$_POST['software'] = $firmware_name.'.HEX';
|
$_POST['software'] = $firmware_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
//GET ALL POST DATA
|
//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>
|
<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>
|
<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>
|
<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_version = '877a739';
|
||||||
$service_tool_current_filename = 'EmergencyFlasherSetup.exe';
|
$service_tool_current_filename = 'EmergencyPlugTestKitSetup_RO-TEST.exe';
|
||||||
$software_download_url = 'https://'.$_SERVER['SERVER_NAME'].'/downloads'.'/';
|
$software_download_url = 'https://'.$_SERVER['SERVER_NAME'].'/firmware'.'/';
|
||||||
|
|
||||||
//getSoftware (legacy)
|
//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 ===================================
|
//SERVICE Tool initialize ===================================
|
||||||
|
|||||||
Reference in New Issue
Block a user