make file permissions user-defined

This commit is contained in:
real_nowhereman 2011-06-21 08:32:00 +00:00
parent f98264df74
commit 003f4b8e73
3 changed files with 14 additions and 8 deletions

View File

@ -17,6 +17,11 @@
// legacy mode; needed with some ill-formed spb files // legacy mode; needed with some ill-formed spb files
define('DUMB_MODE_ENABLED', false); 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... // first some webserver setup...

View File

@ -125,7 +125,7 @@
* @todo cleanup & check bool return value * @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 (is_dir($dir) || (@mkdir($dir,$mode))) {@chmod($dir, $mode); return TRUE;}
if (!fs_mkdir(dirname($dir),$mode)) return FALSE; if (!fs_mkdir(dirname($dir),$mode)) return FALSE;
return (@mkdir($dir,$mode) && @chmod($dir, $mode)); return (@mkdir($dir,$mode) && @chmod($dir, $mode));
@ -181,11 +181,13 @@
class fs_chmodder extends fs_filelister { class fs_chmodder extends fs_filelister {
var $_chmod=0777; var $_chmod_dir;
var $_chmod_file;
function fs_chmodder($directory, $octal=0777) { function fs_chmodder($directory, $ch_file=FILE_PERMISSIONS, $ch_dir=DIR_PERMISSIONS) {
$this->_directory = $directory; $this->_directory = $directory;
$this->_chmod = $octal; $this->_chmod_file = $ch_file;
$this->_chmod_dir = $ch_dir;
parent::fs_filelister(); parent::fs_filelister();
} }
@ -194,7 +196,7 @@
$path = "$directory/$file"; $path = "$directory/$file";
if (is_dir($path)) if (is_dir($path))
$retval = 1; $retval = 1;
if (!@chmod($path, $this->_chmod)) if ( !@chmod($path, ($retval? $this->_chmod_dir : $this->_chmod_file ) ) )
array_push($this->_list, $path); array_push($this->_list, $path);
return $retval; return $retval;

View File

@ -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]); imagecopyresampled($scaled, $image, 0, 0, 0, 0, $new_width, $new_height, $infos[0], $infos[1]);
imagejpeg($scaled, $thumbpath); imagejpeg($scaled, $thumbpath);
@chmod($thumbpath, 0777); @chmod($thumbpath, FILE_PERMISSIONS);
return array($thumbpath, $new_width, $new_height); 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); add_filter('bbcode_img_scale', 'plugin_thumb_bbcodehook', 0, 3);
?>