+2004-06-06 Kasper Skårhøj,,, <kasper@typo3.com>
+
+ * Added "groupChangeMask" option in TYPO3_CONF_VARS - makes it possible to set which group newly created files and folders will get. (Thanks to Stucki)
+
2004-06-03 Kasper Skårhøj,,, <kasper@typo3.com>
* Added API for configuring tables (ending on "cache") that are flushed together with "Clear All Cache".
if ($charset && t3lib_div::validPathStr($charsetConvTableFile) && @is_file($charsetConvTableFile)) {
// Cache file for charsets:
// Caching brought parsing time for gb2312 down from 2400 ms to 150 ms. For other charsets we are talking 11 ms down to zero.
- $cacheFile = t3lib_div::getFileAbsFileName('typo3temp/charset_'.$charset.'.tbl');
+ $cacheFile = t3lib_div::getFileAbsFileName('typo3temp/cs/charset_'.$charset.'.tbl');
if ($cacheFile && @is_file($cacheFile)) {
$this->parsedCharsets[$charset]=unserialize(t3lib_div::getUrl($cacheFile));
} else {
}
}
if ($cacheFile) {
- t3lib_div::writeFile($cacheFile,serialize($this->parsedCharsets[$charset]));
+ t3lib_div::writeFileToTypo3tempDir($cacheFile,serialize($this->parsedCharsets[$charset]));
}
}
return 2;
*/
function initUnicodeData($mode=null) {
// cache files
- $cacheFileCase = t3lib_div::getFileAbsFileName('typo3temp/cscase_utf-8.tbl');
- $cacheFileASCII = t3lib_div::getFileAbsFileName('typo3temp/csascii_utf-8.tbl');
+ $cacheFileCase = t3lib_div::getFileAbsFileName('typo3temp/cs/cscase_utf-8.tbl');
+ $cacheFileASCII = t3lib_div::getFileAbsFileName('typo3temp/cs/csascii_utf-8.tbl');
// Only process if the tables are not yet loaded
switch($mode) {
}
if ($cacheFileCase) {
- t3lib_div::writeFile($cacheFileCase,serialize($utf8CaseFolding));
+ t3lib_div::writeFileToTypo3tempDir($cacheFileCase,serialize($utf8CaseFolding));
}
if ($cacheFileASCII) {
- t3lib_div::writeFile($cacheFileASCII,serialize($ascii));
+ t3lib_div::writeFileToTypo3tempDir($cacheFileASCII,serialize($ascii));
}
return 3;
if (is_array($this->caseFolding[$charset])) return 1;
// Use cached version if possible
- $cacheFile = t3lib_div::getFileAbsFileName('typo3temp/cscase_'.$charset.'.tbl');
+ $cacheFile = t3lib_div::getFileAbsFileName('typo3temp/cs/cscase_'.$charset.'.tbl');
if ($cacheFile && @is_file($cacheFile)) {
$this->caseFolding[$charset] = unserialize(t3lib_div::getUrl($cacheFile));
return 2;
}
if ($cacheFile) {
- t3lib_div::writeFile($cacheFile,serialize($this->caseFolding[$charset]));
+ t3lib_div::writeFileToTypo3tempDir($cacheFile,serialize($this->caseFolding[$charset]));
}
return 3;
if (is_array($this->toASCII[$charset])) return 1;
// Use cached version if possible
- $cacheFile = t3lib_div::getFileAbsFileName('typo3temp/csascii_'.$charset.'.tbl');
+ $cacheFile = t3lib_div::getFileAbsFileName('typo3temp/cs/csascii_'.$charset.'.tbl');
if ($cacheFile && @is_file($cacheFile)) {
$this->toASCII[$charset] = unserialize(t3lib_div::getUrl($cacheFile));
return 2;
}
if ($cacheFile) {
- t3lib_div::writeFile($cacheFile,serialize($this->toASCII[$charset]));
+ t3lib_div::writeFileToTypo3tempDir($cacheFile,serialize($this->toASCII[$charset]));
}
return 3;
fwrite( $fd, $content);
fclose( $fd );
- // Setting file system mode of file:
+ // Setting file system mode & group ownership of file:
if (@is_file($file) && TYPO3_OS!='WIN') {
@chmod($file, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'])); // "@" is there because file is not necessarily OWNED by the user
+ if($GLOBALS['TYPO3_CONF_VARS']['BE']['groupCreateMask']) { // skip this if groupCreateMask is empty
+ @chgrp($file, $GLOBALS['TYPO3_CONF_VARS']['BE']['groupCreateMask']); // "@" is there because file is not necessarily OWNED by the user
+ }
}
return true;
/**
* Writes $content to a filename in the typo3temp/ folder (and possibly a subfolder...)
+ * Accepts an additional subdirectory in the file path!
*
* @param string FileNAME to write to inside "typo3temp/". No directory prefixed, just filename with extension.
* @param string Content string to write
- * @param string Optional sub-directory in typo3temp/ to store the files in. (eg. "123" if the subdir should be "typo3temp/123/"). No trailing slash, only ONE level!
* @return string Returns false on success, otherwise an error string telling about the problem.
*/
- function writeFileToTypo3tempDir($filename,$content,$subdir='') {
- if ($filename && strlen($filename)<60 && t3lib_div::validPathStr($filename) && !strstr('/',$filename)) {
+ function writeFileToTypo3tempDir($filepath,$content) {
+ $filepath = pathinfo($filepath);
+debug($filepath);
+exit;
+ if ($filepath && strlen($filepath)<60 && t3lib_div::validPathStr($filepath) && !strstr('/',$filepath)) {
if (defined('PATH_site')) {
$dirName = PATH_site.'typo3temp/'; // Setting main temporary directory name (standard)
if (@is_dir($dirName)) {
} else return '"'.$dirName.'" is not a directory!';
} else return 'PATH_site + "typo3temp/" was not a directory!';
} else return 'PATH_site constant was NOT defined!';
- } else return 'Input filename was invalid!';
+ } else return 'Input filename "'.$filename.'" was invalid!';
}
/**
- * Wrapper function for mkdir, setting folder permissions according to $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask']
+ * Wrapper function for mkdir, setting folder permissions according to $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] and group ownership according to $GLOBALS['TYPO3_CONF_VARS']['BE']['groupCreateMask']
* Usage: 6
*
* @param string Absolute path to folder, see PHP mkdir() function. Removes trailing slash internally.
$theNewFolder = ereg_replace('\/$','',$theNewFolder);
if (mkdir($theNewFolder, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask']))){
chmod($theNewFolder, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'])); //added this line, because the mode at 'mkdir' has a strange behaviour sometimes
+
+ if($GLOBALS['TYPO3_CONF_VARS']['BE']['groupCreateMask']) { // skip this if groupCreateMask is empty
+ chgrp($theNewFolder, $GLOBALS['TYPO3_CONF_VARS']['BE']['groupCreateMask']);
+ }
return TRUE;
}
}
@copy($source,$destination);
}
- // Setting file system mode of file:
+ // Setting file system mode & group ownership of file:
if (@is_file($destination) && TYPO3_OS!='WIN') {
chmod($destination, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask']));
+ if($GLOBALS['TYPO3_CONF_VARS']['BE']['groupCreateMask']) { // skip this if groupCreateMask is empty
+ chgrp($destination, $GLOBALS['TYPO3_CONF_VARS']['BE']['groupCreateMask']);
+ }
}
// If here the file is copied and the temporary $source is still around, so when returning false the user can try unlink to delete the $source
'userUploadDir' => '', // Suffix to the user home dir which is what gets mounted in TYPO3. Eg. if the user dir is "../123_user/" and this value is "/upload" then "../123_user/upload" gets mounted.
'fileCreateMask' => '0775', // File mode mask for unix file systems (when files are uploaded/created). Execute bit is set since some files installed in extensions might need that.
'folderCreateMask' => '0775', // As above, but for folders.
+ 'groupCreateMask' => '', // Group ownership can be changed on unix file systems (see above). Set this if you want to change the group ownership of created files/folders to a specific group. This makes sense in all cases where the webserver is running with a different user/group as you do. Create a new group on your system and add you and the webserver user to the group. Now you can safely set the last bit in fileCreateMask/folderCreateMask to 0 (e.g. 770). Important: The user who is running your webserver needs to be a member of the group you specify here! Otherwise you might get some errors.
'warning_email_addr' => '', // Email-address that will receive a warning if there has been failed logins 4 times within an hour (all users).
'warning_mode' => '', // Bit 1: If set, warning_email_addr gets a mail everytime a user logs in. Bit 2: If set, a mail is sent if an ADMIN user logs in! Other bits reserved for future options.
'IPmaskList' => '', // String. Lets you define a list of IP-numbers (with *-wildcards) that are the ONLY ones allowed access to ANY backend activity. On error an error header is sent and the script exits. Works like IP masking for users configurable through TSconfig. See syntax for that (or look up syntax for the function t3lib_div::cmpIP())