note 78230 added to function.escapeshellcmd

From: Date: Wed, 03 Oct 2007 17:49:14 +0000
Subject: note 78230 added to function.escapeshellcmd
Groups: php.notes 
Request: Send a blank email to php-notes+get-131046@lists.php.net to get a copy of this message
@Leon: Here is a snippet we use for ImageMajick, that doesn't require any shell escaping: <?php function imageThumbnail($from, $to, $what) { global $PARAM; if ($what == "quote") { $MAX_X = 215; //$MAX_Y = 215; } elseif ($what == 'speaker') { $MAX_X = 293; $MAX_Y = 215; } $command = "chmod 777 $to"; system($command); $command = "convert -geometry ".$MAX_X."x".$MAX_Y." '$from' '$to'"; system($command); } ?> And for the upload: <?php if ($_FILES[picture] != 'none' && $_FILES[picture][name] != '') { $uploadDir = '../images/uploads/speakers/'; // delete old picture if (file_exists($uploadDir.$_POST['photo_b'])) { @unlink($uploadDir.$_POST['photo_b']); } copy($_FILES[picture]['tmp_name'], $uploadDir.$lastId.$_FILES[picture][name]); imageThumbnail($uploadDir.$lastId.$_FILES[picture]['name'], $uploadDir.$lastId.$_FILES[picture]['name'], 'speaker'); mysql_query("UPDATE speakers SET picture = '".$lastId.$_FILES[picture]['name']."' WHERE id = '".$lastId."' LIMIT 1"); } ?> We have never had a problem going this route, hopefully you can find some use out if it. ---- Server IP: 64.71.164.2 Probable Submitter: 71.214.251.186 ---- Manual Page -- http://www.php.net/manual/en/function.escapeshellcmd.php Edit -- https://master.php.net/note/edit/78230 Del: integrated -- https://master.php.net/note/delete/78230/integrated Del: useless -- https://master.php.net/note/delete/78230/useless Del: bad code -- https://master.php.net/note/delete/78230/bad+code Del: spam -- https://master.php.net/note/delete/78230/spam Del: non-english -- https://master.php.net/note/delete/78230/non-english Del: in docs -- https://master.php.net/note/delete/78230/in+docs Del: other reasons-- https://master.php.net/note/delete/78230 Reject -- https://master.php.net/note/reject/78230 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131046) next »