1 --- cacti-0.8.7g/script_server.php 2010-07-09 18:33:46.000000000 -0400
2 +++ cacti-0.8.7g-patched/script_server.php 2010-07-27 21:30:31.000000000 -0400
6 /* record the script start time */
7 -list($micro,$seconds) = split(" ", microtime());
8 +list($micro,$seconds) = explode(" ", microtime());
9 $start = $seconds + $micro;
14 if (isset($command_array[2])) {
15 $parameters = trim($command_array[2]);
16 - $parameter_array = explode(" ", trim($command_array[2]));
17 + $parameter_array = array();
18 + if (!parseArgs($parameters, $parameter_array)) {
19 + cacti_log("WARNING: Script Server count not parse '$parameters' for $function", false, "PHPSVR");
24 $parameters_array = array();
30 +function parseArgs($string, &$str_list, $debug = false) {
31 + $delimiters = array("'",'"');
33 + $str_list = array();
35 + if ($debug) echo "String: '" . $string . "'\n";
37 + foreach($delimiters as $delimiter) {
38 + if (strpos($string, $delimiter) !== false) {
44 + /* process the simple case */
46 + $str_list = explode(" ", $string);
48 + if ($debug) echo "Output: '" . implode(",", $str_list) . "'\n";
53 + /* Break str down into an array of characters and process */
54 + $char_array = str_split($string);
59 + foreach($char_array as $char) {
70 + }elseif (!$escaping) {
71 + $str_list[] = $curstr;
74 + }elseif ($escaping) {
92 + $msg = 'Parse error attempting to parse string';
93 + }elseif ($indelim) {
95 + }elseif (strlen($curstr)) {
96 + $str_list[] = $curstr;
103 + $msg = 'Backtic (`) characters not allowed';
109 + $msg = 'Parse error attempting to parse string';
121 + /* Add the last str to the string array */
122 + if ($indelim || $escaping) {
124 + $msg = 'Parse error attempting to parse string';
128 + echo "ERROR: " . $msg . " '" . $string . "'\n";
130 + $str_list[] = $curstr;
133 + if ($debug) echo "Output: '" . implode(",", $str_list) . "'\n";