new_skinned_page('core/wiki.tpl');
$perms = wiki_get_perms($n);
-switch (Env::v('action')) {
- case '': case 'search':
- wiki_apply_perms($perms[0]);
- break;
-
- case 'edit':
- wiki_apply_perms($perms[1]);
- break;
-
- default:
- wiki_apply_perms('admin');
- break;
-}
-
if ($p = Post::v('setrperms')) {
wiki_apply_perms('admin');
if (wiki_set_perms($n, $p, $perms[1])) {
}
}
-$wiki_cache = wiki_work_dir().'/cache_'.$n.'.tpl';
+$wiki_cache = wiki_work_dir().'/cache_'.wiki_filename($n).'.tpl';
$cache_exists = file_exists($wiki_cache);
if (Env::v('action') || !$cache_exists) {
}
}
+switch (Env::v('action')) {
+ case '': case 'search':
+ wiki_apply_perms($perms[0]);
+ break;
+
+ case 'edit':
+ wiki_apply_perms($perms[1]);
+ break;
+
+ default:
+ wiki_apply_perms('admin');
+ break;
+}
+
$page->assign('perms', $perms);
$page->assign('perms_opts', wiki_perms_options());
require_once 'wiki.inc.php';
-$n = wiki_pagename();
+$n = wiki_pagename();
if (!$n) {
pl_redirect('');
}
new_skinned_page('core/wiki.tpl');
$perms = wiki_get_perms($n);
-if (Env::v('display') == 'light') {
- $page->assign('simple', true);
-}
-
-switch (Env::v('action')) {
- case '': case 'search':
- wiki_apply_perms($perms[0]);
- break;
-
- case 'edit':
- wiki_apply_perms($perms[1]);
- break;
-
- default:
- wiki_apply_perms('admin');
- break;
-}
-
if ($p = Post::v('setrperms')) {
wiki_apply_perms('admin');
if (wiki_set_perms($n, $p, $perms[1])) {
}
}
-$wiki_cache = wiki_work_dir().'/cache_'.$n.'.tpl';
+// Generate cache even if we don't have access rights
+$wiki_cache = wiki_work_dir().'/cache_'.wiki_filename($n).'.tpl';
$cache_exists = file_exists($wiki_cache);
if (Env::v('action') || !$cache_exists) {
}
}
+// Check user perms
+switch (Env::v('action')) {
+ case '': case 'search':
+ wiki_apply_perms($perms[0]);
+ break;
+
+ case 'edit':
+ wiki_apply_perms($perms[1]);
+ break;
+
+ default:
+ wiki_apply_perms('admin');
+ break;
+}
+
+if (Env::v('display') == 'light') {
+ $page->assign('simple', true);
+}
+
$page->assign('perms', $perms);
$page->assign('perms_opts', wiki_perms_options());
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-function wiki_pagename() {
+function wiki_pagename()
+{
if (!Get::v('n')) {
return null;
}
pl_redirect($a.'/'.$b);
}
-function wiki_work_dir() {
+function wiki_filename($s)
+{
+ if (@iconv('utf-8', 'utf-8', $s) == $s) {
+ return utf8_decode($s);
+ }
+ return $s;
+}
+
+function wiki_work_dir()
+{
global $globals;
return $globals->spoolroot.'/spool/wiki.d';
}
function wiki_get_perms($n)
{
- $file = wiki_work_dir().'/'.str_replace('/', '.', $n);
+ $file = wiki_work_dir().'/'.wiki_filename(str_replace('/', '.', $n));
$lines = explode("\n", @file_get_contents($file));
foreach ($lines as $line) {
@list($k, $v) = explode('=', $line, 2);
function wiki_set_perms($n, $pr, $pw)
{
- $file = wiki_work_dir().'/'.str_replace('/', '.', $n);
- if (!file_exists($file))
+ $file = wiki_work_dir().'/'.wiki_filename(str_replace('/', '.', $n));
+ if (!file_exists($file)) {
return false;
+ }
$p = $pr . ':' . $pw;