b62f8858 |
1 | <?php |
2 | /*************************************************************************** |
5ddeb07c |
3 | * Copyright (C) 2003-2007 Polytechnique.org * |
b62f8858 |
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 | |
bf6f6356 |
22 | // $GLOBALS['IS_XNET_SITE'] = true; |
23 | |
e9e9306b |
24 | require_once dirname(__FILE__).'/../include/xorg.inc.php'; |
b62f8858 |
25 | |
b647fb5f |
26 | if (!($path = Env::v('n')) || ($path{0} < 'A' || $path{0} > 'Z')) { |
27472b85 |
27 | |
28 | $platal = new Platal('auth', 'banana', 'carnet', 'email', 'events', |
29 | 'geoloc', 'lists', 'marketing', 'payment', 'platal', |
e2efba7d |
30 | 'profile', 'register', 'search', 'stats', 'admin', |
1fe55241 |
31 | 'newsletter', 'axletter', 'bandeau'); |
27472b85 |
32 | $platal->run(); |
33 | |
34 | exit; |
35 | } |
36 | |
37 | /*** WIKI CODE ***/ |
38 | |
39 | require_once 'wiki.inc.php'; |
40 | |
3b962ded |
41 | $n = wiki_pagename(); |
27472b85 |
42 | if (!$n) { |
43 | pl_redirect(''); |
44 | } |
45 | |
8b1f8e12 |
46 | new_skinned_page('core/wiki.tpl'); |
27472b85 |
47 | $perms = wiki_get_perms($n); |
48 | |
27472b85 |
49 | if ($p = Post::v('setrperms')) { |
50 | wiki_apply_perms('admin'); |
51 | if (wiki_set_perms($n, $p, $perms[1])) { |
52 | $perms = wiki_get_perms($n); |
f517fe56 |
53 | $page->trig('Permissions mises à jour'); |
27472b85 |
54 | } |
55 | } |
56 | |
57 | if ($p = Post::v('setwperms')) { |
58 | wiki_apply_perms('admin'); |
59 | if (wiki_set_perms($n, $perms[0], $p)) { |
60 | $perms = wiki_get_perms($n); |
f517fe56 |
61 | $page->trig('Permissions mises à jour'); |
27472b85 |
62 | } |
63 | } |
64 | |
3b962ded |
65 | // Generate cache even if we don't have access rights |
66 | $wiki_cache = wiki_work_dir().'/cache_'.wiki_filename($n).'.tpl'; |
27472b85 |
67 | $cache_exists = file_exists($wiki_cache); |
68 | |
69 | if (Env::v('action') || !$cache_exists) { |
70 | @unlink($wiki_cache); |
71 | |
72 | // we leave pmwiki do whatever it wants and store everything |
73 | ob_start(); |
74 | require_once($globals->spoolroot.'/wiki/pmwiki.php'); |
75 | |
76 | $wikiAll = ob_get_clean(); |
77 | // the pmwiki skin we are using (almost empty) has these keywords: |
78 | $i = strpos($wikiAll, "<!--/HeaderText-->"); |
79 | $j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i); |
80 | } |
81 | |
82 | if (Env::v('action')) { |
83 | $page->assign('xorg_extra_header', substr($wikiAll, 0, $i)); |
84 | $wikiAll = substr($wikiAll, $j); |
85 | } else { |
86 | if (!$cache_exists) { |
87 | $wikiAll = substr($wikiAll, $j); |
88 | wiki_putfile($wiki_cache, $wikiAll); |
89 | } else { |
90 | $wikiAll = file_get_contents($wiki_cache); |
91 | } |
92 | } |
93 | |
3b962ded |
94 | // Check user perms |
95 | switch (Env::v('action')) { |
96 | case '': case 'search': |
97 | wiki_apply_perms($perms[0]); |
98 | break; |
99 | |
100 | case 'edit': |
101 | wiki_apply_perms($perms[1]); |
102 | break; |
103 | |
104 | default: |
105 | wiki_apply_perms('admin'); |
106 | break; |
107 | } |
108 | |
27472b85 |
109 | $page->assign('perms', $perms); |
110 | $page->assign('perms_opts', wiki_perms_options()); |
111 | |
112 | $page->assign('canedit', wiki_may_have_perms($perms[1])); |
113 | $page->assign('has_perms', wiki_may_have_perms('admin')); |
114 | |
115 | $page->assign('wikipage', str_replace('.', '/', $n)); |
85948b6c |
116 | if ($perms[1] == 'admin' && !Env::v('action')) { |
117 | $page->assign('pmwiki_cache', $wiki_cache); |
118 | } else { |
119 | $page->assign('pmwiki', $wikiAll); |
120 | $page->assign('text', true); |
121 | } |
c99ef281 |
122 | $page->addCssLink('wiki.css'); |
123 | $page->addJsLink('wiki.js'); |
27472b85 |
124 | |
125 | $page->run(); |
b62f8858 |
126 | |
127 | ?> |