From: robert Date: Fri, 6 May 2005 12:58:39 +0000 (+0000) Subject: bail out on a non-set rrd file X-Git-Url: https://git-public.kairo.at/?a=commitdiff_plain;h=2a386f5a68929d82a68f97c83eb0cc1ea6d9b236;p=php-utility-classes.git bail out on a non-set rrd file --- diff --git a/include/classes/rrdstat.php-class b/include/classes/rrdstat.php-class index dc9da65..0709315 100644 --- a/include/classes/rrdstat.php-class +++ b/include/classes/rrdstat.php-class @@ -2,7 +2,7 @@ // ************ RRD status class ************** class rrdstat { - var $rrd_file = 'sample.rrd'; + var $rrd_file = null; var $config_raw = null; var $config_graph = null; @@ -19,19 +19,21 @@ class rrdstat { // ***** init RRD stat module ***** $this->set_def($init_info); - if (!is_writeable($this->rrd_file)) { - if (!file_exists($this->rrd_file)) { - if (touch($this->rrd_file)) { $this->create(); } - else { trigger_error('RRD file can not be created', E_USER_WARNING); } + if (!is_null($this->rrd_file)) { + if (!is_writeable($this->rrd_file)) { + if (!file_exists($this->rrd_file)) { + if (touch($this->rrd_file)) { $this->create(); } + else { trigger_error('RRD file can not be created', E_USER_WARNING); } + } + else { + if (is_readable($this->rrd_file)) { $this->status = 'readonly'; } + else { trigger_error('RRD file is not readable', E_USER_WARNING); } + } } else { - if (is_readable($this->rrd_file)) { $this->status = 'readonly'; } - else { trigger_error('RRD file is not readable', E_USER_WARNING); } + $this->status = 'ok'; } } - else { - $this->status = 'ok'; - } } function set_def($init_info = null) {