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