CIM88 - Changelog en reporting
This commit is contained in:
@@ -235,7 +235,7 @@ echo <<<EOT
|
||||
<link rel="icon" type="image/png" href="$icon_image">
|
||||
<link href="./style/admin.css" rel="stylesheet" type="text/css">
|
||||
<link rel="stylesheet" href="./style/leaflet.css" />
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v6.0.0/css/all.css">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v6.6.0/css/all.css">
|
||||
<script src="./assets/leaflet.js"></script>
|
||||
<script src="./assets/charts.js"></script>
|
||||
</head>
|
||||
@@ -323,6 +323,26 @@ function generate_payload($payload) {
|
||||
|
||||
return $payload_input;
|
||||
}
|
||||
//------------------------------------------
|
||||
//ENCRYPT PAYLOAD
|
||||
//------------------------------------------
|
||||
function encrypt($input, $password) {
|
||||
|
||||
//CHECK IF INPUT IS ARRAY => THEN SERIALIZE INPUT
|
||||
if (is_array($input)){
|
||||
$input = serialize($input);
|
||||
}
|
||||
|
||||
$method = "AES-256-CBC";
|
||||
$key = hash('sha256', $password, true);
|
||||
$iv = openssl_random_pseudo_bytes(16);
|
||||
|
||||
$ciphertext = openssl_encrypt($input, $method, $key, OPENSSL_RAW_DATA, $iv);
|
||||
$hash = hash_hmac('sha256', $ciphertext . $iv, $key, true);
|
||||
|
||||
return $iv . $hash . $ciphertext;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------
|
||||
// Decode Payload
|
||||
@@ -355,6 +375,29 @@ function decode_payload($payload_input) {
|
||||
return $payload_decoded = json_decode($payload)->payload;
|
||||
}
|
||||
}
|
||||
//------------------------------------------
|
||||
// Decrypt payload
|
||||
//------------------------------------------
|
||||
function decrypt($ivHashCiphertext, $password) {
|
||||
$method = "AES-256-CBC";
|
||||
$iv = substr($ivHashCiphertext, 0, 16);
|
||||
$hash = substr($ivHashCiphertext, 16, 32);
|
||||
$ciphertext = substr($ivHashCiphertext, 48);
|
||||
$key = hash('sha256', $password, true);
|
||||
|
||||
if (!hash_equals(hash_hmac('sha256', $ciphertext . $iv, $key, true), $hash)) return null;
|
||||
|
||||
$decrypted = openssl_decrypt($ciphertext, $method, $key, OPENSSL_RAW_DATA, $iv);
|
||||
|
||||
//UNSERIALE AND CHECK IF
|
||||
$data = @unserialize($decrypted);
|
||||
if ($data !== false) {
|
||||
$decrypted = unserialize($decrypted);
|
||||
}
|
||||
|
||||
//RETURN DECRYPTED DATA
|
||||
return $decrypted;
|
||||
}
|
||||
|
||||
function base64url_encode($data) {
|
||||
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
|
||||
@@ -1823,7 +1866,6 @@ function downloadFile($file) {
|
||||
function serviceforecast($messages,$type){
|
||||
|
||||
if ($messages){
|
||||
|
||||
$number = (($type == 'warranty')? 1 : 1);
|
||||
//GET TOTAL SERVICE COUNT
|
||||
$totalcount = 0;
|
||||
@@ -1915,6 +1957,39 @@ function showlog($object,$objectID){
|
||||
return $view;
|
||||
}
|
||||
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// visual changelog +++++++++++++++
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
function changeLogVisual($totals,$details){
|
||||
if ($totals){
|
||||
//GET TOTAL COUNT
|
||||
$totalcount = 0;
|
||||
foreach ($totals as $total){
|
||||
$totalcount += $total['total'];
|
||||
}
|
||||
|
||||
//GET SERIALNUMBERS
|
||||
$url_input = ''; //used to collect serialnumber for onclick event
|
||||
foreach ($details as $detail){
|
||||
$url_input .= $detail['serialnumber'].',';
|
||||
}
|
||||
|
||||
$view = '<div style="margin-bottom: 30px;" onclick="location.href=\'index.php?page=equipments&serialnumber='.substr($url_input,0,-1).'\'">
|
||||
<ul style="width: 100%;max-width:100%" class="chart">
|
||||
';
|
||||
foreach ($totals as $total){
|
||||
|
||||
$height = ($total['total'] / $totalcount) * 100;
|
||||
$title = $total['DoW'].'/'.$total['WoW'];
|
||||
$view .='<li style="text-align:center;">' . $total['total'] . '<span style="height:' . $height . '%" title="' . $title . '"></span></li>';
|
||||
}
|
||||
$view .='</ul></div>';
|
||||
|
||||
return $view;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// download to excell function
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Reference in New Issue
Block a user