source: trunk/admin/inc/ckeditor/filemanager/core/types/type_mime.php@ 239

Last change on this file since 239 was 239, checked in by luc, 9 years ago

Admin: correzione visulaizzazione immissione dati spoglio per Chrome e Safari - Aggiornamento dell'editor da FCKeditor a CKeditor , accessibili anche a Chrome e Safari.

  • Property svn:executable set to *
File size: 1.4 KB
Line 
1<?php
2
3/** This file is part of KCFinder project
4 *
5 * @desc MIME type detection class
6 * @package KCFinder
7 * @version 2.51
8 * @author Pavel Tzonkov <pavelc@users.sourceforge.net>
9 * @copyright 2010, 2011 KCFinder Project
10 * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
11 * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2
12 * @link http://kcfinder.sunhater.com
13 */
14
15class type_mime {
16
17 public function checkFile($file, array $config) {
18 if (!class_exists("finfo"))
19 return "Fileinfo PECL extension is missing.";
20
21 if (!isset($config['params']))
22 return "Undefined MIME types.";
23
24 $finfo = strlen($config['mime_magic'])
25 ? new finfo(FILEINFO_MIME, $config['mime_magic'])
26 : new finfo(FILEINFO_MIME);
27 if (!$finfo)
28 return "Opening fileinfo database failed.";
29
30 $type = $finfo->file($file);
31 $type = substr($type, 0, strrpos($type, ";"));
32
33 $mimes = $config['params'];
34 if (substr($mimes, 0, 1) == "!") {
35 $mimes = trim(substr($mimes, 1));
36 return in_array($type , explode(" ", $mimes))
37 ? "You can't upload such files."
38 : true;
39 }
40
41 return !in_array($type , explode(" ", $mimes))
42 ? "You can't upload such files."
43 : true;
44 }
45}
46
47?>
Note: See TracBrowser for help on using the repository browser.