From 097481aec087634864c2af0c7b2d1b7cd63ba9a7 Mon Sep 17 00:00:00 2001 From: sva-e025532 Date: Wed, 13 Aug 2025 12:14:06 +0200 Subject: [PATCH] Standardize left navbar with sticky and full height styling across multiple pages. Optimize backend functions in `global.php`. --- AD/GroupReview.php | 2 +- AD/GroupSearch.php | 2 +- Hyper-V/Legacy-VMList.php | 2 +- Hyper-V/Migration.php | 2 +- Hyper-V/SYN-VMList.php | 2 +- Hyper-V/VMs-Backups.php | 4 +- Hyper-V/cluster-detail.php | 2 +- Hyper-V/clusters.php | 376 ++++++++++++++++------------- Inventory/Server-Detail.php | 2 +- Links/Links.php | 2 +- Rollups/Rollup-Calendar.php | 2 +- Shared-Folders/HomeDirectories.php | 2 +- Shared-Folders/eqp-prj.php | 2 +- Storage/Dashboard.php | 2 +- Storage/OrphanLUNs.php | 2 +- X/AutoremediationLog.php | 2 +- X/Inventory.php | 2 +- X/StdOut-detail.php | 2 +- X/StdOut.php | 2 +- X/sva-scu.php | 2 +- crossover/Detail.php | 2 +- crossover/Detail2.php | 2 +- crossover/GlobalCrossover.php | 2 +- dashboard/AD-Detail.php | 2 +- dashboard/EPO-Detail.php | 2 +- dashboard/GLPI-Detail.php | 2 +- dashboard/NBU-Detail.php | 2 +- dashboard/Nessus-Detail.php | 2 +- dashboard/S1-Detail.php | 2 +- dashboard/SCCM-Detail.php | 2 +- include/all.php | 288 +++++++++++++++++++++- include/global.php | 14 +- index.php | 2 +- reports/HomeDirectories.php | 2 +- reports/eqp-prj.php | 2 +- reports/heartbeat.php | 2 +- reports/sva-scu.php | 2 +- workstation/GlobalCrossover.php | 2 +- 38 files changed, 530 insertions(+), 220 deletions(-) diff --git a/AD/GroupReview.php b/AD/GroupReview.php index 0da6bee..beef160 100644 --- a/AD/GroupReview.php +++ b/AD/GroupReview.php @@ -30,7 +30,7 @@
-
+
diff --git a/AD/GroupSearch.php b/AD/GroupSearch.php index 4992404..1d2914e 100644 --- a/AD/GroupSearch.php +++ b/AD/GroupSearch.php @@ -35,7 +35,7 @@
-
+
diff --git a/Hyper-V/Legacy-VMList.php b/Hyper-V/Legacy-VMList.php index 7ab1827..5ef4d51 100644 --- a/Hyper-V/Legacy-VMList.php +++ b/Hyper-V/Legacy-VMList.php @@ -37,7 +37,7 @@
-
+
diff --git a/Hyper-V/Migration.php b/Hyper-V/Migration.php index a0afb42..3599046 100644 --- a/Hyper-V/Migration.php +++ b/Hyper-V/Migration.php @@ -35,7 +35,7 @@
-
+
diff --git a/Hyper-V/SYN-VMList.php b/Hyper-V/SYN-VMList.php index 0f2903a..df95599 100644 --- a/Hyper-V/SYN-VMList.php +++ b/Hyper-V/SYN-VMList.php @@ -36,7 +36,7 @@
-
+
diff --git a/Hyper-V/VMs-Backups.php b/Hyper-V/VMs-Backups.php index d28e5f5..28577a3 100644 --- a/Hyper-V/VMs-Backups.php +++ b/Hyper-V/VMs-Backups.php @@ -35,7 +35,7 @@
-
+
@@ -84,7 +84,7 @@ $answers = Invoke_infra("SELECT * FROM VMs_Backup where ( Owner like 'DUN-VMH%' or Owner like 'MDK-VMH%' ) and name not like 'WS%' and owner not like '%WKG%' and owner not like '%VMH-WM%' and Exclusion ='' and (LastResult <> 'OK' or lastresult is null) and policy is not null order by lastresult,name"); foreach ($answers as $row) { $er++; - $date1 = date_create($row['LastKnownGood']); $diff = date_diff($date1, date_create(date("Y-m-d"))); + $date1 = date_create($row['LastKnownGood']??'01/01/1970'); $diff = date_diff($date1, date_create(date("Y-m-d"))); if ($diff->format("%R%a") >= 2 || $row['LastKnownGood'] == ''){ echo ""; }else{ diff --git a/Hyper-V/cluster-detail.php b/Hyper-V/cluster-detail.php index 4f875c7..5d3b465 100644 --- a/Hyper-V/cluster-detail.php +++ b/Hyper-V/cluster-detail.php @@ -34,7 +34,7 @@
-
+
diff --git a/Hyper-V/clusters.php b/Hyper-V/clusters.php index bc0fe29..8e92781 100644 --- a/Hyper-V/clusters.php +++ b/Hyper-V/clusters.php @@ -34,190 +34,233 @@
-
+

Hyper-V Clusters

- - - '' and cluster not like '%-WM%' and cluster not like '%-C1MAS%' and cluster not like '%-vrs%' and (cluster like 'DUN%' or cluster like 'DMV%') order by cluster"); - ?>
-
"; + // ================================================================= + // STEP 1: Fetch all required data with minimal database queries (MSSQL SYNTAX) + // ================================================================= + + // Query 1: Get aggregated data for all clusters at once. + $cluster_query = " + SELECT + cluster, + COUNT(node) as node_count, + MIN(node_ram) as min_node_ram, + SUM(TRY_CAST(vm_count AS INT)) as total_vms, + SUM(TRY_CAST(vm_memory AS INT)) as total_vm_memory, + SUM(TRY_CAST(io_disk AS FLOAT)) as total_io_disk, + STRING_AGG(CAST(csvs AS VARCHAR(MAX)), '|') as all_csvs + FROM + cmdb_HyperV_Hosts + WHERE + cluster <> '' + AND cluster NOT LIKE '%-WM%' + AND cluster NOT LIKE '%-C1MAS%' + AND cluster NOT LIKE '%-vrs%' + AND (cluster LIKE 'DUN%' OR cluster LIKE 'DMV%') + GROUP BY + cluster + ORDER BY + cluster + "; + $all_clusters_data = Invoke_Infra($cluster_query); + + // Query 2: Get VM distribution for all relevant clusters at once. + $vm_repart_query = " + SELECT + v.Cluster, + v.Owner, + count(v.Owner) as vm_count + FROM + cmdb_vms v + INNER JOIN cmdb_HyperV_Hosts h ON v.Cluster = h.cluster + WHERE + v.decomtime IS NULL + AND h.cluster <> '' + AND h.cluster NOT LIKE '%-WM%' + AND h.cluster NOT LIKE '%-C1MAS%' + AND h.cluster NOT LIKE '%-vrs%' + AND (h.cluster LIKE 'DUN%' OR h.cluster LIKE 'DMV%') + GROUP BY + v.Cluster, v.Owner + ORDER BY + v.Cluster, v.Owner + "; + $raw_vm_distribution = Invoke_Infra($vm_repart_query); + + // Process the VM distribution data into an easy-to-use associative array + $vm_distribution = []; + if (is_array($raw_vm_distribution)) { + foreach ($raw_vm_distribution as $repart) { + $vm_distribution[$repart['Cluster']][] = [ + 'owner' => $repart['Owner'], + 'vm_count' => $repart['vm_count'] + ]; } - $data = Invoke_Infra("select * from cmdb_HyperV_Hosts where cluster = '" . $cluster['cluster'] . "'"); - $clumem = (invoke_infra("select min(node_ram) as nmem from cmdb_HyperV_Hosts where cluster ='".$cluster['cluster']."'"))[0]['nmem']; - $nb = (invoke_infra("select count(node) as nb from cmdb_HyperV_Hosts where cluster ='".$cluster['cluster']."'"))[0]['nb']; - $clmem = $clumem-32; if($nb == 4){$clmem = $clmem*2;} - $nodes = count($data); - $vms = 0; - $vm_mem = 0; - $disk = 0; - $io = 0; - $node_mem = 0; - $capacity = 0; $free = 0; - foreach ($data as $d) { - $vms += $d['vm_count']; - $vm_mem += $d['vm_memory']; - $node_mem = (int) $d['node_ram']; - foreach (explode("|", $d['csvs']) as $csv) { - if (str_contains($csv, ';')) { - $free += intval(explode(";", $csv)[1]) - intval(explode(";", $csv)[2]); - $disk = max($disk, $free); - $capacity += (int) explode(";", $csv)[1]; + } + // ================================================================= + // STEP 2: Loop through the pre-fetched data and display it + // ================================================================= + $total_vms_left = 0; + $cluster_count = 0; + + if (is_array($all_clusters_data)) { + foreach ($all_clusters_data as $cluster_data) { + if ($cluster_count > 0 && $cluster_count % 4 == 0) { + echo "
"; + } + + // --- Calculations --- + $cluster_name = $cluster_data['cluster']; + $node_count = (int)$cluster_data['node_count']; + $total_vms = (int)$cluster_data['total_vms']; + $total_vm_memory = (int)$cluster_data['total_vm_memory']; + + // Memory calculation + $cluster_usable_mem = (int)$cluster_data['min_node_ram'] - 32; + if ($node_count == 4) { + $cluster_usable_mem *= 2; + } + $free_mem = $cluster_usable_mem - $total_vm_memory; + $free_mem_percentage = ($cluster_usable_mem > 0) ? round($free_mem / $cluster_usable_mem * 100) : 0; + + // Storage calculation + $capacity_gb = 0; + $free_gb = 0; + if (!empty($cluster_data['all_csvs'])) { + // Explode the big string into an array of all CSV entries (with duplicates) + $all_csv_entries = explode("|", $cluster_data['all_csvs']); + // Create a new array containing only the unique CSV entries + $unique_csv_entries = array_unique($all_csv_entries); + // Loop through the UNIQUE entries to perform the calculation + foreach ($unique_csv_entries as $csv_string) { + if (str_contains($csv_string, ';')) { + $parts = explode(";", $csv_string); + if(count($parts) >= 3) { + $capacity_gb += (int)$parts[1]; + // Free space is Total Capacity (parts[1]) - Used Space (parts[2]) + $free_gb += (int)$parts[1] - (int)$parts[2]; + } + } } } - $io += $d['io_disk']; - } - $node_mem = $node_mem * count($data) / 2; - $io= round($io / count($data) * 1024); - if($io == 0){$io = "?";} - $vmleft = floor(($node_mem - 24 - $vm_mem) / 16); - $storageleft = floor($disk / 110); - $vmleft = min($vmleft, $storageleft); - $totalleft += $vmleft; - if ($vmleft > 2) { - $vleft = "(" . $vmleft . " VMs left)"; - } elseif ($vmleft == 2) { - $vleft = "(" . $vmleft . " VMs left)"; - } else { - $vleft = "(" . $vmleft . " VM left)"; - } + $free_gb = max(0, $free_gb); + $free_storage_percentage = ($capacity_gb > 0) ? round($free_gb / $capacity_gb * 100) : 0; - ?> + // IOPS Calculation + $avg_io = ($node_count > 0) ? round((float)$cluster_data['total_io_disk'] / $node_count * 1024) : 0; + $io_display = ($avg_io == 0) ? "?" : $avg_io; -
- -
-
-

- -

-
- Nodes / VMs -
- 0){ - $Repart = Invoke_Infra("select Owner, count(owner) as nbvm from cmdb_vms where Cluster ='".$cluster['cluster']."' and decomtime is null group by Owner order by Owner"); - $vmCountNode1 = $vmCountNode2 = 0; - $node1_name = $node2_name = ""; - if(isset($Repart) && count($Repart) == 1 ){ - $node1_name = $Repart[0]['Owner']; $vmCountNode1 = $Repart[0]['nbvm']; - }else{ - $node1_name = 'DUN'; $vmCountNode1 = $Repart[0]['nbvm']; - $node2_name = 'MDK'; $vmCountNode2 = $Repart[1]['nbvm']; + // VMs Left Calculation + $vms_left_by_mem = ($free_mem > 0) ? floor($free_mem / 16) : 0; + $vms_left_by_storage = ($free_gb > 0) ? floor($free_gb / 110) : 0; + $vms_left = min($vms_left_by_mem, $vms_left_by_storage); + $total_vms_left += $vms_left; + + // --- Display Logic --- + if ($vms_left > 2) { + $vleft_html = "(" . $vms_left . " VMs left)"; + } elseif ($vms_left >= 1) { // Handles 1 and 2 + $vleft_html = "(" . $vms_left . " VMs left)"; + } else { + $vleft_html = "(" . $vms_left . " VMs left)"; + } + ?> + +
+ +
+
+

+
+ Nodes / VMs +
+ +
"; + if ($total_vms > 0 && isset($vm_distribution[$cluster_name])) { + $dist_data = $vm_distribution[$cluster_name]; + if ($node_count == 2 && count($dist_data) > 0) { + $owner1_name = $dist_data[0]['owner']; + $owner1_count = $dist_data[0]['vm_count']; + $owner2_name = isset($dist_data[1]) ? $dist_data[1]['owner'] : 'N/A'; + $owner2_count = isset($dist_data[1]) ? $dist_data[1]['vm_count'] : 0; + + $p1 = ($total_vms > 0) ? ($owner1_count / $total_vms) * 100 : 0; + $p2 = ($total_vms > 0) ? ($owner2_count / $total_vms) * 100 : 0; + + $vm_dist_html = "
+
$owner1_name: $owner1_count
+
$owner2_name: $owner2_count
+
"; + } } - $totalVMs = $vmCountNode1 + $vmCountNode2; - $percentageNode1 = ($totalVMs > 0) ? ($vmCountNode1 / $totalVMs) * 100 : 0; - $percentageNode2 = ($totalVMs > 0) ? ($vmCountNode2 / $totalVMs) * 100 : 0; - echo "
-
- $node1_name : $vmCountNode1 VMs -
-
- $node2_name : $vmCountNode2 VMs -
-
"; - }elseif($nodes == 4){ - $RepartD = Invoke_Infra("select count(owner) as nbvm from cmdb_vms where Cluster ='".$cluster['cluster']."' and Owner like 'DUN%' and decomtime is null"); - $RepartM = Invoke_Infra("select count(owner) as nbvm from cmdb_vms where Cluster ='".$cluster['cluster']."' and Owner like 'MDK%' and decomtime is null"); - $vmCountNode1 = $vmCountNode2 = 0; - $node1_name = 'DUN'; $vmCountNode1 = $RepartD[0]['nbvm']; - $node2_name = 'MDK'; $vmCountNode2 = $RepartM[0]['nbvm']; - $totalVMs = $vmCountNode1 + $vmCountNode2; - $percentageNode1 = ($totalVMs > 0) ? ($vmCountNode1 / $totalVMs) * 100 : 0; - $percentageNode2 = ($totalVMs > 0) ? ($vmCountNode2 / $totalVMs) * 100 : 0; - echo "
-
- $node1_name : $vmCountNode1 VMs -
-
- $node2_name : $vmCountNode2 VMs -
-
"; + echo $vm_dist_html; + ?> +
+
+ +
+
Free Mem: GB
+
+
+
+
+
+
+
- }else{ - echo "
-
-
"; - } - ?> + 10000) { + $disk_unit = "TB"; + $display_capacity = round($capacity_gb / 1024, 1); + $display_free = round($free_gb / 1024, 1); + } + $disk_color = ($free_storage_percentage <= 5) ? 'bg-danger' : (($free_storage_percentage <= 10) ? 'bg-warning' : 'bg-success'); + $disk_border = ($free_storage_percentage <= 5) ? 'red' : (($free_storage_percentage <= 10) ? 'yellow' : 'green'); + $disk_used_percentage = 100 - $free_storage_percentage; + ?> +
+
Free CSV:
+
+
+
+
+
+
+
+
CSV I/O (24h):
KB/s
+
-
- "; - echo "
"; - echo "Free Mem : ".($clmem - $vm_mem). " / " .$clmem. " GB"; - echo "
"; - $pcent = round(($clmem - $vm_mem)/$clmem*100); - $pcent_restant = 100 - $pcent; - if($pcent <= 5){ - $color = "bg-danger"; $border = "red"; - }else{ - if($pcent <= 10){ - $color = "bg-warning"; $border = "yellow"; - }else{ - $color = "bg-success"; $border = "green"; - } - } - echo " -
-
-
-
"; - echo "
"; - //DISK - echo "
"; - echo "
"; - $unit="GB"; - if($capacity > 10000){ - $capacity = round($capacity / 1024,1); $unit="TB"; - $free = round($free / 1024,1); - } - $used = $capacity - $free; - echo "Free CSV : ".$free. " / " .$capacity. " $unit"; - echo "
"; - $pcent = ($clmem > 0) ? round(($clmem - $vm_mem) / $clmem * 100) : 0; - $pcent_restant = 100 - $pcent; - if($pcent <= 5){ - $color = "bg-danger"; $border = "red"; - }else{ - if($pcent <= 10){ - $color = "bg-warning"; $border = "yellow"; - }else{ - $color = "bg-success"; $border = "green"; - } - } - echo " -
-
-
-
"; - echo "
"; - echo "
CSV I/O R/W (24h) :
$io KB/s
"; +
+
- ?> -
-
- -
- - -

Total VM Left :

+
+
+

+

Total VMs Left:

+
+
@@ -226,6 +269,3 @@ - \ No newline at end of file diff --git a/Inventory/Server-Detail.php b/Inventory/Server-Detail.php index 88d1701..50367a5 100644 --- a/Inventory/Server-Detail.php +++ b/Inventory/Server-Detail.php @@ -77,7 +77,7 @@
-
+
diff --git a/Links/Links.php b/Links/Links.php index 2e77ec9..a27bb32 100644 --- a/Links/Links.php +++ b/Links/Links.php @@ -29,7 +29,7 @@
-
+
diff --git a/Rollups/Rollup-Calendar.php b/Rollups/Rollup-Calendar.php index 2a7f522..b1c14b3 100644 --- a/Rollups/Rollup-Calendar.php +++ b/Rollups/Rollup-Calendar.php @@ -56,7 +56,7 @@
-
+
diff --git a/Shared-Folders/HomeDirectories.php b/Shared-Folders/HomeDirectories.php index 50d6aee..ae444f9 100644 --- a/Shared-Folders/HomeDirectories.php +++ b/Shared-Folders/HomeDirectories.php @@ -43,7 +43,7 @@
-
+
diff --git a/Shared-Folders/eqp-prj.php b/Shared-Folders/eqp-prj.php index a737dbb..9e8fa83 100644 --- a/Shared-Folders/eqp-prj.php +++ b/Shared-Folders/eqp-prj.php @@ -38,7 +38,7 @@
-
+
diff --git a/Storage/Dashboard.php b/Storage/Dashboard.php index 4ad2704..c5ea8b2 100644 --- a/Storage/Dashboard.php +++ b/Storage/Dashboard.php @@ -135,7 +135,7 @@
-
+
diff --git a/Storage/OrphanLUNs.php b/Storage/OrphanLUNs.php index 547b917..5fd512b 100644 --- a/Storage/OrphanLUNs.php +++ b/Storage/OrphanLUNs.php @@ -39,7 +39,7 @@
-
+
diff --git a/X/AutoremediationLog.php b/X/AutoremediationLog.php index fee02a1..35c4c93 100644 --- a/X/AutoremediationLog.php +++ b/X/AutoremediationLog.php @@ -38,7 +38,7 @@
-
+
diff --git a/X/Inventory.php b/X/Inventory.php index a2b181a..2e572a1 100644 --- a/X/Inventory.php +++ b/X/Inventory.php @@ -40,7 +40,7 @@
-
+
diff --git a/X/StdOut-detail.php b/X/StdOut-detail.php index 8aaa002..a67deb9 100644 --- a/X/StdOut-detail.php +++ b/X/StdOut-detail.php @@ -35,7 +35,7 @@
-
+
diff --git a/X/StdOut.php b/X/StdOut.php index 1bc8ea2..6a750a4 100644 --- a/X/StdOut.php +++ b/X/StdOut.php @@ -34,7 +34,7 @@
-
+
diff --git a/X/sva-scu.php b/X/sva-scu.php index 456f625..740f3fa 100644 --- a/X/sva-scu.php +++ b/X/sva-scu.php @@ -38,7 +38,7 @@
-
+
diff --git a/crossover/Detail.php b/crossover/Detail.php index 656b906..b6e3ae3 100644 --- a/crossover/Detail.php +++ b/crossover/Detail.php @@ -31,7 +31,7 @@
-
+
diff --git a/crossover/Detail2.php b/crossover/Detail2.php index fdcf6ac..921a812 100644 --- a/crossover/Detail2.php +++ b/crossover/Detail2.php @@ -31,7 +31,7 @@
-
+
diff --git a/crossover/GlobalCrossover.php b/crossover/GlobalCrossover.php index be8587f..e6a3ca8 100644 --- a/crossover/GlobalCrossover.php +++ b/crossover/GlobalCrossover.php @@ -35,7 +35,7 @@
-
+
diff --git a/dashboard/AD-Detail.php b/dashboard/AD-Detail.php index dff3aac..86a7cb1 100644 --- a/dashboard/AD-Detail.php +++ b/dashboard/AD-Detail.php @@ -31,7 +31,7 @@
-
+
diff --git a/dashboard/EPO-Detail.php b/dashboard/EPO-Detail.php index 99d158d..7e6b77b 100644 --- a/dashboard/EPO-Detail.php +++ b/dashboard/EPO-Detail.php @@ -30,7 +30,7 @@
-
+
diff --git a/dashboard/GLPI-Detail.php b/dashboard/GLPI-Detail.php index 4735d19..72780de 100644 --- a/dashboard/GLPI-Detail.php +++ b/dashboard/GLPI-Detail.php @@ -30,7 +30,7 @@
-
+
diff --git a/dashboard/NBU-Detail.php b/dashboard/NBU-Detail.php index ac6261b..61ea923 100644 --- a/dashboard/NBU-Detail.php +++ b/dashboard/NBU-Detail.php @@ -31,7 +31,7 @@
-
+
diff --git a/dashboard/Nessus-Detail.php b/dashboard/Nessus-Detail.php index 99d158d..7e6b77b 100644 --- a/dashboard/Nessus-Detail.php +++ b/dashboard/Nessus-Detail.php @@ -30,7 +30,7 @@
-
+
diff --git a/dashboard/S1-Detail.php b/dashboard/S1-Detail.php index 9c17d7e..d945bf6 100644 --- a/dashboard/S1-Detail.php +++ b/dashboard/S1-Detail.php @@ -30,7 +30,7 @@
-
+
diff --git a/dashboard/SCCM-Detail.php b/dashboard/SCCM-Detail.php index fc55665..9c41d30 100644 --- a/dashboard/SCCM-Detail.php +++ b/dashboard/SCCM-Detail.php @@ -31,7 +31,7 @@
-
+
diff --git a/include/all.php b/include/all.php index edfb06e..57bf06e 100644 --- a/include/all.php +++ b/include/all.php @@ -1,7 +1,285 @@ ['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 PostJson($url, $content){ + $curl = curl_init($url); + curl_setopt($curl, CURLOPT_HEADER, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json")); + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, $content); + $retour = curl_exec($curl); + curl_close($curl); + return $retour; + } + + //invoke// + function Invoke_Infra($request) + { + error_reporting(E_ALL ^ E_WARNING); + $user = "INFRA_dbo"; + $pwd = decypher("infra"); + $server = "DUN-PRD-R1MSSQL.armony.net\PRD"; + $database = "INFRA"; + $conn = odbc_connect("Driver={SQL Server};Server=$server;Database=$database;", $user, $pwd); + if (!($conn)) { + echo "Pas de connexion"; + } + $rs = odbc_exec($conn, $request); + if (str_contains(strtoupper($request), "SELECT")) { + while ($row = odbc_fetch_array($rs)) { + $answer[] = $row; + } + } + if (isset($answer)) { + return $answer; + } else { + if ($rs) { + return "OK"; + } else { + error_reporting(E_ALL); + return "ERROR : " . odbc_errormsg($conn); + } + } + + } + function Invoke_WebSelfInfra($request) + { + $user = "Scom-Write"; + $pwd = decypher("web-self-infra"); + $server = "DUN-PRD-R1SCOM.armony.net\OPS"; + $database = "web-self-infra"; + $conn = odbc_connect("Driver={SQL Server};Server=$server;Database=$database;", $user, $pwd); + if (!($conn)) { + echo "Pas de connexion"; + } + $rs = odbc_exec($conn, $request); + if (str_contains(strtoupper($request), "SELECT")) { + while ($row = odbc_fetch_array($rs)) { + $answer[] = $row; + } + } + return $answer ?? null; + } + function Invoke_WebInfraReports($request) + { + $user = "admin"; + $pwd = decypher("web-infra-reports"); + $server = "dun-sup-s2entry.armony.net:3306"; + $database = "web-infra-reports"; + $conn = new mysqli($server, $user, $pwd, $database); + $rs = $conn->query($request); + while ($row = mysqli_fetch_array($rs)) { + $answer[] = $row; + } + return $answer ?? null; + + } + function Invoke_SCOMInfra($request) + { + $user = "Scom-Write"; + $pwd = decypher("ScomInfra"); + $server = "DUN-PRD-R1SCOM.armony.net\OPS"; + $database = "infra"; + $conn = odbc_connect("Driver={SQL Server};Server=$server;Database=$database;", $user, $pwd); + if (!($conn)) { + echo "Pas de connexion"; + } + $rs = odbc_exec($conn, $request); + if (str_contains(strtoupper($request), "SELECT")) { + while ($row = odbc_fetch_array($rs)) { + $answer[] = $row; + } + } + return $answer ?? null; + } + function Invoke_Entry01($request) + { + $user = "infra"; + $pwd = decypher("entry01"); + $server = "dun-sup-entry01:3306"; + $database = "infra"; + $conn = new mysqli($server, $user, $pwd, $database); + $rs = $conn->query($request); + while ($row = mysqli_fetch_array($rs)) { + $answer[] = $row; + } + return $answer ?? null; + } + function Invoke_WebInfraTools($request) + { + $user = "admin"; + $pwd = decypher("web-infra-tools"); + $server = "dun-sup-s2entry.armony.net:3306"; + $database = "webinfratools"; + $conn = new mysqli($server, $user, $pwd, $database); + $rs = $conn->query($request); + while ($row = mysqli_fetch_array($rs)) { + $answer[] = $row; + } + return $answer ?? null; + } + function Invoke_GLPI($request) + { + $user="glpi_lect_seule"; + $pwd=decypher("glpi"); + $server="mys_glpi_prod.appliarmony.net"; + $database="glpi"; + $conn = new mysqli($server, $user, $pwd, $database); + $rs = $conn->query($request); + while ($row = mysqli_fetch_array($rs)) { + $answer[] = $row; + } + return $answer ?? null; + } + function Invoke_aixcmdb($request) + { + $conn_string = "DRIVER={IBM DB2 ODBC DRIVER - F_DB2_clidriver};" . + "DATABASE=AIXCMDB; " . + "HOSTNAME=db2_aixcmdb.appliarmony.net;" . + "PORT=50000; " . + "PROTOCOL=TCPIP; " . + "UID=aixcmdb;" . + "AUTHENTICATION=SERVER;" . + "PWD=".decypher('aixcmdb').";"; + + $conn = odbc_connect($conn_string, "", ""); + if (!$conn) { + $error_message = "ODBC Connect Error: " . odbc_errormsg() . " (" . odbc_error() . ")"; + echo "Pas de connexion : " . $error_message . "
"; + return "ERROR: Could not connect to DB2. Check connection string and ODBC setup."; + } + $rs = odbc_exec($conn, $request); + if (str_contains(strtoupper($request), "SELECT")) { + $answer = []; + while ($row = odbc_fetch_array($rs)) { + $answer[] = $row; + } + } + if (isset($answer)) { + return $answer; + } else { + if ($rs) { + return "OK"; + } else { + error_reporting(E_ALL); + return "ERROR : " . odbc_errormsg($conn); + } + } + } + + + + + //DB Conn// + function DB_SCCM(){ + $user = "infra"; + $pwd = decypher("SCCM"); + $conn = odbc_connect("Driver={SQL Server};Server=DUN-SMS-SRV01;Database=CM_SV1;", $user, $pwd); + return $conn; + } + function DB_GLPI() { + $username="glpi_lect_seule"; + $password=decypher( "glpi"); + $dbserver="mys_glpi_prod.appliarmony.net"; + $database="glpi"; + $conn = new mysqli($dbserver,$username,$password,$database); + return $conn; + } + function DB_ENTRY01() { + $username="infra"; + $password=decypher("entry01"); + $dbserver="dun-sup-entry01.armony.net"; + $database="infra"; + $conn = new mysqli($dbserver,$username,$password,$database); + return $conn; + } + function DB_ENTRY02() { + $username="admin"; + $password=decypher("web-infra-reports"); + $dbserver="dun-sup-s2entry.armony.net"; + $database="web-infra-reports"; + $conn = new mysqli($dbserver,$username,$password,$database); + return $conn ; + } + function DB_INFRA() { + $user="INFRA_dbo"; + $pwd=decypher("infra"); + $server="DUN-PRD-R1MSSQL.armony.net\PRD"; + $database="INFRA"; + $conn = odbc_connect("Driver={SQL Server};Server=$server;Database=$database;", $user, $pwd); + return $conn ; + } + 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; + } + +?> + + + \ No newline at end of file diff --git a/include/global.php b/include/global.php index 183fb29..b503cbb 100644 --- a/include/global.php +++ b/include/global.php @@ -10,7 +10,7 @@ //tools// function decypher(string $name): ?string { $openssl = 'C:\Program Files\FireDaemon OpenSSL 3\bin\openssl.exe'; - $cmsFile = "F:\\Include\\dat\\{$name}.p7m"; + $cmsFile = "F:\\Include\\dat\\$name.p7m"; $certPem = "F:\\Include\\certs\\cert_only.pem"; $keyPem = "F:\\Include\\certs\\key_only.pem"; @@ -134,7 +134,6 @@ return $answer ?? null; } - function Invoke_Infra($request) { error_reporting(E_ALL ^ E_WARNING); @@ -203,20 +202,14 @@ { $user="glpi_lect_seule"; $pwd=decypher("glpi"); - $server="srvv-n4glpi-aim.process.dkm"; $server="mys_glpi_prod.appliarmony.net"; $database="glpi"; $conn = new mysqli($server, $user, $pwd, $database); - if (!($conn)) { - echo "Pas de connexion"; - } $rs = $conn->query($request); while ($row = mysqli_fetch_array($rs)) { $answer[] = $row; } - if (isset($answer)) { - return $answer; - } + return $answer ?? null; } //DB Conn// @@ -270,14 +263,13 @@ ?> -//HTML//