aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_upload.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/functions_upload.php')
-rw-r--r--phpBB/includes/functions_upload.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php
index ca2618c96a..9f02c5f74e 100644
--- a/phpBB/includes/functions_upload.php
+++ b/phpBB/includes/functions_upload.php
@@ -305,6 +305,25 @@ class filespec
{
$this->mimetype = $this->image_info['mime'];
}
+
+ // Check image type
+ $types = $this->upload->image_types();
+
+ if (!isset($types[$this->image_info[2]]) || !in_array($this->extension, $types[$this->image_info[2]]))
+ {
+ if (!isset($types[$this->image_info[2]]))
+ {
+ $this->error[] = sprintf($user->lang['IMAGE_FILETYPE_INVALID'], $this->image_info[2], $this->mimetype);
+ }
+ else
+ {
+ $this->error[] = sprintf($user->lang['IMAGE_FILETYPE_MISMATCH'], $types[$this->image_info[2]][0], $this->extension);
+ }
+ }
+ }
+ else
+ {
+ $this->error[] = $user->lang['UNABLE_GET_IMAGE_SIZE'];
}
}
@@ -790,6 +809,31 @@ class fileupload
{
return (isset($_FILES[$form_name]) && $_FILES[$form_name]['name'] != 'none') ? true : false;
}
+
+ /**
+ * Return image type/extension mapping
+ */
+ function image_types()
+ {
+ return array(
+ 1 => array('gif'),
+ 2 => array('jpg', 'jpeg'),
+ 3 => array('png'),
+ 4 => array('swf'),
+ 5 => array('psd'),
+ 6 => array('bmp'),
+ 7 => array('tif', 'tiff'),
+ 8 => array('tif', 'tiff'),
+ 9 => array('jpg', 'jpeg'),
+ 10 => array('jpg', 'jpeg'),
+ 11 => array('jpg', 'jpeg'),
+ 12 => array('jpg', 'jpeg'),
+ 13 => array('swc'),
+ 14 => array('iff'),
+ 15 => array('wbmp'),
+ 16 => array('xbm'),
+ );
+ }
}
?> \ No newline at end of file