// 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
+ if($GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup']) { // skip this if createGroup is empty
+ @chgrp($file, $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup']); // "@" is there because file is not necessarily OWNED by the user
}
}
* 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 Absolute filepath to write to inside "typo3temp/". First part of this string must match PATH_site."typo3temp/"
* @param string Content string to write
* @return string Returns false on success, otherwise an error string telling about the problem.
*/
function writeFileToTypo3tempDir($filepath,$content) {
- $filepath = pathinfo($filepath);
-debug($filepath);
-exit;
- if ($filepath && strlen($filepath)<60 && t3lib_div::validPathStr($filepath) && !strstr('/',$filepath)) {
+
+ // Parse filepath into directory and basename:
+ $fI = pathinfo($filepath);
+ $fI['dirname'].= '/';
+
+ // Check parts:
+ if (t3lib_div::validPathStr($filepath) && $fI['basename'] && strlen($fI['basename'])<60) {
if (defined('PATH_site')) {
$dirName = PATH_site.'typo3temp/'; // Setting main temporary directory name (standard)
if (@is_dir($dirName)) {
- // Checking if the "subdir" string is set and if so, create directory if not present:
- if ($subdir) {
- $dirName.= $subdir.'/';
- if (!@is_dir($dirName)) {
- t3lib_div::mkdir($dirName);
+ if (t3lib_div::isFirstPartOfStr($fI['dirname'],$dirName)) {
+
+ // Checking if the "subdir" is found:
+ $subdir = substr($fI['dirname'],strlen($dirName));
+ if ($subdir) {
+ if (ereg('^[[:alnum:]]+\/$',$subdir)) {
+ $dirName.= $subdir;
+ if (!@is_dir($dirName)) {
+ t3lib_div::mkdir($dirName);
+ }
+ } else return 'Subdir, "'.$subdir.'", was NOT on the form "[a-z]/"';
}
- }
- // Checking dir-name again (sub-dir might have been created):
- if (@is_dir($dirName)) {
- $tempFile = t3lib_div::getFileAbsFileName($dirName.$filename);
- if ($tempFile) {
- t3lib_div::writeFile($tempFile,$content);
- if (!@is_file($tempFile)) return 'File not written to disk! Write permission error in filesystem?';
- } else return 'For some reason, the temporary file was not valid!';
- } else return '"'.$dirName.'" is not a directory!';
+ // Checking dir-name again (sub-dir might have been created):
+ if (@is_dir($dirName)) {
+ if ($filepath == $dirName.$fI['basename']) {
+ t3lib_div::writeFile($filepath, $content);
+ if (!@is_file($filepath)) return 'File not written to disk! Write permission error in filesystem?';
+ } else return 'Calculated filelocation didn\'t match input $filepath!';
+ } else return '"'.$dirName.'" is not a directory!';
+ } else return '"'.$fI['dirname'].'" was not within directory PATH_site + "typo3temp/"';
} else return 'PATH_site + "typo3temp/" was not a directory!';
} else return 'PATH_site constant was NOT defined!';
- } else return 'Input filename "'.$filename.'" was invalid!';
+ } else return 'Input filepath "'.$filepath.'" was generally invalid!';
}
/**
- * 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']
+ * 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']['createGroup']
* Usage: 6
*
* @param string Absolute path to folder, see PHP mkdir() function. Removes trailing slash internally.
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']);
+ if($GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup']) { // skip this if createGroup is empty
+ chgrp($theNewFolder, $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup']);
}
return TRUE;
}
// 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($GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup']) { // skip this if createGroup is empty
+ chgrp($destination, $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup']);
}
}
'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.
+ 'createGroup' => '', // Group for newly created files and folders (UNIX only). 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())
function readLLXMLfile($fileRef,$langKey) {
if (@is_file($fileRef)) {
+
// Set charset:
$origCharset = $this->csConvObj->parse_charset($this->csConvObj->charSetArray[$langKey] ? $this->csConvObj->charSetArray[$langKey] : 'iso-8859-1');
// Cache file name:
$hashSource = substr($fileRef,strlen(PATH_site)).'|'.date('d-m-Y H:i:s',filemtime($fileRef));
- $cacheFileName = 'cache_llxml_'.t3lib_div::md5int($hashSource).'.'.$langKey.'.'.$origCharset.'.ser';
- $cacheFileName_dirPrefix = PATH_site.'typo3temp/llxml/';
+ $cacheFileName = PATH_site.'typo3temp/llxml/cache_llxml_'.t3lib_div::md5int($hashSource).'.'.$langKey.'.'.$origCharset.'.ser';
-#$pt = t3lib_div::milliseconds();
// Check if cache file exists...
- if (!@is_file($cacheFileName_dirPrefix.$cacheFileName)) { // ... if it doesn't, create content and write it:
+ if (!@is_file($cacheFileName)) { // ... if it doesn't, create content and write it:
// Read XML, parse it and set default LOCAL_LANG array content:
$xmlString = t3lib_div::getUrl($fileRef);
}
$serContent = array('origFile'=>$hashSource, 'LOCAL_LANG'=>$LOCAL_LANG);
- t3lib_div::writeFileToTypo3tempDir($cacheFileName, serialize($serContent), 'llxml');
-#debug('Saving cache...', basename($fileRef).' - '.$cacheFileName_dirPrefix.$cacheFileName);
-#debug(t3lib_div::milliseconds()-$pt);
+ t3lib_div::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
} else {
- $serContent = unserialize(t3lib_div::getUrl($cacheFileName_dirPrefix.$cacheFileName));
+ $serContent = unserialize(t3lib_div::getUrl($cacheFileName));
$LOCAL_LANG = $serContent['LOCAL_LANG'];
-#debug('Getting cache...', basename($fileRef).' - '.$cacheFileName_dirPrefix.$cacheFileName);
-#debug(t3lib_div::milliseconds()-$pt);
}
return $LOCAL_LANG;
}