FileStorage.php 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294
  1. <?php
  2. // @requires $_SERVER['SERVER_NAME']
  3. Lib::loadClass('RouteBase');
  4. Lib::loadClass('Response');
  5. Lib::loadClass('Request');
  6. Lib::loadClass('UI');
  7. Lib::loadClass('Http');
  8. /*
  9. # FileStorage:
  10. - [x] create CRM_FILES - sql at the end of file
  11. - [x] only meta fields, perms? - no perms in relation based on record which is connected
  12. - [x] add file to storage - API POST/PUT action
  13. - [ ] base storage folder - from config - default /Library/Server/Web/Data/p5-pliki, chmod - add to instalator, upgrade
  14. - [x] subfolders like postfix, but [0-9],[A-Z] - substr(strrev(base_convert($id, 10, 10 + 26)), 0, 1) - 36 folderów
  15. - [x] file connected to user - A_RECORD_CREATE_AUTHOR
  16. - [ ] ? file connected to user - A_OWNER (L_APP_USER)?
  17. - [ ] connect file to record - {tbl_name}__REF__FILES
  18. - [ ] add A_HAS_REF field to struct - cache to check if file is connected to some record
  19. - [ ] add sync state - remote file name, mtime to check if file has changed in Storage or remote record folder
  20. - [ ] sync - conflict - file connected with 2 objects and both changed and try to store changes to FileStorage
  21. - [ ] add version to REF table
  22. - [x] use streams for upload - better memory usage
  23. - [ ] use streams for upload progress in form - http://www.webiny.com/blog/2012/05/07/webiny-file-upload-with-html5-and-ajax-using-php-streams/
  24. - [x] add IP to table struct
  25. # upload API: `index.php?_route=FileStorage&_task=upload&name={file_name}`
  26. */
  27. class Route_FileStorage extends RouteBase {
  28. public function handleAuth() {
  29. if (!User::logged()) {
  30. User::authByRequest();
  31. }
  32. }
  33. public function defaultAction() {
  34. UI::gora();
  35. UI::menu();
  36. try {
  37. echo '...';
  38. } catch (Exception $e) {
  39. UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage());
  40. }
  41. UI::dol();
  42. }
  43. public function isProduction() {// TODO: mv to Config
  44. // return V::get('P5_ENV', '/Library/Server/Web/Data/p5-file-storage', $_SERVER);
  45. // $env = getenv('P5_ENV');
  46. // if (empty($env)) $env = 'production';
  47. return ('production' == V::get('P5_ENV', 'production', $_SERVER));
  48. }
  49. public function getRootStoragePath() {
  50. return ($this->isProduction()) ? '/Library/Server/Web/Data/p5-file-storage' : '/tmp/test-upload-file-storage';
  51. }
  52. public function getTableName() {
  53. return ($this->isProduction()) ? 'CRM_FILES' : 'CRM_FILES__#DEV';
  54. }
  55. public function addFileStream($inputHandler, $name = '') {
  56. $rootFileStoragePath = $this->getRootStoragePath();
  57. $sqlLogin = User::getLogin();
  58. $sqlIP = Request::getUserIp();
  59. $sqlLabel = DB::getPDO()->quote($name, PDO::PARAM_STR);
  60. $sqlTblName = $this->getTableName();
  61. $sql = "
  62. insert into `{$sqlTblName}` (`A_RECORD_CREATE_AUTHOR`,`A_RECORD_CREATE_DATE`,`FILE_LABEL`, `A_USER_IP`)
  63. values ('{$sqlLogin}', NOW(), {$sqlLabel}, INET_ATON('{$sqlIP}'))
  64. ";
  65. DBG::_('DBG', '>2', "sql", $sql, __CLASS__, __FUNCTION__, __LINE__);
  66. DB::getPDO()->exec($sql);
  67. $dbLastId = DB::getPDO()->lastInsertId();
  68. DBG::_('DBG', '>1', "dbLastId", $dbLastId, __CLASS__, __FUNCTION__, __LINE__);
  69. $filePath = $this->generateFilePathHashFromID($dbLastId);
  70. DBG::_('DBG', '>1', "filePath", $filePath, __CLASS__, __FUNCTION__, __LINE__);
  71. $absFilePath = "{$rootFileStoragePath}/{$filePath}";
  72. $dirPath = dirname($absFilePath);
  73. @mkdir($dirPath, $mode = 0775, $recursive = true);
  74. if (!file_exists($dirPath)) throw new Exception("Cannot create path");
  75. @chmod($dirPath, $mode = 0775);
  76. // create a temp file where to save data from the input stream
  77. $fileHandler = fopen($absFilePath, "w+");
  78. DBG::_('DBG', '>1', "absFilePath", $absFilePath, __CLASS__, __FUNCTION__, __LINE__);
  79. // save data from the input stream
  80. while (true) {
  81. $buffer = fgets($inputHandler, 4096);
  82. if (strlen($buffer) == 0) {
  83. fclose($inputHandler);
  84. fclose($fileHandler);
  85. break;
  86. }
  87. fwrite($fileHandler, $buffer);
  88. }
  89. if (!file_exists($absFilePath)) throw new Exception("Cannot save file");
  90. $mimeType = mime_content_type($absFilePath);
  91. DBG::_('DBG', '>1', "mimeType", $mimeType, __CLASS__, __FUNCTION__, __LINE__);
  92. if (!$this->isAllowedMimeType($mimeType)) {
  93. DB::getPDO()->exec("
  94. update `{$sqlTblName}`
  95. set `A_STATUS` = 'WARNING'
  96. -- , `A_STATUS_INFO` = ''
  97. where `ID` = '{$dbLastId}'
  98. ");
  99. throw new Exception("Niedozwolony typ pliku '{$mimeType}'", 1);
  100. }
  101. $mtime = filemtime($absFilePath);
  102. $size = filesize($absFilePath);
  103. DBG::_('DBG', '>1', "mtime", $mtime, __CLASS__, __FUNCTION__, __LINE__);
  104. DBG::_('DBG', '>1', "size", $size, __CLASS__, __FUNCTION__, __LINE__);
  105. DB::getPDO()->exec("
  106. update `{$sqlTblName}`
  107. set `A_STATUS` = 'NORMAL'
  108. , `FILE_MIME_TYPE` = '{$mimeType}'
  109. , `FILE_MTIME` = '{$mtime}'
  110. , `FILE_SIZE` = '{$size}'
  111. where `ID` = '{$dbLastId}'
  112. ");
  113. echo "
  114. update `{$sqlTblName}`
  115. set `A_STATUS` = 'NORMAL'
  116. , `FILE_MIME_TYPE` = '{$mimeType}'
  117. , `FILE_MTIME` = '{$mtime}'
  118. , `FILE_SIZE` = '{$size}'
  119. where `ID` = '{$dbLastId}'
  120. ";
  121. }
  122. public function addFile($content, $name = '') {
  123. $rootFileStoragePath = $this->getRootStoragePath();
  124. $sqlLogin = User::getLogin();
  125. $sqlLabel = DB::getPDO()->quote($name, PDO::PARAM_STR);
  126. $sqlTblName = $this->getTableName();
  127. $sql = "
  128. insert into `{$sqlTblName}` (`A_RECORD_CREATE_AUTHOR`,`A_RECORD_CREATE_DATE`,`FILE_LABEL`)
  129. values ('{$sqlLogin}', NOW(), {$sqlLabel})
  130. ";
  131. DBG::_('DBG', '>2', "sql", $sql, __CLASS__, __FUNCTION__, __LINE__);
  132. DB::getPDO()->exec($sql);
  133. $dbLastId = DB::getPDO()->lastInsertId();
  134. DBG::_('DBG', '>1', "dbLastId", $dbLastId, __CLASS__, __FUNCTION__, __LINE__);
  135. $filePath = $this->generateFilePathHashFromID($dbLastId);
  136. DBG::_('DBG', '>1', "filePath", $filePath, __CLASS__, __FUNCTION__, __LINE__);
  137. $absFilePath = "{$rootFileStoragePath}/{$filePath}";
  138. $dirPath = dirname($absFilePath);
  139. @mkdir($dirPath, $mode = 0777, $recursive = true);
  140. if (!file_exists($dirPath)) throw new Exception("Cannot create path");
  141. @chmod($dirPath, $mode = 0777);
  142. $fp = fopen($absFilePath, 'w');
  143. fwrite($fp, $fileContent);
  144. fclose($fp);
  145. if (!file_exists($absFilePath)) throw new Exception("Cannot save file");
  146. }
  147. public function uploadStreamAction() {
  148. try {
  149. $sqlLabel = V::get('name', '', $_REQUEST);
  150. // read contents from the input stream
  151. $inputHandler = fopen('php://input', "r");
  152. $this->addFileStream($inputHandler, $sqlLabel);
  153. } catch (Exception $e) {
  154. Http::sendHeaderByCode(500);
  155. echo "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage();
  156. exit;
  157. }
  158. Http::sendHeaderByCode(200);
  159. }
  160. public function uploadAction() {
  161. try {
  162. $fileContent = Request::getRequestBody();
  163. $sqlLabel = V::get('name', '', $_REQUEST);
  164. $this->addFile($fileContent, $sqlLabel);
  165. echo 'file uploaded';
  166. } catch (Exception $e) {
  167. echo "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage();
  168. }
  169. }
  170. public function uploadFromBinaryTestAction() {
  171. try {
  172. $fileContent = Request::getRequestBody();
  173. $filePath = $this->getRootStoragePath() . '/test-upload-data.txt';
  174. $fp = fopen($filePath, 'w');
  175. fwrite($fp, $fileContent);
  176. fclose($fp);
  177. echo 'file uploaded?';
  178. } catch (Exception $e) {
  179. echo "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage();
  180. }
  181. }
  182. public function downloadTestAction() {
  183. try {
  184. $filePath = $this->getRootStoragePath() . '/test-upload-data.txt';
  185. if (!file_exists($filePath)) throw new Exception("file not exists!");
  186. header('Content-Description: File Transfer');
  187. header('Content-Type: application/octet-stream');
  188. header('Content-Disposition: attachment; filename="'.basename($filePath).'"');
  189. header('Expires: 0');
  190. header('Cache-Control: must-revalidate');
  191. header('Pragma: public');
  192. header('Content-Length: ' . filesize($filePath));
  193. readfile($filePath);
  194. exit;
  195. } catch (Exception $e) {
  196. echo "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage();
  197. }
  198. }
  199. public function uploadFromFormTestAction() {
  200. try {
  201. // $fileContent = Request::getRequestBody();
  202. DBG::_(true, true, '_POST', $_POST, __CLASS__, __FUNCTION__, __LINE__);
  203. // $filePath = $this->getRootStoragePath() . '/test-upload-data.txt';
  204. // $fp = fopen($filePath, 'w');
  205. // fwrite($fp, $fileContent);
  206. // fclose($fp);
  207. // echo 'file uploaded?';
  208. } catch (Exception $e) {
  209. echo "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage();
  210. }
  211. }
  212. public function uploadFormTestAction() {
  213. UI::gora();
  214. UI::menu();
  215. try {
  216. // multiple: <input type="file" id="file_input" multiple="multiple" />
  217. // only images: <input type="file" id="file_input" multiple="multiple" accept="image/*" />
  218. ?>
  219. <div class="container">
  220. <form>
  221. <input type="file" id="file_input" style="display:block; width:100%; height:200px; background-color:silver; text-align:center">
  222. </form>
  223. <button class="btn btn-primary" id="upload_file_as_stream_btn">upload as stream</button>
  224. <button class="btn btn-success" id="upload_file_as_binary_btn">upload as binary</button>
  225. <button class="btn btn-default" id="upload_file_as_form_btn">upload as form</button>
  226. <a class="btn btn-default" href="index.php?_route=FileStorage&_task=downloadTest" target="_blank">download</a>
  227. <blockquote>
  228. <p>root storage path: <code><?php echo $this->getRootStoragePath(); ?></code></p>
  229. <p>table name: <code><?php echo $this->getTableName(); ?></code></p>
  230. <p>IP: <code><?php echo Request::getUserIp(); ?></code></p>
  231. </blockquote>
  232. </div>
  233. <?php
  234. $sqlTblName = $this->getTableName();
  235. $rows = DB::getPDO()->fetchAll("
  236. select t.ID
  237. , t.FILE_HASH
  238. , t.FILE_LABEL
  239. , t.FILE_TYPE
  240. , t.FILE_MIME_TYPE
  241. , t.FILE_MTIME
  242. , t.FILE_SIZE
  243. , t.FILE_VERSION
  244. , t.A_STATUS
  245. , t.A_RECORD_CREATE_DATE as created
  246. , t.A_RECORD_CREATE_AUTHOR as author
  247. , t.A_RECORD_UPDATE_DATE as updated
  248. , t.A_RECORD_UPDATE_AUTHOR as editor
  249. , t.A_ADM_COMPANY as zapisDla
  250. , t.A_CLASSIFIED as odczytDla
  251. , INET_NTOA(t.A_USER_IP) as IP
  252. from `{$sqlTblName}` t
  253. order by ID DESC
  254. limit 100
  255. ");
  256. foreach ($rows as $idx => $row) {
  257. $rows[$idx]['FILE_SIZE'] = V::humanFileSize($row['FILE_SIZE']);
  258. }
  259. $params = array();
  260. $params['caption'] = "Files in '" . $this->getTableName() . "'";
  261. $params['rows'] = $rows;
  262. UI::table($params);
  263. ?>
  264. <script>
  265. document.getElementById('file_input').addEventListener('change', function() {
  266. for (var i = 0; i < this.files.length; i++){
  267. var file = this.files[i];
  268. // This code is only for demo ...
  269. console.group("File "+i);
  270. console.log("name : " + file.name);
  271. console.log("size : " + file.size);
  272. console.log("type : " + file.type);
  273. console.log("date : " + file.lastModified);
  274. console.groupEnd();
  275. }
  276. }, false);
  277. function uploadFileAsForm(file) {
  278. var serverUrl = '<?php echo Request::getPathUri() . "index.php?_route=FileStorage&_task=uploadFromFormTest"; ?>';
  279. var xhr = new XMLHttpRequest();
  280. var fd = new FormData();
  281. xhr.open("POST", serverUrl, true);
  282. xhr.onreadystatechange = function() {
  283. if (xhr.readyState == 4 && xhr.status == 200) {
  284. // Every thing ok, file uploaded
  285. console.log(xhr.responseText); // handle response.
  286. }
  287. };
  288. fd.append("upload_file", file);
  289. xhr.send(fd);
  290. }
  291. function uploadFileAsStream(file) {
  292. var serverUrl = '<?php echo Request::getPathUri() . "index.php?_route=FileStorage&_task=uploadStream&DBG=3"; ?>';
  293. var _dbg = true;
  294. // .set('Accept', 'application/json')
  295. superagent.post(serverUrl + '&name=' + file.name)
  296. .set('Content-Type', file.type)
  297. .send(file)
  298. .end(function(err, res) {
  299. if(_dbg)console.log('DBG: res:', res, 'res.body:', res.body);
  300. })
  301. }
  302. function uploadFileAsBinary(file) {
  303. var serverUrl = '<?php echo Request::getPathUri() . "index.php?_route=FileStorage&_task=upload"; ?>';
  304. var _dbg = true;
  305. // .set('Accept', 'application/json')
  306. superagent.post(serverUrl + '&name=' + file.name)
  307. .set('Content-Type', file.type)
  308. .send(file)
  309. .end(function(err, res) {
  310. if(_dbg)console.log('DBG: res:', res, 'res.body:', res.body);
  311. })
  312. return
  313. jQuery.ajax({
  314. type: "POST",
  315. beforeSend: function (request) {
  316. request.setRequestHeader("Content-Type", file.type);
  317. },
  318. url: serverUrl,
  319. data: file,
  320. processData: false,
  321. contentType: false,
  322. success: function (data) {
  323. console.log("File available at: ", data);
  324. },
  325. error: function (data) {
  326. var obj = jQuery.parseJSON(data);
  327. alert(obj.error);
  328. }
  329. })
  330. }
  331. jQuery('#upload_file_as_stream_btn').on('click', function() {
  332. var fileInput = document.getElementById('file_input')
  333. if (!fileInput) return false;// TODO: error msg
  334. if (!fileInput.files) return false;// TODO: error msg
  335. if (!fileInput.files.length) return false;// TODO: error msg
  336. var fileInfo = fileInput.files[0];
  337. console.log('fileInfo', fileInfo);
  338. uploadFileAsStream(fileInfo);
  339. });
  340. jQuery('#upload_file_as_binary_btn').on('click', function() {
  341. var fileInput = document.getElementById('file_input')
  342. if (!fileInput) return false;// TODO: error msg
  343. if (!fileInput.files) return false;// TODO: error msg
  344. if (!fileInput.files.length) return false;// TODO: error msg
  345. var fileInfo = fileInput.files[0];
  346. console.log('fileInfo', fileInfo);
  347. uploadFileAsBinary(fileInfo);
  348. });
  349. jQuery('#upload_file_as_form_btn').on('click', function() {
  350. var fileInput = document.getElementById('file_input')
  351. if (!fileInput) return false;// TODO: error msg
  352. if (!fileInput.files) return false;// TODO: error msg
  353. if (!fileInput.files.length) return false;// TODO: error msg
  354. var fileInfo = fileInput.files[0];
  355. console.log('fileInfo', fileInfo);
  356. uploadFileAsForm(fileInfo);
  357. });
  358. </script>
  359. <?php
  360. } catch (Exception $e) {
  361. UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage());
  362. }
  363. UI::dol();
  364. }
  365. public function generateFilePathHashFromID($intId) {
  366. // $base36Id = base_convert($intId, 10, 10 + 26);// 0-9 + A-Z
  367. $base36Id = base_convert($intId, 10, 10 + 6);// 0-9 + A-F
  368. $base36Str = str_pad($base36Id, 10, "0", STR_PAD_LEFT);
  369. $base36Str = strrev($base36Str);
  370. $pathParts = array();
  371. $pathParts[] = substr($base36Str, 0, 2);
  372. $pathParts[] = substr($base36Str, 2, 2);
  373. $pathParts[] = substr($base36Str, 4);
  374. $hashPath = implode("/", $pathParts);
  375. echo "ID($intId) converted to ({$base36Id})\t to ({$base36Str})\t to path ({$hashPath})\n";
  376. return $hashPath;
  377. }
  378. public function generatePathTestAction() {
  379. try {
  380. $start = 0;
  381. $start = 446071;
  382. $limit = $start + 100;
  383. echo '<pre>';
  384. for ($i = $start; $i < $limit; $i++) {
  385. $this->generateFilePathHashFromID($i);
  386. }
  387. echo '</pre>';
  388. } catch (Exception $e) {
  389. echo "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage();
  390. }
  391. }
  392. public function reinstallAction() {
  393. UI::gora();
  394. UI::menu();
  395. $this->reinstall();
  396. UI::dol();
  397. }
  398. public function reinstall() {
  399. try {
  400. DB::getPDO()->exec("
  401. CREATE TABLE IF NOT EXISTS `CRM_FILES` (
  402. `ID` int(11) NOT NULL AUTO_INCREMENT,
  403. `FILE_HASH` varchar(255) NOT NULL, -- generated from ID by hash function - only for cache
  404. `FILE_LABEL` varchar(255) NOT NULL, -- original file name or system name
  405. `FILE_TYPE` varchar(32) NOT NULL DEFAULT '', -- $TRG_FILE -> config/.cnf--folders...
  406. `FILE_MIME_TYPE` varchar(64) NOT NULL DEFAULT '',
  407. `FILE_MTIME` datetime NOT NULL,
  408. `FILE_SIZE` bigint NOT NULL DEFAULT 0,
  409. `FILE_VERSION` int(11) NOT NULL DEFAULT 0, -- used for update
  410. `A_STATUS` enum('WAITING','NORMAL','MONITOR','OFF_HARD','OFF_SOFT','DELETED') NOT NULL DEFAULT 'WAITING',
  411. `A_RECORD_CREATE_DATE` datetime DEFAULT NULL,
  412. `A_RECORD_CREATE_AUTHOR` varchar(20) NOT NULL DEFAULT '',
  413. `A_RECORD_UPDATE_DATE` datetime DEFAULT NULL,
  414. `A_RECORD_UPDATE_AUTHOR` varchar(20) NOT NULL DEFAULT '',
  415. `A_ADM_COMPANY` varchar(100) NOT NULL DEFAULT '',
  416. `A_CLASSIFIED` varchar(100) NOT NULL DEFAULT '',
  417. `A_USER_IP` bigint NOT NULL DEFAULT '0',
  418. PRIMARY KEY (`ID`),
  419. KEY `FILE_TYPE` (`FILE_MIME_TYPE`)
  420. ) ENGINE=MyISAM DEFAULT CHARSET=latin2;
  421. ");
  422. DB::getPDO()->exec("
  423. CREATE TABLE IF NOT EXISTS `CRM_FILES__#DEV` (
  424. `ID` int(11) NOT NULL AUTO_INCREMENT,
  425. `FILE_HASH` varchar(255) NOT NULL, -- generated from ID by hash function - only for cache
  426. `FILE_LABEL` varchar(255) NOT NULL, -- original file name or system name
  427. `FILE_TYPE` varchar(32) NOT NULL DEFAULT '', -- $TRG_FILE -> config/.cnf--folders...
  428. `FILE_MIME_TYPE` varchar(64) NOT NULL DEFAULT '',
  429. `FILE_MTIME` datetime NOT NULL,
  430. `FILE_SIZE` bigint NOT NULL DEFAULT 0,
  431. `FILE_VERSION` int(11) NOT NULL DEFAULT 0, -- used for update
  432. `A_STATUS` enum('WAITING','NORMAL','MONITOR','OFF_HARD','OFF_SOFT','DELETED') NOT NULL DEFAULT 'WAITING',
  433. `A_RECORD_CREATE_DATE` datetime DEFAULT NULL,
  434. `A_RECORD_CREATE_AUTHOR` varchar(20) NOT NULL DEFAULT '',
  435. `A_RECORD_UPDATE_DATE` datetime DEFAULT NULL,
  436. `A_RECORD_UPDATE_AUTHOR` varchar(20) NOT NULL DEFAULT '',
  437. `A_ADM_COMPANY` varchar(100) NOT NULL DEFAULT '',
  438. `A_CLASSIFIED` varchar(100) NOT NULL DEFAULT '',
  439. `A_USER_IP` bigint NOT NULL DEFAULT '0',
  440. PRIMARY KEY (`ID`),
  441. KEY `FILE_TYPE` (`FILE_MIME_TYPE`)
  442. ) ENGINE=MyISAM DEFAULT CHARSET=latin2;
  443. ");
  444. {// TODO: only in cli mode - require root perms
  445. $devRootPath = '/tmp/test-upload-file-storage';
  446. if (!file_exists($devRootPath)) {
  447. @mkdir($devRootPath, $mode = 0777, $recursive = true);
  448. if (!file_exists($devRootPath)) throw new Exception("Cannot create FileStorage root path for dev");
  449. @chmod($devRootPath, $mode = 0777);
  450. @chown($devRootPath, $user = '_www');
  451. }
  452. $productionRootPath = '/Library/Server/Web/Data/p5-file-storage';
  453. if (!file_exists($productionRootPath)) {
  454. @mkdir($productionRootPath, $mode = 0775, $recursive = true);
  455. if (!file_exists($productionRootPath)) throw new Exception("Cannot create FileStorage root path");
  456. @chmod($productionRootPath, $mode = 0775);
  457. @chown($productionRootPath, $user = '_www');
  458. }
  459. }
  460. } catch (Exception $e) {
  461. UI::alert('danger', $e->getMessage());
  462. }
  463. }
  464. public function isAllowedMimeType($mimeType) {
  465. // http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
  466. switch ($mimeType) {
  467. case 'image/png': return true;
  468. case 'application/atom+xml': return true;// atom
  469. case 'application/atomcat+xml': return true;// atomcat
  470. case 'application/atomsvc+xml': return true;// atomsvc
  471. case 'application/ccxml+xml': return true;// ccxml
  472. case 'application/cdmi-capability': return true;// cdmia
  473. case 'application/cdmi-container': return true;// cdmic
  474. case 'application/cdmi-domain': return true;// cdmid
  475. case 'application/cdmi-object': return true;// cdmio
  476. case 'application/cdmi-queue': return true;// cdmiq
  477. case 'application/cu-seeme': return true;// cu
  478. case 'application/davmount+xml': return true;// davmount
  479. case 'application/docbook+xml': return true;// dbk
  480. case 'application/dssc+der': return true;// dssc
  481. case 'application/dssc+xml': return true;// xdssc
  482. case 'application/ecmascript': return true;// ecma
  483. case 'application/emma+xml': return true;// emma
  484. case 'application/epub+zip': return true;// epub
  485. case 'application/exi': return true;// exi
  486. case 'application/font-tdpfr': return true;// pfr
  487. case 'application/font-woff': return true;// woff
  488. case 'application/gml+xml': return true;// gml
  489. case 'application/gpx+xml': return true;// gpx
  490. case 'application/gxf': return true;// gxf
  491. case 'application/hyperstudio': return true;// stk
  492. case 'application/inkml+xml': return true;// ink inkml
  493. case 'application/ipfix': return true;// ipfix
  494. case 'application/java-archive': return true;// jar
  495. case 'application/java-serialized-object': return true;// ser
  496. case 'application/java-vm': return true;// class
  497. case 'application/javascript': return true;// js
  498. case 'application/json': return true;// json
  499. case 'application/jsonml+json': return true;// jsonml
  500. case 'application/lost+xml': return true;// lostxml
  501. case 'application/mac-binhex40': return true;// hqx
  502. case 'application/mac-compactpro': return true;// cpt
  503. case 'application/mads+xml': return true;// mads
  504. case 'application/marc': return true;// mrc
  505. case 'application/marcxml+xml': return true;// mrcx
  506. case 'application/mathematica': return true;// ma nb mb
  507. case 'application/mathml+xml': return true;// mathml
  508. case 'application/mbox': return true;// mbox
  509. case 'application/mediaservercontrol+xml': return true;// mscml
  510. case 'application/metalink+xml': return true;// metalink
  511. case 'application/metalink4+xml': return true;// meta4
  512. case 'application/mets+xml': return true;// mets
  513. case 'application/mods+xml': return true;// mods
  514. case 'application/mp21': return true;// m21 mp21
  515. case 'application/mp4': return true;// mp4s
  516. case 'application/msword': return true;// doc dot
  517. case 'application/mxf': return true;// mxf
  518. case 'application/octet-stream': return true;// bin dms lrf mar so dist distz pkg bpk dump elc deploy
  519. case 'application/oda': return true;// oda
  520. case 'application/oebps-package+xml': return true;// opf
  521. case 'application/ogg': return true;// ogx
  522. case 'application/omdoc+xml': return true;// omdoc
  523. case 'application/onenote': return true;// onetoc2 onetmp onetoc onepkg
  524. case 'application/oxps': return true;// oxps
  525. case 'application/patch-ops-error+xml': return true;// xer
  526. case 'application/pdf': return true;// pdf
  527. case 'application/pgp-encrypted': return true;// pgp
  528. case 'application/pgp-signature': return true;// asc sig
  529. case 'application/pics-rules': return true;// prf
  530. case 'application/pkcs10': return true;// p10
  531. case 'application/pkcs7-mime': return true;// p7m p7c
  532. case 'application/pkcs7-signature': return true;// p7s
  533. case 'application/pkcs8': return true;// p8
  534. case 'application/pkix-attr-cert': return true;// ac
  535. case 'application/pkix-cert': return true;// cer
  536. case 'application/pkix-crl': return true;// crl
  537. case 'application/pkix-pkipath': return true;// pkipath
  538. case 'application/pkixcmp': return true;// pki
  539. case 'application/pls+xml': return true;// pls
  540. case 'application/postscript': return true;// ai eps ps
  541. case 'application/prs.cww': return true;// cww
  542. case 'application/pskc+xml': return true;// pskcxml
  543. case 'application/rdf+xml': return true;// rdf
  544. case 'application/reginfo+xml': return true;// rif
  545. case 'application/relax-ng-compact-syntax': return true;// rnc
  546. case 'application/resource-lists+xml': return true;// rl
  547. case 'application/resource-lists-diff+xml': return true;// rld
  548. case 'application/rls-services+xml': return true;// rs
  549. case 'application/rpki-ghostbusters': return true;// gbr
  550. case 'application/rpki-manifest': return true;// mft
  551. case 'application/rpki-roa': return true;// roa
  552. case 'application/rsd+xml': return true;// rsd
  553. case 'application/rss+xml': return true;// rss
  554. case 'application/rtf': return true;// rtf
  555. case 'application/sbml+xml': return true;// sbml
  556. case 'application/scvp-cv-request': return true;// scq
  557. case 'application/scvp-cv-response': return true;// scs
  558. case 'application/scvp-vp-request': return true;// spq
  559. case 'application/scvp-vp-response': return true;// spp
  560. case 'application/sdp': return true;// sdp
  561. case 'application/set-payment-initiation': return true;// setpay
  562. case 'application/set-registration-initiation': return true;// setreg
  563. case 'application/shf+xml': return true;// shf
  564. case 'application/smil+xml': return true;// smi smil
  565. case 'application/sparql-query': return true;// rq
  566. case 'application/sparql-results+xml': return true;// srx
  567. case 'application/srgs': return true;// gram
  568. case 'application/srgs+xml': return true;// grxml
  569. case 'application/sru+xml': return true;// sru
  570. case 'application/ssdl+xml': return true;// ssdl
  571. case 'application/ssml+xml': return true;// ssml
  572. case 'application/tei+xml': return true;// tei teicorpus
  573. case 'application/thraud+xml': return true;// tfi
  574. case 'application/timestamped-data': return true;// tsd
  575. case 'application/vnd.3gpp.pic-bw-large': return true;// plb
  576. case 'application/vnd.3gpp.pic-bw-small': return true;// psb
  577. case 'application/vnd.3gpp.pic-bw-var': return true;// pvb
  578. case 'application/vnd.3gpp2.tcap': return true;// tcap
  579. case 'application/vnd.3m.post-it-notes': return true;// pwn
  580. case 'application/vnd.accpac.simply.aso': return true;// aso
  581. case 'application/vnd.accpac.simply.imp': return true;// imp
  582. case 'application/vnd.acucobol': return true;// acu
  583. case 'application/vnd.acucorp': return true;// atc acutc
  584. case 'application/vnd.adobe.air-application-installer-package+zip': return true;// air
  585. case 'application/vnd.adobe.formscentral.fcdt': return true;// fcdt
  586. case 'application/vnd.adobe.fxp': return true;// fxp fxpl
  587. case 'application/vnd.adobe.xdp+xml': return true;// xdp
  588. case 'application/vnd.adobe.xfdf': return true;// xfdf
  589. case 'application/vnd.ahead.space': return true;// ahead
  590. case 'application/vnd.airzip.filesecure.azf': return true;// azf
  591. case 'application/vnd.airzip.filesecure.azs': return true;// azs
  592. case 'application/vnd.amazon.ebook': return true;// azw
  593. case 'application/vnd.americandynamics.acc': return true;// acc
  594. case 'application/vnd.amiga.ami': return true;// ami
  595. case 'application/vnd.android.package-archive': return true;// apk
  596. case 'application/vnd.anser-web-certificate-issue-initiation': return true;// cii
  597. case 'application/vnd.anser-web-funds-transfer-initiation': return true;// fti
  598. case 'application/vnd.antix.game-component': return true;// atx
  599. case 'application/vnd.apple.installer+xml': return true;// mpkg
  600. case 'application/vnd.apple.mpegurl': return true;// m3u8
  601. case 'application/vnd.aristanetworks.swi': return true;// swi
  602. case 'application/vnd.astraea-software.iota': return true;// iota
  603. case 'application/vnd.audiograph': return true;// aep
  604. case 'application/vnd.blueice.multipass': return true;// mpm
  605. case 'application/vnd.bmi': return true;// bmi
  606. case 'application/vnd.businessobjects': return true;// rep
  607. case 'application/vnd.chemdraw+xml': return true;// cdxml
  608. case 'application/vnd.chipnuts.karaoke-mmd': return true;// mmd
  609. case 'application/vnd.cinderella': return true;// cdy
  610. case 'application/vnd.claymore': return true;// cla
  611. case 'application/vnd.cloanto.rp9': return true;// rp9
  612. case 'application/vnd.clonk.c4group': return true;// c4g c4d c4f c4p c4u
  613. case 'application/vnd.cluetrust.cartomobile-config': return true;// c11amc
  614. case 'application/vnd.cluetrust.cartomobile-config-pkg': return true;// c11amz
  615. case 'application/vnd.commonspace': return true;// csp
  616. case 'application/vnd.contact.cmsg': return true;// cdbcmsg
  617. case 'application/vnd.cosmocaller': return true;// cmc
  618. case 'application/vnd.crick.clicker': return true;// clkx
  619. case 'application/vnd.crick.clicker.keyboard': return true;// clkk
  620. case 'application/vnd.crick.clicker.palette': return true;// clkp
  621. case 'application/vnd.crick.clicker.template': return true;// clkt
  622. case 'application/vnd.crick.clicker.wordbank': return true;// clkw
  623. case 'application/vnd.criticaltools.wbs+xml': return true;// wbs
  624. case 'application/vnd.ctc-posml': return true;// pml
  625. case 'application/vnd.cups-ppd': return true;// ppd
  626. case 'application/vnd.curl.car': return true;// car
  627. case 'application/vnd.curl.pcurl': return true;// pcurl
  628. case 'application/vnd.dart': return true;// dart
  629. case 'application/vnd.data-vision.rdz': return true;// rdz
  630. case 'application/vnd.dece.data': return true;// uvf uvvf uvd uvvd
  631. case 'application/vnd.dece.ttml+xml': return true;// uvt uvvt
  632. case 'application/vnd.dece.unspecified': return true;// uvx uvvx
  633. case 'application/vnd.dece.zip': return true;// uvz uvvz
  634. case 'application/vnd.denovo.fcselayout-link': return true;// fe_launch
  635. case 'application/vnd.dna': return true;// dna
  636. case 'application/vnd.dolby.mlp': return true;// mlp
  637. case 'application/vnd.dpgraph': return true;// dpg
  638. case 'application/vnd.dreamfactory': return true;// dfac
  639. case 'application/vnd.ds-keypoint': return true;// kpxx
  640. case 'application/vnd.dvb.ait': return true;// ait
  641. case 'application/vnd.dvb.service': return true;// svc
  642. case 'application/vnd.dynageo': return true;// geo
  643. case 'application/vnd.ecowin.chart': return true;// mag
  644. case 'application/vnd.enliven': return true;// nml
  645. case 'application/vnd.epson.esf': return true;// esf
  646. case 'application/vnd.epson.msf': return true;// msf
  647. case 'application/vnd.epson.quickanime': return true;// qam
  648. case 'application/vnd.epson.salt': return true;// slt
  649. case 'application/vnd.epson.ssf': return true;// ssf
  650. case 'application/vnd.eszigno3+xml es3': return true;// et3
  651. case 'application/vnd.ezpix-album': return true;// ez2
  652. case 'application/vnd.ezpix-package': return true;// ez3
  653. case 'application/vnd.fdf': return true;// fdf
  654. case 'application/vnd.fdsn.mseed': return true;// mseed
  655. case 'application/vnd.fdsn.seed': return true;// seed dataless
  656. case 'application/vnd.flographit': return true;// gph
  657. case 'application/vnd.fluxtime.clip': return true;// ftc
  658. case 'application/vnd.framemaker': return true;// fm frame maker book
  659. case 'application/vnd.frogans.fnc': return true;// fnc
  660. case 'application/vnd.frogans.ltf': return true;// ltf
  661. case 'application/vnd.fsc.weblaunch': return true;// fsc
  662. case 'application/vnd.fujitsu.oasys': return true;// oas
  663. case 'application/vnd.fujitsu.oasys2': return true;// oa2
  664. case 'application/vnd.fujitsu.oasys3': return true;// oa3
  665. case 'application/vnd.fujitsu.oasysgp': return true;// fg5
  666. case 'application/vnd.fujitsu.oasysprs': return true;// bh2
  667. case 'application/vnd.fujixerox.ddd': return true;// ddd
  668. case 'application/vnd.fujixerox.docuworks': return true;// xdw
  669. case 'application/vnd.fujixerox.docuworks.binder': return true;// xbd
  670. case 'application/vnd.fuzzysheet': return true;// fzs
  671. case 'application/vnd.genomatix.tuxedo': return true;// txd
  672. case 'application/vnd.geogebra.file': return true;// ggb
  673. case 'application/vnd.geogebra.tool': return true;// ggt
  674. case 'application/vnd.geometry-explorer': return true;// gex gre
  675. case 'application/vnd.geonext': return true;// gxt
  676. case 'application/vnd.geoplan': return true;// g2w
  677. case 'application/vnd.geospace': return true;// g3w
  678. case 'application/vnd.gmx': return true;// gmx
  679. case 'application/vnd.google-earth.kml+xml': return true;// kml
  680. case 'application/vnd.google-earth.kmz': return true;// kmz
  681. case 'application/vnd.grafeq': return true;// gqf gqs
  682. case 'application/vnd.groove-account': return true;// gac
  683. case 'application/vnd.groove-help': return true;// ghf
  684. case 'application/vnd.groove-identity-message': return true;// gim
  685. case 'application/vnd.groove-injector': return true;// grv
  686. case 'application/vnd.groove-tool-message': return true;// gtm
  687. case 'application/vnd.groove-tool-template': return true;// tpl
  688. case 'application/vnd.groove-vcard': return true;// vcg
  689. case 'application/vnd.hal+xml': return true;// hal
  690. case 'application/vnd.handheld-entertainment+xml': return true;// zmm
  691. case 'application/vnd.hbci': return true;// hbci
  692. case 'application/vnd.hhe.lesson-player': return true;// les
  693. case 'application/vnd.hp-hpgl': return true;// hpgl
  694. case 'application/vnd.hp-hpid': return true;// hpid
  695. case 'application/vnd.hp-hps': return true;// hps
  696. case 'application/vnd.hp-jlyt': return true;// jlt
  697. case 'application/vnd.hp-pcl': return true;// pcl
  698. case 'application/vnd.hp-pclxl': return true;// pclxl
  699. case 'application/vnd.hydrostatix.sof-data': return true;// sfd- hdstx
  700. case 'application/vnd.ibm.minipay': return true;// mpy
  701. case 'application/vnd.ibm.modcap': return true;// afp listafp list3820
  702. case 'application/vnd.ibm.rights-management': return true;// irm
  703. case 'application/vnd.ibm.secure-container': return true;// sc
  704. case 'application/vnd.iccprofile': return true;// icc icm
  705. case 'application/vnd.igloader': return true;// igl
  706. case 'application/vnd.immervision-ivp': return true;// ivp
  707. case 'application/vnd.immervision-ivu': return true;// ivu
  708. case 'application/vnd.insors.igm': return true;// igm
  709. case 'application/vnd.intercon.formnet': return true;// xpw xpx
  710. case 'application/vnd.intergeo': return true;// i2g
  711. case 'application/vnd.intu.qbo': return true;// qbo
  712. case 'application/vnd.intu.qfx': return true;// qfx
  713. case 'application/vnd.ipunplugged.rcprofile': return true;// rcprofile
  714. case 'application/vnd.irepository.package+xml': return true;// irp
  715. case 'application/vnd.is-xpr': return true;// xpr
  716. case 'application/vnd.isac.fcs': return true;// fcs
  717. case 'application/vnd.jam': return true;// jam
  718. case 'application/vnd.jcp.javame.midlet-rms': return true;// rms
  719. case 'application/vnd.jisp': return true;// jisp
  720. case 'application/vnd.joost.joda-archive': return true;// joda
  721. case 'application/vnd.kahootz': return true;// ktz ktr
  722. case 'application/vnd.kde.karbon': return true;// karbon
  723. case 'application/vnd.kde.kchart': return true;// chrt
  724. case 'application/vnd.kde.kformula': return true;// kfo
  725. case 'application/vnd.kde.kivio': return true;// flw
  726. case 'application/vnd.kde.kontour': return true;// kon
  727. case 'application/vnd.kde.kpresenter': return true;// kpr kpt
  728. case 'application/vnd.kde.kspread': return true;// ksp
  729. case 'application/vnd.kde.kword': return true;// kwd kwt
  730. case 'application/vnd.kenameaapp': return true;// htke
  731. case 'application/vnd.kidspiration': return true;// kia
  732. case 'application/vnd.kinar': return true;// kne knp
  733. case 'application/vnd.koan': return true;// skp skd skt skm
  734. case 'application/vnd.kodak-descriptor': return true;// sse
  735. case 'application/vnd.las.las+xml': return true;// lasxml
  736. case 'application/vnd.llamagraphics.life-balance.desktop': return true;// lbd
  737. case 'application/vnd.llamagraphics.life-balance.exchange+xml': return true;// lbe
  738. case 'application/vnd.lotus-1-2-3': return true;// 123
  739. case 'application/vnd.lotus-approach': return true;// apr
  740. case 'application/vnd.lotus-freelance': return true;// pre
  741. case 'application/vnd.lotus-notes': return true;// nsf
  742. case 'application/vnd.lotus-organizer': return true;// org
  743. case 'application/vnd.lotus-screencam': return true;// scm
  744. case 'application/vnd.lotus-wordpro': return true;// lwp
  745. case 'application/vnd.macports.portpkg': return true;// portpkg
  746. case 'application/vnd.mcd': return true;// mcd
  747. case 'application/vnd.medcalcdata': return true;// mc1
  748. case 'application/vnd.mediastation.cdkey': return true;// cdkey
  749. case 'application/vnd.mfer': return true;// mwf
  750. case 'application/vnd.mfmp': return true;// mfm
  751. case 'application/vnd.micrografx.flo': return true;// flo
  752. case 'application/vnd.micrografx.igx': return true;// igx
  753. case 'application/vnd.mif': return true;// mif
  754. case 'application/vnd.mobius.daf': return true;// daf
  755. case 'application/vnd.mobius.dis': return true;// dis
  756. case 'application/vnd.mobius.mbk': return true;// mbk
  757. case 'application/vnd.mobius.mqy': return true;// mqy
  758. case 'application/vnd.mobius.msl': return true;// msl
  759. case 'application/vnd.mobius.plc': return true;// plc
  760. case 'application/vnd.mobius.txf': return true;// txf
  761. case 'application/vnd.mophun.application': return true;// mpn
  762. case 'application/vnd.mophun.certificate': return true;// mpc
  763. case 'application/vnd.mozilla.xul+xml': return true;// xul
  764. case 'application/vnd.ms-artgalry': return true;// cil
  765. case 'application/vnd.ms-cab-compressed': return true;// cab
  766. case 'application/vnd.ms-excel': return true;// xls xlm xla xlc xlt xlw
  767. case 'application/vnd.ms-excel.addin.macroenabled.12': return true;// xlam
  768. case 'application/vnd.ms-excel.sheet.binary.macroenabled.12': return true;// xlsb
  769. case 'application/vnd.ms-excel.sheet.macroenabled.12': return true;// xlsm
  770. case 'application/vnd.ms-excel.template.macroenabled.12': return true;// xltm
  771. case 'application/vnd.ms-fontobject': return true;// eot
  772. case 'application/vnd.ms-htmlhelp': return true;// chm
  773. case 'application/vnd.ms-ims': return true;// ims
  774. case 'application/vnd.ms-lrm': return true;// lrm
  775. case 'application/vnd.ms-office': return true;// theme thmx
  776. case 'application/vnd.ms-pki.seccat': return true;// cat
  777. case 'application/vnd.ms-pki.stl': return true;// stl
  778. case 'application/vnd.ms-powerpoint': return true;// ppt pps pot
  779. case 'application/vnd.ms-powerpoint.addin.macroenabled.12': return true;// ppam
  780. case 'application/vnd.ms-powerpoint.presentation.macroenabled.12': return true;// pptm
  781. case 'application/vnd.ms-powerpoint.slide.macroenabled.12': return true;// sldm
  782. case 'application/vnd.ms-powerpoint.slideshow.macroenabled.12': return true;// ppsm
  783. case 'application/vnd.ms-powerpoint.template.macroenabled.12': return true;// potm
  784. case 'application/vnd.ms-project': return true;// mpp mpt
  785. case 'application/vnd.ms-word.document.macroenabled.12': return true;// docm
  786. case 'application/vnd.ms-word.template.macroenabled.12': return true;// dotm
  787. case 'application/vnd.ms-works': return true;// wps wks wcm wdb
  788. case 'application/vnd.ms-wpl': return true;// wpl
  789. case 'application/vnd.ms-xpsdocument': return true;// xps
  790. case 'application/vnd.mseq': return true;// mseq
  791. case 'application/vnd.musician': return true;// mus
  792. case 'application/vnd.muvee.style': return true;// msty
  793. case 'application/vnd.mynfc': return true;// taglet
  794. case 'application/vnd.neurolanguage.nlu': return true;// nlu
  795. case 'application/vnd.nitf': return true;// ntf nitf
  796. case 'application/vnd.noblenet-directory': return true;// nnd
  797. case 'application/vnd.noblenet-sealer': return true;// nns
  798. case 'application/vnd.noblenet-web': return true;// nnw
  799. case 'application/vnd.nokia.n-gage.data': return true;// ngdat
  800. case 'application/vnd.nokia.n-gage.symbian.install': return true;// n- gage
  801. case 'application/vnd.nokia.radio-preset': return true;// rpst
  802. case 'application/vnd.nokia.radio-presets': return true;// rpss
  803. case 'application/vnd.novadigm.edm': return true;// edm
  804. case 'application/vnd.novadigm.edx': return true;// edx
  805. case 'application/vnd.novadigm.ext': return true;// ext
  806. case 'application/vnd.oasis.opendocument.chart': return true;// odc
  807. case 'application/vnd.oasis.opendocument.chart-template': return true;// otc
  808. case 'application/vnd.oasis.opendocument.database': return true;// odb
  809. case 'application/vnd.oasis.opendocument.formula': return true;// odf
  810. case 'application/vnd.oasis.opendocument.formula-template': return true;// odft
  811. case 'application/vnd.oasis.opendocument.graphics': return true;// odg
  812. case 'application/vnd.oasis.opendocument.graphics-template': return true;// otg
  813. case 'application/vnd.oasis.opendocument.image': return true;// odi
  814. case 'application/vnd.oasis.opendocument.image-template': return true;// oti
  815. case 'application/vnd.oasis.opendocument.presentation': return true;// odp
  816. case 'application/vnd.oasis.opendocument.presentation-template': return true;// otp
  817. case 'application/vnd.oasis.opendocument.spreadsheet': return true;// ods
  818. case 'application/vnd.oasis.opendocument.spreadsheet-template': return true;// ots
  819. case 'application/vnd.oasis.opendocument.text': return true;// odt
  820. case 'application/vnd.oasis.opendocument.text-master': return true;// odm
  821. case 'application/vnd.oasis.opendocument.text-template': return true;// ott
  822. case 'application/vnd.oasis.opendocument.text-web': return true;// oth
  823. case 'application/vnd.olpc-sugar': return true;// xo
  824. case 'application/vnd.oma.dd2+xml': return true;// dd2
  825. case 'application/vnd.openofficeorg.extension': return true;// oxt
  826. case 'application/vnd.openxmlformats-officedocument.presentationml.presentation': return true;// pptx
  827. case 'application/vnd.openxmlformats-officedocument.presentationml.slide': return true;// sldx
  828. case 'application/vnd.openxmlformats-officedocument.presentationml.slideshow': return true;// ppsx
  829. case 'application/vnd.openxmlformats-officedocument.presentationml.template': return true;// potx
  830. case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': return true;// xlsx
  831. case 'application/vnd.openxmlformats-officedocument.spreadsheetml.template': return true;// xltx
  832. case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': return true;// docx
  833. case 'application/vnd.openxmlformats-officedocument.wordprocessingml.template': return true;// dotx
  834. case 'application/vnd.osgeo.mapguide.package': return true;// mgp
  835. case 'application/vnd.osgi.dp': return true;// dp
  836. case 'application/vnd.osgi.subsystem': return true;// esa
  837. case 'application/vnd.palm': return true;// pdb pqa oprc
  838. case 'application/vnd.pawaafile': return true;// paw
  839. case 'application/vnd.pg.format': return true;// str
  840. case 'application/vnd.pg.osasli': return true;// ei6
  841. case 'application/vnd.picsel': return true;// efif
  842. case 'application/vnd.pmi.widget': return true;// wg
  843. case 'application/vnd.pocketlearn': return true;// plf
  844. case 'application/vnd.powerbuilder6': return true;// pbd
  845. case 'application/vnd.previewsystems.box': return true;// box
  846. case 'application/vnd.proteus.magazine': return true;// mgz
  847. case 'application/vnd.publishare-delta-tree': return true;// qps
  848. case 'application/vnd.pvi.ptid1': return true;// ptid
  849. case 'application/vnd.quark.quarkxpress': return true;// qxd qxt qwd qwt qxl qxb
  850. case 'application/vnd.realvnc.bed': return true;// bed
  851. case 'application/vnd.recordare.musicxml': return true;// mxl
  852. case 'application/vnd.recordare.musicxml+xml': return true;// musicxml
  853. case 'application/vnd.rig.cryptonote': return true;// cryptonote
  854. case 'application/vnd.rim.cod': return true;// cod
  855. case 'application/vnd.rn-realmedia': return true;// rm
  856. case 'application/vnd.rn-realmedia-vbr': return true;// rmvb
  857. case 'application/vnd.route66.link66+xml': return true;// link66
  858. case 'application/vnd.sailingtracker.track': return true;// st
  859. case 'application/vnd.seemail': return true;// see
  860. case 'application/vnd.sema': return true;// sema
  861. case 'application/vnd.semd': return true;// semd
  862. case 'application/vnd.semf': return true;// semf
  863. case 'application/vnd.shana.informed.formdata': return true;// ifm
  864. case 'application/vnd.shana.informed.formtemplate': return true;// itp
  865. case 'application/vnd.shana.informed.interchange': return true;// iif
  866. case 'application/vnd.shana.informed.package': return true;// ipk
  867. case 'application/vnd.simtech-mindmapper': return true;// twd twds
  868. case 'application/vnd.smaf': return true;// mmf
  869. case 'application/vnd.smart.teacher': return true;// teacher
  870. case 'application/vnd.solent.sdkm+xml': return true;// sdkm sdkd
  871. case 'application/vnd.spotfire.dxp': return true;// dxp
  872. case 'application/vnd.spotfire.sfs': return true;// sfs
  873. case 'application/vnd.stardivision.calc': return true;// sdc
  874. case 'application/vnd.stardivision.draw': return true;// sda
  875. case 'application/vnd.stardivision.impress': return true;// sdd
  876. case 'application/vnd.stardivision.math': return true;// smf
  877. case 'application/vnd.stardivision.writer': return true;// sdw vor
  878. case 'application/vnd.stardivision.writer-global': return true;// sgl
  879. case 'application/vnd.stepmania.package': return true;// smzip
  880. case 'application/vnd.stepmania.stepchart': return true;// sm
  881. case 'application/vnd.sun.xml.calc': return true;// sxc
  882. case 'application/vnd.sun.xml.calc.template': return true;// stc
  883. case 'application/vnd.sun.xml.draw': return true;// sxd
  884. case 'application/vnd.sun.xml.draw.template': return true;// std
  885. case 'application/vnd.sun.xml.impress': return true;// sxi
  886. case 'application/vnd.sun.xml.impress.template': return true;// sti
  887. case 'application/vnd.sun.xml.math': return true;// sxm
  888. case 'application/vnd.sun.xml.writer': return true;// sxw
  889. case 'application/vnd.sun.xml.writer.global': return true;// sxg
  890. case 'application/vnd.sun.xml.writer.template': return true;// stw
  891. case 'application/vnd.sus-calendar': return true;// sus susp
  892. case 'application/vnd.svd': return true;// svd
  893. case 'application/vnd.symbian.install sis': return true;// sisx
  894. case 'application/vnd.syncml+xml': return true;// xsm
  895. case 'application/vnd.syncml.dm+wbxml': return true;// bdm
  896. case 'application/vnd.syncml.dm+xml': return true;// xdm
  897. case 'application/vnd.tao.intent-module-archive': return true;// tao
  898. case 'application/vnd.tcpdump.pcap': return true;// pcap cap dmp
  899. case 'application/vnd.tmobile-livetv': return true;// tmo
  900. case 'application/vnd.trid.tpt': return true;// tpt
  901. case 'application/vnd.triscape.mxs': return true;// mxs
  902. case 'application/vnd.trueapp': return true;// tra
  903. case 'application/vnd.ufdl': return true;// ufd ufdl
  904. case 'application/vnd.uiq.theme': return true;// utz
  905. case 'application/vnd.umajin': return true;// umj
  906. case 'application/vnd.unity': return true;// unityweb
  907. case 'application/vnd.uoml+xml': return true;// uoml
  908. case 'application/vnd.vcx': return true;// vcx
  909. case 'application/vnd.visio': return true;// vsd vst vss vsw
  910. case 'application/vnd.visionary': return true;// vis
  911. case 'application/vnd.vsf': return true;// vsf
  912. case 'application/vnd.wap.wbxml': return true;// wbxml
  913. case 'application/vnd.wap.wmlc': return true;// wmlc
  914. case 'application/vnd.wap.wmlscriptc': return true;// wmlsc
  915. case 'application/vnd.webturbo': return true;// wtb
  916. case 'application/vnd.wolfram.player': return true;// nbp
  917. case 'application/vnd.wordperfect': return true;// wpd
  918. case 'application/vnd.wqd': return true;// wqd
  919. case 'application/vnd.wt.stf': return true;// stf
  920. case 'application/vnd.xara': return true;// xar
  921. case 'application/vnd.xfdl': return true;// xfdl
  922. case 'application/vnd.yamaha.hv-dic': return true;// hvd
  923. case 'application/vnd.yamaha.hv-script': return true;// hvs
  924. case 'application/vnd.yamaha.hv-voice': return true;// hvp
  925. case 'application/vnd.yamaha.openscoreformat': return true;// osf
  926. case 'application/vnd.yamaha.openscoreformat.osfpvg+xml': return true;// osfpvg
  927. case 'application/vnd.yamaha.smaf-audio': return true;// saf
  928. case 'application/vnd.yamaha.smaf-phrase': return true;// spf
  929. case 'application/vnd.yellowriver-custom-menu': return true;// cmp
  930. case 'application/vnd.zul': return true;// zir zirz
  931. case 'application/vnd.zzazz.deck+xml': return true;// zaz
  932. case 'application/voicexml+xml': return true;// vxml
  933. case 'application/widget': return true;// wgt
  934. case 'application/winhlp': return true;// hlp
  935. case 'application/wsdl+xml': return true;// wsdl
  936. case 'application/wspolicy+xml': return true;// wspolicy
  937. case 'application/x-7z-compressed': return true;// 7z
  938. case 'application/x-abiword': return true;// abw
  939. case 'application/x-ace-compressed': return true;// ace
  940. case 'application/x-apple-diskimage': return true;// dmg
  941. case 'application/x-authorware-bin': return true;// aab x32 u32 vox
  942. case 'application/x-authorware-map': return true;// aam
  943. case 'application/x-authorware-seg': return true;// aas
  944. case 'application/x-archive': return true;// ADMIN_USERS//5027.Pawel_Kamola/projekty/grafy_projekt_python/grafy/numpy/core/lib/libnpymath.a
  945. case 'application/x-empty': return false;// empty files
  946. case 'application/x-bcpio': return true;// bcpio
  947. case 'application/x-bittorrent': return true;// torrent
  948. case 'application/x-blorb': return true;// blb blorb
  949. case 'application/x-bzip': return true;// bz
  950. case 'application/x-bzip2': return true;// bz2 boz
  951. case 'application/x-cbr': return true;// cbr cba cbt cbz cb7
  952. case 'application/x-cdlink': return true;// vcd
  953. case 'application/x-cfs-compressed': return true;// cfs
  954. case 'application/x-chat': return true;// chat
  955. case 'application/x-chess-pgn': return true;// pgn
  956. case 'application/x-conference': return true;// nsc
  957. case 'application/x-cpio': return true;// cpio
  958. case 'application/x-csh': return true;// csh
  959. case 'application/x-debian-package': return true;// deb udeb
  960. case 'application/x-dgc-compressed': return true;// dgc
  961. case 'application/x-director': return true;// dir dcr dxr cst cct cxt w3d fgd swa
  962. case 'application/x-doom': return true;// wad
  963. case 'application/x-dtbncx+xml': return true;// ncx
  964. case 'application/x-dtbook+xml': return true;// dtb
  965. case 'application/x-dtbresource+xml': return true;// res
  966. case 'application/x-dvi': return true;// dvi
  967. case 'application/x-envoy': return true;// evy
  968. case 'application/x-eva': return true;// eva
  969. case 'application/x-font-bdf': return true;// bdf
  970. case 'application/x-font-ghostscript': return true;// gsf
  971. case 'application/x-font-linux-psf': return true;// psf
  972. case 'application/x-font-otf': return true;// otf
  973. case 'application/x-font-pcf': return true;// pcf
  974. case 'application/x-font-snf': return true;// snf
  975. case 'application/x-font-ttf': return true;// ttc ttf
  976. case 'application/x-font-type1': return true;// afm pfa pfb pfm
  977. case 'application/x-freearc': return true;// arc
  978. case 'application/x-futuresplash': return true;// spl
  979. case 'application/x-executable': return true;//
  980. case 'application/x-gca-compressed': return true;// gca
  981. case 'application/x-glulx': return true;// ulx
  982. case 'application/x-gnumeric': return true;// gnumeric
  983. case 'application/x-gramps-xml': return true;// gramps
  984. case 'application/x-gtar': return true;// gtar
  985. case 'application/x-gzip': return true;// gz gzip
  986. case 'application/x-hdf': return true;// hdf
  987. case 'application/x-install-instructions': return true;// install
  988. case 'application/x-iso9660-image': return true;// iso
  989. case 'application/x-java-jnlp-file': return true;// jnlp
  990. case 'application/x-latex': return true;// latex
  991. case 'application/x-lzh-compressed': return true;// lha lzh
  992. case 'application/x-mie': return true;// mie
  993. case 'application/x-mobipocket-ebook': return true;// mobi prc
  994. case 'application/x-ms-application': return true;// application
  995. case 'application/x-ms-shortcut': return true;// lnk
  996. case 'application/x-ms-wmd': return true;// wmd
  997. case 'application/x-ms-wmz': return true;// wmz
  998. case 'application/x-ms-xbap': return true;// xbap
  999. case 'application/x-msaccess': return true;// mdb
  1000. case 'application/x-msbinder': return true;// obd
  1001. case 'application/x-mscardfile': return true;// crd
  1002. case 'application/x-msclip': return true;// clp
  1003. case 'application/x-msdownload': return true;// msi exe dll com bat
  1004. case 'application/x-msmediaview': return true;// m14 mvb m13
  1005. case 'application/x-msmetafile': return true;// emz wmf wmz emf
  1006. case 'application/x-msmoney': return true;// mny
  1007. case 'application/x-mspublisher': return true;// pub
  1008. case 'application/x-msschedule': return true;// scd
  1009. case 'application/x-msterminal': return true;// trm
  1010. case 'application/x-mswrite': return true;// wri
  1011. case 'application/x-netcdf': return true;// cdf nc
  1012. case 'application/x-nzb': return true;// nzb
  1013. case 'application/x-pkcs12': return true;// pfx p12
  1014. case 'application/x-pkcs7-certificates': return true;// spc p7b
  1015. case 'application/x-pkcs7-certreqresp': return true;// p7r
  1016. case 'application/x-rar': return true;// rar
  1017. case 'application/x-rar-compressed': return true;// rar
  1018. case 'application/x-research-info-systems': return true;// ris
  1019. case 'application/x-sh': return true;// sh
  1020. case 'application/x-shar': return true;// shar
  1021. case 'application/x-shockwave-flash': return true;// swf
  1022. case 'application/x-silverlight-app': return true;// xap
  1023. case 'application/x-sql': return true;// sql
  1024. case 'application/x-stuffit': return true;// sit
  1025. case 'application/x-stuffitx': return true;// sitx
  1026. case 'application/x-subrip': return true;// srt
  1027. case 'application/x-sv4cpio': return true;// sv4cpio
  1028. case 'application/x-sv4crc': return true;// sv4crc
  1029. case 'application/x-t3vm-image': return true;// t3
  1030. case 'application/x-tads': return true;// gam
  1031. case 'application/x-tar': return true;// tar
  1032. case 'application/x-tcl': return true;// tcl
  1033. case 'application/x-tex': return true;// tex
  1034. case 'application/x-tex-tfm': return true;// tfm
  1035. case 'application/x-texinfo': return true;// texi texinfo
  1036. case 'application/x-tgif': return true;// obj
  1037. case 'application/x-ustar': return true;// ustar
  1038. case 'application/x-wais-source': return true;// src
  1039. case 'application/x-x509-ca-cert': return true;// crt der
  1040. case 'application/x-xfig': return true;// fig
  1041. case 'application/x-xliff+xml': return true;// xlf
  1042. case 'application/x-xpinstall': return true;// xpi
  1043. case 'application/x-xz': return true;// xz
  1044. case 'application/x-zmachine': return true;// z8 z1 z2 z3 z4 z5 z6 z7
  1045. case 'application/xaml+xml': return true;// xaml
  1046. case 'application/xcap-diff+xml': return true;// xdf
  1047. case 'application/xenc+xml': return true;// xenc
  1048. case 'application/xhtml+xml': return true;// xht xhtml
  1049. case 'application/xml': return true;// xsl xml
  1050. case 'application/xml-dtd': return true;// dtd
  1051. case 'application/xop+xml': return true;// xop
  1052. case 'application/xproc+xml': return true;// xpl
  1053. case 'application/xslt+xml': return true;// xslt
  1054. case 'application/xspf+xml': return true;// xspf
  1055. case 'application/xv+xml': return true;// xvm mxml xhvml xvml
  1056. case 'application/yang': return true;// yang
  1057. case 'application/yin+xml': return true;// yin
  1058. case 'application/zip': return true;// zip
  1059. case 'audio/adpcm': return true;// adp
  1060. case 'audio/basic': return true;// snd au
  1061. case 'audio/midi': return true;// rmi mid midi kar
  1062. case 'audio/mp4': return true;// mp4a m4a
  1063. case 'audio/mpeg': return true;// m3a mpga mp2 mp2a mp3 m2a
  1064. case 'audio/ogg': return true;// spx oga ogg
  1065. case 'audio/s3m': return true;// s3m
  1066. case 'audio/silk': return true;// sil
  1067. case 'audio/vnd.dece.audio': return true;// uvva uva
  1068. case 'audio/vnd.digital-winds': return true;// eol
  1069. case 'audio/vnd.dra': return true;// dra
  1070. case 'audio/vnd.dts': return true;// dts
  1071. case 'audio/vnd.dts.hd': return true;// dtshd
  1072. case 'audio/vnd.lucent.voice': return true;// lvp
  1073. case 'audio/vnd.ms-playready.media.pya': return true;// pya
  1074. case 'audio/vnd.nuera.ecelp4800': return true;// ecelp4800
  1075. case 'audio/vnd.nuera.ecelp7470': return true;// ecelp7470
  1076. case 'audio/vnd.nuera.ecelp9600': return true;// ecelp9600
  1077. case 'audio/vnd.rip': return true;// rip
  1078. case 'audio/webm': return true;// weba
  1079. case 'audio/x-aac': return true;// aac
  1080. case 'audio/x-aiff': return true;// aifc aif aiff
  1081. case 'audio/x-caf': return true;// caf
  1082. case 'audio/x-flac': return true;// flac
  1083. case 'audio/x-matroska': return true;// mka
  1084. case 'audio/x-mpegurl': return true;// m3u
  1085. case 'audio/x-ms-wax': return true;// wax
  1086. case 'audio/x-ms-wma': return true;// wma
  1087. case 'audio/x-pn-realaudio': return true;// ra ram
  1088. case 'audio/x-pn-realaudio-plugin': return true;// rmp
  1089. case 'audio/x-wav': return true;// wav
  1090. case 'audio/xm': return true;// xm
  1091. case 'chemical/x-cdx': return true;// cdx
  1092. case 'chemical/x-cif': return true;// cif
  1093. case 'chemical/x-cmdf': return true;// cmdf
  1094. case 'chemical/x-cml': return true;// cml
  1095. case 'chemical/x-csml': return true;// csml
  1096. case 'chemical/x-xyz': return true;// xyz
  1097. case 'image/bmp': return true;// bmp
  1098. case 'image/cgm': return true;// cgm
  1099. case 'image/g3fax': return true;// g3
  1100. case 'image/gif': return true;// gif
  1101. case 'image/ief': return true;// ief
  1102. case 'image/jpeg': return true;// jpe jpeg jpg
  1103. case 'image/ktx': return true;// ktx
  1104. case 'image/png': return true;// png
  1105. case 'image/prs.btif': return true;// btif
  1106. case 'image/sgi': return true;// sgi
  1107. case 'image/svg+xml': return true;// svgz svg
  1108. case 'image/tiff': return true;// tif tiff
  1109. case 'image/vnd.adobe.photoshop': return true;// psd
  1110. case 'image/vnd.dece.graphic': return true;// uvvg uvi uvvi uvg
  1111. case 'image/vnd.djvu': return true;// djv djvu
  1112. case 'image/vnd.dvb.subtitle': return true;// sub
  1113. case 'image/vnd.dwg': return true;// dwg
  1114. case 'image/vnd.dxf': return true;// dxf
  1115. case 'image/vnd.fastbidsheet': return true;// fbs
  1116. case 'image/vnd.fpx': return true;// fpx
  1117. case 'image/vnd.fst': return true;// fst
  1118. case 'image/vnd.fujixerox.edmics-mmr': return true;// mmr
  1119. case 'image/vnd.fujixerox.edmics-rlc': return true;// rlc
  1120. case 'image/vnd.ms-modi': return true;// mdi
  1121. case 'image/vnd.ms-photo': return true;// wdp
  1122. case 'image/vnd.net-fpx': return true;// npx
  1123. case 'image/vnd.wap.wbmp': return true;// wbmp
  1124. case 'image/vnd.xiff': return true;// xif
  1125. case 'image/webp': return true;// webp
  1126. case 'image/x-3ds': return true;// 3ds
  1127. case 'image/x-cmu-raster': return true;// ras
  1128. case 'image/x-cmx': return true;// cmx
  1129. case 'image/x-freehand': return true;// fh7 fh fhc fh4 fh5
  1130. case 'image/x-ico': return true;// ico
  1131. case 'image/x-icon': return true;// ico
  1132. case 'image/x-mrsid-image': return true;// sid
  1133. case 'image/x-ms-bmp': return true;// bmp
  1134. case 'image/x-pcx': return true;// pcx
  1135. case 'image/x-pict': return true;// pct pic
  1136. case 'image/x-portable-anymap': return true;// pnm
  1137. case 'image/x-portable-bitmap': return true;// pbm
  1138. case 'image/x-portable-graymap': return true;// pgm
  1139. case 'image/x-portable-greymap': return true;// pgm
  1140. case 'image/x-portable-pixmap': return true;// ppm
  1141. case 'image/x-rgb': return true;// rgb
  1142. case 'image/x-tga': return true;// tga
  1143. case 'image/x-xbitmap': return true;// xbm
  1144. case 'image/x-xpixmap': return true;// xpm
  1145. case 'image/x-xwindowdump': return true;// xwd
  1146. case 'message/rfc822': return true;// mime eml
  1147. case 'model/iges': return true;// iges igs
  1148. case 'model/mesh': return true;// silo msh mesh
  1149. case 'model/vnd.collada+xml': return true;// dae
  1150. case 'model/vnd.dwf': return true;// dwf
  1151. case 'model/vnd.gdl': return true;// gdl
  1152. case 'model/vnd.gtw': return true;// gtw
  1153. case 'model/vnd.mts': return true;// mts
  1154. case 'model/vnd.vtu': return true;// vtu
  1155. case 'model/vrml': return true;// vrml wrl
  1156. case 'model/x3d+binary': return true;// x3dbz x3db
  1157. case 'model/x3d+vrml': return true;// x3dvz x3dv
  1158. case 'model/x3d+xml': return true;// x3dz x3d
  1159. case 'text/cache-manifest': return true;// appcache
  1160. case 'text/calendar': return true;// ifb ics
  1161. case 'text/css': return true;// css
  1162. case 'text/csv': return true;// csv
  1163. case 'text/html': return true;// htm html
  1164. case 'text/n3': return true;// n3
  1165. case 'text/plain': return true;// in txt text conf def list log
  1166. case 'text/prs.lines.tag': return true;// dsc
  1167. case 'text/rtf': return true;// rtf
  1168. case 'text/richtext': return true;// rtx
  1169. case 'text/sgml': return true;// sgm sgml
  1170. case 'text/tab-separated-values': return true;// tsv
  1171. case 'text/troff': return true;// ms t tr roff man me
  1172. case 'text/turtle': return true;// ttl
  1173. case 'text/uri-list': return true;// urls uri uris
  1174. case 'text/vcard': return true;// vcard
  1175. case 'text/vnd.curl': return true;// curl
  1176. case 'text/vnd.curl.dcurl': return true;// dcurl
  1177. case 'text/vnd.curl.mcurl': return true;// mcurl
  1178. case 'text/vnd.curl.scurl': return true;// scurl
  1179. case 'text/vnd.dvb.subtitle': return true;// sub
  1180. case 'text/vnd.fly': return true;// fly
  1181. case 'text/vnd.fmi.flexstor': return true;// flx
  1182. case 'text/vnd.graphviz': return true;// gv
  1183. case 'text/vnd.in3d.3dml': return true;// 3dml
  1184. case 'text/vnd.in3d.spot': return true;// spot
  1185. case 'text/vnd.sun.j2me.app-descriptor': return true;// jad
  1186. case 'text/vnd.wap.wml': return true;// wml
  1187. case 'text/vnd.wap.wmlscript': return true;// wmls
  1188. case 'text/x-asm': return true;// s asm
  1189. case 'text/x-c': return true;// c cc cxx cpp h hh dic
  1190. case 'text/x-c++': return true;// c++
  1191. case 'text/x-fortran': return true;// f for f77 f90
  1192. case 'text/x-java': return true;// java
  1193. case 'text/x-java-source': return true;// java
  1194. case 'text/x-makefile': return true;// Makefile
  1195. case 'text/x-nfo': return true;// nfo
  1196. case 'text/x-opml': return true;// opml
  1197. case 'text/x-pascal': return true;// p pas
  1198. case 'text/x-php': return true;// php
  1199. case 'text/x-python': return true;// py
  1200. case 'text/x-setext': return true;// etx
  1201. case 'text/x-sfv': return true;// sfv
  1202. case 'text/x-shellscript': return true;// ...
  1203. case 'text/x-uuencode': return true;// uu
  1204. case 'text/x-vcalendar': return true;// vcs
  1205. case 'text/x-vcard': return true;// vcf
  1206. case 'video/3gpp': return true;// 3gp
  1207. case 'video/3gpp2': return true;// 3g2
  1208. case 'video/h261': return true;// h261
  1209. case 'video/h263': return true;// h263
  1210. case 'video/h264': return true;// h264
  1211. case 'video/jpeg': return true;// jpgv
  1212. case 'video/jpm': return true;// jpm jpgm
  1213. case 'video/mj2': return true;// mjp2 mj2
  1214. case 'video/mp4': return true;// mpg4 mp4 mp4v
  1215. case 'video/mpeg': return true;// m2v mpeg mpg mpe m1v
  1216. case 'video/ogg': return true;// ogv
  1217. case 'video/quicktime': return true;// mov qt
  1218. case 'video/vnd.dece.hd': return true;// uvvh uvh
  1219. case 'video/vnd.dece.mobile': return true;// uvvm uvm
  1220. case 'video/vnd.dece.pd': return true;// uvvp uvp
  1221. case 'video/vnd.dece.sd': return true;// uvvs uvs
  1222. case 'video/vnd.dece.video': return true;// uvvv uvv
  1223. case 'video/vnd.dvb.file': return true;// dvb
  1224. case 'video/vnd.fvt': return true;// fvt
  1225. case 'video/vnd.mpegurl': return true;// m4u mxu
  1226. case 'video/vnd.ms-playready.media.pyv': return true;// pyv
  1227. case 'video/vnd.uvvu.mp4': return true;// uvvu uvu
  1228. case 'video/vnd.vivo': return true;// viv
  1229. case 'video/webm': return true;// webm
  1230. case 'video/x-f4v': return true;// f4v
  1231. case 'video/x-fli': return true;// fli
  1232. case 'video/x-flv': return true;// flv
  1233. case 'video/x-m4v': return true;// m4v
  1234. case 'video/x-matroska': return true;// mks mkv mk3d
  1235. case 'video/x-mng': return true;// mng
  1236. case 'video/x-ms-asf': return true;// asx asf
  1237. case 'video/x-ms-vob': return true;// vob
  1238. case 'video/x-ms-wm': return true;// wm
  1239. case 'video/x-ms-wmv': return true;// wmv
  1240. case 'video/x-ms-wmx': return true;// wmx
  1241. case 'video/x-ms-wvx': return true;// wvx
  1242. case 'video/x-msvideo': return true;// avi
  1243. case 'video/x-sgi-movie': return true;// movie
  1244. case 'video/x-smv': return true;// smv
  1245. case 'x-conference/x-cooltalk': return true;// ice
  1246. }
  1247. return false;
  1248. }
  1249. }