- // the wiki keword is given in the n var
- if ($n = Env::get('n', false))
- {
- // Get the correcti wiki keywords
- $n = str_replace('/', '.', $n);
- $keywords = explode('.', $n);
- $count = count($keywords);
- if ($count == 1)
- $n = $keywords[0].".".$keywords[0];
- else
- $n = $keywords[$count - 2].".".$keywords[$count - 1];
- if (($urln = str_replace('.', '/', $n)) != Env::get('n') &&
- $n != Env::get('n'))
- {
- header("Location: ".$globals->baseurl.'/'.$urln);
- die();
- }
- $_REQUEST['n'] = $n;
-
- $dir_wiki_tmp = '../spool/wiki.d/';
- $tpl_name = 'cache_'.$n.'.tpl';
- $short_tpl = $dir_wiki_tmp.$tpl_name;
- $dir_tpl = $globals->spoolroot.'templates/'.$dir_wiki_tmp;
- $tpl = $globals->spoolroot.'templates/'.$short_tpl;
- $tmpfile_exists = file_exists($tpl);
-
- // don't recreate the tpl if it already exists
- if (Env::get('action') || !$tmpfile_exists)
- {
- if ($tmpfile_exists) {
- unlink($tpl);
- $templates_cache_dir = '../spool/templates_c/';
- $dh = opendir($templates_cache_dir);
- while (false !== ($filename = readdir($dh))) if (strpos($filename, $tpl_name) !== false)
- unlink($templates_cache_dir.$filename);
- }
-
- // we leave pmwiki do whatever it wants and store everything
- ob_start();
- require_once(dirname(dirname(__FILE__)).'/'.$globals->wiki->wikidir.'/pmwiki.php');