3 function wfStreamFile( $fname ) {
5 $stat = stat( $fname );
7 header( 'HTTP/1.0 404 Not Found' );
9 <h1>File not found</h1>
10 <p>Although this PHP script ({$_SERVER['SCRIPT_NAME']}) exists, the file requested for output
16 header( "Cache-Control: s-maxage=$wgSquidMaxage, must-revalidate, max-age=0" );
17 header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s', $stat['mtime'] ) . ' GMT' );
19 if ( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
20 $modsince = preg_replace( '/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
21 $sinceTime = strtotime( $modsince );
22 if ( $stat['mtime'] <= $sinceTime ) {
23 header( "HTTP/1.0 304 Not Modified" );
28 header( 'Content-Length: ' . $stat['size'] );
30 $type = wfGetType( $fname );
31 if ( $type and $type!="unknown/unknown") {
32 header("Content-type: $type");
34 header('Content-type: application/x-wiki');
40 function wfGetType( $filename ) {
41 global $wgTrivialMimeDetection;
43 # trivial detection by file extension,
44 # used for thumbnails (thumb.php)
45 if ($wgTrivialMimeDetection) {
46 $ext= strtolower(strrchr($filename, '.'));
49 case '.gif': return "image/gif";
50 case '.png': return "image/png";
51 case '.jpg': return "image/jpeg";
52 case '.jpeg': return "image/jpeg";
55 return "unknown/unknown";
58 $magic=& wfGetMimeMagic();
59 return $magic->guessMimeType($filename); //full fancy mime detection