Fixed bug #12295: Cleaning config_default, exclude values from being listed in instal...
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_extfilefunc.php
old mode 100755 (executable)
new mode 100644 (file)
index 0d5d954..640f0fd
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
  *
  *
  *  105: class t3lib_extFileFunctions extends t3lib_basicFileFunctions
- *  149:     function start($fileCmds)
- *  179:     function init_actionPerms($setup)
- *  211:     function processData()
- *  268:     function printLogErrorMessages($redirect='')
- *  326:     function findRecycler($theFile)
- *  355:     function writeLog($action,$error,$details_nr,$details,$data)
+ *  151:     function start($fileCmds)
+ *  181:     function init_actionPerms($setup)
+ *  213:     function processData()
+ *  270:     function printLogErrorMessages($redirect='')
+ *  328:     function findRecycler($theFile)
+ *  357:     function writeLog($action,$error,$details_nr,$details,$data)
  *
  *              SECTION: File operation functions
- *  382:     function func_delete($cmds)
- *  449:     function func_copy($cmds)
- *  539:     function func_move($cmds)
- *  632:     function func_rename($cmds)
- *  678:     function func_newfolder($cmds)
- *  708:     function func_newfile($cmds)
- *  745:     function func_edit($cmds)
- *  777:     function func_upload($cmds)
- *  815:     function func_unzip($cmds)
+ *  384:     function func_delete($cmds)
+ *  451:     function func_copy($cmds)
+ *  542:     function func_move($cmds)
+ *  637:     function func_rename($cmds)
+ *  683:     function func_newfolder($cmds)
+ *  713:     function func_newfile($cmds)
+ *  750:     function func_edit($cmds)
+ *  782:     function func_upload($cmds)
+ *  821:     function func_unzip($cmds)
  *
  * TOTAL FUNCTIONS: 15
  * (This index is automatically created/updated by the extension "extdeveval")
@@ -94,7 +94,7 @@
  * You are allowed to copy/move folders between spaces (web/ftp) IF the destination has it's f_ext[]['allow'] set to '*'!
  *
  * Advice:
- * You should always exclude php-files from the webspace. This will keep people from uploading, copy/moving and renaming files to the php3/php-extension.
+ * You should always exclude php-files from the webspace. This will keep people from uploading, copy/moving and renaming files to become executable php scripts.
  * You should never mount a ftp_space 'below' the webspace so that it reaches into the webspace. This is because if somebody unzips a zip-file in the ftp-space so that it reaches out into the webspace this will be a violation of the safety
  * For example this is a bad idea: you have an ftp-space that is '/www/' and a web-space that is '/www/htdocs/'
  *
@@ -139,6 +139,8 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
                // Internal, dynamic:
        var $internalUploadMap = array();       // Will contain map between upload ID and the final filename
 
+       var $lastError = '';
+
 
 
 
