Fixed bug #3961: Upload to TER always transfers hidden or system files
authorKarsten Dambekalns <karsten.dambekalns@typo3.org>
Thu, 14 Dec 2006 05:36:05 +0000 (05:36 +0000)
committerKarsten Dambekalns <karsten.dambekalns@typo3.org>
Thu, 14 Dec 2006 05:36:05 +0000 (05:36 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@1878 709f56b5-9817-0410-a4d7-c38de5d9e867

t3lib/class.t3lib_div.php
t3lib/config_default.php
typo3/mod/tools/em/class.em_index.php

index c01b776..3b45938 100755 (executable)
@@ -2561,9 +2561,10 @@ class t3lib_div {
         * @param       string          $extensionList is the comma list of extensions to read only (blank = all)
         * @param       boolean         If set, then the path is prepended the filenames. Otherwise only the filenames are returned in the array
         * @param       string          $order is sorting: 1= sort alphabetically, 'mtime' = sort by modification time.
+        * @param       string          A comma seperated list of filenames to exclude, no wildcards
         * @return      array           Array of the files found
         */
-       function getFilesInDir($path,$extensionList='',$prependPath=0,$order='')        {
+       function getFilesInDir($path,$extensionList='',$prependPath=0,$order='',$excludePattern='')     {
 
                        // Initialize variabels:
                $filearray = array();
@@ -2579,9 +2580,9 @@ class t3lib_div {
                                        if (@is_file($path.'/'.$entry)) {
                                                $fI = pathinfo($entry);
                                                $key = md5($path.'/'.$entry);   // Don't change this ever - extensions may depend on the fact that the hash is an md5 of the path! (import/export extension)
-                                               if (!$extensionList || t3lib_div::inList($extensionList,strtolower($fI['extension'])))  {
+                                               if ((!strlen($extensionList) || t3lib_div::inList($extensionList,strtolower($fI['extension']))) && (!strlen($excludePattern) || !preg_match('/^'.$excludePattern.'$/',$entry))) {
                                                    $filearray[$key]=($prependPath?$path.'/':'').$entry;
-                                                       if ($order=='mtime') {$sortarray[$key]=filemtime($path.'/'.$entry);}
+                                                               if ($order=='mtime') {$sortarray[$key]=filemtime($path.'/'.$entry);}
                                                                elseif ($order) {$sortarray[$key]=$entry;}
                                                }
                                        }
@@ -2615,17 +2616,18 @@ class t3lib_div {
         * @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...
+        * @param string                $excludePattern: regex pattern of files/directories to exclude
         * @return      array           An array with the found files/directories.
         */
-       function getAllFilesAndFoldersInPath($fileArr,$path,$extList='',$regDirs=0,$recursivityLevels=99)       {
+       function getAllFilesAndFoldersInPath($fileArr,$path,$extList='',$regDirs=0,$recursivityLevels=99,$excludePattern='')    {
                if ($regDirs)   $fileArr[] = $path;
-               $fileArr = array_merge($fileArr, t3lib_div::getFilesInDir($path,$extList,1,1));
+               $fileArr = array_merge($fileArr, t3lib_div::getFilesInDir($path,$extList,1,1,$excludePattern));
 
                $dirs = t3lib_div::get_dirs($path);
                if (is_array($dirs) && $recursivityLevels>0)    {
                        foreach ($dirs as $subdirs)     {
-                               if ((string)$subdirs!=''      {
-                                       $fileArr = t3lib_div::getAllFilesAndFoldersInPath($fileArr,$path.$subdirs.'/',$extList,$regDirs,$recursivityLevels-1);
+                               if ((string)$subdirs!='' && (!strlen($excludePattern) || !preg_match('/^'.$excludePattern.'$/',$subdirs)))      {
+                                       $fileArr = t3lib_div::getAllFilesAndFoldersInPath($fileArr,$path.$subdirs.'/',$extList,$regDirs,$recursivityLevels-1,$excludePattern);
                                }
                        }
                }
index 756e644..fa45a42 100755 (executable)
@@ -98,6 +98,7 @@ $TYPO3_CONF_VARS = Array(
                'em_mirrorListURL' => 'http://repositories.typo3.org/mirrors.xml.gz',                           // Allows to preset the URL for fetching the extension repository mirror list from. Used in the Extension Manager.
 
                'requiredExt' => 'cms,version,lang,sv',                 // String list: List of extensions which are REQUIRED and cannot be unloaded by the Extension Manager!
+               'excludeForPackaging' => '(CVS|\..*|.*~|.*\.bak)',              // String list: List of directories and files which will not be packaged into extensions nor taken into account otherwise by the Extension Manager. Perl regular expression syntax!
                'extCache' => 1,                                                // Int. 0,1,2,3: 0: ext-scripts (ext_localconf.php and ext_tables.php) are NOT cached, but included every time. 1: scripts cached to typo3conf/temp_CACHED_[sitePathHash]* (saves some milliseconds even with PHP accelerators), 2: scripts cached and prefix includes a hash based on the 'extList' string, 3: scripts cached to typo3conf/temp_CACHED_* (no hash included at all...)
                'extList' => 'tsconfig_help,context_help,extra_page_cm_options,impexp,belog,aboutmodules,setup,install',                                                // String list: List of extensions which are enabled for this install. Use the Extension Manager (EM) to manage this!
                'extConf' => array(                                             // Config-options for extensions, stored as serialized arrays by extension-keys. Handled automatically by the EM.
index 2fc9e4b..ff19245 100644 (file)
@@ -342,7 +342,7 @@ class SC_mod_tools_em_index extends t3lib_SCbase {
        function init() {
                global $BE_USER,$LANG,$BACK_PATH,$TYPO3_CONF_VARS;
 
-               // Setting paths of install scopes:
+                       // Setting paths of install scopes:
                $this->typePaths = Array (
                        'S' => TYPO3_mainDir.'sysext/',
                        'G' => TYPO3_mainDir.'ext/',
@@ -354,10 +354,12 @@ class SC_mod_tools_em_index extends t3lib_SCbase {
                        'L' => '../../../../'.TYPO3_mainDir
                );
 
-               // Setting module configuration:
+               $this->excludeForPackaging = $GLOBALS['TYPO3_CONF_VARS']['EXT']['excludeForPackaging'];
+
+                       // Setting module configuration:
                $this->MCONF = $GLOBALS['MCONF'];
 
-               // Setting GPvars:
+                       // Setting GPvars:
                $this->CMD = t3lib_div::_GP('CMD');
                $this->lookUpStr = trim(t3lib_div::_GP('_lookUp'));
                $this->listRemote = t3lib_div::_GP('ter_connect');
@@ -2307,7 +2309,7 @@ EXTENSION KEYS:
                if ($extPath)   {
                        // Read files:
                        $fileArr = array();
-                       $fileArr = t3lib_div::getAllFilesAndFoldersInPath($fileArr,$extPath);
+                       $fileArr = t3lib_div::getAllFilesAndFoldersInPath($fileArr,$extPath,'',0,99,$this->excludeForPackaging);
 
                        // Start table:
                        $lines = array();
@@ -3010,7 +3012,7 @@ EXTENSION KEYS:
                                                        $list[$extKey]['doubleInstall'].= $type;
                                                        $list[$extKey]['type'] = $type;
                                                        $list[$extKey]['EM_CONF'] = $emConf;
-                                                       $list[$extKey]['files'] = t3lib_div::getFilesInDir($path.$extKey);
+                                                       $list[$extKey]['files'] = t3lib_div::getFilesInDir($path.$extKey, '', 0, '', $this->excludeForPackaging);
 
                                                        $this->setCat($cat,$list[$extKey], $extKey);
                                                }
@@ -3383,7 +3385,7 @@ EXTENSION KEYS:
         * @see makeDetailedExtensionAnalysis()
         */
        function getClassIndexLocallangFiles($absPath,$table_class_prefix,$extKey)      {
-               $filesInside = t3lib_div::removePrefixPathFromList(t3lib_div::getAllFilesAndFoldersInPath(array(),$absPath,'php,inc'),$absPath);
+               $filesInside = t3lib_div::removePrefixPathFromList(t3lib_div::getAllFilesAndFoldersInPath(array(),$absPath,'php,inc',0,99,$this->excludeForPackaging),$absPath);
                $out = array();
 
                foreach($filesInside as $fileName)      {
@@ -3928,7 +3930,7 @@ $EM_CONF[$_EXTKEY] = '.$this->arrayToCode($EM_CONF, 0).';
 
                        // Get files for extension:
                        $fileArr = array();
-                       $fileArr = t3lib_div::getAllFilesAndFoldersInPath($fileArr,$extPath);
+                       $fileArr = t3lib_div::getAllFilesAndFoldersInPath($fileArr,$extPath,'',0,99,$this->excludeForPackaging);
 
                        // Calculate the total size of those files:
                        $totalSize = 0;