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