mirror of
https://github.com/Cacti/cacti.git
synced 2026-10-23 03:27:02 +09:00
refactor: replace strpos() boolean checks with str_contains/str_starts_with (#6645)
* refactor: replace strpos() boolean checks with str_contains/str_starts_with Completes the PHP 8.x string function migration started in lib/. Converts remaining legacy patterns across 81 files: - strpos($x, $y) !== false → str_contains($x, $y) - strpos($x, $y) === false → !str_contains($x, $y) - strpos($x, $y) != false → str_contains($x, $y) - bare if (strpos($x, $y)) → if (str_contains($x, $y)) - substr($x, 0, strlen($y)) == $y → str_starts_with($x, $y) Intentionally preserves strpos() calls that use the return value as an integer offset: - user_admin.php / user_group_admin.php (4 calls, ternary for position) - auth_profile.php (2 calls, offset for substr); guards fixed from bare if ($pos) to if ($pos !== false) Behavior fix: ss_esxi_vhosts.php:55 bare strpos() missed position-0 matches; str_contains() now correctly detects 'not installed' at any position. Adjacent line already used str_contains(). Ref: https://github.com/Cacti/cacti/issues/6641 Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix: correct dead-code elseif in plugin_display_compat() version comparison The if/elseif chain in plugin_display_compat() checked >=, >=, >, < — the second >= was unreachable dead code. Corrected to <= to complete the operator set (>=, <=, >, <). Without this fix, <= constraints (e.g. "<=1.2") fell through to the < branch and were rendered as "< =1.2" instead of "<= 1.2". This pre-existing bug was exposed when converting strpos() to str_contains(), which made PHPStan detect the always-false condition. Ref: https://github.com/Cacti/cacti/issues/6641 Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix: add limit to explode('=') in CLI argument parsers 17 CLI scripts used explode('=', $parameter) without a limit of 2, silently truncating values containing = (e.g. --note=a=b parsed as $value='a' instead of 'a=b'). The other 40 CLI scripts already had the correct limit. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> --------- Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> Co-authored-by: TheWitness <thewitness@cacti.net>
This commit is contained in:
1 parent
8eaa19e160
commit
fcbcbdd1d7
81 files changed
+160
-160
No files matched your search
@@ -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 {
|
||||
|
||||
+4
-4
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+2
-2
@@ -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 = '';
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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'] . "'";
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+2
-2
@@ -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 = '';
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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, '<pdp_per_row>') !== false) {
|
||||
if (str_contains($line, '<pdp_per_row>')) {
|
||||
/**
|
||||
* <pdp_per_row>24</pdp_per_row> <!-- 7200 seconds -->
|
||||
* 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, '<database>') !== false) {
|
||||
} elseif (str_contains($line, '<database>')) {
|
||||
$in_database = true;
|
||||
$line .= PHP_EOL;
|
||||
} elseif (strpos($line, '</database>') !== false) {
|
||||
} elseif (str_contains($line, '</database>')) {
|
||||
$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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+2
-2
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+8
-8
@@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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']);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+2
-2
@@ -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 = '';
|
||||
|
||||
@@ -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 = '';
|
||||
|
||||
+1
-1
@@ -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 = ');
|
||||
|
||||
|
||||
+1
-1
@@ -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])) {
|
||||
|
||||
+3
-3
@@ -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', '');
|
||||
}
|
||||
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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';
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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']);
|
||||
|
||||
+5
-5
@@ -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]);
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
|
||||
@@ -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 '<h1>The file \'' . htmle($page['contentfile']) . '\' does not exist!!</h1>';
|
||||
|
||||
+1
-1
@@ -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'])));
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -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);
|
||||
|
||||
|
||||
+7
-7
@@ -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
|
||||
|
||||
+2
-2
@@ -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 = '';
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -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);
|
||||
|
||||
|
||||
+3
-3
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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?
|
||||
|
||||
+2
-2
@@ -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 = '';
|
||||
|
||||
+2
-2
@@ -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 = '';
|
||||
|
||||
+2
-2
@@ -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 = '';
|
||||
|
||||
+3
-3
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
|
||||
+1
-1
@@ -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];
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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++;
|
||||
|
||||
+2
-2
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in new issue
Block a user