/** * Performing the file admin action: * Initializes the objects, setting permissions, sending data to object. * * @return void */ public function main() { // Initializing: $this->fileProcessor->setActionPermissions(); $this->fileProcessor->setExistingFilesConflictMode($this->overwriteExistingFiles); // Checking referrer / executing: $refInfo = parse_url(GeneralUtility::getIndpEnv('HTTP_REFERER')); $httpHost = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'); if ($httpHost !== $refInfo['host'] && $this->vC !== $this->getBackendUser()->veriCode() && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer']) { $this->fileProcessor->writeLog(0, 2, 1, 'Referrer host "%s" and server host "%s" did not match!', [$refInfo['host'], $httpHost]); } else { $this->fileProcessor->start($this->file); $this->fileData = $this->fileProcessor->processData(); } }
/** * Performing the file admin action: * Initializes the objects, setting permissions, sending data to object. * * @return void */ public function main() { // Initializing: $this->fileProcessor->init(array(), $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']); $this->fileProcessor->setActionPermissions(); $this->fileProcessor->dontCheckForUnique = $this->overwriteExistingFiles ? 1 : 0; // Checking referrer / executing: $refInfo = parse_url(GeneralUtility::getIndpEnv('HTTP_REFERER')); $httpHost = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'); if ($httpHost != $refInfo['host'] && $this->vC != $this->getBackendUser()->veriCode() && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer'] && $GLOBALS['CLIENT']['BROWSER'] != 'flash') { $this->fileProcessor->writeLog(0, 2, 1, 'Referrer host "%s" and server host "%s" did not match!', array($refInfo['host'], $httpHost)); } else { $this->fileProcessor->start($this->file); $this->fileData = $this->fileProcessor->processData(); } }
/** * @test */ public function copyFolderInLocalStorage() { // Computes a $folderIdentifier which looks like 8:/folderName.txt where 8 is the storage Uid $storage = $this->getDefaultStorage(); $folderIdentifier = $storage->getUid() . ':/' . $this->copyFolderNameInput; $targetFolder = $this->getRootFolderIdentifier() . $this->newFolderNameInput; // Defines values $fileValues = array('newfolder' => array(array('data' => $this->newFolderNameInput, 'target' => $this->getRootFolderIdentifier()), array('data' => $this->copyFolderNameInput, 'target' => $this->getRootFolderIdentifier())), 'copy' => array(array('data' => $folderIdentifier, 'target' => $targetFolder))); $this->fileProcessor->start($fileValues); $results = $this->fileProcessor->processData(); $folderObject = NULL; if (!empty($results['copy'][0])) { $folderObject = $results['copy'][0]; } // remove parent folder if (!empty($results['newfolder'][0])) { $this->objectsToTearDown[] = $results['newfolder'][0]; } if (!empty($results['newfolder'][1])) { $this->objectsToTearDown[] = $results['newfolder'][1]; } $this->assertEquals(TRUE, $folderObject instanceof \TYPO3\CMS\Core\Resource\Folder); }
/** * Check if a file has been uploaded * * @throws \InvalidArgumentException * @throws \UnexpectedValueException * @return void */ public function checkUpload() { $file = GeneralUtility::_GP('file'); // Initializing: $this->fileProcessor = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::class); $this->fileProcessor->init(array(), $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']); $this->fileProcessor->setActionPermissions(); $this->fileProcessor->setExistingFilesConflictMode((int) GeneralUtility::_GP('overwriteExistingFiles') === 1 ? DuplicationBehavior::REPLACE : DuplicationBehavior::CANCEL); // Checking referer / executing: $refInfo = parse_url(GeneralUtility::getIndpEnv('HTTP_REFERER')); $httpHost = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'); if ($httpHost != $refInfo['host'] && !$GLOBALS['$TYPO3_CONF_VARS']['SYS']['doNotCheckReferer'] && $this->vC != $this->getBackendUser()->veriCode()) { $this->fileProcessor->writeLog(0, 2, 1, 'Referer host "%s" and server host "%s" did not match!', array($refInfo['host'], $httpHost)); } else { $this->fileProcessor->start($file); $result = $this->fileProcessor->processData(); if (!empty($result['upload'])) { foreach ($result['upload'] as $uploadedFiles) { $this->uploadedFiles += $uploadedFiles; } } } }