Commit 4ab53213 authored by Richard Mansfield's avatar Richard Mansfield

Use file_mime_type in place of mime_content_type

Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 2ae7b0b4
......@@ -191,8 +191,8 @@ function adduser_validate(Pieform $form, $values) {
}
if ($values['leap2afile']['type'] == 'application/octet-stream') {
// the browser wasn't sure, so use mime_content_type to guess
$mimetype = mime_content_type($values['leap2afile']['tmp_name']);
require_once('file.php');
$mimetype = file_mime_type($values['leap2afile']['tmp_name']);
}
else {
$mimetype = $values['leap2afile']['type'];
......
......@@ -253,10 +253,11 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
}
// Note: this data is passed (eventually) to ArtefactType->__construct,
// which calls strtotime on the dates for us
require_once('file.php');
$data = (object)array(
'title' => (string)$blogpostentry->title . ' ' . get_string('attachment', 'artefact.blog'),
'owner' => $importer->get('usr'),
'filetype' => mime_content_type($pathname),
'filetype' => file_mime_type($pathname),
);
return ArtefactTypeFile::save_file($pathname, $data, $importer->get('usrobj'), true);
}
......
......@@ -263,9 +263,10 @@ function xmldb_artefact_file_upgrade($oldversion=0) {
if ($oldversion < 2010012702) {
if ($records = get_records_sql_array("SELECT * FROM {artefact_file_files} WHERE filetype='application/octet-stream'", array())) {
require_once('file.php');
foreach ($records as &$r) {
$path = get_config('dataroot') . 'artefact/file/originals/' . $r->fileid % 256 . '/' . $r->fileid;
set_field('artefact_file_files', 'filetype', mime_content_type($path), 'fileid', $r->fileid);
set_field('artefact_file_files', 'filetype', file_mime_type($path), 'fileid', $r->fileid);
}
}
}
......
......@@ -847,9 +847,10 @@ class ArtefactTypeFile extends ArtefactTypeFileBase {
}
$data->size = $size;
// the browser wasn't sure, so use mime_content_type to guess
if($um->file['type'] == 'application/octet-stream') {
$data->filetype = mime_content_type($um->file['tmp_name']);
if ($um->file['type'] == 'application/octet-stream') {
// the browser wasn't sure, so use file_mime_type to guess
require_once('file.php');
$data->filetype = file_mime_type($um->file['tmp_name']);
}
else {
$data->filetype = $um->file['type'];
......
......@@ -403,7 +403,8 @@ abstract class ImporterTransport {
safe_require('artefact', 'file');
$ziptypes = PluginArtefactFile::get_mimetypes_from_description('zip');
if (empty($this->mimetype)) {
$this->mimetype = mime_content_type($this->importfile);
require_once('file.php');
$this->mimetype = file_mime_type($this->importfile);
}
// if we don't have a zipfile, just move the import file to the extract location
if (!in_array($this->mimetype, $ziptypes)) {
......@@ -514,8 +515,9 @@ class MnetImporterTransport extends ImporterTransport {
}
// detect the filetype and bail if it's not a zip file
safe_require('artefact', 'file');
require_once('file.php');
$ziptypes = PluginArtefactFile::get_mimetypes_from_description('zip');
$this->mimetype = mime_content_type($this->tempdir . $this->importfilename);
$this->mimetype = file_mime_type($this->tempdir . $this->importfilename);
if (!in_array($this->mimetype, $ziptypes)) {
throw new ImportException($this->importer, 'Not a valid zipfile - mimetype was ' . $this->mimetype);
}
......
......@@ -43,7 +43,6 @@ $string['registerglobals'] = 'You have dangerous PHP settings, register_globals
$string['magicquotesgpc'] = 'You have dangerous PHP settings, magic_quotes_gpc is on. Mahara is trying to work around this, but you should really fix it';
$string['magicquotesruntime'] = 'You have dangerous PHP settings, magic_quotes_runtime is on. Mahara is trying to work around this, but you should really fix it';
$string['magicquotessybase'] = 'You have dangerous PHP settings, magic_quotes_sybase is on. Mahara is trying to work around this, but you should really fix it';
$string['mimemagicnotloaded'] = 'Your server may have trouble detecting file types, please install the PHP extension Fileinfo (PHP 5.3+) or the mime_magic extension(earlier PHP versions).';
$string['safemodeon'] = 'Your server appears to be running safe mode. Mahara does not support running in safe mode. You must turn this off in either the php.ini file, or in your apache config for the site.
......
......@@ -76,12 +76,6 @@ function ensure_sanity() {
if (!extension_loaded('dom')) {
throw new ConfigSanityException(get_string('domextensionnotloaded', 'error'));
}
if (!function_exists('mime_content_type')) {
log_environ(get_string('mimemagicnotloaded', 'error'));
function mime_content_type($filename) {
return 'application/octet-stream';
}
}
//Check for freetype in the gd extension
$gd_info = gd_info();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment