From 6b00d18b23b0d877695f9a3a56b57437defbd7f6 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 5 Apr 2006 11:06:10 +0000 Subject: [PATCH] Added some checks git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2989 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_ppdManager.inc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/include/class_ppdManager.inc b/include/class_ppdManager.inc index 86f6c5385..a5fad0730 100644 --- a/include/class_ppdManager.inc +++ b/include/class_ppdManager.inc @@ -54,8 +54,10 @@ class ppdManager $section= preg_replace('/^\*/', '', $section); $attribute= preg_replace('/^\*/', '', $attribute); - $rp= fopen($file, "r"); - $wp= fopen("$file.tmp", "w"); + $rp= @fopen($file, "r"); + $wp= @fopen("$file.tmp", "w"); + + while (!feof($rp)){ $lines[]= fgets($rp, 1024); @@ -132,10 +134,17 @@ class ppdManager function saveProperties($ppdFile, $properties) { - foreach ($properties as $name => $section){ - foreach ($section as $attribute => $value){ - if (is_array($value)){ - $this->updateAttribute($ppdFile, $name, $attribute, $value['_default']); + if(!is_readable($ppdFile)){ + print_red(sprintf(_("Specified ppd file '%s' can't be opened for reading."),$ppdFile)); + }elseif(is_writeable($ppdFile.".tmp")){ + print_red(sprintf(_("The required tmp file file '%s' can't be opened for writing."),$ppdFile.".tmp")); + }else{ + + foreach ($properties as $name => $section){ + foreach ($section as $attribute => $value){ + if (is_array($value)){ + $this->updateAttribute($ppdFile, $name, $attribute, $value['_default']); + } } } } -- 2.30.2