mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-01 14:30:32 +02:00
check file type
git-svn-id: file:///svn/phpbb/trunk@6354 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -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'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user