diff options
author | Andreas Gohr <andi@splitbrain.org> | 2006-03-04 16:40:38 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2006-03-04 16:40:38 +0100 |
commit | 1ca31cfe69e2d10cce65c4323eb652b355f4c904 (patch) | |
tree | 5783a2da2d5ef9ba40aef392b7ad959740125e4c /inc/io.php | |
parent | 7c6f82e59d762d68d99d1a88f449d1035ffa5f76 (diff) | |
download | rpg-1ca31cfe69e2d10cce65c4323eb652b355f4c904.tar.gz rpg-1ca31cfe69e2d10cce65c4323eb652b355f4c904.tar.bz2 |
simplified file permission handling
This patch simpliefies the configuration of the file and directory creation
modes. There is no need to set the umask anymore. Only the wanted permissions
for files and directories are set. An init function compares the wanted modes
with the ones that would be choosen by the system automatically (consulting
the system's umask) and sets the modes for chmod when needed.
darcs-hash:20060304154038-7ad00-5ef1db3a87e42563a602f9d050c681d2ea74682f.gz
Diffstat (limited to 'inc/io.php')
-rw-r--r-- | inc/io.php | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/inc/io.php b/inc/io.php index 1b8d2dadf..9160f4718 100644 --- a/inc/io.php +++ b/inc/io.php @@ -87,7 +87,7 @@ function io_saveFile($file,$content,$append=false){ fclose($fh); } - if(!$fileexists and isset($conf['fmask'])) { chmod($file, $conf['fmask']); } + if(!$fileexists and $conf['fperm']) chmod($file, $conf['fperm']); io_unlock($file); return true; } @@ -178,7 +178,7 @@ function io_lock($file){ //waited longer than 3 seconds? -> stale lock if ((time() - $timeStart) > 3) break; $locked = @mkdir($lockDir, $conf['dmode']); - if($locked and isset($conf['dmask'])) { chmod($lockDir, $conf['dmask']); } + if($locked && $conf['dperm']) chmod($lockDir, $conf['dperm']); } while ($locked === false); } @@ -229,7 +229,7 @@ function io_mkdir_p($target){ return io_mkdir_ftp($dir); }else{ $ret = @mkdir($target,$conf['dmode']); // crawl back up & create dir tree - if($ret and isset($conf['dmask'])) { chmod($target, $conf['dmask']); } + if($ret && $conf['dperm']) chmod($target, $conf['dperm']); return $ret; } } @@ -264,8 +264,8 @@ function io_mkdir_ftp($dir){ //create directory $ok = @ftp_mkdir($conn, $dir); - //set permissions (using the directory umask and dmode) - @ftp_site($conn,sprintf("CHMOD %04o %s",$conf['dmask'],$dir)); + //set permissions + @ftp_site($conn,sprintf("CHMOD %04o %s",$conf['dmode'],$dir)); @ftp_close($conn); return $ok; @@ -320,7 +320,7 @@ function io_download($url,$file,$useAttachment=false,$defaultName=''){ if(!$fp) return false; fwrite($fp,$data); fclose($fp); - if(!$fileexists and isset($conf['fmask'])) { chmod($file, $conf['fmask']); } + if(!$fileexists and $conf['fperm']) chmod($file, $conf['fperm']); if ($useAttachment) return $name; return true; } @@ -335,7 +335,7 @@ function io_rename($from,$to){ global $conf; if(!@rename($from,$to)){ if(@copy($from,$to)){ - if(isset($conf['fmask'])) { chmod($file, $conf['fmask']); } + if($conf['fperm']) chmod($file, $conf['fperm']); @unlink($from); return true; } |