X-Git-Url: https://git-public.kairo.at/?p=php-utility-classes.git;a=blobdiff_plain;f=classes%2Frrdstat.php-class;h=0a71f13da11858fc9456fc7e44ed759fd891d90e;hp=1443ec6fa427929d064fc6d1571d4520442f6949;hb=5dd242eff6de2d320c75ec83e5f988cd7c769cea;hpb=7b9ebce7d25e4eaa557e8a64f8b1ed15aad1a9bb diff --git a/classes/rrdstat.php-class b/classes/rrdstat.php-class index 1443ec6..0a71f13 100644 --- a/classes/rrdstat.php-class +++ b/classes/rrdstat.php-class @@ -1,23 +1,7 @@ - * - * ***** END LICENSE BLOCK ***** */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ class rrdstat { // rrdstat PHP class @@ -776,15 +760,16 @@ class rrdstat { } $graph_cmd = $this->rrdtool_bin.' graph '.str_replace('*', '\*', $fname.$gOpts.$gDefs.$gGraphs.$addSpecial); - $return = `$graph_cmd 2>&1`; - - if (strpos($return, 'ERROR') !== false) { - trigger_error($this->rrd_file.' - rrd graph error: '.$return, E_USER_WARNING); - $return = 'command:'.$graph_cmd."\n\n".$return; + if ((file_exists($fname) && !is_writable($fname)) || + (!file_exists($fname) && !is_writable(dirname($fname)))) { + trigger_error($this->rrd_file.' - graph file not writable: '.$fname, E_USER_WARNING); + return 'command:'.$graph_cmd."\n\n".'unwritable file: '.$fname; } - if (0) { - // debug output - $return = 'command:'.$graph_cmd."\n\n".$return; + $graph_out = `$graph_cmd 2>&1`; + + if (strpos($graph_out, 'ERROR') !== false) { + trigger_error($this->rrd_file.' - rrd graph error: '.$graph_out, E_USER_WARNING); + return 'command:'.$graph_cmd."\n\n".$graph_out; } $legendlines = ''; foreach ($graphrows as $grow) { @@ -794,7 +779,7 @@ class rrdstat { $legendline .= '|'.(isset($grow['legend_long'])?$grow['legend_long']:''); $legendlines .= 'legend:'.$legendline."\n"; } - $return = 'file:'.$fname."\n".$legendlines.$return; + $return = 'file:'.$fname."\n".$legendlines.$graph_out; return $return; } @@ -884,7 +869,8 @@ class rrdstat { $td = $this->mod_textdomain; $ptitle = isset($pconf['title_page'])?$pconf['title_page']:dgettext($td, 'RRD statistics index'); - $out = ''."\n"; + $out = ''."\n"; + $out .= ''."\n"; $out .= ''.$ptitle.''."\n"; $out .= '