From ca4976754f3f968cb889b9a86234c8a6b78ad8b7 Mon Sep 17 00:00:00 2001 From: Thomas Vincent Date: Thu, 9 Apr 2026 13:59:05 -0700 Subject: [PATCH 1/4] refactor: add strict typing and clean up standalone infra --- .omc/sessions/c0ab85d1-d888-4fad-b941-516cdad3f729.json | 8 ++++++++ .omc/sessions/df36c0d4-5118-49a8-b66b-5f851e645aa8.json | 8 ++++++++ hmib.php | 2 ++ hmib_types.php | 2 ++ index.php | 2 ++ locales/LC_MESSAGES/index.php | 2 ++ locales/index.php | 2 ++ setup.php | 2 ++ snmp.php | 2 ++ snmp_functions.php | 2 ++ templates/index.php | 2 ++ 11 files changed, 34 insertions(+) create mode 100644 .omc/sessions/c0ab85d1-d888-4fad-b941-516cdad3f729.json create mode 100644 .omc/sessions/df36c0d4-5118-49a8-b66b-5f851e645aa8.json diff --git a/.omc/sessions/c0ab85d1-d888-4fad-b941-516cdad3f729.json b/.omc/sessions/c0ab85d1-d888-4fad-b941-516cdad3f729.json new file mode 100644 index 0000000..c47d5a4 --- /dev/null +++ b/.omc/sessions/c0ab85d1-d888-4fad-b941-516cdad3f729.json @@ -0,0 +1,8 @@ +{ + "session_id": "c0ab85d1-d888-4fad-b941-516cdad3f729", + "ended_at": "2026-04-09T10:42:29.076Z", + "reason": "other", + "agents_spawned": 1, + "agents_completed": 0, + "modes_used": [] +} \ No newline at end of file diff --git a/.omc/sessions/df36c0d4-5118-49a8-b66b-5f851e645aa8.json b/.omc/sessions/df36c0d4-5118-49a8-b66b-5f851e645aa8.json new file mode 100644 index 0000000..562ae2e --- /dev/null +++ b/.omc/sessions/df36c0d4-5118-49a8-b66b-5f851e645aa8.json @@ -0,0 +1,8 @@ +{ + "session_id": "df36c0d4-5118-49a8-b66b-5f851e645aa8", + "ended_at": "2026-04-09T10:29:57.868Z", + "reason": "other", + "agents_spawned": 0, + "agents_completed": 0, + "modes_used": [] +} \ No newline at end of file diff --git a/hmib.php b/hmib.php index b5670eb..d21bff8 100644 --- a/hmib.php +++ b/hmib.php @@ -1,4 +1,6 @@ Date: Thu, 9 Apr 2026 14:02:34 -0700 Subject: [PATCH 2/4] refactor: safe PHP 7.4 modernization (arrays, null coalescing) --- hmib.php | 216 +++++++++++++++++++++++----------------------- hmib_types.php | 58 ++++++------- poller_graphs.php | 32 +++---- poller_hmib.php | 18 ++-- setup.php | 38 ++++---- snmp.php | 20 ++--- 6 files changed, 191 insertions(+), 191 deletions(-) diff --git a/hmib.php b/hmib.php index d21bff8..48676a8 100644 --- a/hmib.php +++ b/hmib.php @@ -100,50 +100,50 @@ function hmib_history() { /* ================= input validation and session storage ================= */ $filters = array( - 'rows' => array( + 'rows' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1' - ), - 'page' => array( + ], + 'page' => [ 'filter' => FILTER_VALIDATE_INT, 'default' => '1' - ), - 'template' => array( + ], + 'template' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), - 'device' => array( + ], + 'device' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), - 'ostype' => array( + ], + 'ostype' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), + ], 'process' => array( 'filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '-1', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), - 'filter' => array( + 'filter' => [ 'filter' => FILTER_DEFAULT, 'pageset' => true, 'default' => '' - ), + ], 'sort_column' => array( 'filter' => FILTER_CALLBACK, 'default' => 'name', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_direction' => array( 'filter' => FILTER_CALLBACK, 'default' => 'ASC', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ) ); @@ -317,7 +317,7 @@ function clearFilter() { } $sql_where = "WHERE hrswls.name!='' AND hrswls.name!='System Idle Process'"; - $sql_params = array(); + $sql_params = []; $sql_limit = ' LIMIT ' . ($num_rows*(get_request_var('page')-1)) . ',' . $num_rows; $sql_order = get_order_string(); @@ -468,51 +468,51 @@ function hmib_running() { /* ================= input validation and session storage ================= */ $filters = array( - 'rows' => array( + 'rows' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1' - ), - 'page' => array( + ], + 'page' => [ 'filter' => FILTER_VALIDATE_INT, 'default' => '1' - ), - 'template' => array( + ], + 'template' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), - 'device' => array( + ], + 'device' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), - 'ostype' => array( + ], + 'ostype' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), + ], 'filter' => array( 'filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'process' => array( 'filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '-1', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_column' => array( 'filter' => FILTER_CALLBACK, 'default' => 'name', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_direction' => array( 'filter' => FILTER_CALLBACK, 'default' => 'ASC', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ) ); @@ -687,7 +687,7 @@ function clearFilter() { $sql_limit = ' LIMIT ' . ($num_rows*(get_request_var('page')-1)) . ',' . $num_rows; $sql_where = "WHERE hrswr.name != '' AND hrswr.name != 'System Idle Process'"; - $sql_params = array(); + $sql_params = []; $sql_order = get_order_string(); if (get_request_var('template') != '-1') { @@ -868,56 +868,56 @@ function hmib_hardware() { /* ================= input validation and session storage ================= */ $filters = array( - 'rows' => array( + 'rows' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1' - ), - 'page' => array( + ], + 'page' => [ 'filter' => FILTER_VALIDATE_INT, 'default' => '1' - ), - 'template' => array( + ], + 'template' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), - 'device' => array( + ], + 'device' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), - 'type' => array( + ], + 'type' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), - 'ostype' => array( + ], + 'ostype' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), + ], 'process' => array( 'filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '-1', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'filter' => array( 'filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_column' => array( 'filter' => FILTER_CALLBACK, 'default' => 'hrd.description', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_direction' => array( 'filter' => FILTER_CALLBACK, 'default' => 'ASC', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ) ); @@ -1090,7 +1090,7 @@ function clearFilter() { } $sql_where = "WHERE (hrd.description IS NOT NULL AND hrd.description!='')"; - $sql_params = array(); + $sql_params = []; $sql_limit = ' LIMIT ' . ($num_rows*(get_request_var('page')-1)) . ',' . $num_rows; $sql_order = get_order_string(); @@ -1221,56 +1221,56 @@ function hmib_storage() { /* ================= input validation and session storage ================= */ $filters = array( - 'rows' => array( + 'rows' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1' - ), - 'page' => array( + ], + 'page' => [ 'filter' => FILTER_VALIDATE_INT, 'default' => '1' - ), - 'template' => array( + ], + 'template' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), - 'device' => array( + ], + 'device' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), - 'type' => array( + ], + 'type' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), - 'ostype' => array( + ], + 'ostype' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), + ], 'process' => array( 'filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '-1', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'filter' => array( 'filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_column' => array( 'filter' => FILTER_CALLBACK, 'default' => 'hrsto.description', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_direction' => array( 'filter' => FILTER_CALLBACK, 'default' => 'ASC', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ) ); @@ -1446,7 +1446,7 @@ function clearFilter() { } $sql_where = "WHERE (hrsto.description IS NOT NULL AND hrsto.description!='')"; - $sql_params = array(); + $sql_params = []; $sql_limit = ' LIMIT ' . ($num_rows*(get_request_var('page')-1)) . ',' . $num_rows; $sql_order = get_order_string(); @@ -1595,51 +1595,51 @@ function hmib_devices() { /* ================= input validation and session storage ================= */ $filters = array( - 'rows' => array( + 'rows' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1' - ), - 'page' => array( + ], + 'page' => [ 'filter' => FILTER_VALIDATE_INT, 'default' => '1' - ), - 'template' => array( + ], + 'template' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), + ], 'process' => array( 'filter' => FILTER_CALLBACK, - 'options' => array('options' => 'sanitize_search_string'), + 'options' => ['options' => 'sanitize_search_string'], 'pageset' => true, 'default' => '-1', ), - 'status' => array( + 'status' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), - 'ostype' => array( + ], + 'ostype' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), + ], 'filter' => array( 'filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_column' => array( 'filter' => FILTER_CALLBACK, 'default' => 'description', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_direction' => array( 'filter' => FILTER_CALLBACK, 'default' => 'ASC', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ) ); @@ -1747,7 +1747,7 @@ function hmib_devices() { INNER JOIN plugin_hmib_hrSystem ON host.id=plugin_hmib_hrSystem.host_id'); - $statuses = array_merge($statuses, array('-2' => array('status' => '-2'))); + $statuses = array_merge($statuses, array('-2' => ['status' => '-2'])); if (cacti_sizeof($statuses)) { foreach($statuses AS $s) { @@ -1831,7 +1831,7 @@ function clearFilter() { $sql_limit = ' LIMIT ' . ($num_rows*(get_request_var('page')-1)) . ',' . $num_rows; $sql_where = ''; - $sql_params = array(); + $sql_params = []; $sql_order = get_order_string(); if (get_request_var('template') != '-1') { @@ -2114,50 +2114,50 @@ function hmib_software() { /* ================= input validation and session storage ================= */ $filters = array( - 'rows' => array( + 'rows' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1' - ), - 'page' => array( + ], + 'page' => [ 'filter' => FILTER_VALIDATE_INT, 'default' => '1' - ), - 'template' => array( + ], + 'template' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), - 'device' => array( + ], + 'device' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), - 'type' => array( + ], + 'type' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), - 'ostype' => array( + ], + 'ostype' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1', - ), + ], 'filter' => array( 'filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_column' => array( 'filter' => FILTER_CALLBACK, 'default' => 'name', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_direction' => array( 'filter' => FILTER_CALLBACK, 'default' => 'ASC', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ) ); @@ -2334,7 +2334,7 @@ function clearFilter() { $sql_limit = ' LIMIT ' . ($num_rows*(get_request_var('page')-1)) . ',' . $num_rows; $sql_where = ''; - $sql_params = array(); + $sql_params = []; $sql_order = get_order_string(); if (get_request_var('template') != '-1') { @@ -2508,24 +2508,24 @@ function hmib_summary() { 'pageset' => true, 'default' => read_config_option('hmib_top_processes') ), - 'page' => array( + 'page' => [ 'filter' => FILTER_VALIDATE_INT, 'default' => '1' - ), - 'filter' => array( + ], + 'filter' => [ 'filter' => FILTER_DEFAULT, 'pageset' => true, 'default' => '' - ), + ], 'sort_column' => array( 'filter' => FILTER_CALLBACK, 'default' => 'maxCpu', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_direction' => array( 'filter' => FILTER_CALLBACK, 'default' => 'DESC', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ) ); @@ -2571,12 +2571,12 @@ function hmib_summary() { 'sort_column' => array( 'filter' => FILTER_CALLBACK, 'default' => 'upHosts', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_direction' => array( 'filter' => FILTER_CALLBACK, 'default' => 'DESC', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ) ); @@ -2890,7 +2890,7 @@ function clearHostFilter() {