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. Calc the size of folders.
*/ */
"foldersize": { "foldersize": {
"enabled": false "enabled": true
}, },
/* /*

View file

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

View file

@ -58,7 +58,7 @@ class Item {
$options = $app->get_options(); $options = $app->get_options();
if ($options["foldersize"]["enabled"]) { if ($options["foldersize"]["enabled"]) {
$cmd = str_replace("[DIR]", escapeshellarg($this->abs_path), Item::$FOLDER_SIZE_CMD); $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 { } else {
$this->size = @filesize($this->abs_path); $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)) { 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("[SOURCE]", escapeshellarg($source_abs_path), $cmd);
$cmd = str_replace("[TARGET]", escapeshellarg($capture_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; return file_exists($capture_abs_path) ? $capture_abs_path : null;

View file

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