Skip to content
Snippets Groups Projects
Commit c0ed4430 authored by Giovannoni Laurent's avatar Giovannoni Laurent
Browse files

evo : control mime type on store resource

parent 97eab691
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,7 @@
//Loads the required class
try {
require_once 'core/class/class_request.php';
require_once 'core/class/docservers.php';
require_once 'core/docservers_tools.php';
require_once 'core/core_tables.php';
......
......@@ -531,3 +531,54 @@ function Ds_isCompleteFile($file, $delay=500, $pointer=0)
return Ds_isCompleteFile($file, $delay, $currentPos);
}
}
/**
* Check the mime type of a file with the extension config file
* Return array with the status of the check and the mime type of the file
* @param string $filePath
* @param array
*/
function Ds_isFileTypeAllowed($filePath)
{
$mimeType = Ds_getMimeType(
$filePath
);
if (file_exists($_SESSION['config']['corepath'] . 'custom'
. DIRECTORY_SEPARATOR.$_SESSION['custom_override_id']
. DIRECTORY_SEPARATOR
. 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
. DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR
. 'extensions.xml')
) {
$path = $_SESSION['config']['corepath'] . 'custom'
. DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
. DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR
. $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . 'xml'
. DIRECTORY_SEPARATOR . 'extensions.xml';
} else {
$path = 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
. DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'extensions.xml';
}
$xmlconfig = simplexml_load_file($path);
$ext_list = array();
$i = 0;
foreach($xmlconfig->FORMAT as $FORMAT) {
$ext_list[$i] = array(
'name' => (string) $FORMAT->name,
'mime' => (string) $FORMAT->mime
);
$i++;
}
$type_state = false;
for($i=0;$i<count($ext_list);$i++) {
if($ext_list[$i]['mime'] == $mimeType) {
$type_state = true;
break;
}
}
$arrayReturn = array(
'status' => $type_state,
'mime_type' => $mimeType,
);
return $arrayReturn;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment