Replace backtick operator with exec.

This commit is contained in:
Lars Jung 2014-05-08 01:31:42 +02:00
parent a75f1b61bc
commit 364f71dd08
5 changed files with 12 additions and 15 deletions

View File

@ -137,7 +137,7 @@ Options
Calc the size of folders.
*/
"foldersize": {
"enabled": false
"enabled": true
},
/*

View File

@ -301,19 +301,16 @@ class App {
}
$exif = function_exists("exif_thumbnail");
$cache = @is_writable($this->get_cache_abs_path());
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$tar = @preg_match("/tar(.exe)?$/i", `which tar`) > 0;
$zip = @preg_match("/zip(.exe)?$/i", `which zip`) > 0;
$convert = @preg_match("/convert(.exe)?$/i", `which convert`) > 0;
$ffmpeg = @preg_match("/ffmpeg(.exe)?$/i", `which ffmpeg`) > 0;
$du = @preg_match("/du(.exe)?$/i", `which du`) > 0;
if (strtoupper(substr(PHP_OS, 0, 3)) === "WIN") {
$cmd = "which";
} else {
$tar = @preg_match("/tar(.exe)?$/i", `command -v tar`) > 0;
$zip = @preg_match("/zip(.exe)?$/i", `command -v zip`) > 0;
$convert = @preg_match("/convert(.exe)?$/i", `command -v convert`) > 0;
$ffmpeg = @preg_match("/ffmpeg(.exe)?$/i", `command -v ffmpeg`) > 0;
$du = @preg_match("/du(.exe)?$/i", `command -v du`) > 0;
$cmd = "command -v";
}
$tar = @preg_match("/tar(.exe)?$/i", exec_cmd($cmd . " tar")) > 0;
$zip = @preg_match("/zip(.exe)?$/i", exec_cmd($cmd . " zip")) > 0;
$convert = @preg_match("/convert(.exe)?$/i", exec_cmd($cmd . " convert")) > 0;
$ffmpeg = @preg_match("/ffmpeg(.exe)?$/i", exec_cmd($cmd . " ffmpeg")) > 0;
$du = @preg_match("/du(.exe)?$/i", exec_cmd($cmd . " du")) > 0;
return array(
"idx" => $this->app_abs_href . "server/php/index.php",

View File

@ -58,7 +58,7 @@ class Item {
$options = $app->get_options();
if ($options["foldersize"]["enabled"]) {
$cmd = str_replace("[DIR]", escapeshellarg($this->abs_path), Item::$FOLDER_SIZE_CMD);
$this->size = intval(preg_replace("/\s.*$/", "", `$cmd`), 10) * 1024;
$this->size = intval(preg_replace("/\s.*$/", "", exec_cmd($cmd)), 10) * 1024;
}
} else {
$this->size = @filesize($this->abs_path);

View File

@ -94,7 +94,7 @@ class Thumb {
if (!file_exists($capture_abs_path) || filemtime($source_abs_path) >= filemtime($capture_abs_path)) {
$cmd = str_replace("[SOURCE]", escapeshellarg($source_abs_path), $cmd);
$cmd = str_replace("[TARGET]", escapeshellarg($capture_abs_path), $cmd);
`$cmd`;
exec_cmd($cmd);
}
return file_exists($capture_abs_path) ? $capture_abs_path : null;

View File

@ -78,7 +78,7 @@ function exec_cmd($cmd) {
$rc = null;
exec($cmd, $lines, $rc);
return $lines;
return implode('\n', $lines);
}
?>