From a76f9e3025d37ccead934d4a416da4a7d4a86608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Thu, 3 Nov 2016 21:55:10 +0000 Subject: [PATCH] Do +w check on DOCUMENT_ROOT only if errors --- src/Movim/Bootstrap.php | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/Movim/Bootstrap.php b/src/Movim/Bootstrap.php index 6361e3f04..c4362d16a 100644 --- a/src/Movim/Bootstrap.php +++ b/src/Movim/Bootstrap.php @@ -46,23 +46,22 @@ class Bootstrap ); $errors = []; - if(!is_writable(DOCUMENT_ROOT)) + if(!file_exists(DOCUMENT_ROOT.'/cache') && !@mkdir(DOCUMENT_ROOT.'/cache')) { + $errors[] = 'Couldn\'t create directory cache'; + } + if(!file_exists(DOCUMENT_ROOT.'/log') && !@mkdir(DOCUMENT_ROOT.'/log')) { + $errors[] = 'Couldn\'t create directory log'; + } + if(!file_exists(DOCUMENT_ROOT.'/config') && !@mkdir(DOCUMENT_ROOT.'/config')) { + $errors[] = 'Couldn\'t create directory config'; + } + if(!file_exists(DOCUMENT_ROOT.'/users') && !@mkdir(DOCUMENT_ROOT.'/users')) { + $errors[] = 'Couldn\'t create directory users'; + } else { + touch(DOCUMENT_ROOT.'/users/index.html'); + } + if(!empty($errors) && !is_writable(DOCUMENT_ROOT)) $errors[] = 'We\'re unable to write to folder '.DOCUMENT_ROOT.': check rights'; - else { - if(!file_exists(DOCUMENT_ROOT.'/cache') && !@mkdir(DOCUMENT_ROOT.'/cache')) { - $errors[] = 'Couldn\'t create directory cache'; - } - if(!file_exists(DOCUMENT_ROOT.'/log') && !@mkdir(DOCUMENT_ROOT.'/log')) { - $errors[] = 'Couldn\'t create directory log'; - } - if(!file_exists(DOCUMENT_ROOT.'/config') && !@mkdir(DOCUMENT_ROOT.'/config')) { - $errors[] = 'Couldn\'t create directory config'; - } - if(!file_exists(DOCUMENT_ROOT.'/users') && !@mkdir(DOCUMENT_ROOT.'/users')) { - $errors[] = 'Couldn\'t create directory users'; - } else { - touch(DOCUMENT_ROOT.'/users/index.html'); - } } foreach($listWritableFile as $fileName) {