Commit 8e3d1425 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Allow users to specify magicdb location (or use PHP's default)" into 1.6_STABLE

parents 909df8da 56dcc6a2
......@@ -222,6 +222,15 @@ $cfg->unziplistarg = '-l';
// you must change this to something unique, eg /tmp/mahara1/ and /tmp/mahara2/
// $cfg->unziptempdir = '/tmp/mahara/';
// Whether to use PHP's internal magicdb or an external one, and if external,
// where it's located.
// * (default) NULL: use the magicdb at /usr/share/misc/magic, or if that's a
// symlink or directory, use /usr/share/misc/magic.mgc
// * FALSE: use PHP's internal magicdb
// * Anything else: Use this value as the path to the magicdb
$cfg->pathtomagicdb = NULL;
// How often Mahara should update the last access time for users. Setting this
// lower means the field will be updated more regularly, but means a database
// write will be required for more requests.
......@@ -327,11 +327,17 @@ function file_mime_type($file, $originalfilename=false) {
// if /usr/share/misc/magic is a directory then finfo still succeeds and
// doesn't fall back onto the .mcg magic_file
// force /usr/share/misc/magic.mgc instead in this case
$MAGICPATH = get_config('pathtomagicdb');
if ($MAGICPATH === null) {
$MAGICPATH = '/usr/share/misc/magic';
$magicfile = null;
if (is_dir($MAGICPATH) or is_link($MAGICPATH)) {
$magicfile = '/usr/share/misc/magic.mgc';
else {
$magicfile = $MAGICPATH;
if (defined('FILEINFO_MIME_TYPE')) {
if ($finfo = @new finfo(FILEINFO_MIME_TYPE, $magicfile)) {
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