From 4b872399ac9fe3b21cb9bb76ed9e61bf9dd07496 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Sun, 10 Mar 2013 09:11:05 +0100 Subject: [PATCH] check for correct array in ApsInstaller, fixes #1098 Signed-off-by: Michael Kaufmann (d00p) --- lib/classes/aps/class.ApsInstaller.php | 46 +++++++++++--------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/lib/classes/aps/class.ApsInstaller.php b/lib/classes/aps/class.ApsInstaller.php index f2023112..faba94e2 100644 --- a/lib/classes/aps/class.ApsInstaller.php +++ b/lib/classes/aps/class.ApsInstaller.php @@ -393,36 +393,28 @@ class ApsInstaller extends ApsParser //check for special PHP permissions //must be done with xpath otherwise check not possible (XML parser problem with attributes) - if($ParentMapping && $ParentMapping !== null) - { + if ($ParentMapping && $ParentMapping !== null) { + $ParentMapping->registerXPathNamespace('p', 'http://apstandard.com/ns/1/php'); $Result = $ParentMapping->xpath('p:permissions'); - - if($Result[0]['writable'] == 'true') - { - //fixing file permissions to writeable - - if(is_dir($Path)) - { - chmod($Path, 0775); + + if (is_array($Result) && isset($Result[0]) && is_array($Result[0])) { + if (isset($Result[0]['writable']) && $Result[0]['writable'] == 'true') { + // fixing file permissions to writeable + if (is_dir($Path)) { + chmod($Path, 0775); + } else { + chmod($Path, 0664); + } } - else - { - chmod($Path, 0664); - } - } - - if($Result[0]['readable'] == 'false') - { - //fixing file permissions to non readable - - if(is_dir($Path)) - { - chmod($Path, 0333); - } - else - { - chmod($Path, 0222); + + if (isset($Result[0]['readable']) && $Result[0]['readable'] == 'false') { + //fixing file permissions to non readable + if (is_dir($Path)) { + chmod($Path, 0333); + } else { + chmod($Path, 0222); + } } } }