CMXX - Update software downloader

This commit is contained in:
“VeLiTi”
2024-11-19 19:03:27 +01:00
parent 974efdf323
commit 0655cf9458
5 changed files with 99 additions and 4 deletions

View File

@@ -53,6 +53,14 @@ if (isset($post_content['productrowid']) && $post_content['productrowid'] != '')
$input_insert = '';
if ($command == 'insert'){
//USE PART OF FILENAME AS VERSION
if (($pos = strpos($post_content['software'], "_")) !== FALSE) {
$version = substr($post_content['software'], $pos+1);
$version = substr($version, 0, -4); //remove filetype
$post_content['version'] = $version;
}
$post_content['latest'] = 1; //New software is always latest
$post_content['created'] = $date;
$post_content['createdby'] = $username;
@@ -100,6 +108,21 @@ if (isset($post_content['productrowid']) && $post_content['productrowid'] != '')
}
elseif ($command == 'delete' && isAllowed('products_software',$profile,$permission,'D') === 1){
//GET FILENAME AND REMOVE FROM SERVER
$sql = 'SELECT * FROM products_software WHERE rowID = ? '.$whereclause.'';
$stmt = $pdo->prepare($sql);
$stmt->execute([$id]);
//Get results
$softwares = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($softwares as $software){
$software_file = dirname(__FILE__,4)."/firmware/".$software['software'];
$file = glob($software_file, GLOB_BRACE);
if (!empty($file)){
unlink($software_file);
}
}
$stmt = $pdo->prepare('DELETE FROM products_software WHERE rowID = ? '.$whereclause.'');
$stmt->execute([ $id ]);