GPL ##################### /* # this was originally implemented for Nanoweb, but can now be used # within ewiki to enhance the download/upload plugin. # As it was created from Debians mime-magic data, it is covered by # the GNU GPL [http://www.gnu.org/]: This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ $ewiki_plugins["mime_magic"][] = "ewiki_mime_magic"; function ewiki_mime_magic(&$binary_data) { global $mime_magic_data; $fd = substr($binary_data, 0, 3072); foreach ($mime_magic_data as $def) { if ($def[0] >= $f_read) { continue; } $pos0 = $def[0]; if ($pos0[0] == ">") { $pos0 = substr($pos0, 1); if (strpos($fd, $def[3], $pos0) !== false) { return($def[4]); } } else { $part = substr($fd, $pos0, $def[1]); if ($mask = $def[2]) { $value = 1 * ('0x'.bin2hex($part)); if (($value & $mask) == $def[3]) { return($def[4]); } } else { if ($part == $def[3]) { return($def[4]); } } } } } $GLOBALS["mime_magic_data"] = array( array(0, 2, 0, "\x06\x02", "application/x-alan-adventure-game"), array(0, 4, 0, "TADS", "application/x-tads-game"), array(0, 2, 0, "\x01\x10", "application/x-executable-file"), array(0, 2, 0, "\x01\x11", "application/x-executable-file"), array(0, 2, 0, "\x01", "application/x-executable-file"), array(0, 5, 0, "Core\001", "application/x-executable-file"), array(0, 22, 0, "AMANDA: TAPESTART DATE", "application/x-amanda-header"), array(0, 2, 0xfff0, 0xf0ff, "audio/mpeg"), array(4, 2, 0, "\x11", "video/fli"), array(4, 2, 0, "\x12", "video/flc"), array(0, 4, 0, "MOVI", "video/x-sgi-movie"), array(4, 4, 0, "moov", "video/quicktime"), array(4, 4, 0, "mdat", "video/quicktime"), array(0, 18, 0, "FiLeStArTfIlEsTaRt", "text/x-apple-binscii"), array(0, 3, 0, "\x0aGL", "application/data"), array(0, 2, 0, "\x76\xff", "application/data"), array(0, 6, 0, "NuFile", "application/data"), array(0, 6, 0, "N\xf5F\xe9l\xe5", "application/data"), array(0, 4, 0, "\x00\x16\x05\x00", "application/data"), array(0, 4, 0, "\x07\x16\x05\x00", "application/data"), array(257, 6, 0, "ustar\0", "application/x-tar"), array(257, 8, 0, "ustar\040\040\0", "application/x-gtar"), array(0, 2, 0, "q", "application/x-cpio"), array(0, 2, 0, "q", "application/x-bcpio"), array(0, 6, 0, "070707", "application/x-cpio"), array(0, 6, 0, "070701", "application/x-cpio"), array(0, 6, 0, "070702", "application/x-cpio"), array(0, 2, 0, "m", "application/data"), array(0, 2, 0, "e", "application/data"), array(0, 5, 0, "=", "application/x-ar"), array(0, 19, 0, "!\n__________E", "application/x-ar"), array(0, 3, 0, "-h-", "application/data"), array(0, 7, 0, "!", "application/x-ar"), array(0, 4, 0, "", "application/x-ar"), array(0, 4, 0, ">ra<", "application/x-ar"), array(0, 4, 0, "!\n\n________64E", "application/data"), array(0, 2, 0, "\x01", "application/x-executable-file"), array(0, 2, 0, "\x01", "application/x-object-file"), array(0, 3, 0, "\377\377\177", "application/data"), array(0, 3, 0, "\377\377\174", "application/data"), array(0, 3, 0, "\377\377\176", "application/data"), array(0, 3, 0, "\033c\033", "application/data"), array(0, 4, 0, "\x00\x12և", "image/x11"), array(0, 8, 0, "!!\n", "application/x-prof"), array(0, 2, 0, "\x05\x01", "application/x-locale"), array(0, 4, 0, "\177ELF", "application/x-executable-file"), array(0, 2, 0, "\x01T", "application/data"), array(0, 2, 0, "\x01U", "application/x-executable-file"), array(0x438, 2, 0, "S", "application/x-linux-ext2fs"), array(0, 4, 0, "\366\366\366\366", "application/x-pc-floppy"), array(0774, 2, 0, "", "application/data"), array(0x1FE, 2, 0, "U", "application/data"), array(0x410, 2, 0, "\x13", "application/x-filesystem"), array(0x410, 2, 0, "\x13", "application/x-filesystem"), array(0x410, 2, 0, "\x24h", "application/x-filesystem"), array(0x410, 2, 0, "\x24x", "application/x-filesystem"), array(0, 9, 0, "-rom1fs-\0", "application/x-filesystem"), array(0, 4, 0, "\x1b\x03\x136", "application/x-bootable"), array(0x18b, 4, 0, "OS/2", "application/x-bootable"), array(0, 4, 0, "FONT", "font/x-vfont"), array(0, 2, 0, "\x01\x1e", "font/x-vfont"), array(0, 2, 0, "\x1e\x01", "font/x-vfont"), array(0, 18, 0, "%!PS-AdobeFont-1.0", "font/type1"), array(6, 18, 0, "%!PS-AdobeFont-1.0", "font/type1"), array(0, 10, 0, "STARTFONT\040", "font/x-bdf"), array(0, 4, 0, "\001fcp", "font/x-pcf"), array(0, 5, 0, "D1.0\015", "font/x-speedo"), array(0, 3, 0, "flf", "font/x-figlet"), array(0, 3, 0, "flc", "application/x-font"), array(0, 4, 0, "\x19Y\x02\x14", "font/x-libgrx"), array(0, 4, 0, "NOF", "font/x-dos"), array(7, 4, 0, "AGE\x00", "font/x-dos"), array(7, 4, 0, "DIV\x00", "font/x-dos"), array(0, 10, 0, "2', 2, 0, "", "application/java"), array(8, 4, 0, "AIFF", "audio/x-aiff"), array(8, 4, 0, "AIFC", "audio/x-aiff"), array(8, 4, 0, "8SVX", "audio/x-aiff"), array('>8', 4, 0, "WAVE", "audio/x-wav"), array('>8', 3, 0, "AVI", "video/x-msvideo"), array(0, 3, 0, "ID3", "audio/mpeg"), array(0, 4, 0, "OggS", "audio/x-ogg"), array(0, 6, 0, "/* XPM", "image/x-xpm"), array(16, 2, 0, "==", "image/x-3ds"), array(0, 11, 0, "#!/bin/tcsh", "application/x-shellscript"), array(0, 12, 0, "#! /bin/tcsh", "application/x-shellscript"), array(0, 18, 0, "#! /usr/local/tcsh", "application/x-shellscript"), array('>8', 6, 0, "debian", "application/x-debian-package"), array('>2', 2, 0, "", "application/x-rpm"), array(2, 5, 0, "-lh -", "application/x-lha"), array(2, 5, 0, "-lh6-", "application/x-lha"), array(2, 5, 0, "-lh7-", "application/x-lha"), array(0, 15, 0, "8', 4, 0, "AVI ", "video/avi"), array(0, 1, 0, "\x01", "video/unknown"), array(0, 1, 0, "\x02", "video/unknown"), array(0, 19, 0, "[KDE Desktop Entry]", "application/x-kdelnk"), array(0, 18, 0, "\# KDE Config File", "application/x-kdelnk"), array(0, 7, 0, "\# xmcd", "text/xmcd"), array(0, 4, 0, "\x8aMNG", "video/x-mng"), array(0, 4, 0, "\x03\x00\x00", "application/x-executable-file"), array(0, 4, 0, "\x03\x00\x00", "application/x-library-file"), array(0, 4, 0, "\x01\x00\x00", "video/mpeg"), array(0, 4, 0, "\x01\x00\x00", "video/mpeg"), array(0, 4, 0, "\x00\x00l", "application/x-apl-workspace"), array(0, 4, 0, "\x00\x00m", "application/x-ar"), array(0, 4, 0, "\x00\x00e", "application/data"), array(0, 4, 0, "\x00\x00\x01\x06", "application/x-executable-file"), array(0, 4, 0, "G\x01\x00\x00", "application/x-object-file"), array(0, 4, 0, "K\x01\x00\x00", "application/x-executable-file"), array(0, 4, 0, "M\x01\x00\x00", "application/x-executable-file"), array(0, 4, 0, "O\x01\x00\x00", "application/x-executable-file"), array(24, 4, 0, "k\x00\x00", "application/data"), array(24, 4, 0, "l\x00\x00", "application/data"), array(24, 4, 0, "m\x00\x00", "application/data"), array(24, 4, 0, "n\x00\x00", "application/data"), array(0, 4, 0, "\x01\x00\x00", "application/x-object-file"), array(0, 4, 0, "\x01\x00\x00", "application/data"), array(24, 4, 0, "\x00\x00l", "application/x-dump"), array(24, 4, 0, "\x00\x00k", "application/x-dump"), array(0, 4, 0, "\x00\x001", "text/vnd.ms-word"), array(0, 2, 0, "\x00\x00", "audio/mpeg"), array('>16', 2, 0, "\x00\x01", "application/x-object"), array('>16', 2, 0, "\x00\x02", "application/x-executable"), array('>16', 2, 0, "\x00\x03", "application/x-sharedlib"), array('>16', 2, 0, "\x00\x04", "application/x-coredump"), array(0, 4, 0, "\x00\x00\x00", "application/x-executable-file"), array(0, 4, 0, "\x04\x00\x00\x00", "font/x-snf"), array(0, 4, 0, "\x00\x00\x00\x04", "font/x-snf"), array('>12', 4, 0, "\x01\x00\x00\x00", "audio/basic"), array('>12', 4, 0, "\x02\x00\x00\x00", "audio/basic"), array('>12', 4, 0, "\x03\x00\x00\x00", "audio/basic"), array('>12', 4, 0, "\x04\x00\x00\x00", "audio/basic"), array('>12', 4, 0, "\x05\x00\x00\x00", "audio/basic"), array('>12', 4, 0, "\x06\x00\x00\x00", "audio/basic"), array('>12', 4, 0, "\x07\x00\x00\x00", "audio/basic"), array('>12', 4, 0, "\x17\x00\x00\x00", "audio/x-adpcm"), array('>12', 4, 0, "\x00\x00\x00\x01", "audio/x-dec-basic"), array('>12', 4, 0, "\x00\x00\x00\x02", "audio/x-dec-basic"), array('>12', 4, 0, "\x00\x00\x00\x03", "audio/x-dec-basic"), array('>12', 4, 0, "\x00\x00\x00\x04", "audio/x-dec-basic"), array('>12', 4, 0, "\x00\x00\x00\x05", "audio/x-dec-basic"), array('>12', 4, 0, "\x00\x00\x00\x06", "audio/x-dec-basic"), array('>12', 4, 0, "\x00\x00\x00\x07", "audio/x-dec-basic"), array('>12', 4, 0, "\x00\x00\x00\x17", "audio/x-dec-adpcm") ); ?>