EOSERV Forum > Game Development > Good way to check link mime-type embed or display in php?
Page: << 1 >>
Good way to check link mime-type embed or display in php?
Author Message
Post #199522 Good way to check link mime-type embed or display in php?

I usually dont mess with web design but ive been for a few days slapping together a media site and basicly what I need to do is check posts for links and mime-types before i display them ect. Atleast I think thats the concept.

I need to check mime-types because I only want people to be able to post linkage for  audio/video/image/shockwave ect??

ok I check their post for links like this does this seem efficent? Is it ok to assume I can play all the audio/video/image/shockwave in a flash player?

I just need some input before I continue writing more cases.

function GetContent($text) //$text is url or path
{
    $pattern = '@(http)?(s)?(://)?(([a-zA-Z])([-\w]+\.)+([^\s 
    \.]+[^\s]*)+[^,.\s])@';

    if(preg_match( $pattern, $text ) != 1 )
    {
        die( "invalid url");
    }
    else
    {
        $file_info = new finfo(FILEINFO_MIME); $mime_type =   
        $file_info->buffer(file_get_contents($text));  
        switch($mime_type)
        {
            case 'image/jpeg':
            case 'image/png':
            case 'image/gif':
            case 'application/x-shockwave-flash';
            case 'image/psd';
            case 'image/bmp';
            case 'image/tiff';
            case 'application/octet-stream';
            case 'image/jp2';
            case 'image/iff';
            case 'image/vnd.wap.wbmp';
            case 'image/xbm';
            case 'image/vnd.microsoft.icon';

            case 'video/mpeg':
            case 'video/mp4':
            case 'video/quicktime':
            case 'video/ogg';

            case 'audio/aac';
            case 'audio/mp4'; .
            case 'audio/mpeg';
            case 'audio/ogg';
            case 'audio/wav';
            case 'audio/webm';

            case 'text/csv':
            case 'text/plain':
            case 'text/xml':
            case 'text/html';

             case 'text/css';   
             case 'text/vnd.curl';    
             case 'text/richtext';
             case 'text/t140';    
             case 'text/vnd.abc';
             case 'text/vnd.fly';
             case 'text/vnd.in3d.spot';    
             case 'text/vnd.latex-z';    
             case 'text/vnd.wap.wml';
             case 'text/vnd.wap.sl';    
           
        }
        echo $mime_type;
    }

   return true;
}


8 years, 10 weeks ago
Post #199994 Re: Good way to check link mime-type embed or display in php?

Instead of doing many case clauses, I would use a lookup table/dictionary that would associate an array of mime's with a type (e.g. video). I think what you have so far is good, especially if you're just linking them and not uploading anything. As far as displaying everything in flash player, I think that should work but I wouldn't display image just due to the unnecessary flash player overhead.

---
Andrewbob - I would be on the fucking copter of rofls

Programmer, Web Developer, and Graphics Designer
7 years, 51 weeks ago
Page: << 1 >>

EOSERV Forum > Game Development > Good way to check link mime-type embed or display in php?