xref: /plugin/graphviz/img.php (revision f3f6ad44d3cc9569c09b2b3e83b13418547e8a4b)
1517bd836SAndreas Gohr<?php
2*f3f6ad44SAndreas Gohr
3517bd836SAndreas Gohr/**
4517bd836SAndreas Gohr * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
5fb9a529dSAndreas Gohr * @author     Andreas Gohr <andi@splitbrain.org>
6517bd836SAndreas Gohr */
7517bd836SAndreas Gohr
8*f3f6ad44SAndreas Gohrif (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../../');
9517bd836SAndreas Gohrdefine('NOSESSION', true);
10517bd836SAndreas Gohrrequire_once(DOKU_INC . 'inc/init.php');
11517bd836SAndreas Gohr
12fb9a529dSAndreas Gohr// let the syntax plugin do the work
13517bd836SAndreas Gohr$data = $_REQUEST;
14517bd836SAndreas Gohr$plugin = plugin_load('syntax', 'graphviz');
159d954370SAndreas Gohr$cache  = $plugin->_imgfile($data);
16fb9a529dSAndreas Gohrif (!$cache) _fail();
17517bd836SAndreas Gohr
18517bd836SAndreas Gohrheader('Content-Type: image/png;');
19517bd836SAndreas Gohrheader('Expires: ' . gmdate("D, d M Y H:i:s", time() + max($conf['cachetime'], 3600)) . ' GMT');
20517bd836SAndreas Gohrheader('Cache-Control: public, proxy-revalidate, no-transform, max-age=' . max($conf['cachetime'], 3600));
21517bd836SAndreas Gohrheader('Pragma: public');
22517bd836SAndreas Gohrhttp_conditionalRequest($time);
23517bd836SAndreas Gohrecho io_readFile($cache, false);
24517bd836SAndreas Gohr
25fb9a529dSAndreas Gohr
26*f3f6ad44SAndreas Gohrfunction _fail()
27*f3f6ad44SAndreas Gohr{
28fb9a529dSAndreas Gohr    header("HTTP/1.0 404 Not Found");
29fb9a529dSAndreas Gohr    header('Content-Type: image/png');
30fb9a529dSAndreas Gohr    echo io_readFile('broken.png', false);
31fb9a529dSAndreas Gohr    exit;
32fb9a529dSAndreas Gohr}
33fb9a529dSAndreas Gohr
34517bd836SAndreas Gohr//Setup VIM: ex: et ts=4 enc=utf-8 :
35