JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
re-licensed under GPLv3
[wfpl.git] / upload.php
index e349cf0..1bca71a 100644 (file)
@@ -2,21 +2,18 @@
 
 #  Copyright (C) 2007 Jason Woofenden
 #
-#  This file is part of wfpl.
-#
-#  wfpl is free software; you can redistribute it and/or modify it under the
-#  terms of the GNU Lesser General Public License as published by the Free
-#  Software Foundation; either version 2.1 of the License, or (at your option)
-#  any later version.
-#
-#  wfpl is distributed in the hope that it will be useful, but WITHOUT ANY
-#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-#  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
-#  more details.
-#
-#  You should have received a copy of the GNU Lesser General Public License
-#  along with wfpl; if not, write to the Free Software Foundation, Inc., 51
-#  Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+#  This program is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#  
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#  
+#  You should have received a copy of the GNU General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 # This file contains functions to accept files being uplodad with the <input
@@ -185,10 +182,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 +265,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 {