diff options
| author | Max Kremmel <xing@synapse.plus.com> | 2008-05-22 07:19:03 +0000 |
|---|---|---|
| committer | Max Kremmel <xing@synapse.plus.com> | 2008-05-22 07:19:03 +0000 |
| commit | 69e65f63d2a31c0b03df0cb5006b03c8f93f4b31 (patch) | |
| tree | 28827cad2af671d24d54e4fa8951c1c3b970ca3b /getid3/demos/demo.mimeonly.php | |
| parent | 2f4451862589acfe9e93bfee4f8a0f261c82643c (diff) | |
| download | util-69e65f63d2a31c0b03df0cb5006b03c8f93f4b31.tar.gz util-69e65f63d2a31c0b03df0cb5006b03c8f93f4b31.tar.bz2 util-69e65f63d2a31c0b03df0cb5006b03c8f93f4b31.zip | |
add getID3 to our set of utilities. great tool for extracting meta data from various filetypes such as audio, video, image...
Diffstat (limited to 'getid3/demos/demo.mimeonly.php')
| -rw-r--r-- | getid3/demos/demo.mimeonly.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/getid3/demos/demo.mimeonly.php b/getid3/demos/demo.mimeonly.php new file mode 100644 index 0000000..dd6dec6 --- /dev/null +++ b/getid3/demos/demo.mimeonly.php @@ -0,0 +1,53 @@ +<?php +///////////////////////////////////////////////////////////////// +/// getID3() by James Heinrich <info@getid3.org> // +// available at http://getid3.sourceforge.net // +// or http://www.getid3.org // +///////////////////////////////////////////////////////////////// +// // +// /demo/demo.mimeonly.php - part of getID3() // +// Sample script for scanning a single file and returning only // +// the MIME information // +// See readme.txt for more details // +// /// +///////////////////////////////////////////////////////////////// + +echo '<HTML><HEAD><STYLE>BODY, TD, TH { font-family: sans-serif; font-size: 10pt; }</STYLE></HEAD><BODY>'; + +if (!empty($_REQUEST['filename'])) { + + echo 'The file "'.$_REQUEST['filename'].'" has a MIME type of "'.GetMIMEtype($_REQUEST['filename']).'"'; + +} else { + + echo 'Usage: <TT>'.$_SERVER['PHP_SELF'].'?filename=<I>filename.ext</I></TT>'; + +} + + +function GetMIMEtype($filename) { + // include getID3() library (can be in a different directory if full path is specified) + require_once('../getid3/getid3.php'); + // Initialize getID3 engine + $getID3 = new getID3; + + $DeterminedMIMEtype = ''; + if ($fp = fopen($filename, 'rb')) { + $ThisFileInfo = array('avdataoffset'=>0, 'avdataend'=>0); + + getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, true); + $tag = new getid3_id3v2($fp, $ThisFileInfo); + + fseek($fp, $ThisFileInfo['avdataoffset'], SEEK_SET); + $formattest = fread($fp, 16); // 16 bytes is sufficient for any format except ISO CD-image + fclose($fp); + + $DeterminedFormatInfo = $getID3->GetFileFormat($formattest); + $DeterminedMIMEtype = $DeterminedFormatInfo['mime_type']; + } + return $DeterminedMIMEtype; +} + +?> +</BODY> +</HTML>
\ No newline at end of file |
