Finetuning software updates, general UI improvements

This commit is contained in:
“VeLiTi”
2026-01-13 14:35:16 +01:00
parent 0d3724395a
commit a0e1d386ad
46 changed files with 317 additions and 120 deletions

View File

@@ -83,7 +83,9 @@ function send_mail($to, $subject, $message, $attachment, $attachment_name){
if( !$mail->send() ){
// render error if it is
$tab = array('error' => 'Mailer Error: '.$mail->ErrorInfo );
debuglog(json_encode($tab));
if(debug){
debuglog(json_encode($tab));
}
exit;
}
else{
@@ -157,7 +159,9 @@ function sendIcsCalendar($appointment, $to, $subject = 'Appointment Confirmation
if (!$mail->send()) {
$tab = array('error' => 'Mailer Error: ' . $mail->ErrorInfo);
debuglog(json_encode($tab));
if(debug){
debuglog(json_encode($tab));
}
return false;
} else {
return true;
@@ -1067,7 +1071,9 @@ function validate_secure_download_token($token, $secret_key = null) {
// Check JSON parsing with detailed error info
if ($header === null) {
$json_error = json_last_error_msg();
debuglog("JSON decode failed for header. Raw JSON: " . $header_json . " Error: " . $json_error);
if(debug){
debuglog("JSON decode failed for header. Raw JSON: " . $header_json . " Error: " . $json_error);
}
return ['error' => 'INVALID_TOKEN', 'message' => 'Failed to decode token header JSON: ' . $json_error];
}
if ($payload === null) {
@@ -1227,6 +1233,11 @@ function log_download($params) {
function ioServer($api_call, $data){
include dirname(__FILE__,2).'/settings/settings_redirector.php';
if(debug){
$data_log = is_array($data) ? json_encode($data) : $data;
debuglog($date." - ioServer incoming call: api_call=$api_call, data=" . $data_log);
}
$token = $_SESSION['userkey'] ?? 'authorization_request';
$bearertoken = createCommunicationToken($token);
@@ -1252,7 +1263,11 @@ function ioServer($api_call, $data){
$resp = curl_exec($curl);
$http_status = curl_getinfo($curl) ?? '200';
curl_close($curl);
if(debug){
debuglog($date." - ioServer: URL=$url, HTTP Code=$http_status, Response=" . substr($resp, 0, 500) . (strlen($resp) > 500 ? '...' : ''));
}
//Check If errorcode is returned
if($http_status['http_code'] == '403' || $http_status['http_code'] == '400') {$resp = generate_payload('NOK');}
@@ -1533,6 +1548,8 @@ function getProfile($profile, $permission){
'software_update' => 'R',
'software_download' => 'R',
'software_available' => 'R',
'history' => 'U',
'payment' => 'U',
'marketing_files' => 'CRUD',
'marketing_folders' => 'CRUD',
'marketing_tags' => 'CRUD',
@@ -1553,11 +1570,16 @@ function getProfile($profile, $permission){
];
// Debug log
debuglog("isAllowed called: page=$page, permission=$permission, action=$action");
if(debug){
debuglog("isAllowed called: page=$page, permission=$permission, action=$action");
}
// 1. Check always allowed
if (isset($always_allowed[$page]) && str_contains($always_allowed[$page], $action)) {
debuglog("Allowed by always_allowed");
if(debug){
debuglog("Allowed by always_allowed");
}
return 1;
}
@@ -1568,11 +1590,15 @@ function getProfile($profile, $permission){
$page_action = str_contains($user_permission,$action) > 0 ? 1 : 0; //CHECK IF USER IS ALLOWED TO DO THE ACTION
$page_access = str_contains($profile,$page) > 0 ? 1 : 0; //CHECK USER IS ALLOWED TO ACCESS PAGE
debuglog("user_permission=$user_permission, page_action=$page_action, page_access=$page_access");
if(debug){
debuglog("user_permission=$user_permission, page_action=$page_action, page_access=$page_access");
}
// 2. Check user permissions (standard)
if ($page_access == 1 && $page_action == 1){
debuglog("Allowed by user permissions");
if(debug){
debuglog("Allowed by user permissions");
}
return 1;
}
@@ -1580,16 +1606,22 @@ function getProfile($profile, $permission){
if ($page_access == 0) {
foreach ($group_permissions as $granting_page => $grants) {
if (str_contains($profile, $granting_page)) {
debuglog("Found granting_page: $granting_page");
if(debug){
debuglog("Found granting_page: $granting_page");
}
if (isset($grants[$page]) && str_contains($grants[$page], $action)) {
debuglog("Allowed by group permissions");
if(debug){
debuglog("Allowed by group permissions");
}
return 1;
}
}
}
}
debuglog("Not allowed");
if(debug){
debuglog("Not allowed");
}
// Not allowed
return 0;
}
@@ -5209,7 +5241,7 @@ function updateSoftwareVersionStatus($pdo, $serialnumber = null) {
SET e.sw_version_latest = 1
WHERE psv.latest = 1
AND psv.status = 1
AND lower(e.sw_version) = lower(psv.version)
AND LOWER(TRIM(LEADING "0" FROM e.sw_version)) = lower(psv.version)
AND (lower(psv.hw_version) = lower(e.hw_version) OR lower(psv.hw_version) IS NULL OR lower(psv.hw_version) = "")
AND e.sw_version_latest = 0' . $sn_clause;

View File

@@ -1034,8 +1034,8 @@ function showPaymentModal(option) {
<label style="display: block; margin-bottom: 5px; color: #333; font-weight: 500;">Payment Method *</label>
<select name="payment_method" required style="width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px;">
<option value="">Select payment method</option>
${typeof MOLLIE_ENABLED !== 'undefined' && MOLLIE_ENABLED ? '<option value="credit_card">Credit Card</option>' : ''}
${typeof PAYPAL_ENABLED !== 'undefined' && PAYPAL_ENABLED ? '<option value="paypal">PayPal</option>' : ''}
${typeof MOLLIE_ENABLED !== 'undefined' && MOLLIE_ENABLED ? '<option value="1">Credit Card</option>' : ''}
${typeof PAYPAL_ENABLED !== 'undefined' && PAYPAL_ENABLED ? '<option value="3">PayPal</option>' : ''}
${typeof PAY_ON_DELIVERY_ENABLED !== 'undefined' && PAY_ON_DELIVERY_ENABLED ? '<option value="bank_transfer">Bank Transfer</option>' : ''}
</select>
</div>