Example #1
0
function GetMIMEtype($filename)
{
    $filename = realpath($filename);
    if (!file_exists($filename)) {
        echo 'File does not exist: "' . htmlentities($filename) . '"<br>';
        return '';
    } elseif (!is_readable($filename)) {
        echo 'File is not readable: "' . htmlentities($filename) . '"<br>';
        return '';
    }
    // 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')) {
        $getID3->openfile($filename);
        if (empty($getID3->info['error'])) {
            // ID3v2 is the only tag format that might be prepended in front of files, and it's non-trivial to skip, easier just to parse it and know where to skip to
            getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'module.tag.id3v2.php', __FILE__, true);
            $getid3_id3v2 = new GetId3\Module\Tag\Id3v2($getID3);
            $getid3_id3v2->analyze();
            fseek($fp, $getID3->info['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'];
        } else {
            echo 'Failed to getID3->openfile "' . htmlentities($filename) . '"<br>';
        }
    } else {
        echo 'Failed to fopen "' . htmlentities($filename) . '"<br>';
    }
    return $DeterminedMIMEtype;
}
Example #2
0
                        if (isset($OldThisFileInfo['tags'][$ValidTagType])) {
                            echo ' checked="checked"';
                        }
                        break;
                }
            }
            echo '>' . $ValidTagType . '<br>';
        }
        if (count($ValidTagTypes) > 1) {
            echo '<hr><input type="checkbox" name="remove_other_tags" value="1"> Remove non-selected tag formats when writing new tag<br>';
        }
        echo '</td></tr>';
        echo '<tr><td align="right"><b>Comment</b></td><td><textarea cols="30" rows="3" name="Comment" wrap="virtual">' . (isset($OldThisFileInfo['comments']['comment']) && is_array($OldThisFileInfo['comments']['comment']) ? implode("\n", $OldThisFileInfo['comments']['comment']) : '') . '</textarea></td></tr>';
        echo '<tr><td align="right"><b>Picture</b><br>(ID3v2 only)</td><td><input type="file" name="userfile" accept="image/jpeg, image/gif, image/png"><br>';
        echo '<select name="APICpictureType">';
        $APICtypes = GetId3\Module\Tag\Id3v2::APICPictureTypeLookup('', true);
        foreach ($APICtypes as $key => $value) {
            echo '<option value="' . htmlentities($key, ENT_QUOTES) . '">' . htmlentities($value) . '</option>';
        }
        echo '</select></td></tr>';
        echo '<tr><td align="center" colspan="2"><input type="submit" name="WriteTags" value="Save Changes"> ';
        echo '<input type="reset" value="Reset"></td></tr>';
    } else {
        echo '<tr><td align="right"><b>Error</b></td><td>' . htmlentities($Filename) . ' does not exist</td></tr>';
    }
    echo '</table>';
    echo '</form>';
}
?>
</body>
</html>