Add API endpoints and management pages for software versions and upgrade paths
- Implemented API endpoint for managing software versions in `products_software_versions.php`. - Created management page for software version assignments in `products_software_assignments.php`. - Developed upgrade paths management functionality in `products_software_upgrade_paths_manage.php`. - Enhanced software version details page in `products_software_version.php`. - Added form handling and validation for software version creation and updates in `products_software_version_manage.php`. - Introduced pagination and filtering for software versions in `products_software_versions.php`. - Implemented success message handling for CRUD operations across various pages.
This commit is contained in:
44
api/v2/get/generate_download_token.php
Normal file
44
api/v2/get/generate_download_token.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
defined($security_key) or exit;
|
||||
|
||||
//------------------------------------------
|
||||
// Generate Download Token Helper
|
||||
// Allows authenticated users to generate download URL tokens server-side
|
||||
//------------------------------------------
|
||||
|
||||
//Connect to DB
|
||||
$pdo = dbConnect($dbname);
|
||||
|
||||
//NEW ARRAY
|
||||
$criterias = [];
|
||||
|
||||
//Parse GET parameters
|
||||
if(isset($get_content) && $get_content != ''){
|
||||
$requests = explode("&", $get_content);
|
||||
foreach ($requests as $y){
|
||||
$v = explode("=", $y);
|
||||
$criterias[$v[0]] = $v[1];
|
||||
}
|
||||
}
|
||||
|
||||
// Validate required parameters
|
||||
if (!isset($criterias['sn']) || !isset($criterias['version_id'])) {
|
||||
http_response_code(400);
|
||||
echo json_encode(["error" => "MISSING_PARAMETERS", "message" => "sn and version_id required"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Generate token
|
||||
$token = create_download_url_token($criterias['sn'], $criterias['version_id']);
|
||||
$download_url = "https://" . $_SERVER['SERVER_NAME'] . "/api.php/v2/get/software_download?token=" . $token;
|
||||
|
||||
// Return token and download URL
|
||||
echo json_encode([
|
||||
"success" => true,
|
||||
"token" => $token,
|
||||
"download_url" => $download_url,
|
||||
"expires_in_seconds" => 900,
|
||||
"serial_number" => $criterias['sn'],
|
||||
"version_id" => $criterias['version_id']
|
||||
]);
|
||||
?>
|
||||
Reference in New Issue
Block a user