| 1 |
<?php
|
| 2 |
// $Id: mimedetect.install,v 1.7 2009/04/15 19:19:18 drewish Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_install().
|
| 6 |
*/
|
| 7 |
function mimedetect_install() {
|
| 8 |
}
|
| 9 |
|
| 10 |
/**
|
| 11 |
* Implementation of hook_uninstall().
|
| 12 |
*/
|
| 13 |
function mimedetect_uninstall() {
|
| 14 |
variable_del('mimedetect_enable_file_binary');
|
| 15 |
variable_del('mimedetect_file_binary');
|
| 16 |
}
|
| 17 |
|
| 18 |
/**
|
| 19 |
* Implementation of hook_requirements().
|
| 20 |
*/
|
| 21 |
function mimedetect_requirements($phase) {
|
| 22 |
$requirements = array();
|
| 23 |
|
| 24 |
$t = get_t();
|
| 25 |
$requirement = array(
|
| 26 |
'title' => $t('Mime type detection'),
|
| 27 |
);
|
| 28 |
|
| 29 |
if (extension_loaded('fileinfo')) {
|
| 30 |
$requirement['value'] = $t('PHP Fileinfo Extension');
|
| 31 |
if (!$finfo = @finfo_open(FILEINFO_MIME, variable_get('mimedetect_magic', drupal_get_path('module', 'mimedetect') .'/magic'))) {
|
| 32 |
$requirement['description'] = $t('Fileinfo could not load the magic file. It could be corrupted. Try reinstalling the magic file distributed with the MimeDetect module.');
|
| 33 |
$requirement['severity'] = REQUIREMENT_ERROR;
|
| 34 |
}
|
| 35 |
}
|
| 36 |
else if (variable_get('mimedetect_enable_file_binary', FALSE)) {
|
| 37 |
$binary = variable_get('mimedetect_file_binary', '/usr/bin/file');
|
| 38 |
$requirement['value'] = $t("UNIX 'file' Command");
|
| 39 |
if (!is_executable($binary)){
|
| 40 |
if (!file_exists($binary)) {
|
| 41 |
$requirement['description'] = $t("The file %path does not exist or is not readable by your webserver. ", array('%path' => $binary));
|
| 42 |
}
|
| 43 |
else {
|
| 44 |
$requirement['description'] = $t("The file %path is not executable by your webserver.", array('%path' => $binary));
|
| 45 |
}
|
| 46 |
$requirement['severity'] = REQUIREMENT_ERROR;
|
| 47 |
}
|
| 48 |
}
|
| 49 |
else {
|
| 50 |
$requirement['value'] = $t('File Extension');
|
| 51 |
$requirement['description'] = $t("MimeDetect is using the browser supplied filename for file extension lookups. It is strongly recommended that you install and configure the PHP Fileinfo Extension or the UNIX 'file' command to provide more accurate severside mime type detection.");
|
| 52 |
$requirement['severity'] = REQUIREMENT_WARNING;
|
| 53 |
}
|
| 54 |
|
| 55 |
return array('mimedetect' => $requirement);
|
| 56 |
}
|