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