[geeklog-cvs] geeklog: Check the MIME type, not the file extension
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sat Nov 15 15:13:01 EST 2008
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/3df6765ee4fa
changeset: 6468:3df6765ee4fa
user: Dirk Haun <dirk at haun-online.de>
date: Sat Nov 15 18:59:54 2008 +0100
description:
Check the MIME type, not the file extension
diffstat:
1 file changed, 7 insertions(+), 3 deletions(-)
system/classes/upload.class.php | 10 +++++++---
diffs (42 lines):
diff -r 4b8a2444f299 -r 3df6765ee4fa system/classes/upload.class.php
--- a/system/classes/upload.class.php Sat Nov 15 17:44:44 2008 +0100
+++ b/system/classes/upload.class.php Sat Nov 15 18:59:54 2008 +0100
@@ -534,6 +534,7 @@
. $newheight . ' using ' . $this->_imageLib);
if ($this->_imageLib == 'imagemagick') {
+
$newsize = $newwidth . 'x' . $newheight;
$quality = '';
if ($this->_jpegQuality > 0) {
@@ -556,17 +557,19 @@
$filename = $this->_fileUploadDirectory . '/' . $this->_getDestinationName();
$cmd_end = " '" . $filename . "' | " . $this->_pathToNetPBM . 'pnmscale -xsize=' . $newwidth . ' -ysize=' . $newheight . ' | ' . $this->_pathToNetPBM;
// convert to pnm, resize, convert back
- if (eregi ('\.png', $filename)) {
+ if (($this->_currentFile['type'] == 'image/png') ||
+ ($this->_currentFile['type'] == 'image/x-png')) {
$tmpfile = $this->_fileUploadDirectory . '/tmp.png';
$cmd .= 'pngtopnm ' . $cmd_end . 'pnmtopng > ' . $tmpfile;
- } else if (eregi ('\.(jpg|jpeg)', $filename)) {
+ } elseif (($this->_currentFile['type'] == 'image/jpeg') ||
+ ($this->_currentFile['type'] == 'image/pjpeg')) {
$tmpfile = $this->_fileUploadDirectory . '/tmp.jpg';
$quality = '';
if ($this->_jpegQuality > 0) {
$quality = sprintf(' -quality=%d', $this->_jpegQuality);
}
$cmd .= 'jpegtopnm ' . $cmd_end . 'pnmtojpeg' . $quality . ' > ' . $tmpfile;
- } else if (eregi ('\.gif', $filename)) {
+ } elseif ($this->_currentFile['type'] == 'image/gif') {
$tmpfile = $this->_fileUploadDirectory . '/tmp.gif';
$cmd .= 'giftopnm ' . $cmd_end . 'ppmquant 256 | '
. $this->_pathToNetPBM . 'ppmtogif > ' . $tmpfile;
@@ -711,6 +714,7 @@
exit;
}
}
+
}
if ($retval > 0) {
More information about the geeklog-cvs
mailing list