X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fwiki.inc.php;h=c0a89451b8b993d9c8f2014b27caefd6d39fcb6b;hb=155819d9ece12a06d37df46e22b76e3c71f65fba;hp=861340ec96ebb9e73154738de6d3099e5c89d00a;hpb=c0d6753f94999376c60d40f15d78b2b369018d7b;p=platal.git diff --git a/include/wiki.inc.php b/include/wiki.inc.php index 861340e..c0a8945 100644 --- a/include/wiki.inc.php +++ b/include/wiki.inc.php @@ -1,6 +1,6 @@ spoolroot.'/spool/wiki.d'; } @@ -47,16 +57,16 @@ function wiki_clear_all_cache() } function wiki_perms_options() { - return array('public' => 'Public', 'logged' => 'Connecté', - 'mdp' => 'Authentifié', 'admin' => 'Admin'); + return array('public' => 'Public', 'logged' => 'Connecté', + 'mdp' => 'Authentifié', 'admin' => 'Admin'); } 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); + @list($k, $v) = explode('=', $line, 2); if ($k == 'platal_perms') { return explode(':', $v); } @@ -73,9 +83,10 @@ function wiki_putfile($f, $s) 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; @@ -103,6 +114,31 @@ function wiki_may_have_perms($perm) { } } +function wiki_apply_feed_perms($perm) +{ + if ($perm == 'public') { + return; + } + + require_once 'rss.inc.php'; + $uid = init_rss(null, Env::v('user'), Env::v('hash')); + if (!$uid) { + exit; + } + $res = XDB::query('SELECT user_id, IF (nom_usage <> \'\', nom_usage, nom) AS nom, prenom, perms + FROM auth_user_md5 + WHERE user_id = {?}', $uid); + if (!$res->numRows()) { + exit; + } + $table = $res->fetchOneAssoc(); + $_SESSION = array_merge($_SESSION, $table, array('forlife' => Env::v('user'))); + if ($perm == 'logged' || S::has_perms()) { + return; + } + exit; +} + function wiki_apply_perms($perm) { global $page, $platal, $globals; @@ -112,7 +148,7 @@ function wiki_apply_perms($perm) { case 'logged': if (!call_user_func(array($globals->session, 'doAuthCookie'))) { - $platal = new Platal(); + $platal = empty($GLOBALS['IS_XNET_SITE']) ? new Platal() : new Xnet(); $platal->force_login($page); } return; @@ -129,4 +165,14 @@ function wiki_apply_perms($perm) { } } +function wiki_require_page($pagename) +{ + global $globals; + $pagename_slashes = str_replace('.','/',$pagename); + $pagename_dots = str_replace('/','.',$pagename); + if (is_file(wiki_work_dir().'/cache_'.$pagename_dots.'.tpl')) return; + system('wget '.$globals->baseurl.'/'.$pagename_slashes.' -O /dev/null'); +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>