From: x2000habouzit Date: Mon, 3 Jul 2006 22:02:35 +0000 (+0000) Subject: yes people, exit/deconnexion is now dealt with from the fancy url module. X-Git-Tag: xorg/0.9.11~536 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=4a5fb34b970c9ba7c469f15935b8ae788dc026b0;p=platal.git yes people, exit/deconnexion is now dealt with from the fancy url module. git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@357 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/classes/PLModule.php b/classes/PLModule.php index d7172fc..c04a2e5 100644 --- a/classes/PLModule.php +++ b/classes/PLModule.php @@ -31,11 +31,11 @@ class PLModule function handlers() { die("implement me"); } function menu_entries() { die("implement me"); } - function make_hook($fun, $auth, $perms, $type = SKINNED) + function make_hook($fun, $auth, $perms = '', $type = SKINNED) { - return array('hook' => array($this, $fun), + return array('hook' => array($this, 'handler_'.$fun), 'auth' => $auth, - 'perms' => split('[ ,|]', $perms), + 'perms' => $perms, 'type' => $type); } diff --git a/classes/Platal.php b/classes/Platal.php index b587458..06ce1b4 100644 --- a/classes/Platal.php +++ b/classes/Platal.php @@ -67,7 +67,7 @@ class Platal { $p = $this->path; - while ($path) { + while ($p) { if (array_key_exists($p, $this->__hooks)) break; diff --git a/htdocs/.htaccess b/htdocs/.htaccess new file mode 100644 index 0000000..4c8f34b --- /dev/null +++ b/htdocs/.htaccess @@ -0,0 +1,15 @@ +DirectoryIndex test.php index.php + +Options +FollowSymLinks +RewriteEngine on + +RewriteBase /~x2000habouzit + +# wiki + +RewriteRule ^([A-Z].*) wiki.php?n=$1 [L,QSA] + +# Rewrite URLs of the form 'index.php?q=x': +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*)$ test.php?p=$1 [L,QSA] diff --git a/htdocs/deconnexion.php b/htdocs/deconnexion.php deleted file mode 100644 index 6067181..0000000 --- a/htdocs/deconnexion.php +++ /dev/null @@ -1,55 +0,0 @@ -log("cookie_off"); -} - -if (Get::has('forgetUid')) { - setcookie('ORGuid', '', time() - 3600, '/', '', 0); - Cookie::kill('ORGuid'); - setcookie('ORGdomain', '', time() - 3600, '/', '', 0); - Cookie::kill('ORGdomain'); -} - -if (isset($_SESSION['log'])) { - $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; - $_SESSION['log']->log('deconnexion',$ref); -} - -XorgSession::destroy(); - -if (Get::has('redirect')) { - redirect(rawurldecode(Get::get('redirect'))); -} else { - new_skinned_page('deconnexion.tpl', AUTH_PUBLIC); - $page->run(); -} - -// vim:set et sws=4 sts=4 sw=4: -?> diff --git a/htdocs/exit.php b/htdocs/exit.php deleted file mode 100644 index c9749cf..0000000 --- a/htdocs/exit.php +++ /dev/null @@ -1,37 +0,0 @@ -log("suid_stop", Session::get('forlife') . " by " . $suid['forlife']); - $_SESSION = $suid; - Session::kill('suid'); - redirect($globals->baseurl.'/admin/utilisateurs.php?login='.$a4l); -} else { - redirect("login.php"); -} - -?> diff --git a/include/xorg/menu.inc.php b/include/xorg/menu.inc.php index 973164d..94139c5 100644 --- a/include/xorg/menu.inc.php +++ b/include/xorg/menu.inc.php @@ -93,9 +93,9 @@ class XOrgMenu { $res = logged() ? $this->_int : $this->_ext; if (identified()) { - $res[XOM_NO][] = Array(0, 'text' => 'Déconnexion', 'url' => 'deconnexion.php'); + $res[XOM_NO][] = Array(0, 'text' => 'Déconnexion', 'url' => 'exit'); } elseif (Cookie::has('ORGaccess')) { - $res[XOM_NO][] = Array(0, 'text' => 'Déconnexion totale', 'url' => 'deconnexion.php?forget=1'); + $res[XOM_NO][] = Array(0, 'text' => 'Déconnexion totale', 'url' => 'exit/forget'); } if (!has_perms()) { unset($res[XOM_ADMIN]); diff --git a/modules/core.php b/modules/core.php index e9766b8..d12b8a7 100644 --- a/modules/core.php +++ b/modules/core.php @@ -29,13 +29,54 @@ class CoreModule extends PLModule function handlers() { return array( - '403' => $this->make_hook('handler_403', AUTH_PUBLIC, ''), - '404' => $this->make_hook('handler_404', AUTH_PUBLIC, ''), + '403' => $this->make_hook('403', AUTH_PUBLIC), + '404' => $this->make_hook('404', AUTH_PUBLIC), + 'exit' => $this->make_hook('exit', AUTH_PUBLIC), ); } - function handler_auth(&$page) + function handler_exit(&$page, $level = null) { + if (Session::has('suid')) { + if (Session::has('suid')) { + $a4l = Session::get('forlife'); + $suid = Session::getMixed('suid'); + $log = Session::getMixed('log'); + $log->log("suid_stop", Session::get('forlife') . " by " . $suid['forlife']); + $_SESSION = $suid; + Session::kill('suid'); + redirect($globals->baseurl.'/admin/utilisateurs.php?login='.$a4l); + } else { + redirect("login.php"); + } + } + + if ($level == 'forget' || $level == 'forgetall') { + setcookie('ORGaccess', '', time() - 3600, '/', '', 0); + Cookie::kill('ORGaccess'); + if (isset($_SESSION['log'])) + $_SESSION['log']->log("cookie_off"); + } + + if ($level == 'forgetuid' || $level == 'forgetall') { + setcookie('ORGuid', '', time() - 3600, '/', '', 0); + Cookie::kill('ORGuid'); + setcookie('ORGdomain', '', time() - 3600, '/', '', 0); + Cookie::kill('ORGdomain'); + } + + if (isset($_SESSION['log'])) { + $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; + $_SESSION['log']->log('deconnexion',$ref); + } + + XorgSession::destroy(); + + if (Get::has('redirect')) { + redirect(rawurldecode(Get::get('redirect'))); + } else { + $page->changeTpl('exit.tpl'); + } return PL_OK; } diff --git a/templates/deconnexion.tpl b/templates/exit.tpl similarity index 90% rename from templates/deconnexion.tpl rename to templates/exit.tpl index 07f7ebc..c31e085 100644 --- a/templates/deconnexion.tpl +++ b/templates/exit.tpl @@ -35,12 +35,12 @@ Tu as demand des fonctionnalités de consultation du site.

-Tu peux donc aussi te deconnecter complètement. +Tu peux donc aussi te deconnecter complètement.

De plus, ton adresse e-mail est toujours en mémoire dans ton navigateur afin de faciliter ta prochaine connexion. Si tu utilises un ordinateur public ou que tu désires l'effacer, tu peux -supprimer cette information et te déconnecter complètement. +supprimer cette information et te déconnecter complètement.

{elseif $smarty.cookies.ORGuid} @@ -48,7 +48,7 @@ prochaine connexion. Si tu utilises un ordinateur public ou que tu d

Ton adresse e-mail est toujours en mémoire dans ton navigateur afin de faciliter ta prochaine connexion. Si tu utilises un ordinateur public ou que tu désires l'effacer, tu peux -supprimer cette information. +supprimer cette information.

{/if} diff --git a/templates/skin/default.tpl b/templates/skin/default.tpl index b41a0a3..2096d7f 100644 --- a/templates/skin/default.tpl +++ b/templates/skin/default.tpl @@ -34,7 +34,7 @@ {$smarty.session.suid} ({$smarty.session.forlife}) - [exit] + [exit] diff --git a/templates/skin/espace.tpl b/templates/skin/espace.tpl index 89f7dfd..26154dc 100644 --- a/templates/skin/espace.tpl +++ b/templates/skin/espace.tpl @@ -36,7 +36,7 @@ {$smarty.session.suid} ({$smarty.session.forlife}) - [exit] + [exit] diff --git a/templates/skin/humlinux.tpl b/templates/skin/humlinux.tpl index d447670..4d3aa44 100644 --- a/templates/skin/humlinux.tpl +++ b/templates/skin/humlinux.tpl @@ -36,7 +36,7 @@ {$smarty.session.suid} ({$smarty.session.forlife}) - [exit] + [exit] diff --git a/templates/skin/linux.tpl b/templates/skin/linux.tpl index 69a2017..92cbbb6 100644 --- a/templates/skin/linux.tpl +++ b/templates/skin/linux.tpl @@ -36,7 +36,7 @@ {$smarty.session.suid} ({$smarty.session.forlife}) - [exit] + [exit] diff --git a/templates/skin/liteskin.tpl b/templates/skin/liteskin.tpl index d7172bd..1adc6d9 100644 --- a/templates/skin/liteskin.tpl +++ b/templates/skin/liteskin.tpl @@ -36,7 +36,7 @@ {$smarty.session.suid} ({$smarty.session.forlife}) - [exit] + [exit] diff --git a/templates/skin/nbviolet.tpl b/templates/skin/nbviolet.tpl index 6dd1c17..2cfca74 100644 --- a/templates/skin/nbviolet.tpl +++ b/templates/skin/nbviolet.tpl @@ -36,7 +36,7 @@ {$smarty.session.suid} ({$smarty.session.forlife}) - [exit] + [exit] diff --git a/templates/skin/newxorg.tpl b/templates/skin/newxorg.tpl index bbb60f6..eaf78e5 100644 --- a/templates/skin/newxorg.tpl +++ b/templates/skin/newxorg.tpl @@ -36,7 +36,7 @@ {$smarty.session.suid} ({$smarty.session.forlife}) - [exit] + [exit] diff --git a/templates/skin/oldtimes.tpl b/templates/skin/oldtimes.tpl index 60d2eba..3f6877f 100644 --- a/templates/skin/oldtimes.tpl +++ b/templates/skin/oldtimes.tpl @@ -36,7 +36,7 @@ {$smarty.session.suid} ({$smarty.session.forlife}) - [exit] + [exit] diff --git a/templates/skin/openweb.tpl b/templates/skin/openweb.tpl index 10e9f79..3785551 100644 --- a/templates/skin/openweb.tpl +++ b/templates/skin/openweb.tpl @@ -35,7 +35,7 @@ {$smarty.session.suid} ({$smarty.session.forlife}) - [exit] + [exit] diff --git a/templates/skin/sharky.tpl b/templates/skin/sharky.tpl index dbf56aa..f54fa82 100644 --- a/templates/skin/sharky.tpl +++ b/templates/skin/sharky.tpl @@ -36,7 +36,7 @@ {$smarty.session.suid} ({$smarty.session.forlife}) - [exit] + [exit] diff --git a/templates/skin/spectral.tpl b/templates/skin/spectral.tpl index dcff345..a50dd07 100644 --- a/templates/skin/spectral.tpl +++ b/templates/skin/spectral.tpl @@ -36,7 +36,7 @@ {$smarty.session.suid} ({$smarty.session.forlife}) - [exit] + [exit] diff --git a/templates/skin/trapped.tpl b/templates/skin/trapped.tpl index c57daca..d0b062f 100644 --- a/templates/skin/trapped.tpl +++ b/templates/skin/trapped.tpl @@ -36,7 +36,7 @@ {$smarty.session.suid} ({$smarty.session.forlife}) - [exit] + [exit]