81 'renameFile' => FALSE,
83 'deleteFile' => FALSE,
86 'readFolder' => FALSE,
87 'writeFolder' => FALSE,
88 'copyFolder' => FALSE,
89 'moveFolder' => FALSE,
90 'renameFolder' => FALSE,
91 'deleteFolder' => FALSE,
92 'recursivedeleteFolder' => FALSE
159 $this->fileCmdMap = $fileCmds;
181 if (empty($permissions)) {
182 $permissions =
$GLOBALS[
'BE_USER']->getFilePermissions();
184 $this->actionPerms = $permissions;
196 if (!$this->isInit) {
199 if (is_array($this->fileCmdMap)) {
201 if ($this->fileCmdMap[
'upload']) {
202 $uploads = $this->fileCmdMap[
'upload'];
203 foreach ($uploads as $upload) {
204 if (empty($_FILES[(
'upload_' . $upload[
'data'])][
'name'])
205 || (is_array($_FILES[(
'upload_' . $upload[
'data'])][
'name'])
206 && empty($_FILES[(
'upload_' . $upload[
'data'])][
'name'][0])
209 unset($this->fileCmdMap[
'upload'][$upload[
'data']]);
212 if (count($this->fileCmdMap[
'upload']) == 0) {
213 $this->writelog(1, 1, 108,
'No file was uploaded!',
'');
218 if ($this->fileCmdMap[
'newfolder']) {
219 foreach ($this->fileCmdMap[
'newfolder'] as $key => $cmdArr) {
220 if (empty($cmdArr[
'data'])) {
221 unset($this->fileCmdMap[
'newfolder'][$key]);
224 if (count($this->fileCmdMap[
'newfolder']) === 0) {
225 $this->
writeLog(6, 1, 108,
'No name for new folder given!',
'');
230 foreach ($this->fileCmdMap as $action => $actionData) {
232 if (is_array($actionData)) {
234 foreach ($actionData as $cmdArr) {
240 $result[$action][] = $this->func_delete($cmdArr);
243 $result[$action][] = $this->func_copy($cmdArr);
261 $result[$action][] = $this->func_upload($cmdArr);
268 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_extfilefunc.php'][
'processData'])) {
269 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_extfilefunc.php'][
'processData'] as $classRef) {
272 throw new \UnexpectedValueException(
'$hookObject must implement interface TYPO3\\CMS\\Core\\Utility\\File\\ExtendedFileUtilityProcessDataHookInterface', 1279719168);
274 $hookObject->processData_postProcessAction($action, $cmdArr,
$result[$action], $this);
304 'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
305 htmlspecialchars($msg),
310 $this->addFlashMessage($flashMessage);
342 if (@is_dir($rDir) && $this->recyclerFN != $fI[
'file']) {
345 $theFile = $fI[
'path'];
364 public function writeLog($action, $error, $details_nr, $details, $data) {
368 $this->
getBackendUser()->writelog($type, $action, $error, $details_nr, $details, $data);
371 $this->lastError = vsprintf($details, $data);
388 public function func_delete(array $cmds) {
390 if (!$this->isInit) {
399 'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
400 sprintf(
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.description.fileNotFound'), $cmds[
'data']),
401 $GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.header.fileNotFound'),
405 $this->addFlashMessage($flashMessage);
411 if ($fileObject instanceof
File) {
415 $table =
'sys_refindex';
416 $refIndexRecords = $databaseConnection->exec_SELECTgetRows(
419 'deleted=0 AND ref_table=' . $databaseConnection->fullQuoteStr(
'sys_file', $table)
420 .
' AND ref_uid=' . (int)$fileObject->getUid()
421 .
' AND tablename != ' . $databaseConnection->fullQuoteStr(
'sys_file_metadata', $table)
424 if (count($refIndexRecords) > 0) {
425 $shortcutContent = array();
426 $brokenReferences = array();
428 foreach ($refIndexRecords as $fileReferenceRow) {
429 if ($fileReferenceRow[
'tablename'] ===
'sys_file_reference') {
431 $shortcutRecord = BackendUtility::getRecord($row[
'tablename'], $row[
'recuid']);
433 if ($shortcutRecord) {
435 $onClick =
'Clickmenu.show("' . $row[
'tablename'] .
'", "' . $row[
'recuid'] .
'", "1", "+info,history,edit", "|", "");return false;';
436 $shortcutContent[] =
'<a href="#" oncontextmenu="this.click();return false;" onclick="' . htmlspecialchars($onClick) .
'">' . $icon .
'</a>' . htmlspecialchars((
BackendUtility::getRecordTitle($row[
'tablename'], $shortcutRecord) .
' [' .
BackendUtility::getRecordPath($shortcutRecord[
'pid'],
'', 80) .
']'));
438 $brokenReferences[] = $fileReferenceRow[
'ref_uid'];
442 if (!empty($brokenReferences)) {
445 '\\TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
446 sprintf(
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.description.fileHasBrokenReferences'), count($brokenReferences)),
447 $GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.header.fileHasBrokenReferences'),
451 $this->addFlashMessage($flashMessage);
453 if (!empty($shortcutContent)) {
456 '\\TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
457 sprintf(
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.description.fileNotDeletedHasReferences'), $fileObject->getName()) .
'<br />' . implode(
'<br />', $shortcutContent),
458 $GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.header.fileNotDeletedHasReferences'),
462 $this->addFlashMessage($flashMessage);
469 $result = $fileObject->delete();
473 '\\TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
474 sprintf(
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.description.fileDeleted'), $fileObject->getName()),
475 $GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.header.fileDeleted'),
479 $this->addFlashMessage($flashMessage);
481 $this->writelog(4, 0, 1,
'File "%s" deleted', array($fileObject->getIdentifier()));
482 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientFileAccessPermissionsException $e) {
483 $this->writelog(4, 1, 112,
'You are not allowed to access the file', array($fileObject->getIdentifier()));
484 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\NotInMountPointException $e) {
485 $this->writelog(4, 1, 111,
'Target was not within your mountpoints! T="%s"', array($fileObject->getIdentifier()));
486 }
catch (\RuntimeException $e) {
487 $this->writelog(4, 1, 110,
'Could not delete file "%s". Write-permission problem?', array($fileObject->getIdentifier()));
492 if (!$this->folderHasFilesInUse($fileObject)) {
494 $result = $fileObject->delete(TRUE);
499 'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
500 sprintf(
$GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.description.folderDeleted'), $fileObject->getName()),
501 $GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.header.folderDeleted'),
505 $this->addFlashMessage($flashMessage);
507 $this->writelog(4, 0, 3,
'Directory "%s" deleted', array($fileObject->getIdentifier()));
509 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientUserPermissionsException $e) {
510 $this->writelog(4, 1, 120,
'Could not delete directory! Is directory "%s" empty? (You are not allowed to delete directories recursively).', array($fileObject->getIdentifier()));
511 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientFolderAccessPermissionsException $e) {
512 $this->writelog(4, 1, 123,
'You are not allowed to access the directory', array($fileObject->getIdentifier()));
513 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\NotInMountPointException $e) {
514 $this->writelog(4, 1, 121,
'Target was not within your mountpoints! T="%s"', array($fileObject->getIdentifier()));
515 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\FileOperationErrorException $e) {
516 $this->writelog(4, 1, 120,
'Could not delete directory "%s"! Write-permission problem?', array($fileObject->getIdentifier()));
532 public function folderHasFilesInUse(\
TYPO3\CMS\Core\Resource\Folder $folder) {
533 $files = $folder->getFiles(0, 0, \
TYPO3\CMS\Core\Resource\Folder::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS, TRUE);
540 foreach ($files as $file) {
541 $fileUids[] = $file->getUid();
546 'deleted=0 AND ref_table="sys_file" AND ref_uid IN (' . implode(
',', $fileUids) .
') AND tablename<>"sys_file_metadata"' 549 $hasReferences = $numberOfReferences > 0;
550 if ($hasReferences) {
553 'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
554 $GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.description.folderNotDeletedHasFilesWithReferences'),
555 $GLOBALS[
'LANG']->sL(
'LLL:EXT:lang/locallang_core.xlf:message.header.folderNotDeletedHasFilesWithReferences'),
559 $this->addFlashMessage($flashMessage);
562 return $hasReferences;
575 'sys_file_reference',
576 'uid=' . (
int)$referenceRecord[
'recuid']
579 'recuid' => $fileReference[
'uid_foreign'],
580 'tablename' => $fileReference[
'tablenames'],
581 'field' => $fileReference[
'fieldname'],
584 'sorting' => $fileReference[
'sorting_foreign']
596 $object = $this->fileFactory->retrieveFileOrFolderObject($identifier);
597 if (!is_object($object)) {
598 throw new \TYPO3\CMS\Core\Resource\Exception\InvalidFileException(
'The item ' . $identifier .
' was not a file or directory!!', 1320122453);
600 if ($object->getStorage()->getUid() === 0) {
601 throw new \TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException(
'You are not allowed to access files outside your storages', 1375889830);
619 protected function func_copy($cmds) {
620 if (!$this->isInit) {
627 if (!$targetFolderObject instanceof \
TYPO3\CMS\Core\Resource\Folder) {
628 $this->writelog(2, 2, 100,
'Destination "%s" was not a directory', array($cmds[
'target']));
632 $appendSuffixOnConflict = (string) $cmds[
'altName'];
633 $resultObject = NULL;
635 if ($sourceFileObject instanceof
File) {
637 $conflictMode = $appendSuffixOnConflict !==
'' ?
'renameNewFile' :
'cancel';
638 $resultObject = $sourceFileObject->copyTo($targetFolderObject, NULL, $conflictMode);
639 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientUserPermissionsException $e) {
640 $this->writelog(2, 1, 114,
'You are not allowed to copy files',
'');
641 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientFileAccessPermissionsException $e) {
642 $this->writelog(2, 1, 110,
'Could not access all necessary resources. Source file or destination maybe was not within your mountpoints? T="%s", D="%s"', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
643 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\IllegalFileExtensionException $e) {
644 $this->writelog(2, 1, 111,
'Extension of file name "%s" is not allowed in "%s"!', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
645 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\ExistingTargetFileNameException $e) {
646 $this->writelog(2, 1, 112,
'File "%s" already exists in folder "%s"!', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
647 }
catch (\BadMethodCallException $e) {
648 $this->writelog(3, 1, 128,
'The function to copy a file between storages is not yet implemented', array());
649 }
catch (\RuntimeException $e) {
650 $this->writelog(2, 2, 109,
'File "%s" WAS NOT copied to "%s"! Write-permission problem?', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
653 $this->writelog(2, 0, 1,
'File "%s" copied to "%s"', array($sourceFileObject->getIdentifier(), $resultObject->getIdentifier()));
657 $sourceFolderObject = $sourceFileObject;
659 $conflictMode = $appendSuffixOnConflict !==
'' ?
'renameNewFile' :
'cancel';
660 $resultObject = $sourceFolderObject->copyTo($targetFolderObject, NULL, $conflictMode);
661 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientUserPermissionsException $e) {
662 $this->writelog(2, 1, 125,
'You are not allowed to copy directories',
'');
663 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientFileAccessPermissionsException $e) {
664 $this->writelog(2, 1, 110,
'Could not access all necessary resources. Source file or destination maybe was not within your mountpoints? T="%s", D="%s"', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
665 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientFolderAccessPermissionsException $e) {
666 $this->writelog(2, 1, 121,
'You don\'t have full access to the destination directory "%s"!', array($targetFolderObject->getIdentifier()));
667 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InvalidTargetFolderException $e) {
668 $this->writelog(2, 1, 122,
'Cannot copy folder "%s" into target folder "%s", because the target folder is already within the folder to be copied!', array($sourceFolderObject->getName(), $targetFolderObject->getName()));
669 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\ExistingTargetFolderException $e) {
670 $this->writelog(2, 1, 123,
'Target "%s" already exists!', array($targetFolderObject->getIdentifier()));
671 }
catch (\BadMethodCallException $e) {
672 $this->writelog(3, 1, 129,
'The function to copy a folder between storages is not yet implemented', array());
673 }
catch (\RuntimeException $e) {
674 $this->writelog(2, 2, 119,
'Directory "%s" WAS NOT copied to "%s"! Write-permission problem?', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
677 $this->writelog(2, 0, 2,
'Directory "%s" copied to "%s"', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
680 return $resultObject;
697 if (!$this->isInit) {
703 if (!$targetFolderObject instanceof \
TYPO3\CMS\Core\Resource\Folder) {
704 $this->writelog(3, 2, 100,
'Destination "%s" was not a directory', array($cmds[
'target']));
707 $alternativeName = (string) $cmds[
'altName'];
708 $resultObject = NULL;
710 if ($sourceFileObject instanceof
File) {
712 if ($alternativeName !==
'') {
714 $resultObject = $sourceFileObject->moveTo($targetFolderObject, $alternativeName,
'renameNewFile');
717 $resultObject = $sourceFileObject->moveTo($targetFolderObject, NULL,
'cancel');
719 $this->writelog(3, 0, 1,
'File "%s" moved to "%s"', array($sourceFileObject->getIdentifier(), $resultObject->getIdentifier()));
720 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientUserPermissionsException $e) {
721 $this->writelog(3, 1, 114,
'You are not allowed to move files',
'');
722 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientFileAccessPermissionsException $e) {
723 $this->writelog(3, 1, 110,
'Could not access all necessary resources. Source file or destination maybe was not within your mountpoints? T="%s", D="%s"', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
724 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\IllegalFileExtensionException $e) {
725 $this->writelog(3, 1, 111,
'Extension of file name "%s" is not allowed in "%s"!', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
726 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\ExistingTargetFileNameException $e) {
727 $this->writelog(3, 1, 112,
'File "%s" already exists in folder "%s"!', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
728 }
catch (\BadMethodCallException $e) {
729 $this->writelog(3, 1, 126,
'The function to move a file between storages is not yet implemented', array());
730 }
catch (\RuntimeException $e) {
731 $this->writelog(3, 2, 109,
'File "%s" WAS NOT copied to "%s"! Write-permission problem?', array($sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()));
735 $sourceFolderObject = $sourceFileObject;
737 if ($alternativeName !==
'') {
739 $resultObject = $sourceFolderObject->moveTo($targetFolderObject, $alternativeName,
'renameNewFile');
742 $resultObject = $sourceFolderObject->moveTo($targetFolderObject, NULL,
'renameNewFile');
744 $this->writelog(3, 0, 2,
'Directory "%s" moved to "%s"', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
745 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientUserPermissionsException $e) {
746 $this->writelog(3, 1, 125,
'You are not allowed to move directories',
'');
747 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientFileAccessPermissionsException $e) {
748 $this->writelog(3, 1, 110,
'Could not access all necessary resources. Source file or destination maybe was not within your mountpoints? T="%s", D="%s"', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
749 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientFolderAccessPermissionsException $e) {
750 $this->writelog(3, 1, 121,
'You don\'t have full access to the destination directory "%s"!', array($targetFolderObject->getIdentifier()));
751 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InvalidTargetFolderException $e) {
752 $this->writelog(3, 1, 122,
'Cannot move folder "%s" into target folder "%s", because the target folder is already within the folder to be moved!', array($sourceFolderObject->getName(), $targetFolderObject->getName()));
753 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\ExistingTargetFolderException $e) {
754 $this->writelog(3, 1, 123,
'Target "%s" already exists!', array($targetFolderObject->getIdentifier()));
755 }
catch (\BadMethodCallException $e) {
756 $this->writelog(3, 1, 127,
'The function to move a folder between storages is not yet implemented', array());
757 }
catch (\RuntimeException $e) {
758 $this->writelog(3, 2, 119,
'Directory "%s" WAS NOT moved to "%s"! Write-permission problem?', array($sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()));
761 return $resultObject;
777 if (!$this->isInit) {
781 $targetFile = $cmds[
'target'];
782 $resultObject = NULL;
783 if ($sourceFileObject instanceof
File) {
786 $resultObject = $sourceFileObject->rename($targetFile);
787 $this->writelog(5, 0, 1,
'File renamed from "%s" to "%s"', array($sourceFileObject->getName(), $targetFile));
788 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientUserPermissionsException $e) {
789 $this->writelog(5, 1, 102,
'You are not allowed to rename files!',
'');
790 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\IllegalFileExtensionException $e) {
791 $this->writelog(5, 1, 101,
'Extension of file name "%s" or "%s" was not allowed!', array($sourceFileObject->getName(), $targetFile));
792 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\ExistingTargetFileNameException $e) {
793 $this->writelog(5, 1, 120,
'Destination "%s" existed already!', array($targetFile));
794 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\NotInMountPointException $e) {
795 $this->writelog(5, 1, 121,
'Destination path "%s" was not within your mountpoints!', array($targetFile));
796 }
catch (\RuntimeException $e) {
797 $this->writelog(5, 1, 100,
'File "%s" was not renamed! Write-permission problem in "%s"?', array($sourceFileObject->getName(), $targetFile));
803 $resultObject = $sourceFileObject->rename($targetFile);
804 $this->writelog(5, 0, 2,
'Directory renamed from "%s" to "%s"', array($sourceFileObject->getName(), $targetFile));
805 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientUserPermissionsException $e) {
806 $this->writelog(5, 1, 111,
'You are not allowed to rename directories!',
'');
807 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\ExistingTargetFileNameException $e) {
808 $this->writelog(5, 1, 120,
'Destination "%s" existed already!', array($targetFile));
809 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\NotInMountPointException $e) {
810 $this->writelog(5, 1, 121,
'Destination path "%s" was not within your mountpoints!', array($targetFile));
811 }
catch (\RuntimeException $e) {
812 $this->writelog(5, 1, 110,
'Directory "%s" was not renamed! Write-permission problem in "%s"?', array($sourceFileObject->getName(), $targetFile));
815 return $resultObject;
830 if (!$this->isInit) {
834 if (!$targetFolderObject instanceof \
TYPO3\CMS\Core\Resource\Folder) {
835 $this->writelog(6, 2, 104,
'Destination "%s" was not a directory', array($cmds[
'target']));
838 $resultObject = NULL;
840 $folderName = $cmds[
'data'];
841 $resultObject = $targetFolderObject->createFolder($folderName);
842 $this->writelog(6, 0, 1,
'Directory "%s" created in "%s"', array($folderName, $targetFolderObject->getIdentifier() .
'/'));
843 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientFolderWritePermissionsException $e) {
844 $this->writelog(6, 1, 103,
'You are not allowed to create directories!',
'');
845 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\NotInMountPointException $e) {
846 $this->writelog(6, 1, 102,
'Destination path "%s" was not within your mountpoints!', array($targetFolderObject->getIdentifier() .
'/'));
847 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\ExistingTargetFolderException $e) {
848 $this->writelog(6, 1, 101,
'File or directory "%s" existed already!', array($folderName));
849 }
catch (\RuntimeException $e) {
850 $this->writelog(6, 1, 100,
'Directory "%s" not created. Write-permission problem in "%s"?', array($folderName, $targetFolderObject->getIdentifier() .
'/'));
852 return $resultObject;
866 if (!$this->isInit) {
870 if (!$targetFolderObject instanceof \
TYPO3\CMS\Core\Resource\Folder) {
871 $this->writelog(8, 2, 104,
'Destination "%s" was not a directory', array($cmds[
'target']));
874 $resultObject = NULL;
876 $fileName = $cmds[
'data'];
877 $resultObject = $targetFolderObject->createFile($fileName);
878 $this->writelog(8, 0, 1,
'File created: "%s"', array($fileName));
879 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\IllegalFileExtensionException $e) {
880 $this->
writeLog(8, 1, 106,
'Extension of file "%s" was not allowed!', array($fileName));
881 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientFolderWritePermissionsException $e) {
882 $this->writelog(8, 1, 103,
'You are not allowed to create files!',
'');
883 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\NotInMountPointException $e) {
884 $this->writelog(8, 1, 102,
'Destination path "%s" was not within your mountpoints!', array($targetFolderObject->getIdentifier()));
885 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\ExistingTargetFileNameException $e) {
886 $this->writelog(8, 1, 101,
'File existed already in "%s"!', array($targetFolderObject->getIdentifier()));
887 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InvalidFileNameException $e) {
888 $this->writelog(8, 1, 106,
'File name "%s" was not allowed!', $fileName);
889 }
catch (\RuntimeException $e) {
890 $this->writelog(8, 1, 100,
'File "%s" was not created! Write-permission problem in "%s"?', array($fileName, $targetFolderObject->getIdentifier()));
892 return $resultObject;
903 if (!$this->isInit) {
908 $fileIdentifier = $cmds[
'target'];
911 $content = $cmds[
'data'];
912 if (!$fileObject instanceof
File) {
913 $this->writelog(9, 2, 123,
'Target "%s" was not a file!', array($fileIdentifier));
916 $extList =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'textfile_ext'];
918 $this->writelog(9, 1, 102,
'File extension "%s" is not a textfile format! (%s)', array($fileObject->getExtension(), $extList));
922 $fileObject->setContents($content);
924 $this->writelog(9, 0, 1,
'File saved to "%s", bytes: %s, MD5: %s ', array($fileObject->getIdentifier(), $fileObject->getSize(), md5($content)));
926 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientUserPermissionsException $e) {
927 $this->writelog(9, 1, 104,
'You are not allowed to edit files!',
'');
929 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientFileWritePermissionsException $e) {
930 $this->writelog(9, 1, 100,
'File "%s" was not saved! Write-permission problem?', array($fileObject->getIdentifier()));
932 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\IllegalFileExtensionException $e) {
933 $this->writelog(9, 1, 100,
'File "%s" was not saved! File extension rejected!', array($fileObject->getIdentifier()));
967 public function func_upload($cmds) {
968 if (!$this->isInit) {
971 $uploadPosition = $cmds[
'data'];
972 $uploadedFileData = $_FILES[
'upload_' . $uploadPosition];
973 if (empty($uploadedFileData[
'name']) || is_array($uploadedFileData[
'name']) && empty($uploadedFileData[
'name'][0])) {
974 $this->writelog(1, 2, 108,
'No file was uploaded!',
'');
980 if (!is_array($uploadedFileData[
'name'])) {
981 $uploadedFileData = array(
982 'name' => array($uploadedFileData[
'name']),
983 'type' => array($uploadedFileData[
'type']),
984 'tmp_name' => array($uploadedFileData[
'tmp_name']),
985 'size' => array($uploadedFileData[
'size'])
988 $resultObjects = array();
989 $numberOfUploadedFilesForPosition = count($uploadedFileData[
'name']);
991 for ($i = 0; $i < $numberOfUploadedFilesForPosition; $i++) {
993 'name' => $uploadedFileData[
'name'][$i],
994 'type' => $uploadedFileData[
'type'][$i],
995 'tmp_name' => $uploadedFileData[
'tmp_name'][$i],
996 'size' => $uploadedFileData[
'size'][$i]
1000 if ($this->dontCheckForUnique) {
1001 $conflictMode =
'replace';
1003 $conflictMode =
'cancel';
1006 $fileObject = $targetFolderObject->addUploadedFile($fileInfo, $conflictMode);
1008 if ($conflictMode ===
'replace') {
1009 $this->
getIndexer($fileObject->getStorage())->updateIndexEntry($fileObject);
1011 $resultObjects[] = $fileObject;
1012 $this->internalUploadMap[$uploadPosition] = $fileObject->getCombinedIdentifier();
1013 $this->writelog(1, 0, 1,
'Uploading file "%s" to "%s"', array($fileInfo[
'name'], $targetFolderObject->getIdentifier()));
1014 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\UploadException $e) {
1015 $this->writelog(1, 2, 106,
'The upload has failed, no uploaded file found!',
'');
1016 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientUserPermissionsException $e) {
1017 $this->writelog(1, 1, 105,
'You are not allowed to upload files!',
'');
1018 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\UploadSizeException $e) {
1019 $this->writelog(1, 1, 104,
'The uploaded file "%s" exceeds the size-limit', array($fileInfo[
'name']));
1020 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\InsufficientFolderWritePermissionsException $e) {
1021 $this->writelog(1, 1, 103,
'Destination path "%s" was not within your mountpoints!', array($targetFolderObject->getIdentifier()));
1022 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\IllegalFileExtensionException $e) {
1023 $this->writelog(1, 1, 102,
'Extension of file name "%s" is not allowed in "%s"!', array($fileInfo[
'name'], $targetFolderObject->getIdentifier()));
1024 }
catch (\
TYPO3\CMS\Core\Resource\
Exception\ExistingTargetFileNameException $e) {
1025 $this->writelog(1, 1, 101,
'No unique filename available in "%s"!', array($targetFolderObject->getIdentifier()));
1026 }
catch (\RuntimeException $e) {
1027 $this->writelog(1, 1, 100,
'Uploaded file could not be moved! Write-permission problem in "%s"?', array($targetFolderObject->getIdentifier()));
1031 return $resultObjects;
1043 if (!$this->isInit || $this->dont_use_exec_commands) {
1046 $theFile = $cmds[
'data'];
1047 if (!@is_file($theFile)) {
1048 $this->writelog(7, 2, 105,
'The file "%s" did not exist!', array($theFile));
1052 if (!isset($cmds[
'target'])) {
1053 $cmds[
'target'] = $fI[
'path'];
1059 $this->writelog(7, 2, 104,
'Destination "%s" was not a directory', array($cmds[
'target']));
1062 if (!$this->actionPerms[
'unzipFile']) {
1063 $this->writelog(7, 1, 103,
'You are not allowed to unzip files',
'');
1066 if ($fI[
'fileext'] !=
'zip') {
1067 $this->writelog(7, 1, 102,
'File extension is not "zip"',
'');
1071 $this->writelog(7, 1, 101,
'You don\'t have full access to the destination directory "%s"!', array($theDest));
1077 $cmd = $this->unzipPath .
'unzip -qq ' . escapeshellarg($theFile) .
' -d ' . escapeshellarg($theDest);
1079 $this->writelog(7, 0, 1,
'Unzipping file "%s" in "%s"', array($theFile, $theDest));
1082 $this->writelog(7, 1, 100,
'File "%s" or destination "%s" was not within your mountpoints!', array($theFile, $theDest));
1093 protected function addFlashMessage(\
TYPO3\CMS\Core\Messaging\
FlashMessage $flashMessage) {
1096 'TYPO3\\CMS\\Core\\Messaging\\FlashMessageService' 1099 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
1100 $defaultFlashMessageQueue->enqueue($flashMessage);
getIndexer(\TYPO3\CMS\Core\Resource\ResourceStorage $storage)
transformFileReferenceToRecordReference(array $referenceRecord)
printLogErrorMessages($redirect='')
getFileObject($identifier)
writeLog($action, $error, $details_nr, $details, $data)
static getCanonicalPath($path)
static validPathStr($theFile)
checkPathAgainstMounts($thePath)
static getUserObj($classRef, $checkPrefix='', $silent=FALSE)
setActionPermissions(array $permissions=array())
static logDeprecatedFunction()
static makeInstance($className)
static getRecordTitle($table, $row, $prep=FALSE, $forceResult=TRUE)
static getSpriteIconForRecord($table, array $row, array $options=array())
checkIfFullAccess($theDest)
static split_fileref($fileNameWithPath)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
pushErrorMessagesToFlashMessageQueue()
static getRecordPath($uid, $clause, $titleLimit, $fullTitleLimit=0)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static inList($list, $item)
static exec($command, &$output=NULL, &$returnValue=0)