Project

General

Profile

Bug #24380 ยป exec_wrapper.patch

Administrator Admin, 2010-12-21 16:56

View differences:

t3lib/class.t3lib_exec.php (revision )
// Try to get the executable with the command 'which'.
// It does the same like already done, but maybe on other paths
if (TYPO3_OS != 'WIN') {
$cmd = @exec('which ' . $cmd);
$cmd = @t3lib_div::exec('which ' . $cmd);
if (@is_executable($cmd)) {
self::$applications[$cmd]['app'] = $cmd;
self::$applications[$cmd]['path'] = dirname($cmd) . '/';
t3lib/class.t3lib_diff.php (revision )
// Perform diff.
$cmd = $GLOBALS['TYPO3_CONF_VARS']['BE']['diff_path'] . ' ' . $this->diffOptions . ' ' . $file1 . ' ' . $file2;
$res = array();
exec($cmd, $res);
t3lib_div::exec($cmd, $res);
unlink($file1);
unlink($file2);
t3lib/thumbs.php (revision )
if (!file_exists($this->output)) {
$parameters = '-sample ' . $this->size . ' ' . $this->wrapFileName($this->input) . '[0] ' . $this->wrapFileName($this->output);
$cmd = t3lib_div::imageMagickCommand('convert', $parameters);
exec($cmd);
t3lib_div::exec($cmd);
if (!file_exists($this->output)) {
$this->errorGif('No thumb','generated!',basename($this->input));
} else {
typo3/sysext/install/mod/class.tx_install.php (revision )
$src = $this->backPath.'gfx/typo3logo.gif';
if (@is_file($src) && !strstr($src,' ') && !strstr($dest,' ')) {
$cmd = t3lib_div::imageMagickCommand('convert', $src.' '.$dest, $path);
exec($cmd);
t3lib_div::exec($cmd);
} else die('No typo3/gfx/typo3logo.gif file!');
$out='';
if (@is_file($dest)) {
......
$cmd = t3lib_div::imageMagickCommand($file, $parameters, $path);
$retVal = false;
exec($cmd, $retVal);
t3lib_div::exec($cmd, $retVal);
$string = $retVal[0];
list(,$ver) = explode('Magick', $string);
list($ver) = explode(' ',trim($ver));
......
$results[] = $this->performUpdateQueries($update_statements['create_table'], $this->INSTALL['database_update']);
$results[] = $this->performUpdateQueries($remove_statements['change_table'], $this->INSTALL['database_update']);
$results[] = $this->performUpdateQueries($remove_statements['drop_table'], $this->INSTALL['database_update']);
$this->databaseUpdateErrorMessages = array();
foreach ($results as $resultSet) {
if (is_array($resultSet)) {
typo3/sysext/indexed_search/class.external_parser.php (revision )
if ($this->app['pdfinfo']) {
// Getting pdf-info:
$cmd = $this->app['pdfinfo'] . ' ' . escapeshellarg($absFile);
exec($cmd,$res);
t3lib_div::exec($cmd,$res);
$pdfInfo = $this->splitPdfInfo($res);
unset($res);
if (intval($pdfInfo['pages'])) {
......
$tempFileName = t3lib_div::tempnam('Typo3_indexer'); // Create temporary name
@unlink ($tempFileName); // Delete if exists, just to be safe.
$cmd = $this->app['pdftotext'] . ' -f ' . $low . ' -l ' . $high . ' -enc UTF-8 -q ' . escapeshellarg($absFile) . ' ' . $tempFileName;
exec($cmd);
t3lib_div::exec($cmd);
if (@is_file($tempFileName)) {
$content = t3lib_div::getUrl($tempFileName);
unlink($tempFileName);
......
case 'doc':
if ($this->app['catdoc']) {
$cmd = $this->app['catdoc'] . ' -d utf-8 ' . escapeshellarg($absFile);
exec($cmd,$res);
t3lib_div::exec($cmd,$res);
$content = implode(LF,$res);
unset($res);
$contentArr = $this->pObj->splitRegularContent($this->removeEndJunk($content));
......
case 'ppt':
if ($this->app['ppthtml']) {
$cmd = $this->app['ppthtml'] . ' ' . escapeshellarg($absFile);
exec($cmd,$res);
t3lib_div::exec($cmd,$res);
$content = implode(LF,$res);
unset($res);
$content = $this->pObj->convertHTMLToUtf8($content);
......
case 'xls':
if ($this->app['xlhtml']) {
$cmd = $this->app['xlhtml'] . ' -nc -te ' . escapeshellarg($absFile);
exec($cmd,$res);
t3lib_div::exec($cmd,$res);
$content = implode(LF,$res);
unset($res);
$content = $this->pObj->convertHTMLToUtf8($content);
......
if ($this->app['unzip']) {
// Read content.xml:
$cmd = $this->app['unzip'] . ' -p ' . escapeshellarg($absFile) . ' content.xml';
exec($cmd,$res);
t3lib_div::exec($cmd,$res);
$content_xml = implode(LF,$res);
unset($res);
// Read meta.xml:
$cmd = $this->app['unzip'] . ' -p ' . escapeshellarg($absFile) . ' meta.xml';
exec($cmd, $res);
t3lib_div::exec($cmd, $res);
$meta_xml = implode(LF,$res);
unset($res);
......
case 'rtf':
if ($this->app['unrtf']) {
$cmd = $this->app['unrtf'] . ' ' . escapeshellarg($absFile);
exec($cmd,$res);
t3lib_div::exec($cmd,$res);
$fileContent = implode(LF,$res);
unset($res);
$fileContent = $this->pObj->convertHTMLToUtf8($fileContent);
......
case 'pdf':
// Getting pdf-info:
$cmd = $this->app['pdfinfo'] . ' ' . escapeshellarg($absFile);
exec($cmd,$res);
t3lib_div::exec($cmd,$res);
$pdfInfo = $this->splitPdfInfo($res);
unset($res);
typo3/sysext/rsaauth/sv1/backends/class.tx_rsaauth_cmdline_backend.php (revision )
// secure.
$command = $this->opensslPath . ' genrsa -out ' .
escapeshellarg($privateKeyFile) . ' 1024';
exec($command);
t3lib_div::exec($command);
// Test that we got a private key
$privateKey = file_get_contents($privateKeyFile);
......
// Ok, we got the private key. Get the modulus.
$command = $this->opensslPath . ' rsa -noout -modulus -in ' .
escapeshellarg($privateKeyFile);
$value = exec($command);
$value = t3lib_div::exec($command);
if (substr($value, 0, 8) === 'Modulus=') {
$publicKey = substr($value, 8);
......
// Execute the command and capture the result
$output = array();
exec($command, $output);
t3lib_div::exec($command, $output);
// Remove the file
@unlink($privateKeyFile);
......
$result = false;
if ($this->opensslPath) {
// If path exists, test that command runs and can produce output
$test = exec($this->opensslPath . ' version');
$test = t3lib_div::exec($this->opensslPath . ' version');
$result = (substr($test, 0, 8) == 'OpenSSL ');
}
return $result;
t3lib/class.t3lib_div.php (revision )
if ($gfxConf['gif_compress'] && strtolower(substr($theFile, -4, 4)) == '.gif') { // GIF...
if (($type == 'IM' || !$type) && $gfxConf['im'] && $gfxConf['im_path_lzw']) { // IM
$cmd = self::imageMagickCommand('convert', '"' . $theFile . '" "' . $theFile . '"', $gfxConf['im_path_lzw']);
exec($cmd);
self::exec($cmd);
$returnCode = 'IM';
if (@is_file($theFile)) {
self::fixPermissions($theFile);
......
&& @is_file($theFile)) { // IM
$newFile = substr($theFile, 0, -4) . '.gif';
$cmd = self::imageMagickCommand('convert', '"' . $theFile . '" "' . $newFile . '"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']);
exec($cmd);
self::exec($cmd);
$theFile = $newFile;
if (@is_file($newFile)) {
self::fixPermissions($newFile);
......
} else {
$newFile = PATH_site . 'typo3temp/readPG_' . md5($theFile . '|' . filemtime($theFile)) . ($output_png ? '.png' : '.gif');
$cmd = self::imageMagickCommand('convert', '"' . $theFile . '" "' . $newFile . '"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path']);
exec($cmd);
self::exec($cmd);
if (@is_file($newFile)) {
self::fixPermissions($newFile);
return $newFile;
......
}
}
/**
* Wrapper function for php exec function
* Needs to be central to have better control and possible fix for safe_mode/low php version restrictions as arised with IM/GM issues
*
* @static
* @param string $command
* @param null|array $output
* @return null|array
*/
public static function exec($command, &$output = NULL, &$returnVar = 0) {
$lastLine = exec($command, $output, $returnVar);
return $lastLine;
}
/*************************
*
* STRING FUNCTIONS
typo3/show_item.php (revision )
if ($ext=='zip') {
$code = '';
$t = array();
exec('unzip -l '.$this->file, $t);
t3lib_div::exec('unzip -l '.$this->file, $t);
if (is_array($t)) {
reset($t);
next($t);
......
$compr = 'z';
}
$t = array();
exec('tar t'.$compr.'f '.$this->file, $t);
t3lib_div::exec('tar t'.$compr.'f '.$this->file, $t);
if (is_array($t)) {
foreach($t as $val) {
$code.='
t3lib/class.t3lib_extfilefunc.php (revision )
copy($theFile, $theDestFile);
} else {
$cmd = 'cp "' . $theFile . '" "' . $theDestFile . '"';
exec($cmd);
t3lib_div::exec($cmd);
}
t3lib_div::fixPermissions($theDestFile);
clearstatcache();
......
if ($this->checkPathAgainstMounts($theDestFile) && $this->checkPathAgainstMounts($theFile)) {
// No way to do this under windows!
$cmd = 'cp -R "' . $theFile . '" "' . $theDestFile . '"';
exec($cmd);
t3lib_div::exec($cmd);
clearstatcache();
if (@is_dir($theDestFile)) {
$this->writelog(2, 0, 2, 'Directory "%s" copied to "%s"', Array($theFile, $theDestFile));
......
@rename($theFile, $theDestFile);
} else {
$cmd = 'mv "' . $theFile . '" "' . $theDestFile . '"';
exec($cmd);
t3lib_div::exec($cmd);
}
clearstatcache();
if (@is_file($theDestFile)) {
......
} else {
$cmd = 'mv "' . $theFile . '" "' . $theDestFile . '"';
$errArr = array();
$retVar = 0;
exec($cmd, $errArr, $retVar);
t3lib_div::exec($cmd, $errArr);
}
clearstatcache();
if (@is_dir($theDestFile)) {
......
if ($this->checkPathAgainstMounts($theFile) && $this->checkPathAgainstMounts($theDest . '/')) {
// No way to do this under windows.
$cmd = $this->unzipPath . 'unzip -qq "' . $theFile . '" -d "' . $theDest . '"';
exec($cmd);
t3lib_div::exec($cmd);
$this->writelog(7, 0, 1, 'Unzipping file "%s" in "%s"', Array($theFile, $theDest));
return TRUE;
} else {
typo3/sysext/tsconfig_help/mod1/index.php (revision )
$output = t3lib_div::getURL($tempPath.$filename);
$cmd = 'rm -r "'.$tempPath.'"';
exec($cmd);
t3lib_div::exec($cmd);
return $output;
}
typo3/sysext/em/classes/tools/class.tx_em_tools.php (revision )
if (strlen($GLOBALS['TYPO3_CONF_VARS']['BE']['unzip_path'])) {
chdir($path);
$cmd = $GLOBALS['TYPO3_CONF_VARS']['BE']['unzip_path'] . ' -o ' . escapeshellarg($file);
exec($cmd, $list, $ret);
t3lib_div::exec($cmd, $list, $ret);
return ($ret === 0);
} else {
// we use a pure PHP unzip
t3lib/class.t3lib_stdgraphic.php (revision )
$frame = $this->noFramePrepended ? '' : '[0]';
$cmd = t3lib_div::imageMagickCommand('identify', $this->wrapFileName($imagefile) . $frame);
$returnVal = array();
exec($cmd, $returnVal);
t3lib_div::exec($cmd, $returnVal);
$splitstring = $returnVal[0];
$this->IM_commands[] = array('identify', $cmd, $returnVal[0]);
if ($splitstring) {
......
$cmd = t3lib_div::imageMagickCommand('convert', $params . ' ' . $this->wrapFileName($input) . $frame . ' ' . $this->wrapFileName($output));
$this->IM_commands[] = array($output, $cmd);
$ret = exec($cmd);
$ret = t3lib_div::exec($cmd);
t3lib_div::fixPermissions($output); // Change the permissions of the file
return $ret;
......
$cmd = t3lib_div::imageMagickCommand('combine', '-compose over +matte ' . $this->wrapFileName($input) . ' ' . $this->wrapFileName($overlay) . ' ' . $this->wrapFileName($theMask) . ' ' . $this->wrapFileName($output)); // +matte = no alpha layer in output
$this->IM_commands[] = array($output, $cmd);
$ret = exec($cmd);
$ret = t3lib_div::exec($cmd);
t3lib_div::fixPermissions($output); // Change the permissions of the file
if (is_file($theMask)) {
    (1-1/1)