make file command configurable

This commit is contained in:
Evan Prodromou 2009-06-23 05:35:20 -07:00
parent ccd9cdd618
commit 7bcaa858af
3 changed files with 9 additions and 1 deletions

4
README
View File

@ -1232,6 +1232,10 @@ supported: an array of mime types you accept to store and distribute,
setup your server to properly reckognize the types you want to setup your server to properly reckognize the types you want to
support. support.
uploads: false to disable uploading files with notices (true by default). uploads: false to disable uploading files with notices (true by default).
filecommand: The required MIME_Type library may need to use the 'file'
command. It tries the one in the Web server's path, but if
you're having problems with uploads, try setting this to the
correct value. Note: 'file' must accept '-b' and '-i' options.
For quotas, be sure you've set the upload_max_filesize and post_max_size For quotas, be sure you've set the upload_max_filesize and post_max_size
in php.ini to be large enough to handle your upload. In httpd.conf in php.ini to be large enough to handle your upload. In httpd.conf

View File

@ -116,6 +116,9 @@ class NewnoticeAction extends Action
function getUploadedFileType() { function getUploadedFileType() {
require_once 'MIME/Type.php'; require_once 'MIME/Type.php';
$cmd = &PEAR::getStaticProperty('MIME_Type', 'fileCmd');
$cmd = common_config('attachments', 'filecommand');
$filetype = MIME_Type::autoDetect($_FILES['attach']['tmp_name']); $filetype = MIME_Type::autoDetect($_FILES['attach']['tmp_name']);
if (in_array($filetype, common_config('attachments', 'supported'))) { if (in_array($filetype, common_config('attachments', 'supported'))) {
return $filetype; return $filetype;

View File

@ -241,6 +241,7 @@ $config =
'user_quota' => 50000000, 'user_quota' => 50000000,
'monthly_quota' => 15000000, 'monthly_quota' => 15000000,
'uploads' => true, 'uploads' => true,
'filecommand' => '/usr/bin/file',
), ),
'group' => 'group' =>
array('maxaliases' => 3), array('maxaliases' => 3),