* Fixed problem in Extension Manager where files and directories was not written...
authorKasper Skårhøj <kasper@typo3.org>
Tue, 23 Mar 2004 13:49:31 +0000 (13:49 +0000)
committerKasper Skårhøj <kasper@typo3.org>
Tue, 23 Mar 2004 13:49:31 +0000 (13:49 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@147 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_div.php
t3lib/class.t3lib_extfilefunc.php
t3lib/config_default.php
typo3/mod/tools/em/index.php
typo3/sysext/cms/tslib/class.tslib_fe.php

index e31e074..b733329 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2004-03-23  Kasper Skårhøj,,,  <kasper@typo3.com>
 
+       * Fixed problem in Extension Manager where files and directories was not written with correct permissions. I also added t3lib_div::mkdir() general function for creating directories.
+
+2004-03-23  Kasper Skårhøj,,,  <kasper@typo3.com>
+
        * Fixed bug that page tree didn't unfold when entering page id in the shortcut frame.
 
 2004-03-23  Kasper Skårhøj,,,  <kasper@typo3.com>
index 6b9c7cf..48aaad5 100755 (executable)
  *
  *              SECTION: FILES FUNCTIONS
  * 1938:     function getURL($url)     
- * 1981:     function writeFile($file,$content)        
+ * 1981:     function writeFile($file,$content)
  * 2004:     function get_dirs($path)  
  * 2030:     function getFilesInDir($path,$extensionList='',$prependPath=0,$order='')  
- * 2075:     function getAllFilesAndFoldersInPath($fileArr,$path,$extList='',$regDirs=0,$recursivityLevels=99) 
+ * 2075:     function getAllFilesAndFoldersInPath($fileArr,$path,$extList='',$regDirs=0,$recursivityLevels=99)
  * 2097:     function removePrefixPathFromList($fileArr,$prefixToRemove)       
  * 2114:     function fixWindowsFilePath($theFile)     
  * 2124:     function resolveBackPath($pathStr)        
@@ -1985,7 +1985,7 @@ class t3lib_div {
 
                                // Setting file system mode of file:
                        if (@is_file($file) && TYPO3_OS!='WIN') {
-                               @chmod ($file, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask']));
+                               chmod($file, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask']));
                        }
 
                        return true;
@@ -1993,6 +1993,20 @@ class t3lib_div {
        }
 
        /**
+        * Wrapper function for mkdir, setting folder permissions according to $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask']
+        *
+        * @param       string          Absolute path to folder, see PHP mkdir() function. Removes trailing slash internally.
+        * @return      boolean         TRUE if @mkdir went well!
+        */
+       function mkdir($theNewFolder)   {
+               $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
+                       return TRUE;
+               }
+       }
+
+       /**
         * Returns an array with the names of folders in a specific path
         * Will return 'error' (string) if there were an error with reading directory content.
         *
@@ -2028,12 +2042,16 @@ class t3lib_div {
         * @return      array           Array of the files found
         */
        function getFilesInDir($path,$extensionList='',$prependPath=0,$order='')        {
-               $filearray=array();
-               $sortarray=array();
-               if ($path)      {
-                       $path = ereg_replace('/$','',$path);
+
+                       // Initialize variabels:
+               $filearray = array();
+               $sortarray = array();
+               $path = ereg_replace('\/$','',$path);
+
+                       // Find files+directories:
+               if (@is_dir($path))     {
                        $extensionList = strtolower($extensionList);
-                       $d = @dir($path);
+                       $d = dir($path);
                        if (is_object($d))      {
                                while($entry=$d->read()) {
                                        if (@is_file($path.'/'.$entry)) {
@@ -2047,8 +2065,10 @@ class t3lib_div {
                                        }
                                }
                                $d->close();
-                       } else return 'error';
+                       } else return 'error opening path: "'.$path.'"';
                }
+
+                       // Sort them:
                if ($order) {
                        asort($sortarray);
                        reset($sortarray);
@@ -2058,6 +2078,8 @@ class t3lib_div {
                        }
                        $filearray=$newArr;
                }
+
+                       // Return result
                reset($filearray);
                return $filearray;
        }
@@ -2066,15 +2088,15 @@ class t3lib_div {
         * Recursively gather all files and folders of a path.
         *
         * @param       array           $fileArr: Empty input array (will have files added to it)
-        * @param       string          $path: The path to read recursively from (absolute)
+        * @param       string          $path: The path to read recursively from (absolute) (include trailing slash!)
         * @param       string          $extList: Comma list of file extensions: Only files with extensions in this list (if applicable) will be selected.
         * @param       boolean         $regDirs: If set, directories are also included in output.
         * @param       integer         $recursivityLevels: The number of levels to dig down...
         * @return      array           An array with the found files/directories.
         */
        function getAllFilesAndFoldersInPath($fileArr,$path,$extList='',$regDirs=0,$recursivityLevels=99)       {
-               if ($regDirs)   $fileArr[]=$path;
-               $fileArr = array_merge($fileArr,t3lib_div::getFilesInDir($path,$extList,1,1));
+               if ($regDirs)   $fileArr[] = $path;
+               $fileArr = array_merge($fileArr, t3lib_div::getFilesInDir($path,$extList,1,1));
 
                $dirs = t3lib_div::get_dirs($path);
                if (is_array($dirs) && $recursivityLevels>0)    {
@@ -2776,7 +2798,7 @@ class t3lib_div {
 
                        // Setting file system mode of file:
                if (@is_file($destination) && TYPO3_OS!='WIN')  {
-                       @chmod ($destination, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask']));
+                       chmod($destination, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask']));
                }
 
                        // 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
index 631381f..193cf75 100755 (executable)
@@ -730,8 +730,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
                                                $theNewFolder = $theTarget.'/'.$theFolder;
                                                if ($this->checkPathAgainstMounts($theNewFolder))       {
                                                        if (!@file_exists($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 (t3lib_div::mkdir($theNewFolder)){
                                                                        $this->writelog(6,0,1,"Directory '%s' created in '%s'",Array($theFolder,$theTarget.'/'));
                                                                        return $theNewFolder;
                                                                } else $this->writelog(6,1,100,"Directory '%s' not created. Write-permission problem in '%s'?",Array($theFolder,$theTarget.'/'));
index 63fdc2e..69f88f6 100755 (executable)
@@ -98,7 +98,7 @@ $TYPO3_CONF_VARS = Array(
                'userHomePath' => '',                                   // Path to the directory where TYPO3 backend-users have their home-dirs.  Eg. '/home/typo3/users/'. A home for backend user 2 would be: '/home/typo3/users/2/'. Ending slash required!
                'groupHomePath' => '',                                  // Path to the directory where TYPO3 backend-groups have their home-dirs. Remember that the first part of this path must be 'lockRootPath'. Eg. '/home/typo3/groups/'. A home for backend group 1 would be: '/home/typo3/groups/1/'. Ending slash required!
                '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' => '0664',                             // File mode mask for unix file systems (when files are uploaded/created)
+               '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.
                '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.
index c7dfb9a..d9588a3 100755 (executable)
  *
  *              SECTION: File system operations
  * 2822:     function createDirsInPath($dirs,$extDirPath)      
- * 2847:     function removeExtDirectory($removePath,$removeContentOnly=0)     
+ * 2847:     function removeExtDirectory($removePath,$removeContentOnly=0)
  * 2908:     function clearAndMakeExtensionDir($importedData,$type)    
  * 2961:     function removeCacheFiles()       
  * 2981:     function extractDirsFromFileList($files)  
@@ -1123,10 +1123,10 @@ EXTENSION KEYS:
                                                                                } elseif (md5(t3lib_div::getUrl($extDirPath.$theFile)) != $fileData['content_md5']) {
                                                                                        $content.='Error: File "'.$extDirPath.$theFile.'" MD5 was different from the original files MD5 - so the file is corrupted!<br />';
                                                                                } elseif (TYPO3_OS!='WIN') {
-                                                                                       chmod ($extDirPath.$theFile, 0755);   
+                                                                                       #chmod ($extDirPath.$theFile, 0755);    # SHOULD NOT do that here since writing the file should already have set adequate permissions!
                                                                                }
                                                                        }
-                                                                       
+
                                                                                // No content, no errors. Create success output here:
                                                                        if (!$content)  {
                                                                                $content='SUCCESS: '.$extDirPath.'<br />';
@@ -1153,7 +1153,7 @@ EXTENSION KEYS:
                                                                                $EM_CONF['_md5_values_when_last_written'] = serialize($sEMD5A);
                                                                                $emConfFile = $this->construct_ext_emconf_file($extKey,$EM_CONF);
                                                                                t3lib_div::writeFile($extDirPath.'ext_emconf.php',$emConfFile);
-               
+
                                                                                $content.='ext_emconf.php: '.$extDirPath.'ext_emconf.php<br />';
                                                                                $content.='Type: '.$loc.'<br />';
                                                                                
@@ -2827,7 +2827,7 @@ EXTENSION KEYS:
                                foreach($allDirs as $dirParts)  {
                                        $root.=$dirParts.'/';
                                        if (!is_dir($extDirPath.$root)) {
-                                               @mkdir(ereg_replace('\/$','',$extDirPath.$root), 0777);
+                                               t3lib_div::mkdir($extDirPath.$root);
                                                if (!@is_dir($extDirPath.$root))        {
                                                        return 'Error: The directory "'.$extDirPath.$root.'" could not be created...';
                                                }
@@ -2840,7 +2840,7 @@ EXTENSION KEYS:
        /**
         * Removes the extension directory (including content)
         *
-        * @param       string          Extension directory to remove.
+        * @param       string          Extension directory to remove (with trailing slash)
         * @param       boolean         If set, will leave the extension directory
         * @return      boolean         False on success, otherwise error string.
         */
@@ -2852,8 +2852,9 @@ EXTENSION KEYS:
                        (t3lib_div::isFirstPartOfStr($removePath,PATH_site.$this->typePaths['S']) && $this->systemInstall) ||
                        t3lib_div::isFirstPartOfStr($removePath,PATH_site.'fileadmin/_temp_/'))         // Playing-around directory...
                        ) {
-                       
-                       $fileArr = t3lib_div::getAllFilesAndFoldersInPath(array(),$removePath,'',1);
+
+                               // All files in extension directory:
+                       $fileArr = t3lib_div::getAllFilesAndFoldersInPath(array(),$removePath);
                        if (is_array($fileArr)) {
 
                                        // Remove files in dirs:
@@ -2866,7 +2867,7 @@ EXTENSION KEYS:
                                                                $errors[] = 'Error: "'.$removeFile.'" could not be deleted!';
                                                        }
                                                } else $errors[] = 'Error: "'.$removeFile.'" was either not a file, or it was equal to the removed directory or simply outside the removed directory "'.$removePath.'"!';
-                                       } else $errors[] = 'Error: "'.$removeFile.'" was a directory! Strange!';
+                                       }
                                }
 
                                        // Remove directories:
@@ -2918,7 +2919,7 @@ EXTENSION KEYS:
                                
                                        // Creates the typo3conf/ext/ directory if it does NOT already exist:
                                if ((string)$type=='L' && !@is_dir($path))      {
-                                       mkdir(ereg_replace('\/$','',$path), 0777);
+                                       t3lib_div::mkdir($path);
                                }
                        break;
                        default:
@@ -2947,7 +2948,7 @@ EXTENSION KEYS:
                        }
 
                                // We go create...
-                       @mkdir(ereg_replace('\/$','',$extDirPath), 0777);
+                       t3lib_div::mkdir($extDirPath);
                        if (!is_dir($extDirPath))       return 'ERROR: Could not create extension directory "'.$extDirPath.'"';
                        return array($extDirPath);
                } else return 'ERROR: The extension install path "'.$path.'" was not a directory.';
@@ -3253,13 +3254,13 @@ EXTENSION KEYS:
                                                $uploadArray['FILES'][$relFileName]['content_md5'] = md5($uploadArray['FILES'][$relFileName]['content']);
                                        }
                                }
-                               
+
                                        // Return upload-array:
                                return $uploadArray;
                        } else return 'Error: Total size of uncompressed upload ('.$totalSize.') exceeds '.t3lib_div::formatSize($this->maxUploadSize);
                }
        }
-       
+
        /**
         * Include a locallang file and return the $LOCAL_LANG array serialized.
         *
@@ -3505,7 +3506,7 @@ EXTENSION KEYS:
                $uploadFolder = PATH_site.$this->ulFolder($extKey);
                if ($extInfo['EM_CONF']['uploadfolder'] && !@is_dir($uploadFolder))     {
                        if (t3lib_div::_POST('_uploadfolder'))  {       // CREATE dir:
-                               mkdir(ereg_replace('\/$','',$uploadFolder), 0777);
+                               t3lib_div::mkdir($uploadFolder);
                                $indexContent = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
 <HTML>
 <HEAD>
@@ -3541,7 +3542,7 @@ EXTENSION KEYS:
                                                        if (strcmp($dirP,''))   {
                                                                $crDirStart.= $dirP.'/';
                                                                if (!@is_dir(PATH_site.$crDirStart))    {
-                                                                       mkdir(ereg_replace('\/$', '', PATH_site.$crDirStart), 0777);
+                                                                       t3lib_div::mkdir(PATH_site.$crDirStart);
                                                                        $finalDir = PATH_site.$crDirStart;
                                                                }
                                                        } else {
index efdc130..e741a7f 100755 (executable)
  *
  *              SECTION: Various internal API functions
  * 2342:     function makeSimulFileName($inTitle,$page,$type,$addParams='',$no_cache='')       
- * 2389:     function simulateStaticDocuments_pEnc_onlyP_proc($linkVars)       
+ * 2389:     function simulateStaticDocuments_pEnc_onlyP_proc($linkVars)
  * 2417:     function getSimulFileName()       
  * 2430:     function encryptEmail($string,$back=0)    
  * 2447:     function checkFileInclude($incFile)       
                                        }
                                                // if .simulateStaticDocuments was not present, the default value will rule.
                                        if (!isset($this->config['config']['simulateStaticDocuments'])) {
-                                               $this->config['config']['simulateStaticDocuments']=$this->TYPO3_CONF_VARS['FE']['simulateStaticDocuments'];
+                                               $this->config['config']['simulateStaticDocuments'] = $this->TYPO3_CONF_VARS['FE']['simulateStaticDocuments'];
                                        }
                
                                                        // Processing for the config_array: