Files
assetmgt/cronjob.php
“VeLiTi” 24481279d5 Refactor user session handling and permissions management
- Updated session variables to use 'authorization' array instead of 'username' for user identification across multiple files.
- Introduced a new function `getUserPermissions` to consolidate user permissions retrieval based on assigned roles.
- Modified API calls to use the new authorization structure and updated endpoints to v2.
- Enhanced language support by adding 'PL' to the list of supported languages.
- Cleaned up redundant code and improved session management during user login and registration processes.
- Added a new API endpoint for fetching user permissions based on user ID.
2026-01-19 15:29:16 +01:00

120 lines
4.0 KiB
PHP

<?php
define('secure_34563$52', true);
include_once './assets/functions.php';
include_once './settings/settings_redirector.php';
include_once './settings/config_redirector.php';
if (debug && debug_id == $_SESSION['authorization']['id']){
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// check for security_code if not exit +++++++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
if (isset($_GET['code']) && $_GET['code'] != '') {
$test = $_GET['code'] / cronjob_number;
if ($test !== 1){
//EXIT IF CODE DOES NOT EQUAL 1
http_response_code(404);
exit;
} }
else {
//EXIT IF NOT CODE IS SEND
http_response_code(404);
exit;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// CODE IS CORRECT +++++++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
//CONNECT TO DB
$pdo = dbConnect($dbname);
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// SEND FIRMWARE COMMUNICATION TO END-USER ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
$sql = 'SELECT rowID, email FROM communication WHERE type_1 = 1 AND send_indicator = 1 LIMIT 0,15';
$stmt = $pdo->prepare($sql);
$stmt->execute();
$communications = $stmt->fetchAll(PDO::FETCH_ASSOC);
//ITERATE OVER RESULTS
foreach ($communications as $communication){
$to = $communication['email'];
include './assets/mail/email_template_firmware.php';
send_mail($to,$subject,$message,'','');
//UPDATE COMMUNICATION RECORD
$sql = 'UPDATE communication SET send_indicator = 0, send = ? WHERE rowID = ?';
$stmt = $pdo->prepare($sql);
$stmt->execute([$date,$communication['rowID']]);
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// END FIRMWARE COMMUNICATION TO END-USER ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// getUserkey ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
$token ='';
$data = json_encode(array("username" => interface_user, "password" => interface_pw), JSON_UNESCAPED_UNICODE);
//API call
$responses = ioServer('/v2/authorization', $data);
//Decode Payload
if (!empty($responses)){$responses = json_decode($responses);}else{$responses = '400';}
if ($responses === 'NOK' || $responses === '400'){
//Not allowed
http_response_code(403);
exit;
}
else {
// Store data in session
$token = $responses->userkey;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Contracts ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
//close contracts past due
closeContract();
//block contract where usage limit is reached
//blockContracts($token);
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Machine learning ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
$total_measurement = traintotalMeasurement();
$total_results = statisticalAnalyses($total_measurement);
//update Productversions
storeMeasurementProduct($total_results, $token);
//update Equipment data
storeMeasurementEquipment('');
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// GeoUpdate ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
geolocationUpdate($token);
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Debuglog ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
if (debug){
$time_elapsed = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
$message = $date.';cronjob;'.$time_elapsed.';interface';
debuglog($message);
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// EXIT ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
http_response_code(200);
exit;