summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/init.php47
-rw-r--r--inc/io.php4
2 files changed, 37 insertions, 14 deletions
diff --git a/inc/init.php b/inc/init.php
index 114c012f6..e4d2fac5b 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -128,39 +128,62 @@ function init_paths(){
foreach($paths as $c => $p){
if(!$conf[$c]) $conf[$c] = $conf['savedir'].'/'.$p;
$conf[$c] = init_path($conf[$c]);
- if(!$conf[$c]) die("$c does not exist or isn't writable. Check config!");
+ if(!$conf[$c]) die("$c does not exist, isn't accessable or writable. Check config and permissions!");
}
}
/**
- * Checks the existance of certain files and creates them if missing
+ * Checks the existance of certain files and creates them if missing.
*/
function init_files(){
global $conf;
+
$files = array( $conf['cachedir'].'/word.idx',
$conf['cachedir'].'/page.idx',
- $conf['cachedir'].'/index.idx', );
+ $conf['cachedir'].'/index.idx');
foreach($files as $file){
if(!@file_exists($file)){
- $fh = fopen($file,'a');
- fclose($fh);
- if(isset($conf['fmask'])) { chmod($file, $conf['fmask']); }
+ $fh = @fopen($file,'a');
+ if($fh){
+ fclose($fh);
+ if(isset($conf['fmask'])) { chmod($file, $conf['fmask']); }
+ }else{
+ die("$file is not writable. Check permissions!");
+ }
}
}
}
/**
- * returns absolute path
+ * Returns absolute path
+ *
+ * This tries the given path first, then checks in DOKU_INC.
+ * Check for accessability on directories as well.
*
- * This tries the given path first, then checks in DOKU_INC
+ * @author Andreas Gohr <andi@splitbrain.org>
*/
function init_path($path){
+ // check existance
$p = realpath($path);
- if(@file_exists($p)) return $p;
- $p = realpath(DOKU_INC.$path);
- if(@file_exists($p)) return $p;
- return '';
+ if(!@file_exists($p)){
+ $p = realpath(DOKU_INC.$path);
+ if(!@file_exists($p)){
+ return '';
+ }
+ }
+
+ // check writability
+ if(!@is_writable($p)){
+ return '';
+ }
+
+ // check accessability (execute bit) for directories
+ if(@is_dir($p) && !@file_exists("$p/.")){
+ return '';
+ }
+
+ return $p;
}
/**
diff --git a/inc/io.php b/inc/io.php
index 47f2e1149..1b8d2dadf 100644
--- a/inc/io.php
+++ b/inc/io.php
@@ -206,7 +206,7 @@ function io_makeFileDir($file){
global $conf;
$dir = dirname($file);
- if(!is_dir($dir)){
+ if(!@is_dir($dir)){
io_mkdir_p($dir) || msg("Creating directory $dir failed",-1);
}
}
@@ -220,7 +220,7 @@ function io_makeFileDir($file){
*/
function io_mkdir_p($target){
global $conf;
- if (is_dir($target)||empty($target)) return 1; // best case check first
+ if (@is_dir($target)||empty($target)) return 1; // best case check first
if (@file_exists($target) && !is_dir($target)) return 0;
//recursion
if (io_mkdir_p(substr($target,0,strrpos($target,'/')))){