make the path be taken from 'n' instead of 'p' so that it's the same as
[platal.git] / htdocs.net / index.php
1 <?php
2 /***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
5 * *
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. *
10 * *
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. *
15 * *
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 *
18 * Foundation, Inc., *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
21
22 $GLOBALS['IS_XNET_SITE'] = true;
23
24 require 'xnet.inc.php';
25
26 require_once dirname(__FILE__).'/../classes/Xnet.php';
27 require_once dirname(__FILE__).'/../classes/PLModule.php';
28
29 if ($path = Env::v('n') && substr($path, 0, 4) != 'Xnet') {
30
31 $platal = new Xnet('xnet', 'xnetgrp', 'xnetlists', 'xnetevents', 'geoloc');
32 $platal->run();
33
34 exit;
35 }
36
37 require_once 'wiki.inc.php';
38
39 $n = wiki_pagename();
40 if (!$n) {
41 pl_redirect('');
42 }
43
44 new_skinned_page('wiki.tpl');
45 $perms = wiki_get_perms($n);
46
47 switch (Env::v('action')) {
48 case '':
49 wiki_apply_perms($perms[0]);
50 break;
51
52 case 'edit':
53 wiki_apply_perms($perms[1]);
54 break;
55
56 default:
57 wiki_apply_perms('admin');
58 break;
59 }
60
61 if ($p = Post::v('setrperms')) {
62 wiki_apply_perms('admin');
63 if (wiki_set_perms($n, $p, $perms[1])) {
64 $perms = wiki_get_perms($n);
65 $page->trig('Permissions mises à jour');
66 }
67 }
68
69 if ($p = Post::v('setwperms')) {
70 wiki_apply_perms('admin');
71 if (wiki_set_perms($n, $perms[0], $p)) {
72 $perms = wiki_get_perms($n);
73 $page->trig('Permissions mises à jour');
74 }
75 }
76
77 $wiki_cache = wiki_work_dir().'/cache_'.$n.'.tpl';
78 $cache_exists = file_exists($wiki_cache);
79
80 if (Env::v('action') || !$cache_exists) {
81 @unlink($wiki_cache);
82
83 // we leave pmwiki do whatever it wants and store everything
84 ob_start();
85 require_once($globals->spoolroot.'/wiki/pmwiki.php');
86
87 $wikiAll = ob_get_clean();
88 // the pmwiki skin we are using (almost empty) has these keywords:
89 $i = strpos($wikiAll, "<!--/HeaderText-->");
90 $j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i);
91 }
92
93 if (Env::v('action')) {
94 $page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
95 $wikiAll = substr($wikiAll, $j);
96 } else {
97 if (!$cache_exists) {
98 $wikiAll = substr($wikiAll, $j);
99 wiki_putfile($wiki_cache, $wikiAll);
100 } else {
101 $wikiAll = file_get_contents($wiki_cache);
102 }
103 }
104
105 $page->assign('perms', $perms);
106 $page->assign('perms_opts', wiki_perms_options());
107
108 $page->assign('canedit', wiki_may_have_perms($perms[1]));
109 $page->assign('has_perms', wiki_may_have_perms('admin'));
110
111 $page->assign('wikipage', str_replace('.', '/', $n));
112 $page->assign('pmwiki', $wikiAll);
113
114 $page->addCssLink('wiki.css');
115 $page->addJsLink('javascript/wiki.js');
116
117 $page->useMenu();
118 $page->run();
119
120 ?>