Files
assetmgt/cronjob.php
“VeLiTi” bc1c5147e9 CMXX - Cronjob
2024-10-04 09:14:48 +02:00

99 lines
3.4 KiB
PHP

<?php
define('secure_34563$52', true);
include_once './assets/functions.php';
include_once './settings/settings.php';
include_once './settings/config.php';
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// 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);
//Secure data
$payload = generate_payload($data);
//API call
$responses = ioServer('/v1/authorization', $payload);
//Decode Payload
if (!empty($responses)){$responses = decode_payload($responses);}else{$responses = '400';}
if ($responses === 'NOK' || $responses === '400'){
//Not allowed
http_response_code(403);
exit;
}
else {
// Store data in session
$token = $responses->userkey;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// close Contracts ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
closeContract();
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Machine learning ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
$total_measurement = traintotalMeasurement();
$total_results = statisticalAnalyses($total_measurement);
storeMeasurementProduct($total_results, $token);
storeMeasurementEquipment('');
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// GeoUpdate ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
geolocationUpdate($token);
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
// EXIT ++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
http_response_code(200);
exit;