From 74fa77b8fcdc5eb4af63ec92f7450897748ea0fd Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Fri, 4 Dec 2020 16:24:20 +0100 Subject: [PATCH 1/2] Fix deprecations --- cacti/scripts/ss_get_by_ssh.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cacti/scripts/ss_get_by_ssh.php b/cacti/scripts/ss_get_by_ssh.php index 9b36f26..c464027 100644 --- a/cacti/scripts/ss_get_by_ssh.php +++ b/cacti/scripts/ss_get_by_ssh.php @@ -240,13 +240,16 @@ function usage($message) { # ============================================================================ function parse_cmdline( $args ) { $options = array(); - while (list($tmp, $p) = each($args)) { + foreach ($args as $tmp => $p) { if (strpos($p, '--') === 0) { $param = substr($p, 2); $value = null; - $nextparam = current($args); + $nextparam = false; + if (isset($args[$tmp + 1])) { + $nextparam = $args[$tmp + 1]; + } if ($nextparam !== false && strpos($nextparam, '--') !==0) { - list($tmp, $value) = each($args); + $value = $nextparam; } $options[$param] = $value; } From 3595f44bb261d8143026eac5f8d81b906d65b307 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Fri, 4 Dec 2020 16:32:52 +0100 Subject: [PATCH 2/2] Consistency changes --- cacti/scripts/ss_get_by_ssh.php | 6 ++---- cacti/scripts/ss_get_mysql_stats.php | 13 +++++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cacti/scripts/ss_get_by_ssh.php b/cacti/scripts/ss_get_by_ssh.php index ad52732..cc87644 100644 --- a/cacti/scripts/ss_get_by_ssh.php +++ b/cacti/scripts/ss_get_by_ssh.php @@ -243,12 +243,11 @@ function parse_cmdline( $args ) { foreach ($args as $tmp => $p) { if (strpos($p, '--') === 0) { $param = substr($p, 2); - $value = null; - $nextparam = false; + $value = $nextparam = null; if (isset($args[$tmp + 1])) { $nextparam = $args[$tmp + 1]; } - if ($nextparam !== false && strpos($nextparam, '--') !==0) { + if (!empty($nextparam) && strpos($nextparam, '--') !== 0) { $value = $nextparam; } $options[$param] = $value; @@ -1609,4 +1608,3 @@ function vmstat_cachefile ( $options ) { function vmstat_cmdline ( $options ) { return "cat /proc/vmstat"; } - diff --git a/cacti/scripts/ss_get_mysql_stats.php b/cacti/scripts/ss_get_mysql_stats.php index 1411e31..0a7910f 100644 --- a/cacti/scripts/ss_get_mysql_stats.php +++ b/cacti/scripts/ss_get_mysql_stats.php @@ -222,13 +222,15 @@ function usage($message) { # ============================================================================ function parse_cmdline( $args ) { $options = array(); - while (list($tmp, $p) = each($args)) { + foreach ($args as $tmp => $p) { if (strpos($p, '--') === 0) { $param = substr($p, 2); - $value = null; - $nextparam = current($args); - if ($nextparam !== false && strpos($nextparam, '--') !==0) { - list($tmp, $value) = each($args); + $value = $nextparam = null; + if (isset($args[$tmp + 1])) { + $nextparam = $args[$tmp + 1]; + } + if (!empty($nextparam) && strpos($nextparam, '--') !== 0) { + $value = $nextparam; } $options[$param] = $value; } @@ -1414,4 +1416,3 @@ function debug($val) { $debug_log = FALSE; } } -