84 static public function exec($command, &$output = NULL, &$returnValue = 0) {
85 $lastLine =
exec($command, $output, $returnValue);
98 $gfxConf =
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'];
99 $isExt = TYPO3_OS ==
'WIN' ?
'.exe' :
'';
100 $switchCompositeParameters = FALSE;
102 $path = $gfxConf[
'im_path'];
105 $im_version = strtolower($gfxConf[
'im_version_5']);
107 if ($command ===
'combine') {
108 $command =
'composite';
111 if ($im_version ===
'gm') {
112 $switchCompositeParameters = TRUE;
113 $path = escapeshellarg(($path .
'gm' . $isExt)) .
' ' . $command;
115 if ($im_version ===
'im6') {
116 $switchCompositeParameters = TRUE;
118 $path = escapeshellarg($path . ($command ==
'composite' ?
'composite' : $command) . $isExt);
121 if (
$parameters && $command !=
'identify' && $gfxConf[
'im_useStripProfileByDefault'] && $gfxConf[
'im_stripProfileCommand'] !=
'') {
122 if (strpos(
$parameters, $gfxConf[
'im_stripProfileCommand']) === FALSE) {
134 if ($command ==
'composite' && $switchCompositeParameters) {
137 if (count($paramsArr) > 5) {
138 $tmp = $paramsArr[count($paramsArr) - 3];
139 $paramsArr[count($paramsArr) - 3] = $paramsArr[count($paramsArr) - 4];
140 $paramsArr[count($paramsArr) - 4] = $tmp;
142 $cmdLine = $path .
' ' . implode(
' ', $paramsArr);
159 if ($handler && !self::checkCommand($handler)) {
163 if (self::$applications[$cmd][
'valid']) {
167 if (isset(self::$applications[$cmd][
'valid'])) {
171 foreach (self::$paths as $path => $validPath) {
174 if (TYPO3_OS ==
'WIN') {
177 if (@is_file($path . $cmd)) {
178 self::$applications[$cmd][
'app'] = $cmd;
179 self::$applications[$cmd][
'path'] = $path;
180 self::$applications[$cmd][
'valid'] = TRUE;
183 if (@is_file($path . $cmd .
'.exe')) {
184 self::$applications[$cmd][
'app'] = $cmd .
'.exe';
185 self::$applications[$cmd][
'path'] = $path;
186 self::$applications[$cmd][
'valid'] = TRUE;
191 $filePath = realpath($path . $cmd);
192 if ($filePath && @is_executable($filePath)) {
193 self::$applications[$cmd][
'app'] = $cmd;
194 self::$applications[$cmd][
'path'] = $path;
195 self::$applications[$cmd][
'valid'] = TRUE;
204 if (TYPO3_OS !=
'WIN') {
205 $cmd = @self::exec(
'which ' . $cmd);
206 if (@is_executable($cmd)) {
207 self::$applications[$cmd][
'app'] = $cmd;
208 self::$applications[$cmd][
'path'] = dirname($cmd) .
'/';
209 self::$applications[$cmd][
'valid'] = TRUE;
225 public static function getCommand($cmd, $handler =
'', $handlerOpt =
'') {
232 $handler = self::getCommand($handler);
237 $handler .=
' ' . $handlerOpt .
' ';
241 if (!self::checkCommand($cmd)) {
244 $cmd = self::$applications[$cmd][
'path'] . self::$applications[$cmd][
'app'] .
' ';
246 return trim($handler . $cmd);
265 public static function getPaths($addInvalid = FALSE) {
273 foreach (
$paths as $path => $validPath) {
287 protected static function init() {
288 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'disable_exec_function']) {
291 if (!self::$initialized) {
293 self::$applications = self::getConfiguredApps();
294 self::$initialized = TRUE;
309 if (!is_array(self::$paths)) {
310 self::$paths = self::getPathsInternal();
317 foreach (
$paths as $path) {
319 if (!preg_match(
'#^/#', $path)) {
320 $path = PATH_site . $path;
322 if (!isset(self::$paths[$path])) {
323 if (@is_dir($path)) {
324 self::$paths[$path] = $path;
326 self::$paths[$path] = FALSE;
334 foreach (self::$paths as $path => $valid) {
336 if ($valid AND !@is_dir($path)) {
337 self::$paths[$path] = FALSE;
351 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'binSetup']) {
352 $binSetup = str_replace(array(
'\'.chr(10).\
'',
'\' . LF . \
''), LF,
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'binSetup']);
353 $pathSetup = preg_split(
'/[\n,]+/', $binSetup);
354 foreach ($pathSetup as $val) {
355 if (trim($val) ===
'') {
359 $cmdArr[$cmd][
'app'] = basename($cmdPath);
360 $cmdArr[$cmd][
'path'] = dirname($cmdPath) .
'/';
361 $cmdArr[$cmd][
'valid'] = TRUE;
376 $sysPathArr = array();
380 if (($imPath = (
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im_path_lzw'] ?:
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im_path']))) {
381 $imPath = self::fixPath($imPath);
382 $pathsArr[$imPath] = $imPath;
386 if ($GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'binPath']) {
388 foreach ($sysPath as $val) {
389 $val = self::fixPath($val);
390 $sysPathArr[$val] = $val;
396 if ($GLOBALS[
'_SERVER'][
'PATH']) {
397 $sep = (TYPO3_OS ==
'WIN' ?
';' :
':');
399 foreach ($envPath as $val) {
400 $val = self::fixPath($val);
401 $sysPathArr[$val] = $val;
406 if (TYPO3_OS !==
'WIN') {
407 $sysPathArr = array_merge($sysPathArr, array(
408 '/usr/bin/' =>
'/usr/bin/',
409 '/usr/local/bin/' =>
'/usr/local/bin/',
413 $pathsArr = array_merge($pathsArr, $sysPathArr);
426 return str_replace(
'//',
'/', $path .
'/');
static initPaths($paths='')
static checkCommand($cmd, $handler='')
static getCommand($cmd, $handler='', $handlerOpt='')
static getConfiguredApps()
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
static getPathsInternal()
static unQuoteFilenames($parameters, $unQuote=FALSE)
static imageMagickCommand($command, $parameters, $path='')
static fixWindowsFilePath($theFile)
static getPaths($addInvalid=FALSE)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static exec($command, &$output=NULL, &$returnValue=0)