lib
6 months ago
FileManager.php
6 months ago
FileManagerHelper.php
6 months ago
index.php
6 months ago
FileManagerHelper.php
122 lines
| 1 | <?php |
| 2 | |
| 3 | defined('ABSPATH') || exit; |
| 4 | |
| 5 | if(!class_exists('FileManagerHelper')): |
| 6 | |
| 7 | class FileManagerHelper{ |
| 8 | |
| 9 | public function getArrMimeTypes() |
| 10 | { |
| 11 | $arrMimeTypes = array ( |
| 12 | //text |
| 13 | '.txt' => 'text/plain', |
| 14 | '.htm' => 'text/html', |
| 15 | '.html' => 'text/html', |
| 16 | '.php' => 'text/x-php', |
| 17 | '.css' => 'text/css', |
| 18 | '.csv' => 'text/csv', |
| 19 | '.js' => 'text/javascript', |
| 20 | '.json' => 'application/json', |
| 21 | '.xml' => 'text/xml', |
| 22 | '.ics' => 'text/calendar', |
| 23 | |
| 24 | //font |
| 25 | '.woff' => 'font/woff,application/font-woff,application/x-font-opentype,application/x-font-truetype,application/vnd.ms-fontobject', |
| 26 | '.woff2' => 'font/woff2', |
| 27 | '.ttf' => 'application/x-font-ttf,font/ttf', |
| 28 | '.otf' => 'font/otf', |
| 29 | '.sfnt' => 'font/sfnt,application/font-sfnt', |
| 30 | |
| 31 | // images |
| 32 | '.png' => 'image/png', |
| 33 | '.jpe' => 'image/jpeg', |
| 34 | '.jpg' => 'image/jpeg', |
| 35 | '.jpeg' => 'image/jpeg', |
| 36 | '.jpg' => 'image/jpeg', |
| 37 | '.gif' => 'image/gif', |
| 38 | '.bmp' => 'image/bmp', |
| 39 | '.ico' => 'image/vnd.microsoft.icon,image/x-icon', |
| 40 | '.tiff' => 'image/tiff', |
| 41 | '.tif' => 'image/tiff', |
| 42 | '.svg' => 'image/svg+xml', |
| 43 | '.svgz' => 'image/svg+xml', |
| 44 | |
| 45 | // archives |
| 46 | '.zip' => 'application/zip', |
| 47 | '.rar' => 'application/x-rar-compressed', |
| 48 | '.exe' => 'application/x-msdownload', |
| 49 | '.msi' => 'application/x-msdownload', |
| 50 | '.cab' => 'application/vnd.ms-cab-compressed', |
| 51 | '.tar' => 'application/x-tar', |
| 52 | '.gz' => 'application/x-gzip', |
| 53 | '.bz2' => 'application/x-bzip2', |
| 54 | '.7z' => 'application/x-7z-compressed', |
| 55 | |
| 56 | // audio |
| 57 | '.mp3' => 'audio/mpeg', |
| 58 | '.mp4a' => 'audio/mp4', |
| 59 | '.mpega' => 'audio/mpeg', |
| 60 | '.mpga' => 'audio/mpeg', |
| 61 | '.aac' => 'audio/x-aac', |
| 62 | '.m3u' => 'audio/x-mpegurl', |
| 63 | '.mpa' => 'audio/mpeg', |
| 64 | '.wav' => 'audio/x-wav', |
| 65 | '.wma' => 'audio/x-ms-wma', |
| 66 | |
| 67 | //video |
| 68 | '.flv' => 'video/x-flv', |
| 69 | '.qt' => 'video/quicktime', |
| 70 | '.mov' => 'video/quicktime', |
| 71 | '.avi' => 'video/x-msvideo', |
| 72 | '.mp4' => 'video/mp4', |
| 73 | '.mpeg' => 'video/mpeg', |
| 74 | '.mpg' => 'video/mpeg', |
| 75 | '.wmv' => 'video/x-ms-wmv', |
| 76 | '.mpav' => 'video/mpeg', |
| 77 | '.swf' => 'application/x-shockwave-flash', |
| 78 | |
| 79 | // adobe |
| 80 | '.pdf' => 'application/pdf', |
| 81 | '.psd' => 'image/vnd.adobe.photoshop', |
| 82 | '.ai' => 'application/postscript', |
| 83 | '.eps' => 'application/postscript', |
| 84 | '.ps' => 'application/postscript', |
| 85 | |
| 86 | // ms office |
| 87 | '.doc' => 'application/msword', |
| 88 | '.rtf' => 'application/rtf', |
| 89 | '.xls' => 'application/vnd.ms-excel', |
| 90 | '.ppt' => 'application/vnd.ms-powerpoint', |
| 91 | '.docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', |
| 92 | '.pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', |
| 93 | '.xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', |
| 94 | '.xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12', |
| 95 | '.xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12', |
| 96 | '.dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', |
| 97 | '.xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', |
| 98 | '.potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', |
| 99 | '.ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', |
| 100 | '.sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', |
| 101 | |
| 102 | // open office |
| 103 | 'odt' => 'application/vnd.oasis.opendocument.text', |
| 104 | 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', |
| 105 | ); |
| 106 | return $arrMimeTypes; |
| 107 | } |
| 108 | |
| 109 | public function madeStripcslashesFile($cmd, &$args, $elfinder, $volume) |
| 110 | { |
| 111 | $args['content'] = stripcslashes($args['content']); |
| 112 | return true; |
| 113 | } |
| 114 | |
| 115 | public function listFileCanNotUpload() |
| 116 | { |
| 117 | $list = array('.php', '.php3', '.php4', '.phar', '.phtml', '.htaccess', '.txt', 'text/plain', 'text/x-php', 'text/php', 'text/html', 'text/javascript'); |
| 118 | return apply_filters('njt_fs_list_file_can_not_upload', $list); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | endif; |