コード例 #1
0
 /**
  * @param string $originalFileName
  * @param string $temporaryFileName
  * @param array $configuration
  */
 protected function resizeImage($originalFileName, $temporaryFileName, $configuration)
 {
     // Create the temporary file
     if (empty($GLOBALS['TYPO3_CONF_VARS']['GFX']['im'])) {
         return;
     }
     if (file_exists($originalFileName)) {
         $arguments = CommandUtility::escapeShellArguments(array('width' => $configuration['width'], 'height' => $configuration['height'], 'originalFileName' => $originalFileName, 'temporaryFileName' => $temporaryFileName));
         $parameters = '-sample ' . $arguments['width'] . 'x' . $arguments['height'] . ' ' . $arguments['originalFileName'] . '[0] ' . $arguments['temporaryFileName'];
         $cmd = GeneralUtility::imageMagickCommand('convert', $parameters) . ' 2>&1';
         CommandUtility::exec($cmd);
     }
     if (!file_exists($temporaryFileName)) {
         // Create a error image
         $graphicalFunctions = $this->getGraphicalFunctionsObject();
         $graphicalFunctions->getTemporaryImageWithText($temporaryFileName, 'No thumb', 'generated!', basename($originalFileName));
     }
 }
コード例 #2
0
ファイル: Scheduler.php プロジェクト: rickymathew/TYPO3.CMS
 /**
  * Schedule the next run of scheduler
  * For the moment only the "at"-daemon is used, and only if it is enabled
  *
  * @return bool Successfully scheduled next execution using "at"-daemon
  * @see tx_scheduler::fetchTask()
  */
 public function scheduleNextSchedulerRunUsingAtDaemon()
 {
     if ((int) $this->extConf['useAtdaemon'] !== 1) {
         return false;
     }
     /** @var $registry Registry */
     $registry = GeneralUtility::makeInstance(Registry::class);
     // Get at job id from registry and remove at job
     $atJobId = $registry->get('tx_scheduler', 'atJobId');
     if (MathUtility::canBeInterpretedAsInteger($atJobId)) {
         shell_exec('atrm ' . (int) $atJobId . ' 2>&1');
     }
     // Can not use fetchTask() here because if tasks have just executed
     // they are not in the list of next executions
     $tasks = $this->fetchTasksWithCondition('');
     $nextExecution = false;
     foreach ($tasks as $task) {
         try {
             /** @var $task Task\AbstractTask */
             $tempNextExecution = $task->getNextDueExecution();
             if ($nextExecution === false || $tempNextExecution < $nextExecution) {
                 $nextExecution = $tempNextExecution;
             }
         } catch (\OutOfBoundsException $e) {
             // The event will not be executed again or has already ended - we don't have to consider it for
             // scheduling the next "at" run
         }
     }
     if ($nextExecution !== false) {
         if ($nextExecution > $GLOBALS['EXEC_TIME']) {
             $startTime = strftime('%H:%M %F', $nextExecution);
         } else {
             $startTime = 'now+1minute';
         }
         $cliDispatchPath = PATH_site . 'typo3/cli_dispatch.phpsh';
         list($cliDispatchPathEscaped, $startTimeEscaped) = CommandUtility::escapeShellArguments(array($cliDispatchPath, $startTime));
         $cmd = 'echo ' . $cliDispatchPathEscaped . ' scheduler | at ' . $startTimeEscaped . ' 2>&1';
         $output = shell_exec($cmd);
         $outputParts = '';
         foreach (explode(LF, $output) as $outputLine) {
             if (GeneralUtility::isFirstPartOfStr($outputLine, 'job')) {
                 $outputParts = explode(' ', $outputLine, 3);
                 break;
             }
         }
         if ($outputParts[0] === 'job' && MathUtility::canBeInterpretedAsInteger($outputParts[1])) {
             $atJobId = (int) $outputParts[1];
             $registry->set('tx_scheduler', 'atJobId', $atJobId);
         }
     }
     return true;
 }