# HG changeset patch # User Matti Hamalainen # Date 1448019560 -7200 # Node ID b17c41ffe43b2a2bb8ee8a15bc68adc4db1d2fbe # Parent f188caaedf0f18d065b318cf5292cf40a3751ed4 Implement wtGetExecutable() and use it for getting executable names for external utilities for faptool. diff -r f188caaedf0f -r b17c41ffe43b faptool.php --- 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;