TYPO3 API  SVNRelease
class.t3lib_extfilefunc.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003  *  Copyright notice
00004  *
00005  *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
00006  *  All rights reserved
00007  *
00008  *  This script is part of the TYPO3 project. The TYPO3 project is
00009  *  free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  The GNU General Public License can be found at
00015  *  http://www.gnu.org/copyleft/gpl.html.
00016  *  A copy is found in the textfile GPL.txt and important notices to the license
00017  *  from the author is found in LICENSE.txt distributed with these scripts.
00018  *
00019  *
00020  *  This script is distributed in the hope that it will be useful,
00021  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *  GNU General Public License for more details.
00024  *
00025  *  This copyright notice MUST APPEAR in all copies of the script!
00026  ***************************************************************/
00027 /**
00028  * extending class to class t3lib_basicFileFunctions
00029  *
00030  * $Id: class.t3lib_extfilefunc.php 10121 2011-01-18 20:15:30Z ohader $
00031  * Revised for TYPO3 3.6 May/2004 by Kasper Skårhøj
00032  *
00033  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00034  */
00035 /**
00036  * [CLASS/FUNCTION INDEX of SCRIPT]
00037  *
00038  *
00039  *
00040  *  105: class t3lib_extFileFunctions extends t3lib_basicFileFunctions
00041  *  151:     function start($fileCmds)
00042  *  181:     function init_actionPerms($setup)
00043  *  213:     function processData()
00044  *  270:     function printLogErrorMessages($redirect='')
00045  *  328:     function findRecycler($theFile)
00046  *  357:     function writeLog($action,$error,$details_nr,$details,$data)
00047  *
00048  *            SECTION: File operation functions
00049  *  384:     function func_delete($cmds)
00050  *  451:     function func_copy($cmds)
00051  *  542:     function func_move($cmds)
00052  *  637:     function func_rename($cmds)
00053  *  683:     function func_newfolder($cmds)
00054  *  713:     function func_newfile($cmds)
00055  *  750:     function func_edit($cmds)
00056  *  782:     function func_upload($cmds)
00057  *  821:     function func_unzip($cmds)
00058  *
00059  * TOTAL FUNCTIONS: 15
00060  * (This index is automatically created/updated by the extension "extdeveval")
00061  *
00062  */
00063 
00064 
00065 /**
00066  * Contains functions for performing file operations like copying, pasting, uploading, moving, deleting etc. through the TCE
00067  * Extending class to class t3lib_basicFileFunctions.
00068  *
00069  * see basicFileFunctions
00070  * see document "TYPO3 Core API" for syntax
00071  *
00072  * This class contains functions primarily used by tce_file.php (TYPO3 Core Engine for file manipulation)
00073  * Functions include copying, moving, deleting, uploading and so on...
00074  *
00075  * Important internal variables:
00076  *
00077  * $filemounts      (see basicFileFunctions)
00078  * $f_ext     (see basicFileFunctions)
00079  *   ... All fileoperations must be within the filemount-paths. Further the fileextension MUST validate true with the f_ext array
00080  *
00081  * The unzip-function allows unzip only if the destination path has it's f_ext[]['allow'] set to '*'!!
00082  * You are allowed to copy/move folders within the same 'space' (web/ftp).
00083  * You are allowed to copy/move folders between spaces (web/ftp) IF the destination has it's f_ext[]['allow'] set to '*'!
00084  *
00085  * Advice:
00086  * 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.
00087  * 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
00088  * For example this is a bad idea: you have an ftp-space that is '/www/' and a web-space that is '/www/htdocs/'
00089  *
00090  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00091  * @package TYPO3
00092  * @subpackage t3lib
00093  */
00094 class t3lib_extFileFunctions extends t3lib_basicFileFunctions {
00095 
00096         // External static variables:
00097         // Notice; some of these are overridden in the start() method with values from $GLOBALS['TYPO3_CONF_VARS']['BE']
00098     var $maxCopyFileSize = 10000; // max copy size (kb) for files
00099     var $maxMoveFileSize = 10000; // max move size (kb) for files
00100     var $maxUploadFileSize = 10000; // max upload size (kb) for files. Remember that PHP has an inner limit often set to 2 MB
00101     var $unzipPath = ''; // Path to unzip-program (with trailing '/')
00102     var $dontCheckForUnique = 0; // If set, the uploaded files will overwrite existing files.
00103 
00104     var $actionPerms = Array( // This array is self-explaning (look in the class below). It grants access to the functions. This could be set from outside in order to enabled functions to users. See also the function init_actionPerms() which takes input directly from the user-record
00105         'deleteFile' => 0, // Deleting files physically
00106         'deleteFolder' => 0, // Deleting foldes physically
00107         'deleteFolderRecursively' => 0, // normally folders are deleted by the PHP-function rmdir(), but with this option a user deletes with 'rm -Rf ....' which is pretty wild!
00108         'moveFile' => 0,
00109         'moveFolder' => 0,
00110         'copyFile' => 0,
00111         'copyFolder' => 0,
00112         'newFolder' => 0,
00113         'newFile' => 0,
00114         'editFile' => 0,
00115         'unzipFile' => 0,
00116         'uploadFile' => 0,
00117         'renameFile' => 0,
00118         'renameFolder' => 0
00119     );
00120 
00121     var $recyclerFN = '_recycler_'; // This is regarded to be the recycler folder
00122     var $useRecycler = 1; // 0 = no, 1 = if available, 2 = always
00123 
00124         // Internal, static:
00125     var $PHPFileFunctions = 0; // If set, all fileoperations are done by the default PHP-functions. This is necessary under windows! On UNIX the system commands by exec() can be used unless safe_mode is enabled
00126     var $dont_use_exec_commands = 0; // This is necessary under windows!
00127 
00128         // Internal, dynamic:
00129     var $internalUploadMap = array(); // Will contain map between upload ID and the final filename
00130 
00131     var $lastError = '';
00132 
00133 
00134     /**
00135      * Initialization of the class
00136      *
00137      * @param   array       The $file array with the commands to execute. See "TYPO3 Core API" document
00138      * @return  void
00139      */
00140     function start($fileCmds) {
00141 
00142             // Configure settings from TYPO3_CONF_VARS:
00143         if (TYPO3_OS == 'WIN' || $GLOBALS['TYPO3_CONF_VARS']['BE']['disable_exec_function']) {
00144             $this->PHPFileFunctions = 1;
00145             $this->dont_use_exec_commands = 1;
00146         } else {
00147             $this->PHPFileFunctions = $GLOBALS['TYPO3_CONF_VARS']['BE']['usePHPFileFunctions'];
00148         }
00149 
00150         $this->unzipPath = $GLOBALS['TYPO3_CONF_VARS']['BE']['unzip_path'];
00151 
00152         $maxFileSize = intval($GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize']);
00153         if ($maxFileSize > 0) {
00154             $this->maxCopyFileSize = $maxFileSize;
00155             $this->maxMoveFileSize = $maxFileSize;
00156         }
00157         $this->maxUploadFileSize = t3lib_div::getMaxUploadFileSize();
00158 
00159             // Initializing file processing commands:
00160         $this->fileCmdMap = $fileCmds;
00161     }
00162 
00163     /**
00164      * Sets up permission to perform file/directory operations.
00165      * See below or the be_user-table for the significance of the various bits in $setup.
00166      *
00167      * @param   integer     File permission integer from BE_USER OR'ed with permissions of back-end groups this user is a member of
00168      * @return  void
00169      */
00170     function init_actionPerms($setup) {
00171         if (($setup & 1) == 1) { // Files: Upload,Copy,Move,Delete,Rename
00172             $this->actionPerms['uploadFile'] = 1;
00173             $this->actionPerms['copyFile'] = 1;
00174             $this->actionPerms['moveFile'] = 1;
00175             $this->actionPerms['deleteFile'] = 1;
00176             $this->actionPerms['renameFile'] = 1;
00177             $this->actionPerms['editFile'] = 1;
00178             $this->actionPerms['newFile'] = 1;
00179         }
00180         if (($setup & 2) == 2) { // Files: Unzip
00181             $this->actionPerms['unzipFile'] = 1;
00182         }
00183         if (($setup & 4) == 4) { // Directory: Move,Delete,Rename,New
00184             $this->actionPerms['moveFolder'] = 1;
00185             $this->actionPerms['deleteFolder'] = 1;
00186             $this->actionPerms['renameFolder'] = 1;
00187             $this->actionPerms['newFolder'] = 1;
00188         }
00189         if (($setup & 8) == 8) { // Directory: Copy
00190             $this->actionPerms['copyFolder'] = 1;
00191         }
00192         if (($setup & 16) == 16) { // Directory: Delete recursively (rm -Rf)
00193             $this->actionPerms['deleteFolderRecursively'] = 1;
00194         }
00195     }
00196 
00197     /**
00198      * Processing the command array in $this->fileCmdMap
00199      *
00200      * @return  mixed   false, if the file functions were not initialized
00201      *                  otherwise returns an array of all the results that are returned
00202      *                  from each command, separated in each action.
00203      */
00204     function processData() {
00205         $result = array();
00206         if (!$this->isInit) {
00207             return FALSE;
00208         }
00209 
00210         if (is_array($this->fileCmdMap)) {
00211 
00212                 // Check if there were uploads expected, but no one made
00213             if ($this->fileCmdMap['upload']) {
00214                 $uploads = $this->fileCmdMap['upload'];
00215                 foreach ($uploads as $upload) {
00216                     if (!$_FILES['upload_' . $upload['data']]['name']) {
00217                         unset($this->fileCmdMap['upload'][$upload['data']]);
00218                     }
00219                 }
00220                 if (count($this->fileCmdMap['upload']) == 0) {
00221                     $this->writelog(1, 1, 108, 'No file was uploaded!', '');
00222                 }
00223             }
00224 
00225                 // Traverse each set of actions
00226             foreach ($this->fileCmdMap as $action => $actionData) {
00227 
00228                     // Traverse all action data. More than one file might be affected at the same time.
00229                 if (is_array($actionData)) {
00230                     $result[$action] = array();
00231                     foreach ($actionData as $cmdArr) {
00232 
00233                             // Clear file stats
00234                         clearstatcache();
00235 
00236                             // Branch out based on command:
00237                         switch ($action) {
00238                             case 'delete':
00239                                 $result[$action][] = $this->func_delete($cmdArr);
00240                             break;
00241                             case 'copy':
00242                                 $result[$action][] = $this->func_copy($cmdArr);
00243                             break;
00244                             case 'move':
00245                                 $result[$action][] = $this->func_move($cmdArr);
00246                             break;
00247                             case 'rename':
00248                                 $result[$action][] = $this->func_rename($cmdArr);
00249                             break;
00250                             case 'newfolder':
00251                                 $result[$action][] = $this->func_newfolder($cmdArr);
00252                             break;
00253                             case 'newfile':
00254                                 $result[$action][] = $this->func_newfile($cmdArr);
00255                             break;
00256                             case 'editfile':
00257                                 $result[$action][] = $this->func_edit($cmdArr);
00258                             break;
00259                             case 'upload':
00260                                 $result[$action][] = $this->func_upload($cmdArr);
00261                             break;
00262                             case 'unzip':
00263                                 $result[$action][] = $this->func_unzip($cmdArr);
00264                             break;
00265                         }
00266 
00267                             // Hook for post-processing the action
00268                         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_extfilefunc.php']['processData'])) {
00269                             foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_extfilefunc.php']['processData'] as $classRef) {
00270                                 $hookObject = t3lib_div::getUserObj($classRef);
00271 
00272                                 if (!($hookObject instanceof t3lib_extFileFunctions_processDataHook)) {
00273                                     throw new UnexpectedValueException('$hookObject must implement interface t3lib_extFileFunctions_processDataHook', 1279719168);
00274                                 }
00275 
00276                                 $hookObject->processData_postProcessAction($action, $cmdArr, $result[$action], $this);
00277                             }
00278                         }
00279                     }
00280                 }
00281             }
00282         }
00283         return $result;
00284     }
00285 
00286     /**
00287      * Adds log error messages from the operations of this script instance to the FlashMessageQueue
00288      *
00289      * @param   string      Redirect URL (for creating link in message)
00290      * @return  void
00291      */
00292     function printLogErrorMessages($redirect = '') {
00293         $this->getErrorMessages();
00294     }
00295 
00296 
00297     /**
00298      * Adds log error messages from the previous file operations of this script instance
00299      * to the FlashMessageQueue
00300      *
00301      * @return  void
00302      */
00303     function getErrorMessages() {
00304         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00305             '*',
00306             'sys_log',
00307                 'type = 2 AND userid = ' . intval($GLOBALS['BE_USER']->user['uid'])
00308                         . ' AND tstamp=' . intval($GLOBALS['EXEC_TIME'])
00309                         . ' AND error != 0'
00310         );
00311         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00312             $logData = unserialize($row['log_data']);
00313             $msg = $row['error'] . ': ' . sprintf($row['details'], $logData[0], $logData[1], $logData[2], $logData[3], $logData[4]);
00314             $flashMessage = t3lib_div::makeInstance(
00315                 't3lib_FlashMessage',
00316                 $msg,
00317                 '',
00318                 t3lib_FlashMessage::ERROR,
00319                 TRUE
00320             );
00321             t3lib_FlashMessageQueue::addMessage($flashMessage);
00322         }
00323         $GLOBALS['TYPO3_DB']->sql_free_result($res);
00324     }
00325 
00326 
00327     /**
00328      * Goes back in the path and checks in each directory if a folder named $this->recyclerFN (usually '_recycler_') is present.
00329      * 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
00330      *
00331      * @param   string      Takes a valid Path ($theFile)
00332      * @return  string      Returns the path (without trailing slash) of the closest recycle-folder if found. Else false.
00333      */
00334     function findRecycler($theFile) {
00335         if ($this->isPathValid($theFile)) {
00336             $theFile = $this->cleanDirectoryName($theFile);
00337             $fI = t3lib_div::split_fileref($theFile);
00338             $c = 0;
00339             while ($this->checkPathAgainstMounts($fI['path']) && $c < 20) {
00340                 $rDir = $fI['path'] . $this->recyclerFN;
00341                 if (@is_dir($rDir) && $this->recyclerFN != $fI['file']) {
00342                     return $rDir;
00343                 }
00344                 $theFile = $fI['path'];
00345                 $theFile = $this->cleanDirectoryName($theFile);
00346                 $fI = t3lib_div::split_fileref($theFile);
00347                 $c++;
00348             }
00349         }
00350     }
00351 
00352     /**
00353      * Logging file operations
00354      *
00355      * @param   integer     The action number. See the functions in the class for a hint. Eg. edit is '9', upload is '1' ...
00356      * @param   integer     The severity: 0 = message, 1 = error, 2 = System Error, 3 = security notice (admin)
00357      * @param   integer     This number is unique for every combination of $type and $action. This is the error-message number, which can later be used to translate error messages.
00358      * @param   string      This is the default, raw error message in english
00359      * @param   array       Array with special information that may go into $details by "%s" marks / sprintf() when the log is shown
00360      * @return  void
00361      * @see class.t3lib_userauthgroup.php
00362      */
00363     function writeLog($action, $error, $details_nr, $details, $data) {
00364         $type = 2; // Type value for tce_file.php
00365         if (is_object($GLOBALS['BE_USER'])) {
00366             $GLOBALS['BE_USER']->writelog($type, $action, $error, $details_nr, $details, $data);
00367         }
00368         $this->lastError = vsprintf($details, $data);
00369     }
00370 
00371 
00372     /*************************************
00373      *
00374      * File operation functions
00375      *
00376      **************************************/
00377 
00378     /**
00379      * Deleting files and folders (action=4)
00380      *
00381      * @param   array       $cmds['data'] is the file/folder to delete
00382      * @return  boolean     Returns true upon success
00383      */
00384     function func_delete($cmds) {
00385         if (!$this->isInit) {
00386             return FALSE;
00387         }
00388 
00389             // Checking path:
00390         $theFile = $cmds['data'];
00391         if (!$this->isPathValid($theFile)) {
00392             $this->writelog(4, 2, 101, 'Target "%s" had invalid path (".." and "//" is not allowed in path).', Array($theFile));
00393             return FALSE;
00394         }
00395 
00396             // Recycler moving or not?
00397         if ($this->useRecycler && $recyclerPath = $this->findRecycler($theFile)) {
00398                 // If a recycler is found, the deleted items is moved to the recycler and not just deleted.
00399             $newCmds = Array();
00400             $newCmds['data'] = $theFile;
00401             $newCmds['target'] = $recyclerPath;
00402             $newCmds['altName'] = 1;
00403             $this->func_move($newCmds);
00404             $this->writelog(4, 0, 4, 'Item "%s" moved to recycler at "%s"', Array($theFile, $recyclerPath));
00405             return TRUE;
00406         } elseif ($this->useRecycler != 2) { // if $this->useRecycler==2 then we cannot delete for real!!
00407             if (@is_file($theFile)) { // If we are deleting a file...
00408                 if ($this->actionPerms['deleteFile']) {
00409                     if ($this->checkPathAgainstMounts($theFile)) {
00410                         if (@unlink($theFile)) {
00411                             $this->writelog(4, 0, 1, 'File "%s" deleted', Array($theFile));
00412                             return TRUE;
00413                         } else {
00414                             $this->writelog(4, 1, 110, 'Could not delete file "%s". Write-permission problem?', Array($theFile));
00415                         }
00416                     } else {
00417                         $this->writelog(4, 1, 111, 'Target was not within your mountpoints! T="%s"', Array($theFile));
00418                     }
00419                 } else {
00420                     $this->writelog(4, 1, 112, 'You are not allowed to delete files', '');
00421                 }
00422                 // FINISHED deleting file
00423 
00424             } elseif (@is_dir($theFile)) { // if we're deleting a folder
00425                 if ($this->actionPerms['deleteFolder']) {
00426                     $theFile = $this->is_directory($theFile);
00427                     if ($theFile) {
00428                         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...)
00429                             if ($this->actionPerms['deleteFolderRecursively']) {
00430                                 if (t3lib_div::rmdir($theFile, TRUE)) {
00431                                     $this->writelog(4, 0, 2, 'Directory "%s" deleted recursively!', Array($theFile));
00432                                     return TRUE;
00433                                 } else {
00434                                     $this->writelog(4, 2, 119, 'Directory "%s" WAS NOT deleted recursively! Write-permission problem?', Array($theFile));
00435                                 }
00436                             } else {
00437                                 if (@rmdir($theFile)) {
00438                                     $this->writelog(4, 0, 3, 'Directory "%s" deleted', Array($theFile));
00439                                     return TRUE;
00440                                 } else {
00441                                     $this->writelog(4, 1, 120, 'Could not delete directory! Write-permission problem? Is directory "%s" empty? (You are not allowed to delete directories recursively).', Array($theFile));
00442                                 }
00443                             }
00444                         } else {
00445                             $this->writelog(4, 1, 121, 'Target was not within your mountpoints! T="%s"', Array($theFile));
00446                         }
00447                     } else {
00448                         $this->writelog(4, 2, 122, 'Target seemed not to be a directory! (Shouldn\'t happen here!)', '');
00449                     }
00450                 } else {
00451                     $this->writelog(4, 1, 123, 'You are not allowed to delete directories', '');
00452                 }
00453                 // FINISHED copying directory
00454 
00455             } else {
00456                 $this->writelog(4, 2, 130, 'The item was not a file or directory! "%s"', Array($theFile));
00457             }
00458         } else {
00459             $this->writelog(4, 1, 131, 'No recycler found!', '');
00460         }
00461     }
00462 
00463     /**
00464      * Copying files and folders (action=2)
00465      *
00466      * @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
00467      * @return  string      Returns the new filename upon success
00468      */
00469     function func_copy($cmds) {
00470         if (!$this->isInit) {
00471             return FALSE;
00472         }
00473 
00474             // Initialize and check basic conditions:
00475         $theFile = $cmds['data'];
00476         $theDest = $this->is_directory($cmds['target']); // Clean up destination directory
00477         $altName = $cmds['altName'];
00478         if (!$theDest) {
00479             $this->writelog(2, 2, 100, 'Destination "%s" was not a directory', Array($cmds['target']));
00480             return FALSE;
00481         }
00482         if (!$this->isPathValid($theFile) || !$this->isPathValid($theDest)) {
00483             $this->writelog(2, 2, 101, 'Target or destination had invalid path (".." and "//" is not allowed in path). T="%s", D="%s"', Array($theFile, $theDest));
00484             return FALSE;
00485         }
00486 
00487             // Processing of file or directory.
00488         if (@is_file($theFile)) { // If we are copying a file...
00489             if ($this->actionPerms['copyFile']) {
00490                 if (filesize($theFile) < ($this->maxCopyFileSize * 1024)) {
00491                     $fI = t3lib_div::split_fileref($theFile);
00492                     if ($altName) { // If altName is set, we're allowed to create a new filename if the file already existed
00493                         $theDestFile = $this->getUniqueName($fI['file'], $theDest);
00494                         $fI = t3lib_div::split_fileref($theDestFile);
00495                     } else {
00496                         $theDestFile = $theDest . '/' . $fI['file'];
00497                     }
00498                     if ($theDestFile && !file_exists($theDestFile)) {
00499                         if ($this->checkIfAllowed($fI['fileext'], $theDest, $fI['file'])) {
00500                             if ($this->checkPathAgainstMounts($theDestFile) && $this->checkPathAgainstMounts($theFile)) {
00501                                 if ($this->PHPFileFunctions) {
00502                                     copy($theFile, $theDestFile);
00503                                 } else {
00504                                     $cmd = 'cp "' . $theFile . '" "' . $theDestFile . '"';
00505                                     t3lib_utility_Command::exec($cmd);
00506                                 }
00507                                 t3lib_div::fixPermissions($theDestFile);
00508                                 clearstatcache();
00509                                 if (@is_file($theDestFile)) {
00510                                     $this->writelog(2, 0, 1, 'File "%s" copied to "%s"', Array($theFile, $theDestFile));
00511                                     return $theDestFile;
00512                                 } else {
00513                                     $this->writelog(2, 2, 109, 'File "%s" WAS NOT copied to "%s"! Write-permission problem?', Array($theFile, $theDestFile));
00514                                 }
00515                             } else  {
00516                                 $this->writelog(2, 1, 110, 'Target or destination was not within your mountpoints! T="%s", D="%s"', Array($theFile, $theDestFile));
00517                             }
00518                         } else {
00519                             $this->writelog(2, 1, 111, 'Extension of file name "%s" is not allowed in "%s"!', Array($fI['file'], $theDest . '/'));
00520                         }
00521                     } else {
00522                         $this->writelog(2, 1, 112, 'File "%s" already exists!', Array($theDestFile));
00523                     }
00524                 } else {
00525                     $this->writelog(2, 1, 113, 'File "%s" exceeds the size-limit of %s bytes', Array($theFile, $this->maxCopyFileSize * 1024));
00526                 }
00527             } else {
00528                 $this->writelog(2, 1, 114, 'You are not allowed to copy files', '');
00529             }
00530             // FINISHED copying file
00531 
00532         } elseif (@is_dir($theFile) && !$this->dont_use_exec_commands) { // if we're copying a folder
00533             if ($this->actionPerms['copyFolder']) {
00534                 $theFile = $this->is_directory($theFile);
00535                 if ($theFile) {
00536                     $fI = t3lib_div::split_fileref($theFile);
00537                     if ($altName) { // If altName is set, we're allowed to create a new filename if the file already existed
00538                         $theDestFile = $this->getUniqueName($fI['file'], $theDest);
00539                         $fI = t3lib_div::split_fileref($theDestFile);
00540                     } else {
00541                         $theDestFile = $theDest . '/' . $fI['file'];
00542                     }
00543                     if ($theDestFile && !file_exists($theDestFile)) {
00544                         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?
00545                             if ($this->checkIfFullAccess($theDest) || $this->is_webPath($theDestFile) == $this->is_webPath($theFile)) { // no copy of folders between spaces
00546                                 if ($this->checkPathAgainstMounts($theDestFile) && $this->checkPathAgainstMounts($theFile)) {
00547                                     // No way to do this under windows!
00548                                     $cmd = 'cp -R "' . $theFile . '" "' . $theDestFile . '"';
00549                                     t3lib_utility_Command::exec($cmd);
00550                                     clearstatcache();
00551                                     if (@is_dir($theDestFile)) {
00552                                         $this->writelog(2, 0, 2, 'Directory "%s" copied to "%s"', Array($theFile, $theDestFile));
00553                                         return $theDestFile;
00554                                     } else {
00555                                         $this->writelog(2, 2, 119, 'Directory "%s" WAS NOT copied to "%s"! Write-permission problem?', Array($theFile, $theDestFile));
00556                                     }
00557                                 } else {
00558                                     $this->writelog(2, 1, 120, 'Target or destination was not within your mountpoints! T="%s", D="%s"', Array($theFile, $theDestFile));
00559                                 }
00560                             } else {
00561                                 $this->writelog(2, 1, 121, 'You don\'t have full access to the destination directory "%s"!', Array($theDest . '/'));
00562                             }
00563                         } else {
00564                             $this->writelog(2, 1, 122, 'Destination cannot be inside the target! D="%s", T="%s"', Array($theDestFile . '/', $theFile . '/'));
00565                         }
00566                     } else {
00567                         $this->writelog(2, 1, 123, 'Target "%s" already exists!', Array($theDestFile));
00568                     }
00569                 } else {
00570                     $this->writelog(2, 2, 124, 'Target seemed not to be a directory! (Shouldn\'t happen here!)', '');
00571                 }
00572             } else {
00573                 $this->writelog(2, 1, 125, 'You are not allowed to copy directories', '');
00574             }
00575             // FINISHED copying directory
00576 
00577         } else {
00578             $this->writelog(2, 2, 130, 'The item "%s" was not a file or directory!', Array($theFile));
00579         }
00580     }
00581 
00582     /**
00583      * Moving files and folders (action=3)
00584      *
00585      * @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
00586      * @return  string      Returns the new filename upon success
00587      */
00588     function func_move($cmds) {
00589         if (!$this->isInit) {
00590             return FALSE;
00591         }
00592 
00593             // Initialize and check basic conditions:
00594         $theFile = $cmds['data'];
00595         $theDest = $this->is_directory($cmds['target']); // Clean up destination directory
00596         $altName = $cmds['altName'];
00597         if (!$theDest) {
00598             $this->writelog(3, 2, 100, 'Destination "%s" was not a directory', Array($cmds['target']));
00599             return FALSE;
00600         }
00601         if (!$this->isPathValid($theFile) || !$this->isPathValid($theDest)) {
00602             $this->writelog(3, 2, 101, 'Target or destination had invalid path (".." and "//" is not allowed in path). T="%s", D="%s"', Array($theFile, $theDest));
00603             return FALSE;
00604         }
00605 
00606             // Processing of file or directory:
00607         if (@is_file($theFile)) { // If we are moving a file...
00608             if ($this->actionPerms['moveFile']) {
00609                 if (filesize($theFile) < ($this->maxMoveFileSize * 1024)) {
00610                     $fI = t3lib_div::split_fileref($theFile);
00611                     if ($altName) { // If altName is set, we're allowed to create a new filename if the file already existed
00612                         $theDestFile = $this->getUniqueName($fI['file'], $theDest);
00613                         $fI = t3lib_div::split_fileref($theDestFile);
00614                     } else {
00615                         $theDestFile = $theDest . '/' . $fI['file'];
00616                     }
00617                     if ($theDestFile && !file_exists($theDestFile)) {
00618                         if ($this->checkIfAllowed($fI['fileext'], $theDest, $fI['file'])) {
00619                             if ($this->checkPathAgainstMounts($theDestFile) && $this->checkPathAgainstMounts($theFile)) {
00620                                 if ($this->PHPFileFunctions) {
00621                                     @rename($theFile, $theDestFile);
00622                                 } else {
00623                                     $cmd = 'mv "' . $theFile . '" "' . $theDestFile . '"';
00624                                     t3lib_utility_Command::exec($cmd);
00625                                 }
00626                                 clearstatcache();
00627                                 if (@is_file($theDestFile)) {
00628                                     $this->writelog(3, 0, 1, 'File "%s" moved to "%s"', Array($theFile, $theDestFile));
00629                                     return $theDestFile;
00630                                 } else {
00631                                     $this->writelog(3, 2, 109, 'File "%s" WAS NOT moved to "%s"! Write-permission problem?', Array($theFile, $theDestFile));
00632                                 }
00633                             } else {
00634                                 $this->writelog(3, 1, 110, 'Target or destination was not within your mountpoints! T="%s", D="%s"', Array($theFile, $theDestFile));
00635                             }
00636                         } else {
00637                             $this->writelog(3, 1, 111, 'Extension of file name "%s" is not allowed in "%s"!', Array($fI['file'], $theDest . '/'));
00638                         }
00639                     } else {
00640                         $this->writelog(3, 1, 112, 'File "%s" already exists!', Array($theDestFile));
00641                     }
00642                 } else {
00643                     $this->writelog(3, 1, 113, 'File "%s" exceeds the size-limit of %s bytes', Array($theFile, $this->maxMoveFileSize * 1024));
00644                 }
00645             } else {
00646                 $this->writelog(3, 1, 114, 'You are not allowed to move files', '');
00647             }
00648             // FINISHED moving file
00649 
00650         } elseif (@is_dir($theFile)) { // if we're moving a folder
00651             if ($this->actionPerms['moveFolder']) {
00652                 $theFile = $this->is_directory($theFile);
00653                 if ($theFile) {
00654                     $fI = t3lib_div::split_fileref($theFile);
00655                     if ($altName) { // If altName is set, we're allowed to create a new filename if the file already existed
00656                         $theDestFile = $this->getUniqueName($fI['file'], $theDest);
00657                         $fI = t3lib_div::split_fileref($theDestFile);
00658                     } else {
00659                         $theDestFile = $theDest . '/' . $fI['file'];
00660                     }
00661                     if ($theDestFile && !file_exists($theDestFile)) {
00662                         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?
00663                             if ($this->checkIfFullAccess($theDest) || $this->is_webPath($theDestFile) == $this->is_webPath($theFile)) { // // no moving of folders between spaces
00664                                 if ($this->checkPathAgainstMounts($theDestFile) && $this->checkPathAgainstMounts($theFile)) {
00665                                     if ($this->PHPFileFunctions) {
00666                                         @rename($theFile, $theDestFile);
00667                                     } else {
00668                                         $cmd = 'mv "' . $theFile . '" "' . $theDestFile . '"';
00669                                         $errArr = array();
00670                                         t3lib_utility_Command::exec($cmd, $errArr);
00671                                     }
00672                                     clearstatcache();
00673                                     if (@is_dir($theDestFile)) {
00674                                         $this->writelog(3, 0, 2, 'Directory "%s" moved to "%s"', Array($theFile, $theDestFile));
00675                                         return $theDestFile;
00676                                     } else {
00677                                         $this->writelog(3, 2, 119, 'Directory "%s" WAS NOT moved to "%s"! Write-permission problem?', Array($theFile, $theDestFile));
00678                                     }
00679                                 } else {
00680                                     $this->writelog(3, 1, 120, 'Target or destination was not within your mountpoints! T="%s", D="%s"', Array($theFile, $theDestFile));
00681                                 }
00682                             } else {
00683                                 $this->writelog(3, 1, 121, 'You don\'t have full access to the destination directory "%s"!', Array($theDest . '/'));
00684                             }
00685                         } else {
00686                             $this->writelog(3, 1, 122, 'Destination cannot be inside the target! D="%s", T="%s"', Array($theDestFile . '/', $theFile . '/'));
00687                         }
00688                     } else {
00689                         $this->writelog(3, 1, 123, 'Target "%s" already exists!', Array($theDestFile));
00690                     }
00691                 } else {
00692                     $this->writelog(3, 2, 124, 'Target seemed not to be a directory! (Shouldn\'t happen here!)', '');
00693                 }
00694             } else {
00695                 $this->writelog(3, 1, 125, 'You are not allowed to move directories', '');
00696             }
00697             // FINISHED moving directory
00698 
00699         } else {
00700             $this->writelog(3, 2, 130, 'The item "%s" was not a file or directory!', Array($theFile));
00701         }
00702     }
00703 
00704     /**
00705      * Renaming files or foldes (action=5)
00706      *
00707      * @param   array       $cmds['data'] is the new name. $cmds['target'] is the target (file or dir).
00708      * @return  string      Returns the new filename upon success
00709      */
00710     function func_rename($cmds) {
00711         if (!$this->isInit) {
00712             return FALSE;
00713         }
00714 
00715         $theNewName = $this->cleanFileName($cmds['data']);
00716         if ($theNewName) {
00717             if ($this->checkFileNameLen($theNewName)) {
00718                 $theTarget = $cmds['target'];
00719                 $type = filetype($theTarget);
00720                 if ($type == 'file' || $type == 'dir') { // $type MUST BE file or dir
00721                     $fileInfo = t3lib_div::split_fileref($theTarget); // Fetches info about path, name, extention of $theTarget
00722                     if ($fileInfo['file'] != $theNewName) { // The name should be different from the current. And the filetype must be allowed
00723                         $theRenameName = $fileInfo['path'] . $theNewName;
00724                         if ($this->checkPathAgainstMounts($fileInfo['path'])) {
00725                             if (!file_exists($theRenameName)) {
00726                                 if ($type == 'file') {
00727                                     if ($this->actionPerms['renameFile']) {
00728                                         $fI = t3lib_div::split_fileref($theRenameName);
00729                                         if ($this->checkIfAllowed($fI['fileext'], $fileInfo['path'], $fI['file'])) {
00730                                             if (@rename($theTarget, $theRenameName)) {
00731                                                 $this->writelog(5, 0, 1, 'File renamed from "%s" to "%s"', Array($fileInfo['file'], $theNewName));
00732                                                 return $theRenameName;
00733                                             } else {
00734                                                 $this->writelog(5, 1, 100, 'File "%s" was not renamed! Write-permission problem in "%s"?', Array($theTarget, $fileInfo['path']));
00735                                             }
00736                                         } else {
00737                                             $this->writelog(5, 1, 101, 'Extension of file name "%s" was not allowed!', Array($fI['file']));
00738                                         }
00739                                     } else {
00740                                         $this->writelog(5, 1, 102, 'You are not allowed to rename files!', '');
00741                                     }
00742                                 } elseif ($type == 'dir') {
00743                                     if ($this->actionPerms['renameFolder']) {
00744                                         if (@rename($theTarget, $theRenameName)) {
00745                                             $this->writelog(5, 0, 2, 'Directory renamed from "%s" to "%s"', Array($fileInfo['file'], $theNewName));
00746                                             return $theRenameName;
00747                                         } else {
00748                                             $this->writelog(5, 1, 110, 'Directory "%s" was not renamed! Write-permission problem in "%s"?', Array($theTarget, $fileInfo['path']));
00749                                         }
00750                                     } else {
00751                                         $this->writelog(5, 1, 111, 'You are not allowed to rename directories!', '');
00752                                     }
00753                                 }
00754                             } else {
00755                                 $this->writelog(5, 1, 120, 'Destination "%s" existed already!', Array($theRenameName));
00756                             }
00757                         } else {
00758                             $this->writelog(5, 1, 121, 'Destination path "%s" was not within your mountpoints!', Array($fileInfo['path']));
00759                         }
00760                     } else {
00761                         $this->writelog(5, 1, 122, 'Old and new name is the same (%s)', Array($theNewName));
00762                     }
00763                 } else {
00764                     $this->writelog(5, 2, 123, 'Target "%s" was neither a directory nor a file!', Array($theTarget));
00765                 }
00766             } else {
00767                 $this->writelog(5, 1, 124, 'New name "%s" was too long (max %s characters)', Array($theNewName, $this->maxInputNameLen));
00768             }
00769         }
00770     }
00771 
00772     /**
00773      * This creates a new folder. (action=6)
00774      *
00775      * @param   array       $cmds['data'] is the foldername. $cmds['target'] is the path where to create it.
00776      * @return  string      Returns the new foldername upon success
00777      */
00778     function func_newfolder($cmds) {
00779         if (!$this->isInit) {
00780             return FALSE;
00781         }
00782 
00783         $theFolder = $this->cleanFileName($cmds['data']);
00784         if (isset($theFolder) && trim($theFolder) != '') {
00785             if ($this->checkFileNameLen($theFolder)) {
00786                 $theTarget = $this->is_directory($cmds['target']); // Check the target dir
00787                 if ($theTarget) {
00788                     if ($this->actionPerms['newFolder']) {
00789                         $theNewFolder = $theTarget . '/' . $theFolder;
00790                         if ($this->checkPathAgainstMounts($theNewFolder)) {
00791                             if (!file_exists($theNewFolder)) {
00792                                 if (t3lib_div::mkdir($theNewFolder)) {
00793                                     $this->writelog(6, 0, 1, 'Directory "%s" created in "%s"', Array($theFolder, $theTarget . '/'));
00794                                     return $theNewFolder;
00795                                 } else {
00796                                     $this->writelog(6, 1, 100, 'Directory "%s" not created. Write-permission problem in "%s"?', Array($theFolder, $theTarget . '/'));
00797                                 }
00798                             } else {
00799                                 $this->writelog(6, 1, 101, 'File or directory "%s" existed already!', Array($theNewFolder));
00800                             }
00801                         } else {
00802                             $this->writelog(6, 1, 102, 'Destination path "%s" was not within your mountpoints!', Array($theTarget . '/'));
00803                         }
00804                     } else {
00805                         $this->writelog(6, 1, 103, 'You are not allowed to create directories!', '');
00806                     }
00807                 } else {
00808                     $this->writelog(6, 2, 104, 'Destination "%s" was not a directory', Array($cmds['target']));
00809                 }
00810             } else {
00811                 $this->writelog(6, 1, 105, 'New name "%s" was too long (max %s characters)', Array($theFolder, $this->maxInputNameLen));
00812             }
00813         }
00814     }
00815 
00816     /**
00817      * This creates a new file. (action=8)
00818      *
00819      * @param   array       $cmds['data'] is the new filename. $cmds['target'] is the path where to create it
00820      * @return  string      Returns the new filename upon success
00821      */
00822     function func_newfile($cmds) {
00823         $extList = $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'];
00824         if (!$this->isInit) {
00825             return FALSE;
00826         }
00827         $newName = $this->cleanFileName($cmds['data']);
00828         if ($newName) {
00829             if ($this->checkFileNameLen($newName)) {
00830                 $theTarget = $this->is_directory($cmds['target']); // Check the target dir
00831                 $fileInfo = t3lib_div::split_fileref($theTarget); // Fetches info about path, name, extention of $theTarget
00832                 if ($theTarget) {
00833                     if ($this->actionPerms['newFile']) {
00834                         $theNewFile = $theTarget . '/' . $newName;
00835                         if ($this->checkPathAgainstMounts($theNewFile)) {
00836                             if (!file_exists($theNewFile)) {
00837                                 $fI = t3lib_div::split_fileref($theNewFile);
00838                                 if ($this->checkIfAllowed($fI['fileext'], $fileInfo['path'], $fI['file'])) {
00839                                     if (t3lib_div::inList($extList, $fI['fileext'])) {
00840                                         if (t3lib_div::writeFile($theNewFile, '')) {
00841                                             clearstatcache();
00842                                             $this->writelog(8, 0, 1, 'File created: "%s"', Array($fI['file']));
00843                                             return $theNewFile;
00844                                         } else {
00845                                             $this->writelog(8, 1, 100, 'File "%s" was not created! Write-permission problem in "%s"?', Array($fI['file'], $theTarget));
00846                                         }
00847                                     } else {
00848                                         $this->writelog(8, 1, 107, 'File extension "%s" is not a textfile format! (%s)', Array($fI['fileext'], $extList));
00849                                     }
00850                                 } else {
00851                                     $this->writelog(8, 1, 106, 'Extension of file name "%s" was not allowed!', Array($fI['file']));
00852                                 }
00853                             } else {
00854                                 $this->writelog(8, 1, 101, 'File "%s" existed already!', Array($theNewFile));
00855                             }
00856                         } else {
00857                             $this->writelog(8, 1, 102, 'Destination path "%s" was not within your mountpoints!', Array($theTarget . '/'));
00858                         }
00859                     } else {
00860                         $this->writelog(8, 1, 103, 'You are not allowed to create files!', '');
00861                     }
00862                 } else {
00863                     $this->writelog(8, 2, 104, 'Destination "%s" was not a directory', Array($cmds['target']));
00864                 }
00865             } else {
00866                 $this->writelog(8, 1, 105, 'New name "%s" was too long (max %s characters)', Array($newName, $this->maxInputNameLen));
00867             }
00868         }
00869     }
00870 
00871     /**
00872      * Editing textfiles or folders (action=9)
00873      *
00874      * @param   array       $cmds['data'] is the new content. $cmds['target'] is the target (file or dir)
00875      * @return  boolean     Returns true on success
00876      */
00877     function func_edit($cmds) {
00878         if (!$this->isInit) {
00879             return FALSE;
00880         }
00881         $theTarget = $cmds['target'];
00882         $content = $cmds['data'];
00883         $extList = $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'];
00884         $type = filetype($theTarget);
00885         if ($type == 'file') { // $type MUST BE file
00886             $fileInfo = t3lib_div::split_fileref($theTarget); // Fetches info about path, name, extention of $theTarget
00887             $fI = $fileInfo;
00888             if ($this->checkPathAgainstMounts($fileInfo['path'])) {
00889                 if ($this->actionPerms['editFile']) {
00890                     $fI = t3lib_div::split_fileref($theTarget);
00891                     if ($this->checkIfAllowed($fI['fileext'], $fileInfo['path'], $fI['file'])) {
00892                         if (t3lib_div::inList($extList, $fileInfo['fileext'])) {
00893                             if (t3lib_div::writeFile($theTarget, $content)) {
00894                                 clearstatcache();
00895                                 $this->writelog(9, 0, 1, 'File saved to "%s", bytes: %s, MD5: %s ', Array($fileInfo['file'], @filesize($theTarget), md5($content)));
00896                                 return TRUE;
00897                             } else {
00898                                 $this->writelog(9, 1, 100, 'File "%s" was not saved! Write-permission problem in "%s"?', Array($theTarget, $fileInfo['path']));
00899                             }
00900                         } else {
00901                             $this->writelog(9, 1, 102, 'File extension "%s" is not a textfile format! (%s)', Array($fI['fileext'], $extList));
00902                         }
00903                     } else {
00904                         $this->writelog(9, 1, 103, 'Extension of file name "%s" was not allowed!', Array($fI['file']));
00905                     }
00906                 } else {
00907                     $this->writelog(9, 1, 104, 'You are not allowed to edit files!', '');
00908                 }
00909             } else {
00910                 $this->writelog(9, 1, 121, 'Destination path "%s" was not within your mountpoints!', Array($fileInfo['path']));
00911             }
00912         } else {
00913             $this->writelog(9, 2, 123, 'Target "%s" was not a file!', Array($theTarget));
00914         }
00915     }
00916 
00917     /**
00918      * Upload of files (action=1)
00919      *
00920      * @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)
00921      * @return  string      Returns the new filename upon success
00922      */
00923     function func_upload($cmds) {
00924         if (!$this->isInit) {
00925             return FALSE;
00926         }
00927         $id = $cmds['data'];
00928         if ($_FILES['upload_' . $id]['name']) {
00929             $theFile = $_FILES['upload_' . $id]['tmp_name']; // filename of the uploaded file
00930             $theFileSize = $_FILES['upload_' . $id]['size']; // filesize of the uploaded file
00931             $theName = $this->cleanFileName(stripslashes($_FILES['upload_' . $id]['name']), (isset($cmds['charset']) ? $cmds['charset'] : '')); // The original filename
00932             if (is_uploaded_file($theFile) && $theName) { // Check the file
00933                 if ($this->actionPerms['uploadFile']) {
00934                     if ($theFileSize < ($this->maxUploadFileSize * 1024)) {
00935                         $fI = t3lib_div::split_fileref($theName);
00936                         $theTarget = $this->is_directory($cmds['target']); // Check the target dir
00937                         if ($theTarget && $this->checkPathAgainstMounts($theTarget . '/')) {
00938                             if ($this->checkIfAllowed($fI['fileext'], $theTarget, $fI['file'])) {
00939                                 $theNewFile = $this->getUniqueName($theName, $theTarget, $this->dontCheckForUnique);
00940                                 if ($theNewFile) {
00941                                     t3lib_div::upload_copy_move($theFile, $theNewFile);
00942                                     clearstatcache();
00943                                     if (@is_file($theNewFile)) {
00944                                         $this->internalUploadMap[$id] = $theNewFile;
00945                                         $this->writelog(1, 0, 1, 'Uploading file "%s" to "%s"', Array($theName, $theNewFile, $id));
00946                                         return $theNewFile;
00947                                     } else {
00948                                         $this->writelog(1, 1, 100, 'Uploaded file could not be moved! Write-permission problem in "%s"?', Array($theTarget . '/'));
00949                                     }
00950                                 } else {
00951                                     $this->writelog(1, 1, 101, 'No unique filename available in "%s"!', Array($theTarget . '/'));
00952                                 }
00953                             } else {
00954                                 $this->writelog(1, 1, 102, 'Extension of file name "%s" is not allowed in "%s"!', Array($fI['file'], $theTarget . '/'));
00955                             }
00956                         } else {
00957                             $this->writelog(1, 1, 103, 'Destination path "%s" was not within your mountpoints!', Array($theTarget . '/'));
00958                         }
00959                     } else {
00960                         $this->writelog(1, 1, 104, 'The uploaded file exceeds the size-limit of %s bytes', Array($this->maxUploadFileSize * 1024));
00961                     }
00962                 } else {
00963                     $this->writelog(1, 1, 105, 'You are not allowed to upload files!', '');
00964                 }
00965             } else {
00966                 $this->writelog(1, 2, 106, 'The upload has failed, no uploaded file found!', '');
00967             }
00968         } else {
00969             $this->writelog(1, 2, 108, 'No file was uploaded!', '');
00970         }
00971     }
00972 
00973     /**
00974      * Unzipping file (action=7)
00975      * This is permitted only if the user has fullAccess or if the file resides
00976      *
00977      * @param   array       $cmds['data'] is the zip-file. $cmds['target'] is the target directory. If not set we'll default to the same directory as the file is in.
00978      * @return  boolean     Returns true on success
00979      */
00980     function func_unzip($cmds) {
00981         if (!$this->isInit || $this->dont_use_exec_commands) {
00982             return FALSE;
00983         }
00984 
00985         $theFile = $cmds['data'];
00986         if (@is_file($theFile)) {
00987             $fI = t3lib_div::split_fileref($theFile);
00988             if (!isset($cmds['target'])) {
00989                 $cmds['target'] = $fI['path'];
00990             }
00991             $theDest = $this->is_directory($cmds['target']); // Clean up destination directory
00992             if ($theDest) {
00993                 if ($this->actionPerms['unzipFile']) {
00994                     if ($fI['fileext'] == 'zip') {
00995                         if ($this->checkIfFullAccess($theDest)) {
00996                             if ($this->checkPathAgainstMounts($theFile) && $this->checkPathAgainstMounts($theDest . '/')) {
00997                                 // No way to do this under windows.
00998                                 $cmd = $this->unzipPath . 'unzip -qq "' . $theFile . '" -d "' . $theDest . '"';
00999                                 t3lib_utility_Command::exec($cmd);
01000                                 $this->writelog(7, 0, 1, 'Unzipping file "%s" in "%s"', Array($theFile, $theDest));
01001                                 return TRUE;
01002                             } else {
01003                                 $this->writelog(7, 1, 100, 'File "%s" or destination "%s" was not within your mountpoints!', Array($theFile, $theDest));
01004                             }
01005                         } else {
01006                             $this->writelog(7, 1, 101, 'You don\'t have full access to the destination directory "%s"!', Array($theDest));
01007                         }
01008                     } else {
01009                         $this->writelog(7, 1, 102, 'File extension is not "zip"', '');
01010                     }
01011                 } else {
01012                     $this->writelog(7, 1, 103, 'You are not allowed to unzip files', '');
01013                 }
01014             } else {
01015                 $this->writelog(7, 2, 104, 'Destination "%s" was not a directory', Array($cmds['target']));
01016             }
01017         } else {
01018             $this->writelog(7, 2, 105, 'The file "%s" did not exist!', Array($theFile));
01019         }
01020     }
01021 }
01022 
01023 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_extfilefunc.php'])) {
01024     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_extfilefunc.php']);
01025 }
01026 
01027 ?>