From: Jason Woofenden Date: Fri, 12 Oct 2007 06:54:47 +0000 (-0400) Subject: metaform's image handler fixed. metaform's *_main() factored X-Git-Url: https://jasonwoof.com/gitweb/?p=wfpl.git;a=commitdiff_plain;h=0bdfef457a85585b652827116173a939e4172d0e metaform's image handler fixed. metaform's *_main() factored --- diff --git a/metaform/template.html b/metaform/template.html index a4c088e..e4b85d7 100644 --- a/metaform/template.html +++ b/metaform/template.html @@ -36,7 +36,7 @@
- +
~caption.html~: ~caption.html~: ~caption.html~: ~caption.html~: ~caption.html~:
~caption.html~: ~caption.html~: ~caption.html~: ~caption.html~? ~caption.html~?
~caption.html~: ~caption.html~: ~caption.html~: ~caption.html~: ~caption.html~:
~caption.html~: ~caption.html~: ~caption.html~: ~caption.html~? ~caption.html~?
diff --git a/metaform/template.php b/metaform/template.php index 6729930..d408ee8 100644 --- a/metaform/template.php +++ b/metaform/template.php @@ -82,7 +82,15 @@ function ~form_name~_display_listing($where = 'order by ~always_field~ limit 100 return true; } -function ~form_name~_main() { +function ~form_name~_main() { + $ret = _~form_name~_main(); + if($ret) { + return $ret; + } + display_messages() +} + +function _~form_name~_main() { # To remove password protection, just delete this block: if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != AUTH_USER || $_SERVER['PHP_AUTH_PW'] != AUTH_PASS) { header('WWW-Authenticate: Basic realm="' . AUTH_REALM . '"'); diff --git a/upload.php b/upload.php index e349cf0..f6a196b 100644 --- a/upload.php +++ b/upload.php @@ -185,10 +185,10 @@ function path_to($prog, $or_die = true) { function _path_to($prog, $or_die) { # relies on PHP's short-circuit mechanism - if(file_exists($convert = "/usr/local/bin/$prog") || - file_exists($convert = "/usr/bin/$prog") || - ($convert = `which convert` != '' && file_exists($convert))) { - return $convert; + if(file_exists($path = "/usr/local/bin/$prog") || + file_exists($path = "/usr/bin/$prog") || + ($path = `which $prog` != '' && file_exists($path))) { + return $path; } else { if($or_die) { die("Failed to locate '$prog' executable."); @@ -268,7 +268,7 @@ function make_thumbnail($filename, $max_width = '70', $max_height = '70') { function image_dimensions($image) { $identify = path_to('identify'); $command = "$identify -format '%wx%h' " . escapeshellarg($image); - $dimensions = substr(`$command`, 0, -1); # substr() to remove newline + $dimensions = rtrim(`$command`); if($dimensions == '') { return false; } else {