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