From fce088c179adecaf9d013e927db96dfe960bccba Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Fri, 26 Jan 2007 22:13:07 +0000 Subject: [PATCH] Merge xnet and xorg wiki code into the same file Fix authentification on xnet wiki git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1402 839d8a87-29fc-0310-9880-83ba4fa771e5 --- htdocs/xnet.php | 90 +------------------------------------- htdocs/xorg.php | 90 +------------------------------------- include/wiki.inc.php | 2 +- include/wiki/engine.php | 112 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 116 insertions(+), 178 deletions(-) create mode 100644 include/wiki/engine.php diff --git a/htdocs/xnet.php b/htdocs/xnet.php index 1f206a5..4528800 100644 --- a/htdocs/xnet.php +++ b/htdocs/xnet.php @@ -20,6 +20,7 @@ ***************************************************************************/ $GLOBALS['IS_XNET_SITE'] = true; +global $platal; require_once dirname(__FILE__).'/../include/xnet.inc.php'; @@ -32,93 +33,6 @@ if (!($path = Env::v('n')) || substr($path, 0, 4) != 'Xnet') { /*** WIKI CODE ***/ -require_once 'wiki.inc.php'; - -$n = wiki_pagename(); -if (!$n) { - pl_redirect(''); -} - -new_skinned_page('core/wiki.tpl'); -$perms = wiki_get_perms($n); - -if ($p = Post::v('setrperms')) { - wiki_apply_perms('admin'); - if (wiki_set_perms($n, $p, $perms[1])) { - $perms = wiki_get_perms($n); - $page->trig('Permissions mises à jour'); - } -} - -if ($p = Post::v('setwperms')) { - wiki_apply_perms('admin'); - if (wiki_set_perms($n, $perms[0], $p)) { - $perms = wiki_get_perms($n); - $page->trig('Permissions mises à jour'); - } -} - -$wiki_cache = wiki_work_dir().'/cache_'.wiki_filename($n).'.tpl'; -$cache_exists = file_exists($wiki_cache); - -if (Env::v('action') || !$cache_exists) { - @unlink($wiki_cache); - - // we leave pmwiki do whatever it wants and store everything - ob_start(); - require_once($globals->spoolroot.'/wiki/pmwiki.php'); - - $wikiAll = ob_get_clean(); - // the pmwiki skin we are using (almost empty) has these keywords: - $i = strpos($wikiAll, ""); - $j = strpos($wikiAll, "", $i); -} - -if (Env::v('action')) { - $page->assign('xorg_extra_header', substr($wikiAll, 0, $i)); - $wikiAll = substr($wikiAll, $j); -} else { - if (!$cache_exists) { - $wikiAll = substr($wikiAll, $j); - wiki_putfile($wiki_cache, $wikiAll); - } else { - $wikiAll = file_get_contents($wiki_cache); - } -} - -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()); - -$page->assign('canedit', wiki_may_have_perms($perms[1])); -$page->assign('has_perms', wiki_may_have_perms('admin')); - -$page->assign('wikipage', str_replace('.', '/', $n)); -$page->assign('wikipage', str_replace('.', '/', $n)); -if ($perms[1] == 'admin' && !Env::v('action')) { - $page->assign('pmwiki_cache', $wiki_cache); -} else { - $page->assign('pmwiki', $wikiAll); - $page->assign('text', true); -} - -$page->addCssLink('wiki.css'); -$page->addJsLink('wiki.js'); - -$page->useMenu(); -$page->run(); +include 'wiki/engine.php'; ?> diff --git a/htdocs/xorg.php b/htdocs/xorg.php index fc0bb57..7b6a810 100644 --- a/htdocs/xorg.php +++ b/htdocs/xorg.php @@ -19,8 +19,6 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -// $GLOBALS['IS_XNET_SITE'] = true; - require_once dirname(__FILE__).'/../include/xorg.inc.php'; if (!($path = Env::v('n')) || ($path{0} < 'A' || $path{0} > 'Z')) { @@ -36,92 +34,6 @@ if (!($path = Env::v('n')) || ($path{0} < 'A' || $path{0} > 'Z')) { /*** WIKI CODE ***/ -require_once 'wiki.inc.php'; - -$n = wiki_pagename(); -if (!$n) { - pl_redirect(''); -} - -new_skinned_page('core/wiki.tpl'); -$perms = wiki_get_perms($n); - -if ($p = Post::v('setrperms')) { - wiki_apply_perms('admin'); - if (wiki_set_perms($n, $p, $perms[1])) { - $perms = wiki_get_perms($n); - $page->trig('Permissions mises à jour'); - } -} - -if ($p = Post::v('setwperms')) { - wiki_apply_perms('admin'); - if (wiki_set_perms($n, $perms[0], $p)) { - $perms = wiki_get_perms($n); - $page->trig('Permissions mises à jour'); - } -} - -// 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) { - @unlink($wiki_cache); - - // we leave pmwiki do whatever it wants and store everything - ob_start(); - require_once($globals->spoolroot.'/wiki/pmwiki.php'); - - $wikiAll = ob_get_clean(); - // the pmwiki skin we are using (almost empty) has these keywords: - $i = strpos($wikiAll, ""); - $j = strpos($wikiAll, "", $i); -} - -if (Env::v('action')) { - $page->assign('xorg_extra_header', substr($wikiAll, 0, $i)); - $wikiAll = substr($wikiAll, $j); -} else { - if (!$cache_exists) { - $wikiAll = substr($wikiAll, $j); - wiki_putfile($wiki_cache, $wikiAll); - } else { - $wikiAll = file_get_contents($wiki_cache); - } -} - -// 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; -} - -$page->assign('perms', $perms); -$page->assign('perms_opts', wiki_perms_options()); - -$page->assign('canedit', wiki_may_have_perms($perms[1])); -$page->assign('has_perms', wiki_may_have_perms('admin')); - -$page->assign('wikipage', str_replace('.', '/', $n)); -if ($perms[1] == 'admin' && !Env::v('action')) { - $page->assign('pmwiki_cache', $wiki_cache); -} else { - $page->assign('pmwiki', $wikiAll); - $page->assign('text', true); -} -$page->addCssLink('wiki.css'); -$page->addJsLink('wiki.js'); - -$page->run(); +include 'wiki/engine.php'; ?> diff --git a/include/wiki.inc.php b/include/wiki.inc.php index 6ab71a4..e1766e2 100644 --- a/include/wiki.inc.php +++ b/include/wiki.inc.php @@ -123,7 +123,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; diff --git a/include/wiki/engine.php b/include/wiki/engine.php new file mode 100644 index 0000000..1ac5511 --- /dev/null +++ b/include/wiki/engine.php @@ -0,0 +1,112 @@ +trig('Permissions mises à jour'); + } +} + +if ($p = Post::v('setwperms')) { + wiki_apply_perms('admin'); + if (wiki_set_perms($n, $perms[0], $p)) { + $perms = wiki_get_perms($n); + $page->trig('Permissions mises à jour'); + } +} + +// 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) { + @unlink($wiki_cache); + + // we leave pmwiki do whatever it wants and store everything + ob_start(); + require_once($globals->spoolroot.'/wiki/pmwiki.php'); + + $wikiAll = ob_get_clean(); + // the pmwiki skin we are using (almost empty) has these keywords: + $i = strpos($wikiAll, ""); + $j = strpos($wikiAll, "", $i); +} + +if (Env::v('action')) { + $page->assign('xorg_extra_header', substr($wikiAll, 0, $i)); + $wikiAll = substr($wikiAll, $j); +} else { + if (!$cache_exists) { + $wikiAll = substr($wikiAll, $j); + wiki_putfile($wiki_cache, $wikiAll); + } else { + $wikiAll = file_get_contents($wiki_cache); + } +} + +// Check user perms +wiki_apply_perms($perms[0]); + +$page->assign('perms', $perms); +$page->assign('perms_opts', wiki_perms_options()); + +$page->assign('canedit', wiki_may_have_perms($perms[1])); +$page->assign('has_perms', wiki_may_have_perms('admin')); + +$page->assign('wikipage', str_replace('.', '/', $n)); +if ($perms[1] == 'admin' && !Env::v('action')) { + $page->assign('pmwiki_cache', $wiki_cache); +} else { + $page->assign('pmwiki', $wikiAll); + $page->assign('text', true); +} +$page->addCssLink('wiki.css'); +$page->addJsLink('wiki.js'); + +$page->run(); + +?> -- 2.1.4