[contents] Fix open_basedir warning (#832)

References #818
This commit is contained in:
ORelio 2018-09-15 14:46:11 +02:00 committed by LogMANOriginal
parent e34ef6cb4f
commit ae45a8cfee

View file

@ -163,13 +163,15 @@ function getMimeType($url) {
static $mime = null; static $mime = null;
if (is_null($mime)) { if (is_null($mime)) {
// Default values, overriden by /etc/mime.types when present
$mime = array( $mime = array(
'jpg' => 'image/jpeg', 'jpg' => 'image/jpeg',
'gif' => 'image/gif', 'gif' => 'image/gif',
'png' => 'image/png', 'png' => 'image/png',
'image' => 'image/*' 'image' => 'image/*'
); );
if (is_file('/etc/mime.types')) { // '@' is used to mute open_basedir warning, see issue #818
if (@is_readable('/etc/mime.types')) {
$file = fopen('/etc/mime.types', 'r'); $file = fopen('/etc/mime.types', 'r');
while(($line = fgets($file)) !== false) { while(($line = fgets($file)) !== false) {
$line = trim(preg_replace('/#.*/', '', $line)); $line = trim(preg_replace('/#.*/', '', $line));