1<?php
2/**
3 * DokuWiki StyleSheet creator wrapper
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Pascal Bihler <bihler@iai.uni-bonn.de>
7 */
8
9 //Load all the basic includes (like css.php tries to do later)
10
11if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/');
12if(!defined('NOSESSION')) define('NOSESSION',true); // we do not use a session or authentication here (better caching)
13
14$template = NULL;
15if (isset($_REQUEST['tpl'])) {
16    $tpl = $_REQUEST['tpl'];
17		if (preg_match('/^[a-z0-9_-]+$/iD', $tpl)) { //seems to be a valid template name, and not a code injection...
18		    $template = $tpl;
19		}
20}
21
22// We set the template constants before init.php can do it...
23if (isset($template)) {
24
25    //Inherit DOKU_BASE from server variables in order to avoid config reading here...
26		$script_name = $_SERVER['SCRIPT_NAME'];
27    $DOKU_BASE = substr($script_name,0,strlen($script_name)-strlen('lib/plugins/multitemplate_styleman/css.php'));
28    define('DOKU_TPL', $DOKU_BASE.'lib/tpl/'  . $template .'/');
29    define('DOKU_TPLINC',realpath(dirname(__FILE__).'/../../') . '/tpl/' . $template .'/');
30}
31
32//Load environment parameters
33require_once(DOKU_INC.'inc/init.php');
34require_once(DOKU_INC.'inc/pageutils.php');
35require_once(DOKU_INC.'inc/io.php');
36require_once(DOKU_INC.'inc/confutils.php');
37
38// Redirect template:
39if (isset($template))
40   $conf['template'] = $template;
41
42//Now we let the original css.php do the rest
43require_once(realpath(dirname(__FILE__).'/../../').'/exe/css.php');
44
45?>