1<?php
2/**
3 * file access method.
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Andreas Gohr <andi@splitbrain.org>
7 */
8
9if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../../');
10define('NOSESSION',true);
11define('DOKU_DISABLE_GZIP_OUTPUT', 1);
12require_once(DOKU_INC.'inc/init.php');
13require_once(DOKU_INC.'inc/common.php');
14require_once(DOKU_INC.'inc/pageutils.php');
15
16// what should be served?
17if($_GET['t'] == 'png'){
18    $file = getCacheName($_GET['f'],'.godiag.png');
19    $mime = 'image/png';
20}else{
21    $file = getCacheName($_GET['f'],'.godiag.sgf');
22    $mime = 'application/sgf';
23}
24
25// does it exist?
26$fmtime = @filemtime($file);
27if(!$fmtime){
28    header('HTTP/1.0 404 Not Found');
29    echo 'Not found';
30    exit;
31}
32
33// set headers with a 1 hour expiry
34header('Content-Type: '.$mime);
35if($_GET['t'] != 'png') header('Content-Disposition: attachment; filename="'.basename($file).'";');
36header('Expires: '.gmdate("D, d M Y H:i:s", time()+3600).' GMT');
37header('Cache-Control: public, proxy-revalidate, no-transform, max-age=3600');
38header('Pragma: public');
39
40//send important headers first, script stops here if '304 Not Modified' response
41http_conditionalRequest($fmtime);
42
43// put data
44readfile($file);
45