Improve inventory handling and cookie management:
- Replace old cookie logic with `Set_Cookie()` for enhanced security (SameSite, Secure, HttpOnly). - Add dynamic AIX/Linux filtering on `/X/Inventory.php` with checkbox-driven UI and adjusted SQL queries. - Expand `/X/Inventory.php` table with additional columns (`BES`, `FI`) and enhance data validation/styling. - Add `decypher()` function in `Z_data_linux.php` to support OpenSSL-based file decryption with error handling.
This commit is contained in:
@@ -1,5 +1,48 @@
|
||||
<?php
|
||||
include $_SERVER['DOCUMENT_ROOT']."/include/all.php" ;
|
||||
function decypher(string $name): ?string {
|
||||
$openssl = 'C:\Program Files\FireDaemon OpenSSL 3\bin\openssl.exe';
|
||||
$cmsFile = "F:\\Include\\dat\\$name.p7m";
|
||||
$certPem = "F:\\Include\\certs\\cert_only.pem";
|
||||
$keyPem = "F:\\Include\\certs\\key_only.pem";
|
||||
|
||||
foreach ([$openssl,$cmsFile,$certPem,$keyPem] as $p) {
|
||||
if (!is_file($p)) { error_log("Missing file: $p"); return null; }
|
||||
}
|
||||
|
||||
$cmd = '"' . $openssl . '" cms -decrypt -inform PEM'
|
||||
. ' -in ' . escapeshellarg($cmsFile)
|
||||
. ' -recip ' . escapeshellarg($certPem)
|
||||
. ' -inkey ' . escapeshellarg($keyPem)
|
||||
. ' -out -';
|
||||
|
||||
$spec = [
|
||||
0 => ['pipe','r'], // stdin (unused)
|
||||
1 => ['pipe','w'], // stdout -> texte déchiffré
|
||||
2 => ['pipe','w'], // stderr -> erreurs OpenSSL
|
||||
];
|
||||
$proc = proc_open($cmd, $spec, $pipes);
|
||||
if (!is_resource($proc)) { error_log('proc_open failed'); return null; }
|
||||
fclose($pipes[0]); // rien à envoyer en stdin
|
||||
|
||||
$stdout = stream_get_contents($pipes[1]); fclose($pipes[1]);
|
||||
$stderr = stream_get_contents($pipes[2]); fclose($pipes[2]);
|
||||
$code = proc_close($proc);
|
||||
|
||||
if ($code !== 0) {
|
||||
error_log("OpenSSL failed (code $code): $stderr");
|
||||
return null;
|
||||
}
|
||||
return $stdout;
|
||||
}
|
||||
function DB_ZABBIX()
|
||||
{
|
||||
$host = 'aztprdzabbix52.armony.net';
|
||||
$dbname = 'zabbix';
|
||||
$user = 'patrick';
|
||||
$pass = decypher( 'zabbix');
|
||||
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
|
||||
return $pdo;
|
||||
}
|
||||
$pdo = DB_ZABBIX();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user