"; $scrbits = ""; $firstbits = "\n\n\nPHP Content Type Primer Tutorial" . $stybits . $scrbits . "\n\n"; $erroneousbits = "

Sorry, but " . urldecode($selname) . " is too big a media file to display.


"; $formbits = "

PHP Content Type Url


\n
Url:

  \n\n
"; $suffix = ""; if ($selname != "") { $prefix = "application/"; $qbits = explode("?", urldecode($selname)); $otherbits = explode(".", $qbits[0]); //echo urldecode($selname); $firstbits = ""; $erroneousbits = ""; $formbits = ""; // Thanks to http://www.sitepoint.com/web-foundations/mime-types-complete-list/ if (!file_exists("our_mime.list")) file_put_contents("our_mime.list", file_get_contents("http://www.sitepoint.com/web-foundations/mime-types-complete-list/")); $mimelist = file_get_contents("our_mime.list"); // Mime type considerations below ... $ct = ""; $cells = explode("", $mimelist); for ($ii=0; $ii<(sizeof($cells) - 1); $ii+=2) { $precells = explode(">", $cells[$ii]); $extis = strtolower(str_replace(".", "", $precells[sizeof($precells) - 1])); if ($ct == "" && strtolower($otherbits[sizeof($otherbits) - 1]) == $extis) { $precells = explode(">", $cells[1 + $ii]); $ct = $precells[sizeof($precells) - 1]; } } if ($ct == "") { if (strpos(strtolower(urldecode($selname)), ".") === false) { $ct = "text/html"; } else { if (strtolower($otherbits[sizeof($otherbits) - 1]) == "m4v") { $prefix = "video/"; $otherbits[sizeof($otherbits) - 1] = "mpeg"; } if (strtolower($otherbits[sizeof($otherbits) - 1]) == "m4a") { $prefix = "audio/"; $otherbits[sizeof($otherbits) - 1] = "mpeg"; } if (strtolower($otherbits[sizeof($otherbits) - 1]) == "html") $prefix = "text/"; if (strtolower($otherbits[sizeof($otherbits) - 1]) == "htm") $prefix = "text/"; if (strtolower($otherbits[sizeof($otherbits) - 1]) == "jpg") $prefix = "image/"; if (strtolower($otherbits[sizeof($otherbits) - 1]) == "jpeg") $prefix = "image/"; if (strtolower($otherbits[sizeof($otherbits) - 1]) == "gif") $prefix = "image/"; if (strtolower($otherbits[sizeof($otherbits) - 1]) == "bmp") $prefix = "image/"; if (strtolower($otherbits[sizeof($otherbits) - 1]) == "tif") $prefix = "image/"; if (strtolower($otherbits[sizeof($otherbits) - 1]) == "tiff") $prefix = "image/"; if (strtolower($otherbits[sizeof($otherbits) - 1]) == "png") $prefix = "image/"; $ct = $prefix . strtolower($otherbits[sizeof($otherbits) - 1]); } } //echo $ct; header('Content-Type: ' . $ct); echo file_get_contents(urldecode($selname)); } else { $erroneousbits = ""; } echo $firstbits; echo $erroneousbits; echo $formbits; ?>