diff --git a/auth_changepassword.php b/auth_changepassword.php index 8e3d65bda..05d4cb2ac 100644 --- a/auth_changepassword.php +++ b/auth_changepassword.php @@ -58,7 +58,7 @@ if (isset($_SERVER['HTTP_REFERER'])) { $return = $_SERVER['HTTP_REFERER']; if (basename($return) != 'auth_changepassword.php') { - if (strpos($return, '/plugins/') !== false) { + if (str_contains($return, '/plugins/')) { $parts = explode('/plugins/', $return); $return = CACTI_PATH_URL . 'plugins/' . $parts[1]; } else { diff --git a/auth_profile.php b/auth_profile.php index 97517a408..4fcffa170 100644 --- a/auth_profile.php +++ b/auth_profile.php @@ -299,10 +299,10 @@ function settings() : bool { if (isset($_SERVER['HTTP_REFERER'])) { $referer = $_SERVER['HTTP_REFERER']; - if (strpos($referer, 'auth_profile.php') === false) { + if (!str_contains($referer, 'auth_profile.php')) { $timespan_sel_pos = strpos($referer, '&predefined_timespan'); - if ($timespan_sel_pos) { + if ($timespan_sel_pos !== false) { $referer = substr($referer, 0, $timespan_sel_pos); } @@ -510,10 +510,10 @@ function settings_2fa() : bool { if (isset($_SERVER['HTTP_REFERER'])) { $referer = $_SERVER['HTTP_REFERER']; - if (strpos($referer, 'auth_profile.php') === false) { + if (!str_contains($referer, 'auth_profile.php')) { $timespan_sel_pos = strpos($referer, '&predefined_timespan'); - if ($timespan_sel_pos) { + if ($timespan_sel_pos !== false) { $referer = substr($referer, 0, $timespan_sel_pos); } diff --git a/cli/add_data_query.php b/cli/add_data_query.php index d5e9f40aa..1576f0803 100755 --- a/cli/add_data_query.php +++ b/cli/add_data_query.php @@ -57,7 +57,7 @@ if (cacti_sizeof($parms)) { unset($reindex_method); foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/add_datasource.php b/cli/add_datasource.php index 921310e54..e43f7e687 100755 --- a/cli/add_datasource.php +++ b/cli/add_datasource.php @@ -43,7 +43,7 @@ unset($graph_template_id); unset($data_template_id); foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/add_device.php b/cli/add_device.php index d90990aed..c0de956c4 100755 --- a/cli/add_device.php +++ b/cli/add_device.php @@ -90,7 +90,7 @@ if (cacti_sizeof($parms)) { $quietMode = false; foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/add_graph_template.php b/cli/add_graph_template.php index 146a6479f..07db22398 100755 --- a/cli/add_graph_template.php +++ b/cli/add_graph_template.php @@ -44,7 +44,7 @@ if (cacti_sizeof($parms)) { unset($graph_template_id); foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/add_group.php b/cli/add_group.php index 42837747a..45dc670c0 100755 --- a/cli/add_group.php +++ b/cli/add_group.php @@ -49,7 +49,7 @@ if (cacti_sizeof($params) == 0) { $displayHosts = false; foreach ($params as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/add_group_perms.php b/cli/add_group_perms.php index a4b784448..d8361ef03 100755 --- a/cli/add_group_perms.php +++ b/cli/add_group_perms.php @@ -59,7 +59,7 @@ if (cacti_sizeof($params) == 0) { $displayGraphTemplates = false; foreach ($params as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/add_perms.php b/cli/add_perms.php index f082a4408..4a3df0c62 100755 --- a/cli/add_perms.php +++ b/cli/add_perms.php @@ -57,7 +57,7 @@ if (cacti_sizeof($parms) == 0) { $displayGraphTemplates = false; foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/add_site.php b/cli/add_site.php index daa0b7065..dbfc153da 100755 --- a/cli/add_site.php +++ b/cli/add_site.php @@ -64,8 +64,8 @@ if (sizeof($parms)) { $hosts = ''; foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { - [$arg, $value] = explode('=', $parameter); + if (str_contains($parameter, '=')) { + [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; $value = ''; diff --git a/cli/add_tree.php b/cli/add_tree.php index 1ddd6d7eb..3b4d4a486 100755 --- a/cli/add_tree.php +++ b/cli/add_tree.php @@ -65,7 +65,7 @@ if (cacti_sizeof($parms)) { $sites = getSites(); foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/analyze_database.php b/cli/analyze_database.php index 37867d5f5..35df4918b 100755 --- a/cli/analyze_database.php +++ b/cli/analyze_database.php @@ -38,7 +38,7 @@ $start = time(); if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/apply_automation_rules.php b/cli/apply_automation_rules.php index 8769566e6..91d61eea0 100755 --- a/cli/apply_automation_rules.php +++ b/cli/apply_automation_rules.php @@ -57,7 +57,7 @@ $ids = []; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/audit_database.php b/cli/audit_database.php index dd4da2c46..d12adee3e 100755 --- a/cli/audit_database.php +++ b/cli/audit_database.php @@ -188,9 +188,9 @@ function upgrade_database() : void { $preorder[] = CACTI_PATH_PLUGINS . '/syslog'; foreach ($plugins as $p) { - if (strpos($p, 'thold') !== false) { + if (str_contains($p, 'thold')) { // Skip, upgrading this first - } elseif (strpos($p, 'syslog') !== false) { + } elseif (str_contains($p, 'syslog')) { // Skip, upgrading this second } else { $preorder[] = $p; @@ -536,7 +536,7 @@ function report_audit_results(bool $output = true) : array { $dbc[$dbcol] = ! $dbc[$dbcol] ?: str_replace('on update', 'ON UPDATE', $dbc[$dbcol]); // work around MySQL 8.x simplified int columns - if (strpos($dbc[$dbcol], 'int(') !== false) { + if (str_contains($dbc[$dbcol], 'int(')) { // Get the integer first $parts = explode('(', $dbc[$dbcol]); $adbccol = $parts[0]; @@ -782,7 +782,7 @@ function make_column_props(array &$dbc) : string { if ($dbc['table_default'] == 'CURRENT_TIMESTAMP') { $alter_cmd .= ' DEFAULT CURRENT_TIMESTAMP'; } elseif ($dbc['table_extra'] != 'auto_increment') { - if (strpos($dbc['table_type'], 'int(') !== false && $dbc['table_default'] == '') { + if (str_contains($dbc['table_type'], 'int(') && $dbc['table_default'] == '') { $alter_cmd .= ' DEFAULT "0"'; } else { $alter_cmd .= " DEFAULT '" . $dbc['table_default'] . "'"; diff --git a/cli/batchgapfix.php b/cli/batchgapfix.php index f274dbeaf..c1895107e 100755 --- a/cli/batchgapfix.php +++ b/cli/batchgapfix.php @@ -76,7 +76,7 @@ if (function_exists('pcntl_signal')) { $start = microtime(true); foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/change_device.php b/cli/change_device.php index 5d7b13a62..24c5c782c 100755 --- a/cli/change_device.php +++ b/cli/change_device.php @@ -55,7 +55,7 @@ $quietMode = false; $overrides = []; foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/convert_tables.php b/cli/convert_tables.php index 171bbee65..cf353b9a9 100755 --- a/cli/convert_tables.php +++ b/cli/convert_tables.php @@ -46,7 +46,7 @@ $local = false; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/copy_user.php b/cli/copy_user.php index 1ff913398..b8fcc0247 100755 --- a/cli/copy_user.php +++ b/cli/copy_user.php @@ -35,8 +35,8 @@ $template_user = ''; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { - [$arg, $value] = explode('=', $parameter); + if (str_contains($parameter, '=')) { + [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; $value = ''; diff --git a/cli/fix_mediumint.php b/cli/fix_mediumint.php index a1c44f93b..09a9eaae3 100755 --- a/cli/fix_mediumint.php +++ b/cli/fix_mediumint.php @@ -36,7 +36,7 @@ $local = false; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; @@ -145,8 +145,8 @@ function database_fix_mediumint_columns() : int { $attribs = database_get_column_attribs($table, $c); if (cacti_sizeof($attribs)) { - if (strpos($attribs['Type'], 'mediumint') === false) { - if (strpos($attribs['Type'], 'int(10) unsigned') !== false) { + if (!str_contains($attribs['Type'], 'mediumint')) { + if (str_contains($attribs['Type'], 'int(10) unsigned')) { debug("Column $c in Table $table already converted."); continue; @@ -198,8 +198,8 @@ function database_fix_mediumint_columns() : int { foreach ($columns as $field => $attribs) { if (array_key_exists($field, $known_columns)) { - if (strpos($attribs['Type'], 'mediumint') === false) { - if (strpos($attribs['Type'], 'int(10) unsigned') !== false) { + if (!str_contains($attribs['Type'], 'mediumint')) { + if (str_contains($attribs['Type'], 'int(10) unsigned')) { debug("Column $field in Table $table already converted."); continue; diff --git a/cli/float_rrdfiles.php b/cli/float_rrdfiles.php index 467d18e48..2bf7a1829 100755 --- a/cli/float_rrdfiles.php +++ b/cli/float_rrdfiles.php @@ -68,7 +68,7 @@ $forcerun = false; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; @@ -373,7 +373,7 @@ function float_rrdfile(string $rrd_path, int $local_data_id, mixed $step, int $s $gdelta = 0; foreach ($output as $line) { - if (strpos($line, '') !== false) { + if (str_contains($line, '')) { /** * 24 * split the database record into pieces @@ -389,10 +389,10 @@ function float_rrdfile(string $rrd_path, int $local_data_id, mixed $step, int $s $curstep = $granularity; $line .= PHP_EOL; - } elseif (strpos($line, '') !== false) { + } elseif (str_contains($line, '')) { $in_database = true; $line .= PHP_EOL; - } elseif (strpos($line, '') !== false) { + } elseif (str_contains($line, '')) { $in_database = false; $line .= PHP_EOL; } elseif ($in_database) { @@ -689,7 +689,7 @@ function sig_handler(int $signo) : void { case SIGINT: cacti_log('WARNING: RRDfile Data Float Tool terminated by user', false, 'RFLOAT'); - if (strpos($type, 'rmaster') !== false) { + if (str_contains($type, 'rmaster')) { float_kill_running_processes(); } diff --git a/cli/host_update_template.php b/cli/host_update_template.php index 6b66a0548..505b8e53d 100755 --- a/cli/host_update_template.php +++ b/cli/host_update_template.php @@ -62,7 +62,7 @@ $params = []; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/import_package.php b/cli/import_package.php index 4067c7d80..9b86095af 100755 --- a/cli/import_package.php +++ b/cli/import_package.php @@ -55,7 +55,7 @@ if (cacti_sizeof($parms)) { $profile_set = false; foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/import_template.php b/cli/import_template.php index d6e24e9fe..188593c39 100755 --- a/cli/import_template.php +++ b/cli/import_template.php @@ -48,7 +48,7 @@ if (cacti_sizeof($parms)) { $profile_id = ''; foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/input_whitelist.php b/cli/input_whitelist.php index 57fe3eeae..915b84013 100755 --- a/cli/input_whitelist.php +++ b/cli/input_whitelist.php @@ -44,7 +44,7 @@ array_shift($parms); if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/install_cacti.php b/cli/install_cacti.php index 05c6d253b..f892f93b5 100755 --- a/cli/install_cacti.php +++ b/cli/install_cacti.php @@ -45,7 +45,7 @@ define('log_install_echo', 'on'); if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/md5sum.php b/cli/md5sum.php index 9afd1a9f3..6fb8bf902 100755 --- a/cli/md5sum.php +++ b/cli/md5sum.php @@ -40,7 +40,7 @@ $base_dir = __DIR__ . '/../'; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; @@ -246,7 +246,7 @@ function dirToArray(mixed $dir, string $base, string $ignore) : array { $fulldir = realpath($fulldir); - if (strpos($fulldir, $base) !== false) { + if (str_contains($fulldir, $base)) { if (is_dir($fulldir)) { $cdir = scandir($fulldir); } else { diff --git a/cli/migrate_poller.php b/cli/migrate_poller.php index 0b8ae7291..cc7fa36ca 100755 --- a/cli/migrate_poller.php +++ b/cli/migrate_poller.php @@ -57,7 +57,7 @@ $migration_log_file = CACTI_PATH_LOG . '/migration_log_' . date('Y-m-d_H-i-s') . $migration_csv_file = CACTI_PATH_LOG . '/migration_list_' . date('Y-m-d_H-i-s') . '.csv'; foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/poller_data_sources_reapply_names.php b/cli/poller_data_sources_reapply_names.php index b0f5aab09..a54f624a0 100755 --- a/cli/poller_data_sources_reapply_names.php +++ b/cli/poller_data_sources_reapply_names.php @@ -53,7 +53,7 @@ $filter = ''; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/poller_graphs_reapply_names.php b/cli/poller_graphs_reapply_names.php index f0c6e7245..aacb9ddc6 100755 --- a/cli/poller_graphs_reapply_names.php +++ b/cli/poller_graphs_reapply_names.php @@ -43,7 +43,7 @@ $filter = ''; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/poller_output_empty.php b/cli/poller_output_empty.php index fa1fc15a1..070c6f64f 100755 --- a/cli/poller_output_empty.php +++ b/cli/poller_output_empty.php @@ -37,7 +37,7 @@ array_shift($parms); if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/poller_reindex_hosts.php b/cli/poller_reindex_hosts.php index 1b9770e66..78fe4b684 100755 --- a/cli/poller_reindex_hosts.php +++ b/cli/poller_reindex_hosts.php @@ -80,8 +80,8 @@ if ($threads == 0) { $forcerun = false; foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { - [$arg, $value] = explode('=', $parameter); + if (str_contains($parameter, '=')) { + [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; $value = ''; @@ -436,7 +436,7 @@ function sig_handler(int $signo) : void { case SIGINT: cacti_log('WARNING: Poller reindex hosts terminated by user', false, 'REINDEX'); - if (strpos($type, 'rmaster') !== false) { + if (str_contains($type, 'rmaster')) { reindex_kill_running_processes(); } diff --git a/cli/poller_replicate.php b/cli/poller_replicate.php index 38c881669..82e929336 100755 --- a/cli/poller_replicate.php +++ b/cli/poller_replicate.php @@ -45,7 +45,7 @@ array_shift($parms); if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/rebuild_poller_cache.php b/cli/rebuild_poller_cache.php index 93df2c0db..b964ca1a6 100755 --- a/cli/rebuild_poller_cache.php +++ b/cli/rebuild_poller_cache.php @@ -71,7 +71,7 @@ if ($threads == 0) { $forcerun = false; foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; @@ -394,7 +394,7 @@ function sig_handler(int $signo) : void { case SIGINT: cacti_log('WARNING: Rebuild poller cache terminated by user', false, 'PUSHOUT'); - if (strpos($type, 'rmaster') !== false) { + if (str_contains($type, 'rmaster')) { pushout_kill_running_processes(); } diff --git a/cli/refresh_csrf.php b/cli/refresh_csrf.php index 2092c0a04..0b3a4a2c0 100755 --- a/cli/refresh_csrf.php +++ b/cli/refresh_csrf.php @@ -33,7 +33,7 @@ array_shift($parms); if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/remove_broken_graphs.php b/cli/remove_broken_graphs.php index 75146294f..f238915f0 100755 --- a/cli/remove_broken_graphs.php +++ b/cli/remove_broken_graphs.php @@ -54,7 +54,7 @@ if (empty($github_actions) && CACTI_SERVER_OS == 'unix') { if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/remove_device.php b/cli/remove_device.php index db7a85bef..7fe82e41a 100755 --- a/cli/remove_device.php +++ b/cli/remove_device.php @@ -54,7 +54,7 @@ if (cacti_sizeof($parms)) { $debug = false; foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; @@ -83,7 +83,7 @@ if (cacti_sizeof($parms)) { case '--id': $id = trim($value); - if (strpos($id, ',') !== false) { + if (str_contains($id, ',')) { $ids_id = explode(',', $id); } else { $ids_id = [$id]; diff --git a/cli/removespikes.php b/cli/removespikes.php index 003feba39..14035a44a 100755 --- a/cli/removespikes.php +++ b/cli/removespikes.php @@ -84,7 +84,7 @@ array_shift($parms); if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/reorder_data_query.php b/cli/reorder_data_query.php index 9cf4f0f50..008c8802d 100755 --- a/cli/reorder_data_query.php +++ b/cli/reorder_data_query.php @@ -46,7 +46,7 @@ $host_descr = ''; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/repair_database.php b/cli/repair_database.php index 6aee2b291..e2da96823 100755 --- a/cli/repair_database.php +++ b/cli/repair_database.php @@ -48,7 +48,7 @@ $repaired_hosts = []; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/repair_graphs.php b/cli/repair_graphs.php index 28777b7e7..aec803df1 100755 --- a/cli/repair_graphs.php +++ b/cli/repair_graphs.php @@ -47,7 +47,7 @@ unset($graph_template_id); unset($data_template_id); foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/repair_templates.php b/cli/repair_templates.php index bad78eb5d..89f921431 100755 --- a/cli/repair_templates.php +++ b/cli/repair_templates.php @@ -41,7 +41,7 @@ $execute = false; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/rrdresize.php b/cli/rrdresize.php index 5fb7dc12d..906ba89e2 100755 --- a/cli/rrdresize.php +++ b/cli/rrdresize.php @@ -45,8 +45,8 @@ if (sizeof($parms)) { $tmp_backup_folder = false; foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { - [$arg, $value] = explode('=', $parameter); + if (str_contains($parameter, '=')) { + [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; $value = ''; @@ -394,7 +394,7 @@ if ($scanned_directory['folders']) { f_notify('RRDtool info'); $output = rrdtool_pipe_execute(' info ' . $file . "\r\n", $rrdtool_pipes); - if (strpos($output, 'ERROR')) { + if (str_contains($output, 'ERROR')) { f_notify(false, "\033[0;31m[FAILED]\033[0m"); f_log('[ERROR] Unable to fetch RRDtool Info: ' . $file); @@ -550,7 +550,7 @@ if ($scanned_directory['folders']) { f_notify('RRDtool dump'); $file_dump = rrdtool_pipe_execute(' dump ' . $file . "\r\n", $rrdtool_pipes); - if (strpos($file_dump, 'ERROR')) { + if (str_contains($file_dump, 'ERROR')) { f_notify(false, "\033[0;31m[FAILED]\033[0m"); // ## log_missing @@ -875,7 +875,7 @@ if ($scanned_directory['folders']) { f_notify('RRDtool Restore'); $file_restore = rrdtool_pipe_execute(' restore -r -f ' . $tmp_xml_file . ' ' . $tmp_rrd_file . "\r\n", $rrdtool_pipes); - if (strpos($file_restore, 'ERROR')) { + if (str_contains($file_restore, 'ERROR')) { f_notify(false, "\033[0;31m[FAILED]\033[0m"); // / log_missing @@ -1042,13 +1042,13 @@ function f_log(string $msg) : void { fwrite($log_handle, date('Y-m-d H:i:s T', time()) . ' ' . $msg . PHP_EOL); - if (strpos($msg, '[ERROR]')) { + if (str_contains($msg, '[ERROR]')) { $total_errors++; $total_skipped++; - } elseif (strpos($msg, '[OUTDATED]')) { + } elseif (str_contains($msg, '[OUTDATED]')) { $total_outdated++; $total_skipped++; - } elseif (strpos($msg, '[SKIPPED]')) { + } elseif (str_contains($msg, '[SKIPPED]')) { $total_skipped++; } } diff --git a/cli/splice_rrd.php b/cli/splice_rrd.php index a94ce98f3..279e9d90a 100755 --- a/cli/splice_rrd.php +++ b/cli/splice_rrd.php @@ -115,7 +115,7 @@ array_shift($parms); if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/sqltable_to_php.php b/cli/sqltable_to_php.php index e0822a6f2..8098afc2a 100755 --- a/cli/sqltable_to_php.php +++ b/cli/sqltable_to_php.php @@ -40,7 +40,7 @@ $create = true; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; @@ -122,7 +122,7 @@ function sqltable_to_php(string $table, bool $create, string $plugin = '') : str $text .= "\$data['columns'][] = array("; $text .= "'name' => '" . $r['Field'] . "'"; - if (strpos(strtolower($r['Type']), ' unsigned') !== false) { + if (str_contains(strtolower($r['Type']), ' unsigned')) { $r['Type'] = str_ireplace(' unsigned', '', $r['Type']); $text .= ", 'unsigned' => true"; } @@ -133,7 +133,7 @@ function sqltable_to_php(string $table, bool $create, string $plugin = '') : str if ($r['Default'] != '' && trim($r['Default']) != '') { if ($r['Default'] == "''") { $r['Default'] = ''; - } elseif (strpos($r['Default'], 'current_timestamp()') !== false) { + } elseif (str_contains($r['Default'], 'current_timestamp()')) { $r['Default'] = str_replace('current_timestamp()', 'CURRENT_TIMESTAMP', $r['Default']); } diff --git a/cli/structure_rra_paths.php b/cli/structure_rra_paths.php index 0e914fcaf..9007c6723 100755 --- a/cli/structure_rra_paths.php +++ b/cli/structure_rra_paths.php @@ -49,7 +49,7 @@ array_shift($parms); if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/update_heartbeat.php b/cli/update_heartbeat.php index e2aa26eb8..459dff9eb 100755 --- a/cli/update_heartbeat.php +++ b/cli/update_heartbeat.php @@ -47,7 +47,7 @@ global $heartbeats; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/upgrade_database.php b/cli/upgrade_database.php index a41dcee67..03e5d146b 100755 --- a/cli/upgrade_database.php +++ b/cli/upgrade_database.php @@ -48,7 +48,7 @@ $forcever = ''; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { + if (str_contains($parameter, '=')) { [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; diff --git a/cli/version.php b/cli/version.php index 668f65bb2..24e8a2d78 100755 --- a/cli/version.php +++ b/cli/version.php @@ -36,8 +36,8 @@ $dev = false; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { - [$arg, $value] = explode('=', $parameter); + if (str_contains($parameter, '=')) { + [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; $value = ''; diff --git a/cmd.php b/cmd.php index fd19ebddc..dd6e853ae 100755 --- a/cmd.php +++ b/cmd.php @@ -59,8 +59,8 @@ $version = false; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { - [$arg, $value] = explode('=', $parameter); + if (str_contains($parameter, '=')) { + [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; $value = ''; diff --git a/graph_json.php b/graph_json.php index 33042aa05..3ab0c1b6b 100644 --- a/graph_json.php +++ b/graph_json.php @@ -185,7 +185,7 @@ $output = trim($output); $oarray = ['type' => $gtype, 'local_graph_id' => grv('local_graph_id'), 'rra_id' => $rra_id]; // Check if we received back something populated from rrdtool -if ($output != false && $output != '' && strpos($output, 'image = ') !== false) { +if ($output != false && $output != '' && str_contains($output, 'image = ')) { // Find the beginning of the image definition row $image_begin_pos = strpos($output, 'image = '); diff --git a/graphs.php b/graphs.php index 3f477597c..ed0a4bc92 100644 --- a/graphs.php +++ b/graphs.php @@ -291,7 +291,7 @@ function add_tree_names_to_actions_array() : void { function parse_validate_graph_template_id(string $variable) : string { $output_type_id = 0; - if (strpos(gnrv($variable), '_') !== false) { + if (str_contains(gnrv($variable), '_')) { $template_parts = explode('_', gnrv($variable)); if (is_numeric($template_parts[0]) && is_numeric($template_parts[1])) { diff --git a/graphs_new.php b/graphs_new.php index 2b728cf01..59cf9f87f 100644 --- a/graphs_new.php +++ b/graphs_new.php @@ -133,7 +133,7 @@ function form_save() : void { $selected_graphs['sg'][$matches[1]][gnrv('sgg_' . $matches[1])][$matches[2]] = true; } - if (strpos($var, 'sgg_') !== false) { + if (str_contains($var, 'sgg_')) { $snmp_query_id = intval(str_replace('sgg_', '', $var)); input_validate_input_number($snmp_query_id, 'sgg'); @@ -1015,7 +1015,7 @@ function graphs() : void { if ($_SERVER['SERVER_NAME'] != $referer_url['host']) { // Potential security exploit 1 srv('returnto', 'host.php'); - } elseif (strpos($_SERVER['HTTP_REFERER'], 'graphs_new') === false) { + } elseif (!str_contains($_SERVER['HTTP_REFERER'], 'graphs_new')) { srv('returnto', basename($_SERVER['HTTP_REFERER'])); } else { srv('returnto', 'host.php'); @@ -1031,7 +1031,7 @@ function graphs() : void { load_current_session_value('returnto', 'sess_grn_returnto', ''); - if (strpos(gnrv('returnto'), 'host.php') === false) { + if (!str_contains(gnrv('returnto'), 'host.php')) { srv('returnto', ''); } diff --git a/host.php b/host.php index 53a1b2482..5402b4676 100644 --- a/host.php +++ b/host.php @@ -628,7 +628,7 @@ function host_export() : void { foreach ($hosts as $h) { foreach (array_keys($h) as $hc) { - if ($h[$hc] != '' && (strpos($h[$hc], "\n") !== false || strpos($h[$hc], "\r") !== false)) { + if ($h[$hc] != '' && (str_contains($h[$hc], "\n") || str_contains($h[$hc], "\r"))) { $h[$hc] = str_replace(["\n", "\r"], ' ', $h[$hc]); } } diff --git a/install/functions.php b/install/functions.php index fad57be50..097e5e23d 100644 --- a/install/functions.php +++ b/install/functions.php @@ -298,7 +298,7 @@ function install_unlink(string $file) : void { $full_file = $file; } - if (strpos($full_file, CACTI_PATH_BASE) === false) { + if (!str_contains($full_file, CACTI_PATH_BASE)) { log_install_high('file', "Not Unlinking file: $full_file due to it not being in the Cacti base path."); } @@ -316,7 +316,7 @@ function install_rmdir(string $directory) : void { $directory = CACTI_PATH_BASE . '/' . $directory; } - if (strpos($directory, CACTI_PATH_BASE) === false) { + if (!str_contains($directory, CACTI_PATH_BASE)) { log_install_high('file', "Not Unlinking directory: $directory due to it not being in the Cacti base path."); } @@ -343,7 +343,7 @@ function install_rmdir_recursive(string $directory, bool $del_parent = false) : $directory = CACTI_PATH_BASE . '/' . $directory; } - if (strpos($directory, CACTI_PATH_BASE) === false) { + if (!str_contains($directory, CACTI_PATH_BASE)) { log_install_high('file', "Not Unlinking directory: $directory due to it not being in the Cacti base path."); } @@ -1283,7 +1283,7 @@ function remote_update_config_file() : string { if (cacti_sizeof($file_array)) { foreach ($file_array as $line) { - if (strpos(trim($line), '$poller_id') !== false) { + if (str_contains(trim($line), '$poller_id')) { $newfile[] = "\$poller_id = $poller_id;" . PHP_EOL; } else { $newfile[] = $line; diff --git a/install/install.php b/install/install.php index d6b6efa6c..518649cc8 100644 --- a/install/install.php +++ b/install/install.php @@ -61,7 +61,7 @@ $help = ''; if (CACTI_SERVER_OS == 'unix') { if ($config['cacti_db_version'] == 'new_install') { - if (isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) { + if (isset($_SERVER['SERVER_SOFTWARE']) && str_contains($_SERVER['SERVER_SOFTWARE'], 'Apache')) { $help = 'Install-Under-CentOS_LAMP.html'; } elseif (file_exists('/etc/redhat-release')) { $help = 'Install-Under-CentOS_LAMP.html'; diff --git a/install/upgrades/1_1_36.php b/install/upgrades/1_1_36.php index 0b87218ea..75a9ec8cb 100644 --- a/install/upgrades/1_1_36.php +++ b/install/upgrades/1_1_36.php @@ -34,7 +34,7 @@ function upgrade_to_1_1_36() : void { if (cacti_sizeof($users_to_update)) { foreach ($users_to_update as $user) { - if (strpos($user['value'], '-') === false) { + if (!str_contains($user['value'], '-')) { $locale = repair_locale($user['value']); db_install_execute('UPDATE settings_user @@ -53,7 +53,7 @@ function upgrade_to_1_1_36() : void { if (cacti_sizeof($groups_to_update)) { foreach ($groups_to_update as $group) { - if (strpos($group['value'], '-') === false) { + if (!str_contains($group['value'], '-')) { $locale = repair_locale($group['value']); db_install_execute('UPDATE settings_user_group diff --git a/install/upgrades/1_2_17.php b/install/upgrades/1_2_17.php index 1f8480f24..b3f646116 100644 --- a/install/upgrades/1_2_17.php +++ b/install/upgrades/1_2_17.php @@ -136,8 +136,8 @@ function database_fix_mediumint_columns() : int { $attribs = database_get_column_attribs($table, $c); if (cacti_sizeof($attribs)) { - if (strpos($attribs['Type'], 'mediumint') === false) { - if (strpos($attribs['Type'], 'int(10) unsigned') !== false) { + if (!str_contains($attribs['Type'], 'mediumint')) { + if (str_contains($attribs['Type'], 'int(10) unsigned')) { continue; } } @@ -185,8 +185,8 @@ function database_fix_mediumint_columns() : int { foreach ($columns as $field => $attribs) { if (array_key_exists($field, $known_columns)) { - if (strpos($attribs['Type'], 'mediumint') === false) { - if (strpos($attribs['Type'], 'int(10) unsigned') !== false) { + if (!str_contains($attribs['Type'], 'mediumint')) { + if (str_contains($attribs['Type'], 'int(10) unsigned')) { continue; } } diff --git a/lib/api_aggregate.php b/lib/api_aggregate.php index 0a08897ff..8123d3333 100644 --- a/lib/api_aggregate.php +++ b/lib/api_aggregate.php @@ -408,7 +408,7 @@ function aggregate_graphs_insert_graph_items(int $_new_graph_id, int $_old_graph // no more prepending until next line break is encountered $prepend = false; $prepend_cnt++; - } elseif (strpos($save['text_format'], ':current:')) { + } elseif (str_contains($save['text_format'], ':current:')) { if ($_total_type == AGGREGATE_TOTAL_TYPE_ALL || $_total_type == AGGREGATE_TOTAL_TYPE_SIMILAR) { // All so use sum functions $save['text_format'] = str_replace(':current:', ':aggregate_sum:', $save['text_format']); @@ -416,7 +416,7 @@ function aggregate_graphs_insert_graph_items(int $_new_graph_id, int $_old_graph // Similar to separate $save['text_format'] = str_replace(':current:', ':current:', $save['text_format']); } - } elseif (strpos($save['text_format'], ':max:')) { + } elseif (str_contains($save['text_format'], ':max:')) { if ($_total_type == AGGREGATE_TOTAL_TYPE_ALL || $_total_type == AGGREGATE_TOTAL_TYPE_SIMILAR) { // All so use sum functions $save['text_format'] = str_replace(':max:', ':aggregate_sum:', $save['text_format']); diff --git a/lib/functions.php b/lib/functions.php index fa3bc258b..8f0be0317 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -4940,7 +4940,7 @@ function sanitize_uri($uri) { static $drop_char_match = ['^', '$', '<', '>', '`', "'", '"', '|', '+', '[', ']', '{', '}', ';', '!', '(', ')']; static $drop_char_replace = [ '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']; - if (strpos($uri, 'graph_view.php')) { + if (str_contains($uri, 'graph_view.php')) { if (!strpos($uri, 'action=')) { $uri = $uri . (strpos($uri, '?') ? '&' : '?') . 'action=' . gnrv('action'); } @@ -5263,7 +5263,7 @@ function send_mail(mixed $to, mixed $from = null, string $subject = '', } } - if ($from != '' && strpos($from, '<') === false) { + if ($from != '' && !str_contains($from, '<')) { if ($name == '') { $full_name = db_fetch_cell_prepared('SELECT full_name FROM user_auth @@ -5872,7 +5872,7 @@ function split_emaildetail(mixed $email) : array { * Handle the special case where sendmail is being used * without an email domain */ - if (!is_array($email) && strpos($email, '@') === false) { + if (!is_array($email) && !str_contains($email, '@')) { return ['name' => '', 'email' => $email]; } @@ -5880,8 +5880,8 @@ function split_emaildetail(mixed $email) : array { * Handle the case where the Email is a string, but may * include the name at the beginning of the Email. */ - if (!is_array($email) && strpos($email, '@') !== false) { - if (strpos($email, '<') !== false) { + if (!is_array($email) && str_contains($email, '@')) { + if (str_contains($email, '<')) { $parts = explode('<', $email); $name = str_replace(['"', "'"], ['', ''], $parts[0]); $email = str_replace('>', '', $parts[1]); diff --git a/lib/plugins.php b/lib/plugins.php index 791057c99..c66d8ec46 100644 --- a/lib/plugins.php +++ b/lib/plugins.php @@ -1235,7 +1235,7 @@ function api_plugin_register_realm(string $plugin, string $file, string $display db_execute_prepared('DELETE FROM plugin_realms WHERE id = ?', [$realm_info['id']]); - } elseif (strpos($realm_info['file'], (string) $file)) { + } elseif (str_contains($realm_info['file'], (string) $file)) { if (str_starts_with($realm_info['file'], $file)) { $file = substr($file, strlen($file) - 1); } else { diff --git a/link.php b/link.php index 66156bf3e..c7ee7e09c 100644 --- a/link.php +++ b/link.php @@ -32,7 +32,7 @@ $page = db_fetch_row_prepared('SELECT // Prevent redirect loops if (isset($_SERVER['HTTP_REFERER'])) { - if (strpos($_SERVER['HTTP_REFERER'], 'link.php') === false) { + if (!str_contains($_SERVER['HTTP_REFERER'], 'link.php')) { $referer = $_SERVER['HTTP_REFERER']; $_SESSION['link_referer'] = $referer; } elseif (isset($_SESSION['link_referer'])) { @@ -86,7 +86,7 @@ if (!cacti_sizeof($page)) { $basepath = CACTI_PATH_INCLUDE . '/content'; $file = realpath($basepath . '/' . $page['contentfile']); - if ($file !== false && substr($file, 0, strlen($basepath)) == $basepath) { + if ($file !== false && str_starts_with($file, $basepath)) { require_once($file); } else { print '

The file \'' . htmle($page['contentfile']) . '\' does not exist!!

'; diff --git a/package.php b/package.php index 805af96ff..2bb47dd21 100644 --- a/package.php +++ b/package.php @@ -101,7 +101,7 @@ function form_save() : void { // search xml files for scripts if (cacti_sizeof($files)) { foreach ($files as $file) { - if (strpos($file['file'], '.xml') !== false) { + if (str_contains($file['file'], '.xml')) { $files = array_merge($files, find_dependent_files(file_get_contents($file['file']))); } } diff --git a/package_import.php b/package_import.php index 084d4a164..aef5251c4 100644 --- a/package_import.php +++ b/package_import.php @@ -239,7 +239,7 @@ function form_actions() : void { // loop through each of the graphs selected on the previous page and get more info about them foreach ($_POST as $var => $val) { - if (strpos($var, 'chk_file_') !== false) { + if (str_contains($var, 'chk_file_')) { $id = base64_decode(str_replace('chk_file_', '', $var), true); $id = json_decode($id, true); @@ -256,7 +256,7 @@ function form_actions() : void { $found_pkg_file_array[$id['package']] = $id['package']; } - if (strpos($var, 'chk_import_') !== false) { + if (str_contains($var, 'chk_import_')) { $id = base64_decode(str_replace('chk_import_', '', $var), true); $id = json_decode($id, true); @@ -464,13 +464,13 @@ function form_save() : void { // loop through each of the graphs selected on the previous page and get more info about them foreach ($_POST as $var => $val) { - if (strpos($var, 'chk_file_') !== false) { + if (str_contains($var, 'chk_file_')) { $id = base64_decode(str_replace('chk_file_', '', $var), true); $id = json_decode($id, true); - if (strpos($id['pfile'], '/') !== false) { + if (str_contains($id['pfile'], '/')) { $parts = explode('/', $id['pfile']); - } elseif (strpos($id['pfile'], '\\') !== false) { + } elseif (str_contains($id['pfile'], '\\')) { $parts = explode('\\', $id['pfile']); } else { $parts = [$id['pfile']]; @@ -493,7 +493,7 @@ function form_save() : void { $files[] = $id['pfile']; } - if (strpos($var, 'chk_import_') !== false) { + if (str_contains($var, 'chk_import_')) { $id = base64_decode(str_replace('chk_import_', '', $var), true); $id = json_decode($id, true); diff --git a/plugins.php b/plugins.php index 5f66b1da4..b42704f87 100644 --- a/plugins.php +++ b/plugins.php @@ -1425,7 +1425,7 @@ function format_plugin_row(array $plugin, bool $last_plugin, bool $include_order } if (POLLER_ID > 1) { - if (isset($plugin['capabilities']) && (strpos($plugin['capabilities'], 'remote_collect:1') !== false || strpos($plugin['capabilities'], 'remote_poller:1') !== false)) { + if (isset($plugin['capabilities']) && (str_contains($plugin['capabilities'], 'remote_collect:1') || str_contains($plugin['capabilities'], 'remote_poller:1'))) { if ($plugin['remote_status'] == '-1') { $status = plugin_is_compatible($plugin['plugin']); $row .= ' / ' . __('Not Compatible, \'%s\'', $status['requires']); @@ -1775,13 +1775,13 @@ function plugin_display_compat(string $compat) : string { $compat = explode(' ', $compat); foreach ($compat as $index => $c) { - if (strpos($c, '>=') != false) { + if (str_contains($c, '>=')) { $compat[$index] = str_replace('>=', '>= ', $c); - } elseif (strpos($c, '>=') != false) { - $compat[$index] = str_replace('>=', '>= ', $c); - } elseif (strpos($c, '>') != false) { + } elseif (str_contains($c, '<=')) { + $compat[$index] = str_replace('<=', '<= ', $c); + } elseif (str_contains($c, '>')) { $compat[$index] = str_replace('>', '> ', $c); - } elseif (strpos($c, '<') != false) { + } elseif (str_contains($c, '<')) { $compat[$index] = str_replace('<', '< ', $c); } else { $compat[$index] = '>= ' . $c; @@ -1943,7 +1943,7 @@ function plugin_actions(array $plugin, string $table) : string { } if (POLLER_ID > 1) { - if (isset($plugin['capabilities']) && (strpos($plugin['capabilities'], 'remote_collect:1') !== false || strpos($plugin['capabilities'], 'remote_poller:1') !== false)) { + if (isset($plugin['capabilities']) && (str_contains($plugin['capabilities'], 'remote_collect:1') || str_contains($plugin['capabilities'], 'remote_poller:1'))) { if ($plugin['remote_status'] == 1) { // Installed and Active // ToDo: Disabling here does not make much sense as the main will be replicated // with any change of any other plugin thus undoing. Fix that moving forward diff --git a/poller.php b/poller.php index c2219f0d4..21b3c87fd 100755 --- a/poller.php +++ b/poller.php @@ -100,8 +100,8 @@ array_shift($parms); if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { - [$arg, $value] = explode('=', $parameter); + if (str_contains($parameter, '=')) { + [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; $value = ''; diff --git a/poller_automation.php b/poller_automation.php index acd211fd0..7d5ba0bcb 100644 --- a/poller_automation.php +++ b/poller_automation.php @@ -151,8 +151,8 @@ global $debug, $poller_id, $network_id, $thread, $master, $dryrun; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { - [$arg, $value] = explode('=', $parameter); + if (str_contains($parameter, '=')) { + [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; $value = ''; @@ -696,7 +696,7 @@ function discoverDevices(int $network_id, int $thread) : bool { $hostname = gethostbyaddr($device['ip_address']); if ($hostname != $device['ip_address']) { - if (strpos($hostname, '.')) { + if (str_contains($hostname, '.')) { $hostname = substr($hostname, 0, strpos($hostname, '.') - 1); } } diff --git a/poller_boost.php b/poller_boost.php index 712e884f2..2cebbd3b8 100644 --- a/poller_boost.php +++ b/poller_boost.php @@ -58,8 +58,8 @@ global $boost_debug, $boost_log, $cacti_log; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { - [$arg, $value] = explode('=', $parameter); + if (str_contains($parameter, '=')) { + [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; $value = ''; @@ -998,7 +998,7 @@ function boost_process_local_data_ids(int $last_id, int $child, mixed $rrdtool_p } // single one value output - if (strpos($value, 'DNP') !== false) { + if (str_contains($value, 'DNP')) { // continue, bad time } elseif ((is_numeric($value)) || ($value == 'U' && $item['rrd_name'] !== '')) { $tv_tmpl[$item['rrd_name']] = $value; @@ -1009,7 +1009,7 @@ function boost_process_local_data_ids(int $last_id, int $child, mixed $rrdtool_p $tv_tmpl[$item['rrd_name']] = $tval; $buflen += strlen(':' . $tval); $vals_in_buffer++; - } elseif (strpos($value, ':') !== false) { + } elseif (str_contains($value, ':')) { // break out multiple value output to an array $values = preg_split('/\s+/', $value); diff --git a/poller_commands.php b/poller_commands.php index 2a2124acd..4395e48c6 100755 --- a/poller_commands.php +++ b/poller_commands.php @@ -73,8 +73,8 @@ array_shift($parms); if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { - [$arg, $value] = explode('=', $parameter); + if (str_contains($parameter, '=')) { + [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; $value = ''; @@ -388,7 +388,7 @@ function sig_handler(int $signo) : void { case SIGINT: cacti_log('WARNING: RRDfile Cleanup Poller terminated by user', false, 'CLEANUP'); - if (strpos($type, 'master') !== false) { + if (str_contains($type, 'master')) { commands_kill_running_processes(); } diff --git a/poller_dsstats.php b/poller_dsstats.php index f2ba3ad82..8fed240e3 100644 --- a/poller_dsstats.php +++ b/poller_dsstats.php @@ -63,8 +63,8 @@ $rrd_files = 0; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { - [$arg, $value] = explode('=', $parameter); + if (str_contains($parameter, '=')) { + [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; $value = ''; @@ -478,7 +478,7 @@ function sig_handler($signo) : void { set_config_option('dsstats_poller_status', 'terminated - end time:' . date('Y-m-d G:i:s')); } - if (strpos($type, 'master') !== false) { + if (str_contains($type, 'master')) { dsstats_kill_running_processes(); } diff --git a/poller_maintenance.php b/poller_maintenance.php index a398f9d4b..3b93ec2e4 100644 --- a/poller_maintenance.php +++ b/poller_maintenance.php @@ -57,8 +57,8 @@ $start = microtime(true); if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { - [$arg, $value] = explode('=', $parameter); + if (str_contains($parameter, '=')) { + [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; $value = ''; @@ -673,7 +673,7 @@ function logrotate_file_clean(string $name, string $log, object $date, int $rota $fileparts = explode('-', $d); $matches = false; - if (strpos($d, $baselogname) !== false) { + if (str_contains($d, $baselogname)) { if (cacti_sizeof($fileparts) > 1) { foreach ($fileparts as $p) { // Is it in the form YYYYMMDD? diff --git a/poller_realtime.php b/poller_realtime.php index 1a7198daf..8051f2282 100755 --- a/poller_realtime.php +++ b/poller_realtime.php @@ -44,8 +44,8 @@ array_shift($parms); if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { - [$arg, $value] = explode('=', $parameter); + if (str_contains($parameter, '=')) { + [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; $value = ''; diff --git a/poller_recovery.php b/poller_recovery.php index 0f76cce7b..b3bb2946d 100755 --- a/poller_recovery.php +++ b/poller_recovery.php @@ -100,8 +100,8 @@ $poller_id = POLLER_ID; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { - [$arg, $value] = explode('=', $parameter); + if (str_contains($parameter, '=')) { + [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; $value = ''; diff --git a/poller_reports.php b/poller_reports.php index 96a03d2c9..1761e5927 100755 --- a/poller_reports.php +++ b/poller_reports.php @@ -50,8 +50,8 @@ $queue_id = false; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { - [$arg, $value] = explode('=', $parameter); + if (str_contains($parameter, '=')) { + [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; $value = ''; diff --git a/poller_rrdcheck.php b/poller_rrdcheck.php index e0d17a7b8..bf7fd0e8a 100755 --- a/poller_rrdcheck.php +++ b/poller_rrdcheck.php @@ -61,8 +61,8 @@ $rrd_files = 0; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { - [$arg, $value] = explode('=', $parameter); + if (str_contains($parameter, '=')) { + [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; $value = ''; @@ -283,7 +283,7 @@ function sig_handler(int $signo) : void { set_config_option('rrdcheck_poller_status', 'terminated - end time:' . date('Y-m-d G:i:s')); } - if (strpos($type, 'master') !== false) { + if (str_contains($type, 'master')) { rrdcheck_kill_running_processes(); } diff --git a/poller_spikekill.php b/poller_spikekill.php index 6800c3c59..f6e0567ce 100644 --- a/poller_spikekill.php +++ b/poller_spikekill.php @@ -40,8 +40,8 @@ $kills = 0; if (cacti_sizeof($parms)) { foreach ($parms as $parameter) { - if (strpos($parameter, '=')) { - [$arg, $value] = explode('=', $parameter); + if (str_contains($parameter, '=')) { + [$arg, $value] = explode('=', $parameter, 2); } else { $arg = $parameter; $value = ''; @@ -228,7 +228,7 @@ function purge_spike_backups() : mixed { foreach ($files as $file) { $filepath = $directory . '/' . $file; - if (is_file($filepath) && strpos($filepath, 'rrd') !== false) { + if (is_file($filepath) && str_contains($filepath, 'rrd')) { $mtime = filemtime($filepath); if ($mtime < $earlytime) { diff --git a/pollers.php b/pollers.php index 3bb8e6308..1ea346fe1 100644 --- a/pollers.php +++ b/pollers.php @@ -387,7 +387,7 @@ function poller_check_duplicate_poller_id(int $poller_id, string $hostname, stri } $ip_addresses[$hostname] = $hostname; - } elseif (strpos($hostname, '.') !== false) { + } elseif (str_contains($hostname, '.')) { $addresses = @dns_get_record($hostname); $ip = @gethostbyname($hostname); diff --git a/remote_agent.php b/remote_agent.php index 5514a21e3..6dabab151 100644 --- a/remote_agent.php +++ b/remote_agent.php @@ -126,7 +126,7 @@ function debug(string $message) : void { } function remote_agent_strip_domain(string $host) : string { - if (strpos($host, '.') !== false) { + if (str_contains($host, '.')) { $parts = explode('.', $host); return $parts[0]; diff --git a/script_server.php b/script_server.php index 8e1d33ec4..b4bbb54fb 100644 --- a/script_server.php +++ b/script_server.php @@ -339,7 +339,7 @@ function parseArgs(string $string, array &$str_list, bool $debug = false) : bool } foreach ($delimiters as $delimiter) { - if (strpos($string, $delimiter) !== false) { + if (str_contains($string, $delimiter)) { $delimited = true; break; diff --git a/scripts/ss_esxi_vhosts.php b/scripts/ss_esxi_vhosts.php index 7cf43888c..b6e12db08 100644 --- a/scripts/ss_esxi_vhosts.php +++ b/scripts/ss_esxi_vhosts.php @@ -52,9 +52,9 @@ function ss_esxi_vhosts(int $device_id) : string { if (cacti_sizeof($array)) { foreach ($array as $key => $value) { - if (strpos($value['value'], 'not installed')) { + if (str_contains($value['value'], 'not installed')) { $vh_tools_ninst++; - } elseif (strpos($value['value'], 'not running') !== false) { + } elseif (str_contains($value['value'], 'not running')) { $vh_tools_nrun++; } else { $vh_tools_run++; diff --git a/support.php b/support.php index 37bb8a095..0bc28ac5c 100644 --- a/support.php +++ b/support.php @@ -800,7 +800,7 @@ function show_cacti_processes() : void { $timeout_time = $p['timeout']; $timeout_date = get_daysfromtime($timeout_time, true); - if (strpos($timeout_date, 'y:') !== false) { + if (str_contains($timeout_date, 'y:')) { $timeout_date = __('> 1 Year'); } } else { @@ -1006,7 +1006,7 @@ function show_cacti_changelog() : void { } if (strlen(trim($s)) && stripos($s, 'CHANGELOG') === false) { - if (strpos($s, '-') === false || strpos($s, '-dev') !== false) { + if (!str_contains($s, '-') || str_contains($s, '-dev')) { html_section_header(__('Version %s', $s), 2); } else { form_alternate_row(); diff --git a/templates_import.php b/templates_import.php index 73fe681c2..2cf59fdee 100644 --- a/templates_import.php +++ b/templates_import.php @@ -99,7 +99,7 @@ function form_save() : void { // loop through each of the graphs selected on the previous page and get more info about them foreach ($_POST as $var => $val) { - if (strpos($var, 'chk_') !== false) { + if (str_contains($var, 'chk_')) { $id = base64_decode(str_replace('chk_', '', $var), true); $id = json_decode($id, true);