mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-24 02:48:56 +00:00
Merge remote-tracking branch 'Fyorl/ticket/10963' into develop
* Fyorl/ticket/10963: [ticket/10963] filespec::get_mimetype now used [ticket/10963] Removed superfluous ternary statement and strpos now stricter [ticket/10963] Modified filespec::is_image() to check actual mimetype
This commit is contained in:
commit
c54d74ec0e
1 changed files with 6 additions and 9 deletions
|
@ -151,7 +151,8 @@ class filespec
|
|||
*/
|
||||
function is_image()
|
||||
{
|
||||
return (strpos($this->mimetype, 'image/') !== false) ? true : false;
|
||||
$mimetype = $this->get_mimetype($this->filename);
|
||||
return (strpos($mimetype, 'image/') === 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -200,17 +201,12 @@ class filespec
|
|||
}
|
||||
|
||||
/**
|
||||
* Get mimetype. Utilize mime_content_type if the function exist.
|
||||
* Not used at the moment...
|
||||
* Get mimetype. Utilises the finfo class.
|
||||
*/
|
||||
function get_mimetype($filename)
|
||||
{
|
||||
$mimetype = '';
|
||||
|
||||
if (function_exists('mime_content_type'))
|
||||
{
|
||||
$mimetype = mime_content_type($filename);
|
||||
}
|
||||
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
||||
$mimetype = $finfo->file($filename);
|
||||
|
||||
// Some browsers choke on a mimetype of application/octet-stream
|
||||
if (!$mimetype || $mimetype == 'application/octet-stream')
|
||||
|
@ -342,6 +338,7 @@ class filespec
|
|||
|
||||
// Remove temporary filename
|
||||
@unlink($this->filename);
|
||||
$this->filename = $this->destination_file;
|
||||
|
||||
if (sizeof($this->error))
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue