clean($v); require_once 'File/MimeType.php'; $fm = new File_MimeType(); $mt = $fm->fromExt($ext); if (!isset($_REQUEST['html'])) { header("Content-type: $mt"); $fh = fopen($fp,'r'); fpassthru($fh); fclose($fh); exit; } switch($mt) { case 'text/plain': case 'application/xml': $fc = file_get_contents($fp); $matches = array(); if (preg_match('#^\s*<\?xml.*encoding="([^"]+)"#mi', $fc, $matches)) { $fc = iconv($matches[1], "UTF8//IGNORE", $fc); //} } if ($mt == 'application/xml') { //dl('tidy'); //if (class_exists('Tidy')) { $tidy = new Tidy(); $tidy->parseString($fc, array('indent'=>true,'output-xml' => true,'input-xml' => true), 'utf8'); // $tidy->cleanRepair(); $fc = (string)$tidy; } echo '
'. htmlspecialchars($fc) . '
'; exit; case 'image/jpeg': echo ''; exit; default: // handle download. require_once 'File/Convert.php'; $f = new File_Convert($fp, $mt); $f->convert("application/pdf"); // does no conversion (as it's the same. $f->serve('attachment'); die("Can not handle " . $mt . " yet"); } var_dump($fp); die("done"); exit; } }