mime_content_type requires access to the file, not just the name
This commit is contained in:
		
							
								
								
									
										2
									
								
								boot.php
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								boot.php
									
									
									
									
									
								
							| @@ -9,7 +9,7 @@ require_once('include/nav.php'); | |||||||
| require_once('include/cache.php'); | require_once('include/cache.php'); | ||||||
|  |  | ||||||
| define ( 'FRIENDICA_PLATFORM',     'Friendica'); | define ( 'FRIENDICA_PLATFORM',     'Friendica'); | ||||||
| define ( 'FRIENDICA_VERSION',      '2.3.1237' ); | define ( 'FRIENDICA_VERSION',      '2.3.1238' ); | ||||||
| define ( 'DFRN_PROTOCOL_VERSION',  '2.22'    ); | define ( 'DFRN_PROTOCOL_VERSION',  '2.22'    ); | ||||||
| define ( 'DB_UPDATE_VERSION',      1118      ); | define ( 'DB_UPDATE_VERSION',      1118      ); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -38,6 +38,7 @@ function z_mime_content_type($filename) { | |||||||
|  |  | ||||||
| 		// audio/video | 		// audio/video | ||||||
| 		'mp3' => 'audio/mpeg', | 		'mp3' => 'audio/mpeg', | ||||||
|  | 		'wav' => 'audio/wav', | ||||||
| 		'qt' => 'video/quicktime', | 		'qt' => 'video/quicktime', | ||||||
| 		'mov' => 'video/quicktime', | 		'mov' => 'video/quicktime', | ||||||
| 		'ogg' => 'application/ogg', | 		'ogg' => 'application/ogg', | ||||||
| @@ -68,12 +69,13 @@ function z_mime_content_type($filename) { | |||||||
| 			return $mime_types[$ext]; | 			return $mime_types[$ext]; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	elseif (function_exists('finfo_open')) { | // can't use this because we're just passing a name, e.g. not a file that can be opened | ||||||
| 		$finfo = finfo_open(FILEINFO_MIME); | //	elseif (function_exists('finfo_open')) { | ||||||
| 		$mimetype = finfo_file($finfo, $filename); | //		$finfo = @finfo_open(FILEINFO_MIME); | ||||||
| 		finfo_close($finfo); | //		$mimetype = @finfo_file($finfo, $filename); | ||||||
| 		return $mimetype; | //		@finfo_close($finfo); | ||||||
| 	} | //		return $mimetype; | ||||||
|  | //	} | ||||||
| 	else { | 	else { | ||||||
| 		return 'application/octet-stream'; | 		return 'application/octet-stream'; | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -61,8 +61,6 @@ function wall_attach_post(&$a) { | |||||||
|  |  | ||||||
| 	$filedata = @file_get_contents($src); | 	$filedata = @file_get_contents($src); | ||||||
| 	$mimetype = z_mime_content_type($filename); | 	$mimetype = z_mime_content_type($filename); | ||||||
| 	if(((! strlen($mimetype)) || ($mimetype === 'application/octet-stream')) && function_exists('mime_content_type')) |  | ||||||
| 		$mimetype = mime_content_type($filename); |  | ||||||
| 	$hash = random_string(); | 	$hash = random_string(); | ||||||
| 	$created = datetime_convert(); | 	$created = datetime_convert(); | ||||||
| 	$r = q("INSERT INTO `attach` ( `uid`, `hash`, `filename`, `filetype`, `filesize`, `data`, `created`, `edited`, `allow_cid`, `allow_gid`,`deny_cid`, `deny_gid` ) | 	$r = q("INSERT INTO `attach` ( `uid`, `hash`, `filename`, `filetype`, `filesize`, `data`, `created`, `edited`, `allow_cid`, `allow_gid`,`deny_cid`, `deny_gid` ) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user