Implement downgrade prevention for paid software versions and update invoice templates with new contact details
This commit is contained in:
@@ -441,6 +441,46 @@ if (isset($criterias['sn']) && $criterias['sn'] != ''){
|
||||
}
|
||||
}
|
||||
|
||||
//PREVENT DOWNGRADE FROM PAID VERSION TO FREE VERSION (if config enabled)
|
||||
if (defined('PREVENT_PAID_VERSION_DOWNGRADE') && PREVENT_PAID_VERSION_DOWNGRADE && $current_sw_version) {
|
||||
// Check if user is currently on a paid version (check if there was a paid upgrade path TO current version)
|
||||
$sql = 'SELECT COUNT(*) as paid_to_current
|
||||
FROM products_software_upgrade_paths pup
|
||||
JOIN products_software_versions to_ver ON pup.to_version_id = to_ver.rowID
|
||||
WHERE LOWER(TRIM(LEADING "0" FROM to_ver.version)) = ?
|
||||
AND pup.price > 0
|
||||
AND pup.is_active = 1';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$current_sw_version]);
|
||||
$paid_check = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$is_current_paid_version = ($paid_check['paid_to_current'] > 0);
|
||||
|
||||
if (debug) {
|
||||
$debug['downgrade_prevention'] = [
|
||||
'enabled' => true,
|
||||
'current_version' => $current_sw_version,
|
||||
'is_current_paid_version' => $is_current_paid_version
|
||||
];
|
||||
}
|
||||
|
||||
// If current version is paid, remove all free versions from the output (except current)
|
||||
if ($is_current_paid_version) {
|
||||
$output = array_filter($output, function($option) {
|
||||
$price = floatval($option['price']);
|
||||
$is_current = $option['is_current'];
|
||||
// Keep if it's the current version OR if it's a paid version
|
||||
return $is_current || $price > 0;
|
||||
});
|
||||
// Re-index array after filtering
|
||||
$output = array_values($output);
|
||||
|
||||
if (debug) {
|
||||
$debug['downgrade_prevention']['filtered_count'] = count($output);
|
||||
$debug['downgrade_prevention']['message'] = 'Removed free versions to prevent downgrade from paid version';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//GENERATE DOWNLOAD TOKENS FOR EACH OPTION
|
||||
foreach ($output as &$option) {
|
||||
// Generate time-based download token
|
||||
|
||||
Reference in New Issue
Block a user