From 003f4b8e734bd572901b8b35fef2f14dd77d80a7 Mon Sep 17 00:00:00 2001 From: real_nowhereman Date: Tue, 21 Jun 2011 08:32:00 +0000 Subject: [PATCH] make file permissions user-defined --- defaults.php | 5 +++++ fp-includes/core/core.filesystem.php | 14 ++++++++------ fp-plugins/thumb/plugin.thumb.php | 3 +-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/defaults.php b/defaults.php index 6889a8f..04dc4e0 100755 --- a/defaults.php +++ b/defaults.php @@ -17,6 +17,11 @@ // legacy mode; needed with some ill-formed spb files define('DUMB_MODE_ENABLED', false); + // default file permissions + // change file to 644 and dir to 755 if your webserver "complains" + define('FILE_PERMISSIONS', 0777); + define('DIR_PERMISSIONS', 0777); + // first some webserver setup... diff --git a/fp-includes/core/core.filesystem.php b/fp-includes/core/core.filesystem.php index f136ff1..e62418f 100755 --- a/fp-includes/core/core.filesystem.php +++ b/fp-includes/core/core.filesystem.php @@ -125,7 +125,7 @@ * @todo cleanup & check bool return value * */ - function fs_mkdir($dir, $mode=0777) { + function fs_mkdir($dir, $mode=DIR_PERMISSIONS) { if (is_dir($dir) || (@mkdir($dir,$mode))) {@chmod($dir, $mode); return TRUE;} if (!fs_mkdir(dirname($dir),$mode)) return FALSE; return (@mkdir($dir,$mode) && @chmod($dir, $mode)); @@ -181,11 +181,13 @@ class fs_chmodder extends fs_filelister { - var $_chmod=0777; - - function fs_chmodder($directory, $octal=0777) { + var $_chmod_dir; + var $_chmod_file; + + function fs_chmodder($directory, $ch_file=FILE_PERMISSIONS, $ch_dir=DIR_PERMISSIONS) { $this->_directory = $directory; - $this->_chmod = $octal; + $this->_chmod_file = $ch_file; + $this->_chmod_dir = $ch_dir; parent::fs_filelister(); } @@ -194,7 +196,7 @@ $path = "$directory/$file"; if (is_dir($path)) $retval = 1; - if (!@chmod($path, $this->_chmod)) + if ( !@chmod($path, ($retval? $this->_chmod_dir : $this->_chmod_file ) ) ) array_push($this->_list, $path); return $retval; diff --git a/fp-plugins/thumb/plugin.thumb.php b/fp-plugins/thumb/plugin.thumb.php index 9c197bc..6347490 100755 --- a/fp-plugins/thumb/plugin.thumb.php +++ b/fp-plugins/thumb/plugin.thumb.php @@ -99,7 +99,7 @@ function plugin_thumb_create($fpath, $infos, $new_width, $new_height) { imagecopyresampled($scaled, $image, 0, 0, 0, 0, $new_width, $new_height, $infos[0], $infos[1]); imagejpeg($scaled, $thumbpath); - @chmod($thumbpath, 0777); + @chmod($thumbpath, FILE_PERMISSIONS); return array($thumbpath, $new_width, $new_height); @@ -115,4 +115,3 @@ function plugin_thumb_bbcodehook($actualpath, $props, $newsize){ add_filter('bbcode_img_scale', 'plugin_thumb_bbcodehook', 0, 3); -?>