- $page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
- $page->assign('menu-pmwiki', substr($wikiAll, $i, $j-$i));
- $page->assign('pmwiki', substr($wikiAll, $j));
+ $wikiAll = ob_get_clean();
+ // the pmwiki skin we are using (almost empty) has these keywords:
+ $i = strpos($wikiAll, "<!--/HeaderText-->");
+ $j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i);
+
+ }
+ if (Env::get('action'))
+ {
+ // clean old tmp files (more than one hour)
+ $dh = opendir($dir_wiki_tmp);
+ $time = time();
+ while (($file = readdir($dh)) !== false)
+ {
+ if (strpos($file, 'temp_') === 0)
+ {
+ $created = filectime($dir_wiki_tmp.$file);
+ if ($time-$created > 60 * 60)
+ unlink($dir_wiki_tmp.$file);
+ }
+ }
+
+ $page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
+ $tmp_tpl = tempnam($dir_tpl, "temp_");
+ $f = fopen($tmp_tpl, 'w');
+ fputs($f, substr($wikiAll, $j));
+ fclose($f);
+ new_skinned_page($tmp_tpl, AUTH_PUBLIC);
+ if ($tmpfile_exists)
+ unlink($tpl);
+ } else {
+ if (!$tmpfile_exists)
+ {
+ $f = fopen($tpl, 'w');
+ fputs($f, substr($wikiAll, $j));
+ fclose($f);
+ }
+ new_skinned_page($short_tpl, AUTH_PUBLIC);
+ }
+ }