xref: /plugin/graphviz/img.php (revision 9d954370cc99a7ad567bfa05ad196b85cc4fda55)
1<?php
2/**
3 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
4 * @author     Andreas Gohr <gohr@cosmocode.de>
5 */
6
7if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../../');
8define('NOSESSION',true);
9require_once(DOKU_INC.'inc/init.php');
10require_once(DOKU_INC.'inc/pageutils.php');
11require_once(DOKU_INC.'inc/httputils.php');
12require_once(DOKU_INC.'inc/io.php');
13
14// let the plugin do the work
15$data = $_REQUEST;
16$plugin = plugin_load('syntax','graphviz');
17$cache  = $plugin->_imgfile($data);
18
19
20// something went wrong, we're missing the file
21if(!file_exists($cache)){
22    header("HTTP/1.0 404 Not Found");
23    header('Content-Type: image/png');
24    echo io_readFile('broken.png',false);
25    exit;
26}
27
28header('Content-Type: image/png;');
29header('Expires: '.gmdate("D, d M Y H:i:s", time()+max($conf['cachetime'], 3600)).' GMT');
30header('Cache-Control: public, proxy-revalidate, no-transform, max-age='.max($conf['cachetime'], 3600));
31header('Pragma: public');
32http_conditionalRequest($time);
33echo io_readFile($cache,false);
34
35//Setup VIM: ex: et ts=4 enc=utf-8 :
36