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;
}