more simplifications: we don't need the temp_* mechanism at all.
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 22 Jul 2006 15:02:49 +0000 (15:02 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 22 Jul 2006 15:02:49 +0000 (15:02 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@561 839d8a87-29fc-0310-9880-83ba4fa771e5

htdocs/wiki.php
include/wiki.inc.php

index 1fbf9e3..c702d7a 100644 (file)
@@ -29,13 +29,11 @@ if (!S::identified()) {
 require_once 'wiki.inc.php';
 
 if ($n = wiki_pagename()) {
-    $wiki_template  = wiki_work_dir().'/cache_'.$n.'.tpl';
-    $tmpfile_exists = file_exists($wiki_template);
+    $wiki_cache   = wiki_work_dir().'/cache_'.$n.'.tpl';
+    $cache_exists = file_exists($wiki_cache);
 
-    if (Env::get('action') || !$tmpfile_exists) {
-        if ($tmpfile_exists) {
-            @unlink($wiki_template);
-        }
+    if (Env::get('action') || !$cache_exists) {
+        @unlink($wiki_cache);
 
         // we leave pmwiki do whatever it wants and store everything
         ob_start();
@@ -48,21 +46,16 @@ if ($n = wiki_pagename()) {
     }
 
     if (Env::get('action')) {
-        // clean old tmp files
-        wiki_clean_tmp();
-
-        // create new tmp files with editing page from wiki engine
         $page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
         $wikiAll = substr($wikiAll, $j);
-        $wiki_template = wiki_create_tmp($wikiAll);
     } else {
-        if (!$tmpfile_exists) {
-            $f = fopen($wiki_template, 'w');
+        if (!$cache_exists) {
+            $f = fopen($wiki_cache, 'w');
             $wikiAll = substr($wikiAll, $j);
             fputs($f, $wikiAll);
             fclose($f);
         } else {
-            $wikiAll = file_get_contents($wiki_template);
+            $wikiAll = file_get_contents($wiki_cache);
         }
     }
 
@@ -70,7 +63,7 @@ if ($n = wiki_pagename()) {
 }
 
 $page->assign('pmwiki', $wikiAll);
-wiki_assign_auth();
+$page->assign('has_perms',  S::has_perms());
 $page->addCssLink('css/wiki.css');
 
 $page->run();
index 2aa2dd2..6f9c83c 100644 (file)
@@ -43,40 +43,7 @@ function wiki_work_dir() {
 
 function wiki_clear_all_cache()
 {
-    system("rm -f ".wiki_work_dir()."/cache_*");
-}
-
-// editing pages are not static but used templates too, so we used
-// temp template files containing result from wiki
-function wiki_create_tmp($content) {
-    $tmpfile = tempnam(wiki_work_dir(), "temp_");
-    $f = fopen($tmpfile, 'w');
-    fputs($f, $content);
-    fclose($f);
-    return $tmpfile;
-}
-
-function wiki_clean_tmp() {
-    // clean old tmp files (more than one hour)
-    $wiki_work_dir = wiki_work_dir();
-    $dh = opendir(wiki_work_dir());
-    $time = time();
-    while (($file = readdir($dh)) !== false) {
-        if (strpos($file, 'temp_') === 0) {
-            $created = filectime($wiki_work_dir.'/'.$file);
-            if ($time-$created > 60 * 60)
-                @unlink($wiki_work_dir.'/'.$file);
-        }
-    }
-}
-
-function wiki_assign_auth() {
-    global $page;
-    $page->assign('true',       true);
-    $page->assign('public',     true);
-    $page->assign('logged',     S::logged());
-    $page->assign('identified', S::identified());
-    $page->assign('has_perms',  S::has_perms());
+    system('rm -f '.wiki_work_dir().'/cache_*');
 }
 
 ?>