04a43a196d9cba0b2644402a3daeaf176d05179f
2 /***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 function wiki_pagename() {
27 $words = explode('/', trim(Env
::get('n'), '/'));
28 if (count($words) == 2) {
29 return join('.', $words);
32 array_unshift($words, $words[0]);
33 $b = array_pop($words);
34 $a = array_pop($words);
37 redirect($globals->baseurl
.'/'.$a.'/'.$b);
40 function wiki_work_dir() {
42 return $globals->spoolroot
.'/spool/wiki.d';
45 function wiki_clear_all_cache()
47 system("rm -f ".wiki_work_dir()."/cache_*");
50 // editing pages are not static but used templates too, so we used
51 // temp template files containing result from wiki
52 function wiki_create_tmp($content) {
53 $tmpfile = tempnam(wiki_work_dir(), "temp_");
54 $f = fopen($tmpfile, 'w');
60 function wiki_clean_tmp() {
61 // clean old tmp files (more than one hour)
62 $wiki_work_dir = wiki_work_dir();
63 $dh = opendir(wiki_work_dir());
65 while (($file = readdir($dh)) !== false
) {
66 if (strpos($file, 'temp_') === 0) {
67 $created = filectime($wiki_work_dir.'/'.$file);
68 if ($time-$created > 60 * 60)
69 @unlink
($wiki_work_dir.'/'.$file);
74 function wiki_assign_auth() {
76 $page->assign('true', true
);
77 $page->assign('public', true
);
78 $page->assign('logged', S
::logged());
79 $page->assign('identified', S
::identified());
80 $page->assign('has_perms', S
::has_perms());