yes people, exit/deconnexion is now dealt with from the fancy url module.
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 3 Jul 2006 22:02:35 +0000 (22:02 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Mon, 3 Jul 2006 22:02:35 +0000 (22:02 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@357 839d8a87-29fc-0310-9880-83ba4fa771e5

20 files changed:
classes/PLModule.php
classes/Platal.php
htdocs/.htaccess [new file with mode: 0644]
htdocs/deconnexion.php [deleted file]
htdocs/exit.php [deleted file]
include/xorg/menu.inc.php
modules/core.php
templates/exit.tpl [moved from templates/deconnexion.tpl with 90% similarity]
templates/skin/default.tpl
templates/skin/espace.tpl
templates/skin/humlinux.tpl
templates/skin/linux.tpl
templates/skin/liteskin.tpl
templates/skin/nbviolet.tpl
templates/skin/newxorg.tpl
templates/skin/oldtimes.tpl
templates/skin/openweb.tpl
templates/skin/sharky.tpl
templates/skin/spectral.tpl
templates/skin/trapped.tpl

index d7172fc..c04a2e5 100644 (file)
@@ -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);
     }
 
index b587458..06ce1b4 100644 (file)
@@ -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 (file)
index 0000000..4c8f34b
--- /dev/null
@@ -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 (file)
index 6067181..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once('xorg.inc.php');
-
-if (isset($_SESSION['suid'])) { require_once('./exit.php'); }
-
-if (Get::has('forget')) {
-    setcookie('ORGaccess', '', time() - 3600, '/', '', 0);
-    Cookie::kill('ORGaccess');
-    if (isset($_SESSION['log']))
-        $_SESSION['log']->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 (file)
index c9749cf..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once("xorg.inc.php");
-new_skinned_page('index.tpl',AUTH_MDP);
-
-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");
-}
-
-?>
index 973164d..94139c5 100644 (file)
@@ -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]);
index e9766b8..d12b8a7 100644 (file)
@@ -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;
     }
 
similarity index 90%
rename from templates/deconnexion.tpl
rename to templates/exit.tpl
index 07f7ebc..c31e085 100644 (file)
@@ -35,12 +35,12 @@ Tu as demand
 des fonctionnalités de consultation du site.
 </p>
 <p>
-Tu peux donc aussi te <a href='?forget=1'>deconnecter complètement</a>.
+Tu peux donc aussi te <a href='{rel}/exit/forget'>deconnecter complètement</a>.
 </p>
 <p>
 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
-<a href='?forgetUid=1&amp;forget=1'>supprimer cette information et te déconnecter complètement</a>.
+<a href='{rel}/exit/forgetall'>supprimer cette information et te déconnecter complètement</a>.
 </p>
 
 {elseif $smarty.cookies.ORGuid}
@@ -48,7 +48,7 @@ prochaine connexion. Si tu utilises un ordinateur public ou que tu d
 <p>
 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
-<a href='?forgetUid=1'>supprimer cette information</a>.
+<a href='{rel}/exit/forgetuid'>supprimer cette information</a>.
 </p>
 {/if}
 
index b41a0a3..2096d7f 100644 (file)
@@ -34,7 +34,7 @@
       <tr>
         <td>
           {$smarty.session.suid} ({$smarty.session.forlife})
-          [<a href="{rel}/exit.php">exit</a>]
+          [<a href="{rel}/exit">exit</a>]
         </td>
       </tr>
     </table>
index 89f7dfd..26154dc 100644 (file)
@@ -36,7 +36,7 @@
       <tr>
         <td>
           {$smarty.session.suid} ({$smarty.session.forlife})
-          [<a href="{"exit.php"|url}">exit</a>]
+          [<a href="{rel}/exit">exit</a>]
         </td>
       </tr>
     </table>
index d447670..4d3aa44 100644 (file)
@@ -36,7 +36,7 @@
       <tr>
         <td>
           {$smarty.session.suid} ({$smarty.session.forlife})
-          [<a href="{"exit.php"|url}">exit</a>]
+          [<a href="{rel}/exit">exit</a>]
         </td>
       </tr>
     </table>
index 69a2017..92cbbb6 100644 (file)
@@ -36,7 +36,7 @@
       <tr>
         <td>
           {$smarty.session.suid} ({$smarty.session.forlife})
-          [<a href="{"exit.php"|url}">exit</a>]
+          [<a href="{rel}/exit">exit</a>]
         </td>
       </tr>
     </table>
index d7172bd..1adc6d9 100644 (file)
@@ -36,7 +36,7 @@
       <tr>
         <td>
           {$smarty.session.suid} ({$smarty.session.forlife})
-          [<a href="{"exit.php"|url}">exit</a>]
+          [<a href="{rel}/exit">exit</a>]
         </td>
       </tr>
     </table>
index 6dd1c17..2cfca74 100644 (file)
@@ -36,7 +36,7 @@
       <tr>
         <td>
           {$smarty.session.suid} ({$smarty.session.forlife})
-          [<a href="{"exit.php"|url}">exit</a>]
+          [<a href="{rel}/exit">exit</a>]
         </td>
       </tr>
     </table>
index bbb60f6..eaf78e5 100644 (file)
@@ -36,7 +36,7 @@
       <tr>
         <td>
           {$smarty.session.suid} ({$smarty.session.forlife})
-          [<a href="{"exit.php"|url}">exit</a>]
+          [<a href="{rel}/exit">exit</a>]
         </td>
       </tr>
     </table>
index 60d2eba..3f6877f 100644 (file)
@@ -36,7 +36,7 @@
       <tr>
         <td>
           {$smarty.session.suid} ({$smarty.session.forlife})
-          [<a href="{"exit.php"|url}">exit</a>]
+          [<a href="{rel}/exit">exit</a>]
         </td>
       </tr>
     </table>
index 10e9f79..3785551 100644 (file)
@@ -35,7 +35,7 @@
       <tr>
         <td>
           {$smarty.session.suid} ({$smarty.session.forlife})
-          [<a href="{rel}/exit.php">exit</a>]
+          [<a href="{rel}/exit">exit</a>]
         </td>
       </tr>
     </table>
index dbf56aa..f54fa82 100644 (file)
@@ -36,7 +36,7 @@
       <tr>
         <td>
           {$smarty.session.suid} ({$smarty.session.forlife})
-          [<a href="{"exit.php"|url}">exit</a>]
+          [<a href="{rel}/exit">exit</a>]
         </td>
       </tr>
     </table>
index dcff345..a50dd07 100644 (file)
@@ -36,7 +36,7 @@
       <tr>
         <td>
           {$smarty.session.suid} ({$smarty.session.forlife})
-          [<a href="{"exit.php"|url}">exit</a>]
+          [<a href="{rel}/exit">exit</a>]
         </td>
       </tr>
     </table>
index c57daca..d0b062f 100644 (file)
@@ -36,7 +36,7 @@
       <tr>
         <td>
           {$smarty.session.suid} ({$smarty.session.forlife})
-          [<a href="{"exit.php"|url}">exit</a>]
+          [<a href="{rel}/exit">exit</a>]
         </td>
       </tr>
     </table>