Beispiel #1
0
 /**
  * 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();
     }
 }
 /**
  * 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;
             }
         }
     }
 }