@@ -161,11 +163,11 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions     {
                $this->unzipPath = $GLOBALS['TYPO3_CONF_VARS']['BE']['unzip_path'];
 
                $maxFileSize = intval($GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize']);
-               if ($maxFileSize>0)     {
+               if ($maxFileSize > 0) {
                        $this->maxCopyFileSize = $maxFileSize;
                        $this->maxMoveFileSize = $maxFileSize;
-                       $this->maxUploadFileSize = $maxFileSize;
                }
+               $this->maxUploadFileSize = t3lib_div::getMaxUploadFileSize();
 
                        // Initializing file processing commands:
                $this->fileCmdMap = $fileCmds;
@@ -173,9 +175,9 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
 
        /**
         * Sets up permission to perform file/directory operations.
-        * See below or the be_user-table for the significanse of the various bits in $setup ($BE_USER->user['fileoper_perms'])
+        * See below or the be_user-table for the significance of the various bits in $setup.
         *
-        * @param       integer         File permission integer from BE_USER object.
+        * @param       integer         File permission integer from BE_USER OR'ed with permissions of back-end groups this user is a member of
         * @return      void
         */
        function init_actionPerms($setup)       {
@@ -208,116 +210,121 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions   {
        /**
         * Processing the command array in $this->fileCmdMap
         *
-        * @return      void
+        * @return      mixed   false, if the file functions were not initialized
+        *                                      otherwise returns an array of all the results that are returned
+        *                                      from each command, separated in each action.
         */
-       function processData()  {
-               if (!$this->isInit) return FALSE;
+       function processData() {
+               $result = array();
+               if (!$this->isInit) {
+                       return false;
+               }
 
-               if (is_array($this->fileCmdMap))        {
+               if (is_array($this->fileCmdMap)) {
+
+                               // Check if there were uploads expected, but no one made
+                       if ($this->fileCmdMap['upload']) {
+                               $uploads = $this->fileCmdMap['upload'];
+                               foreach ($uploads as $upload) {
+                                       if (!$_FILES['upload_' . $upload['data']]['name']) {
+                                               unset($this->fileCmdMap['upload'][$upload['data']]);
+                                       }
+                               }
+                               if (count($this->fileCmdMap['upload']) == 0) {
+                                       $this->writelog(1,1,108,'No file was uploaded!','');
+                               }
+                       }
 
                                // Traverse each set of actions
-                       foreach($this->fileCmdMap as $action => $actionData)    {
+                       foreach ($this->fileCmdMap as $action => $actionData) {
 
                                        // Traverse all action data. More than one file might be affected at the same time.
-                               if (is_array($actionData))      {
-                                       foreach($actionData as $cmdArr) {
+                               if (is_array($actionData)) {
+                                       $result[$action] = array();
+                                       foreach ($actionData as $cmdArr) {
 
                                                        // Clear file stats
                                                clearstatcache();
 
                                                        // Branch out based on command:
-                                               switch ($action)        {
+                                               switch ($action) {
                                                        case 'delete':
-                                                               $this->func_delete($cmdArr);
+                                                               $result[$action][] = $this->func_delete($cmdArr);
                                                        break;
                                                        case 'copy':
-                                                               $this->func_copy($cmdArr);
+                                                               $result[$action][] = $this->func_copy($cmdArr);
                                                        break;
                                                        case 'move':
-                                                               $this->func_move($cmdArr);
+                                                               $result[$action][] = $this->func_move($cmdArr);
                                                        break;
                                                        case 'rename':
-                                                               $this->func_rename($cmdArr);
+                                                               $result[$action][] = $this->func_rename($cmdArr);
                                                        break;
                                                        case 'newfolder':
-                                                               $this->func_newfolder($cmdArr);
+                                                               $result[$action][] = $this->func_newfolder($cmdArr);
                                                        break;
                                                        case 'newfile':
-                                                               $this->func_newfile($cmdArr);
+                                                               $result[$action][] = $this->func_newfile($cmdArr);
                                                        break;
                                                        case 'editfile':
-                                                               $this->func_edit($cmdArr);
+                                                               $result[$action][] = $this->func_edit($cmdArr);
                                                        break;
                                                        case 'upload':
-                                                               $this->func_upload($cmdArr);
+                                                               $result[$action][] = $this->func_upload($cmdArr);
                                                        break;
                                                        case 'unzip':
-                                                               $this->func_unzip($cmdArr);
+                                                               $result[$action][] = $this->func_unzip($cmdArr);
                                                        break;
                                                }
                                        }
                                }
                        }
                }
+               return $result;
        }
 
        /**
-        * Print log error messages from the operations of this script instance
+        * Adds log error messages from the operations of this script instance to the FlashMessageQueue
         *
         * @param       string          Redirect URL (for creating link in message)
-        * @return      void            (Will exit on error)
+        * @return      void
         */
-       function printLogErrorMessages($redirect='')    {
-
-               $res_log = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                                       '*',
-                                       'sys_log',
-                                       'type=2 AND userid='.intval($GLOBALS['BE_USER']->user['uid']).' AND tstamp='.intval($GLOBALS['EXEC_TIME']).'    AND error!=0'
-                               );
-               $errorJS = array();
-               while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res_log)) {
-                       $log_data = unserialize($row['log_data']);
-                       $errorJS[] = $row[error].': '.sprintf($row['details'], $log_data[0],$log_data[1],$log_data[2],$log_data[3],$log_data[4]);
-               }
-
-               if (count($errorJS))    {
-                       $error_doc = t3lib_div::makeInstance('template');
-                       $error_doc->backPath = '';
-
-                       $content.= $error_doc->startPage('tce_db.php Error output');
-
-                       $lines[] = '
-                                       <tr class="bgColor5">
-                                               <td colspan="2" align="center"><strong>Errors:</strong></td>
-                                       </tr>';
+       function printLogErrorMessages($redirect = '') {
+               $this->getErrorMessages();
+       }
 
-                       foreach($errorJS as $line)      {
-                               $lines[] = '
-                                       <tr class="bgColor4">
-                                               <td valign="top"><img'.t3lib_iconWorks::skinImg('','gfx/icon_fatalerror.gif','width="18" height="16"').' alt="" /></td>
-                                               <td>'.htmlspecialchars($line).'</td>
-                                       </tr>';
-                       }
 
-                       $lines[] = '
-                                       <tr>
-                                               <td colspan="2" align="center"><br />'.
-                                               '<form action=""><input type="submit" value="Continue" onclick="'.htmlspecialchars('document.location=\''.$redirect.'\';return false;').'" /></form>'.
-                                               '</td>
-                                       </tr>';
-
-                       $content.= '
-                               <br /><br />
-                               <table border="0" cellpadding="1" cellspacing="1" width="300" align="center">
-                                       '.implode('',$lines).'
-                               </table>';
-
-                       $content.= $error_doc->endPage();
-                       echo $content;
-                       exit;
+       /**
+        * Adds log error messages from the previous file operations of this script instance
+        * to the FlashMessageQueue
+        *
+        * @return      void
+        */
+       function getErrorMessages() {
+               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
+                               '*',
+                               'sys_log',
+                               'type = 2 AND userid = ' . intval($GLOBALS['BE_USER']->user['uid'])
+                               . ' AND tstamp=' . intval($GLOBALS['EXEC_TIME'])
+                               . ' AND error != 0'
+               );
+               while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+                       $logData = unserialize($row['log_data']);
+                       $msg = $row['error'] . ': ' . sprintf($row['details'], $logData[0], $logData[1], $logData[2], $logData[3], $logData[4]);
+                       $flashMessage = t3lib_div::makeInstance(
+                                       't3lib_FlashMessage',
+                                       $msg,
+                                       '',
+                                       t3lib_FlashMessage::ERROR,
+                                       TRUE
+                       );
+                       t3lib_FlashMessageQueue::addMessage($flashMessage);
                }
+               $GLOBALS['TYPO3_DB']->sql_free_result($res);
        }
 
+
+
        /**
         * Goes back in the path and checks in each directory if a folder named $this->recyclerFN (usually '_recycler_') is present.
         * If a folder in the tree happens to be a _recycler_-folder (which means that we're deleting something inside a _recycler_-folder) this is ignored
@@ -359,6 +366,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
                if (is_object($GLOBALS['BE_USER']))     {
                        $GLOBALS['BE_USER']->writelog($type,$action,$error,$details_nr,$details,$data);
                }
+               $this->lastError = vsprintf($details, $data);
        }
 
 
@@ -378,7 +386,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
        /**
         * Deleting files and folders (action=4)
         *
-        * @param       array           $cmds['data'] is the the file/folder to delete
+        * @param       array           $cmds['data'] is the file/folder to delete
         * @return      boolean         Returns true upon success
         */
        function func_delete($cmds)     {
@@ -413,17 +421,13 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions     {
                                } else $this->writelog(4,1,112,'You are not allowed to delete files','');
                                // FINISHED deleting file
 
-                       } elseif (@is_dir($theFile) && !$this->dont_use_exec_commands) {        // if we're deleting a folder
+                       } elseif (@is_dir($theFile)) {  // if we're deleting a folder
                                if ($this->actionPerms['deleteFolder']) {
                                        $theFile = $this->is_directory($theFile);
                                        if ($theFile)   {
                                                if ($this->checkPathAgainstMounts($theFile))    {       // I choose not to append '/' to $theFile here as this will prevent us from deleting mounts!! (which makes sense to me...)
-                                                       if ($this->actionPerms['deleteFolderRecursively'])      {
-                                                                       // No way to do this under windows
-                                                               $cmd = 'rm -Rf "'.$theFile.'"';
-                                                               exec($cmd);             // This is a quite critical command...
-                                                               clearstatcache();
-                                                               if (!@file_exists($theFile))    {
+                                                       if ($this->actionPerms['deleteFolderRecursively']) {
+                                                               if (t3lib_div::rmdir($theFile,true))    {
                                                                        $this->writelog(4,0,2,'Directory "%s" deleted recursively!',Array($theFile));
                                                                        return TRUE;
                                                                } else $this->writelog(4,2,119,'Directory "%s" WAS NOT deleted recursively! Write-permission problem?',Array($theFile));
@@ -445,7 +449,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
        /**
         * Copying files and folders (action=2)
         *
-        * @param       array           $cmds['data'] is the the file/folder to copy. $cmds['target'] is the path where to copy to. $cmds['altName'] (boolean): If set, another filename is found in case the target already exists
+        * @param       array           $cmds['data'] is the file/folder to copy. $cmds['target'] is the path where to copy to. $cmds['altName'] (boolean): If set, another filename is found in case the target already exists
         * @return      string          Returns the new filename upon success
         */
        function func_copy($cmds)       {
@@ -475,7 +479,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
                                        } else {
                                                $theDestFile = $theDest.'/'.$fI['file'];
                                        }
-                                       if ($theDestFile && !@file_exists($theDestFile))        {
+                                       if ($theDestFile && !file_exists($theDestFile)) {
                                                if ($this->checkIfAllowed($fI['fileext'], $theDest, $fI['file'])) {
                                                        if ($this->checkPathAgainstMounts($theDestFile) && $this->checkPathAgainstMounts($theFile))     {
                                                                if ($this->PHPFileFunctions)    {
@@ -484,13 +488,14 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions     {
                                                                        $cmd = 'cp "'.$theFile.'" "'.$theDestFile.'"';
                                                                        exec($cmd);
                                                                }
+                                                               t3lib_div::fixPermissions($theDestFile);
                                                                clearstatcache();
                                                                if (@is_file($theDestFile))     {
                                                                        $this->writelog(2,0,1,'File "%s" copied to "%s"',Array($theFile,$theDestFile));
                                                                        return $theDestFile;
                                                                } else $this->writelog(2,2,109,'File "%s" WAS NOT copied to "%s"! Write-permission problem?',Array($theFile,$theDestFile));
                                                        } else  $this->writelog(2,1,110,'Target or destination was not within your mountpoints! T="%s", D="%s"',Array($theFile,$theDestFile));
-                                               } else $this->writelog(2,1,111,'Fileextension "%s" is not allowed in "%s"!',Array($fI['fileext'],$theDest.'/'));
+                                               } else $this->writelog(2,1,111,'Extension of file name "%s" is not allowed in "%s"!',Array($fI['file'],$theDest.'/'));
                                        } else $this->writelog(2,1,112,'File "%s" already exists!',Array($theDestFile));
                                } else $this->writelog(2,1,113,'File "%s" exceeds the size-limit of %s bytes',Array($theFile,$this->maxCopyFileSize*1024));
                        } else $this->writelog(2,1,114,'You are not allowed to copy files','');
@@ -507,7 +512,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
                                        } else {
                                                $theDestFile = $theDest.'/'.$fI['file'];
                                        }
-                                       if ($theDestFile && !@file_exists($theDestFile))        {
+                                       if ($theDestFile && !file_exists($theDestFile)) {
                                                if (!t3lib_div::isFirstPartOfStr($theDestFile.'/',$theFile.'/'))        {                       // Check if the one folder is inside the other or on the same level... to target/dest is the same?
                                                        if ($this->checkIfFullAccess($theDest) || $this->is_webPath($theDestFile)==$this->is_webPath($theFile)) {       // no copy of folders between spaces
                                                                if ($this->checkPathAgainstMounts($theDestFile) && $this->checkPathAgainstMounts($theFile))     {
@@ -535,7 +540,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
        /**
         * Moving files and folders (action=3)
         *
-        * @param       array           $cmds['data'] is the the file/folder to move. $cmds['target'] is the path where to move to. $cmds['altName'] (boolean): If set, another filename is found in case the target already exists
+        * @param       array           $cmds['data'] is the file/folder to move. $cmds['target'] is the path where to move to. $cmds['altName'] (boolean): If set, another filename is found in case the target already exists
         * @return      string          Returns the new filename upon success
         */
        function func_move($cmds)       {
@@ -565,7 +570,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
                                        } else {
                                                $theDestFile = $theDest.'/'.$fI['file'];
                                        }
-                                       if ($theDestFile && !@file_exists($theDestFile))        {
+                                       if ($theDestFile && !file_exists($theDestFile)) {
                                                if ($this->checkIfAllowed($fI['fileext'], $theDest, $fI['file'])) {
                                                        if ($this->checkPathAgainstMounts($theDestFile) && $this->checkPathAgainstMounts($theFile))     {
                                                                if ($this->PHPFileFunctions)    {
@@ -580,7 +585,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
                                                                        return $theDestFile;
                                                                } else $this->writelog(3,2,109,'File "%s" WAS NOT moved to "%s"! Write-permission problem?',Array($theFile,$theDestFile));
                                                        } else $this->writelog(3,1,110,'Target or destination was not within your mountpoints! T="%s", D="%s"',Array($theFile,$theDestFile));
-                                               } else $this->writelog(3,1,111,'Fileextension "%s" is not allowed in "%s"!',Array($fI['fileext'],$theDest.'/'));
+                                               } else $this->writelog(3,1,111,'Extension of file name "%s" is not allowed in "%s"!',Array($fI['file'],$theDest.'/'));
                                        } else $this->writelog(3,1,112,'File "%s" already exists!',Array($theDestFile));
                                } else $this->writelog(3,1,113,'File "%s" exceeds the size-limit of %s bytes',Array($theFile,$this->maxMoveFileSize*1024));
                        } else $this->writelog(3,1,114,'You are not allowed to move files','');
@@ -597,7 +602,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
                                        } else {
                                                $theDestFile = $theDest.'/'.$fI['file'];
                                        }
-                                       if ($theDestFile && !@file_exists($theDestFile))        {
+                                       if ($theDestFile && !file_exists($theDestFile)) {
                                                if (!t3lib_div::isFirstPartOfStr($theDestFile.'/',$theFile.'/'))        {                       // Check if the one folder is inside the other or on the same level... to target/dest is the same?
                                                        if ($this->checkIfFullAccess($theDest) || $this->is_webPath($theDestFile)==$this->is_webPath($theFile)) {       // // no moving of folders between spaces
                                                                if ($this->checkPathAgainstMounts($theDestFile) && $this->checkPathAgainstMounts($theFile))     {
@@ -605,6 +610,8 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
                                                                                rename($theFile, $theDestFile);
                                                                        } else {
                                                                                $cmd = 'mv "'.$theFile.'" "'.$theDestFile.'"';
+                                                                               $errArr = array();
+                                                                               $retVar = 0;
                                                                                exec($cmd,$errArr,$retVar);
                                                                        }
                                                                        clearstatcache();
@@ -644,7 +651,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
                                        if ($fileInfo['file']!=$theNewName)     {       // The name should be different from the current. And the filetype must be allowed
                                                $theRenameName = $fileInfo['path'].$theNewName;
                                                if ($this->checkPathAgainstMounts($fileInfo['path']))   {
-                                                       if (!@file_exists($theRenameName))      {
+                                                       if (!file_exists($theRenameName))       {
                                                                if ($type=='file')      {
                                                                        if ($this->actionPerms['renameFile'])   {
                                                                                $fI = t3lib_div::split_fileref($theRenameName);
@@ -653,7 +660,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
                                                                                                $this->writelog(5,0,1,'File renamed from "%s" to "%s"',Array($fileInfo['file'],$theNewName));
                                                                                                return $theRenameName;
                                                                                        } else $this->writelog(5,1,100,'File "%s" was not renamed! Write-permission problem in "%s"?',Array($theTarget,$fileInfo['path']));
-                                                                               } else $this->writelog(5,1,101,'Fileextension "%s" was not allowed!',Array($fI['fileext']));
+                                                                               } else $this->writelog(5,1,101,'Extension of file name "%s" was not allowed!',Array($fI['file']));
                                                                        } else $this->writelog(5,1,102,'You are not allowed to rename files!','');
                                                                } elseif ($type=='dir') {
                                                                        if ($this->actionPerms['renameFolder']) {
@@ -681,14 +688,14 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions     {
                if (!$this->isInit) return FALSE;
 
                $theFolder = $this->cleanFileName($cmds['data']);
-               if ($theFolder) {
+               if (isset($theFolder) && trim($theFolder) != '') {
                        if ($this->checkFileNameLen($theFolder))        {
                                $theTarget = $this->is_directory($cmds['target']);      // Check the target dir
                                if ($theTarget) {
                                        if ($this->actionPerms['newFolder'])    {
                                                $theNewFolder = $theTarget.'/'.$theFolder;
                                                if ($this->checkPathAgainstMounts($theNewFolder))       {
-                                                       if (!@file_exists($theNewFolder))       {
+                                                       if (!file_exists($theNewFolder))        {
                                                                if (t3lib_div::mkdir($theNewFolder)){
                                                                        $this->writelog(6,0,1,'Directory "%s" created in "%s"',Array($theFolder,$theTarget.'/'));
                                                                        return $theNewFolder;
@@ -719,7 +726,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
                                        if ($this->actionPerms['newFile'])      {
                                                $theNewFile = $theTarget.'/'.$newName;
                                                if ($this->checkPathAgainstMounts($theNewFile)) {
-                                                       if (!@file_exists($theNewFile)) {
+                                                       if (!file_exists($theNewFile))  {
                                                                $fI = t3lib_div::split_fileref($theNewFile);
                                                                if ($this->checkIfAllowed($fI['fileext'], $fileInfo['path'], $fI['file'])) {
                                                                        if (t3lib_div::inList($extList, $fI['fileext']))        {
@@ -729,7 +736,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
                                                                                        return $theNewFile;
                                                                                } else $this->writelog(8,1,100,'File "%s" was not created! Write-permission problem in "%s"?',Array($fI['file'], $theTarget));
                                                                        } else $this->writelog(8,1,107,'Fileextension "%s" is not a textfile format! (%s)',Array($fI['fileext'], $extList));
-                                                               } else $this->writelog(8,1,106,'Fileextension "%s" was not allowed!',Array($fI['fileext']));
+                                                               } else $this->writelog(8,1,106,'Extension of file name "%s" was not allowed!',Array($fI['file']));
                                                        } else $this->writelog(8,1,101,'File "%s" existed already!',Array($theNewFile));
                                                } else $this->writelog(8,1,102,'Destination path "%s" was not within your mountpoints!',Array($theTarget.'/'));
                                        } else $this->writelog(8,1,103,'You are not allowed to create files!','');
@@ -739,7 +746,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
        }
 
        /**
-        * Editing textfiles or foldes (action=9)
+        * Editing textfiles or folders (action=9)
         *
         * @param       array           $cmds['data'] is the new content. $cmds['target'] is the target (file or dir)
         * @return      boolean         Returns true on success
@@ -764,7 +771,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
                                                                return TRUE;
                                                        } else $this->writelog(9,1,100,'File "%s" was not saved! Write-permission problem in "%s"?',Array($theTarget,$fileInfo['path']));
                                                } else $this->writelog(9,1,102,'Fileextension "%s" is not a textfile format! (%s)',Array($fI['fileext'], $extList));
-                                       } else $this->writelog(9,1,103,'Fileextension "%s" was not allowed!',Array($fI['fileext']));
+                                       } else $this->writelog(9,1,103,'Extension of file name "%s" was not allowed!',Array($fI['file']));
                                } else $this->writelog(9,1,104,'You are not allowed to edit files!','');
                        } else $this->writelog(9,1,121,'Destination path "%s" was not within your mountpoints!',Array($fileInfo['path']));
                } else $this->writelog(9,2,123,'Target "%s" was not a file!',Array($theTarget));
@@ -773,7 +780,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
        /**
         * Upload of files (action=1)
         *
-        * @param       array           $cmds['data'] is the ID-number (points to the global var that holds the filename-ref  ($_FILES['upload_'.$id]['name']). $cmds['target'] is the target directory
+        * @param       array           $cmds['data'] is the ID-number (points to the global var that holds the filename-ref  ($_FILES['upload_'.$id]['name']). $cmds['target'] is the target directory, $cmds['charset'] is the the character set of the file name (utf-8 is needed for JS-interaction)
         * @return      string          Returns the new filename upon success
         */
        function func_upload($cmds)     {
@@ -782,7 +789,7 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
                if ($_FILES['upload_'.$id]['name'])     {
                        $theFile = $_FILES['upload_'.$id]['tmp_name'];                          // filename of the uploaded file
                        $theFileSize = $_FILES['upload_'.$id]['size'];                          // filesize of the uploaded file
-                       $theName = $this->cleanFileName(stripslashes($_FILES['upload_'.$id]['name']));  // The original filename
+                       $theName = $this->cleanFileName(stripslashes($_FILES['upload_'.$id]['name']), (isset($cmds['charset']) ? $cmds['charset'] : ''));       // The original filename
                        if (is_uploaded_file($theFile) && $theName)     {       // Check the file
                                if ($this->actionPerms['uploadFile'])   {
                                        if ($theFileSize<($this->maxUploadFileSize*1024))       {
@@ -800,12 +807,12 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions     {
                                                                                return $theNewFile;
                                                                        } else $this->writelog(1,1,100,'Uploaded file could not be moved! Write-permission problem in "%s"?',Array($theTarget.'/'));
                                                                } else $this->writelog(1,1,101,'No unique filename available in "%s"!',Array($theTarget.'/'));
-                                                       } else $this->writelog(1,1,102,'Fileextension "%s" is not allowed in "%s"!',Array($fI['fileext'],$theTarget.'/'));
+                                                       } else $this->writelog(1,1,102,'Extension of file name "%s" is not allowed in "%s"!',Array($fI['file'], $theTarget.'/'));
                                                } else $this->writelog(1,1,103,'Destination path "%s" was not within your mountpoints!',Array($theTarget.'/'));
                                        } else $this->writelog(1,1,104,'The uploaded file exceeds the size-limit of %s bytes',Array($this->maxUploadFileSize*1024));
                                } else $this->writelog(1,1,105,'You are not allowed to upload files!','');
-                       } else $this->writelog(1,2,106,'The uploaded file did not exist!','');
-               }
+                       } else $this->writelog(1,2,106,'The upload has failed, no uploaded file found!','');
+               } else $this->writelog(1,2,108,'No file was uploaded!','');
        }
 
        /**
@@ -847,4 +854,5 @@ class t3lib_extFileFunctions extends t3lib_basicFileFunctions       {
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_extfilefunc.php'])      {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_extfilefunc.php']);
 }
+
 ?>