Mercurial > hg > fapweb
changeset 912:514d460c60a9
Fixes, etc.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 27 Nov 2014 10:58:41 +0200 |
parents | f007b3081872 |
children | 211de08d40fd |
files | faptool.php |
diffstat | 1 files changed, 27 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/faptool.php Thu Nov 27 10:53:30 2014 +0200 +++ b/faptool.php Thu Nov 27 10:58:41 2014 +0200 @@ -6,17 +6,23 @@ stCheckCLIExec(); -function wtExec($exe, $args) +function wtExec($exe, $args, $expect = 0) { echo "@@EXEC: ".$exe." ".$args."\n"; - if (passthru($exe." ".$args) == 0) + exec(escapeshellcmd($exe)." ".$args, $output, $code); + if ($code !== $expect) { - echo "Error executing ".$exe.":\n".$args."\n"; + echo + "Error executing ".$exe.": ".$code."\n".$args."\n". + "------------------------------------------------\n". + implode("\n", $output). + "------------------------------------------------\n"; return FALSE; } return TRUE; } + function wtExecOrDie($exe, $args) { if (wtExec($exe, $args) === false) @@ -27,6 +33,7 @@ function wtConvertImage($inFilename, $inFileType, $outFilename, $setDim, $setFormat, $setQuality, $thumb) { global $setPreviewPath; + $isTemp = FALSE; if (($outDim = stGetSetting($setDim)) === FALSE || ($outFormat = stGetSetting($osetFormat)) === FALSE || @@ -39,9 +46,18 @@ { // Oh great .. we need gfxconv here because Imagick handles ILBM like shit $filename = tempnam($setPreviewPath, "tmp"); - wtExecOrDie( + $isTemp = TRUE; + if (wtExec( "/usr/local/bin/gfxconv", - escapeshellarg($inFilename)." -f png -o ".escapeshellarg($filename)); + escapeshellarg($inFilename)." -f png -o ".escapeshellarg($filename)) === false) + return FALSE; + + if (!file_exists($filename)) + { + echo "ERROR: gfxconv did not output a temporary conversion inbetween.\n"; + return FALSE; + } + } else $filename = $inFilename; @@ -52,7 +68,10 @@ // Create conversion entity $img = new Imagick($filename); if ($img === false) - die("Oh noes! ImageMagick could not digest the file '".$filename."' (".$inFilename.")\n"); + { + echo "ERROR: Oh noes! ImageMagick could not digest the file '".$filename."' (".$inFilename.")\n"; + return FALSE; + } // Get dimensions, setup background $dim = $img->getImageGeometry(); @@ -177,7 +196,7 @@ echo "Attempting to scan archive file '".$filename."' ...\n"; - if (wtUnpackArchiveTo($efile["filetype"], $filename, $path)) === false) + if (wtUnpackArchiveTo($efile["filetype"], $filename, $path) === false) return FALSE; // Scan through files ... @@ -319,7 +338,7 @@ "\n". " clean [delete]\n". " Clean files marked to be deleted. This includes any old\n". - " or stale preview files and entry files.\n" + " or stale preview files and entry files.\n". " Without 'delete' parameter just checks and shows what would\n". " be deleted, but with it ACTUALLY DELETES THE FILES, SO BE CAREFUL!\n". "\n".