Mercurial > hg > fapweb
changeset 1042:b17c41ffe43b
Implement wtGetExecutable() and use it for getting executable names for
external utilities for faptool.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 20 Nov 2015 13:39:20 +0200 |
parents | f188caaedf0f |
children | c0e21a405256 |
files | faptool.php |
diffstat | 1 files changed, 16 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/faptool.php Fri Nov 20 10:48:18 2015 +0200 +++ b/faptool.php Fri Nov 20 13:39:20 2015 +0200 @@ -17,6 +17,15 @@ require_once "msite.inc.php"; +function wtGetExecutable($name, $path = FALSE) +{ + if (stChkSetting($name)) + return stGetSetting($name); + else + return $name; +} + + function wtConvertImage($inFilename, $outFilename, $outDim, $outFormat, $outQuality, $thumb, $useGfxConv) { global $setPreviewPath; @@ -27,8 +36,7 @@ // Oh great .. we need gfxconv here because Imagick handles ILBM like shit $tmpFilename = tempnam($setPreviewPath, "tmp"); $isTemp = TRUE; - if (wtExec( - "/usr/local/bin/gfxconv", + if (wtExec(wtGetExecutable("gfxconv"), escapeshellarg($inFilename)." -f png -o ".escapeshellarg($tmpFilename), 0) === false) return FALSE; @@ -92,7 +100,7 @@ $schannels = intval(stGetSetting("sampleChannels")); return wtExec( - "/usr/local/bin/openmpt123" + wtGetExecutable("openmpt123") , "--force --quiet ". "--samplerate ".$sfreq." ". @@ -115,7 +123,7 @@ $optStr .= $okey." ".$oval." "; return wtExec( - "/usr/local/bin/avconv", + wtGetExecutable("avconv"), "-y -v 1 -t ".intval($sduration)." ". "-i ".escapeshellarg($inFilename). " ".$optStr." -ac ".$schannels. @@ -174,22 +182,22 @@ switch ($atype) { case "LHA": - $exe = "/usr/bin/lha"; + $exe = wtGetExecutable("lha"); $args = "x ".escapeshellarg($filename); break; case "ZIP": - $exe = "/usr/bin/unzip"; + $exe = wtGetExecutable("unzip"); $args = "-d ".escapeshellarg($path)." ".escapeshellarg($filename); break; case "RAR": - $exe = "/usr/bin/rar"; + $exe = wtGetExecutable("rar"); $args = "x -w".escapeshellarg($path)." ".escapeshellarg($filename); break; case "7ZIP": - $exe = "/usr/bin/7z"; + $exe = wtGetExecutable("7z"); $args = "x -o".escapeshellarg($path)." ".escapeshellarg($filename); break;