diff --git a/cacti/scripts/ss_get_by_ssh.php b/cacti/scripts/ss_get_by_ssh.php index 3ddc5ab..cc87644 100644 --- a/cacti/scripts/ss_get_by_ssh.php +++ b/cacti/scripts/ss_get_by_ssh.php @@ -240,13 +240,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; } @@ -1606,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; } } -