migrate e-confiance things into auth.php
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Wed, 12 Jul 2006 22:31:47 +0000 (22:31 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Wed, 12 Jul 2006 22:31:47 +0000 (22:31 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@455 839d8a87-29fc-0310-9880-83ba4fa771e5

htdocs/groupex/donne-chall.php [deleted file]
htdocs/groupex/export-econfiance.php [deleted file]
modules/auth.php

diff --git a/htdocs/groupex/donne-chall.php b/htdocs/groupex/donne-chall.php
deleted file mode 100644 (file)
index 8720106..0000000
+++ /dev/null
@@ -1,30 +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                *
- ***************************************************************************/
-
-
-/* Ce script donne un challenge et un numéro de session afin de permettre l'extraction de données pour eConfiance tout en procédant à une identification préalable... */
-
-session_start();
-session_register("chall");
-$_SESSION["chall"] = uniqid(rand(), 1);
-echo $_SESSION["chall"] . "\n" . session_id();
-
-?>
diff --git a/htdocs/groupex/export-econfiance.php b/htdocs/groupex/export-econfiance.php
deleted file mode 100644 (file)
index d508c23..0000000
+++ /dev/null
@@ -1,71 +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                *
- ***************************************************************************/
-
-
-/* Script permettant l'export de la liste des membres de la mailing list eConfiance, pour intégration par J-P Figer dans la liste des membres de X-Informatique */
-
-require_once('xorg.inc.php');
-require_once('platal/xmlrpc-client.inc.php');
-require_once('lists.inc.php');
-
-$cle = $globals->core->econfiance;
-
-if (isset($_SESSION["chall"]) && $_SESSION["chall"] != "" && $_GET["PASS"] == md5($_SESSION["chall"].$cle)) {
-
-    $res  = $globals->xdb->query("SELECT password FROM auth_user_md5 WHERE user_id=10154");
-    $pass = $res->fetchOneCell();
-
-    $client =& lists_xmlrpc(10154, $pass, "x-econfiance.polytechnique.org");
-    $members = $client->get_members('membres');
-    if(is_array($members)) {
-        $membres = Array();
-        foreach($members[1] as $member) {
-            if(preg_match('/^([^.]*.[^.]*.(\d\d\d\d))@polytechnique.org$/', $member[1], $matches)) {
-                $membres[] = "a.alias='{$matches[1]}'";
-            }
-        }
-    }
-
-    $where = join(' OR ',$membres);
-
-    $all = $globals->xdb->iterRow(
-            "SELECT  u.prenom,u.nom,a.alias
-               FROM  auth_user_md5 AS u
-         INNER JOIN  aliases       AS a ON ( u.user_id = a.id AND a.type!='homonyme' )
-              WHERE  $where
-           ORDER BY  nom");
-
-    $res = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n<membres>\n\n";
-
-    while (list ($prenom1,$nom1,$email1) = $all->next()) {
-            $res .= "<membre>\n";
-            $res .= "\t<nom>$nom1</nom>\n";
-            $res .= "\t<prenom>$prenom1</prenom>\n";
-            $res .= "\t<email>$email1</email>\n";
-            $res .= "</membre>\n\n";
-    }
-
-    $res .= "</membres>\n\n";
-
-    echo $res;
-}
-
-?>
index b1dae86..34c2b30 100644 (file)
@@ -24,11 +24,74 @@ class AuthModule extends PLModule
     function handlers()
     {
         return array(
+            'groupex/done-chall.php'        => $this->make_hook('chall', AUTH_PUBLIC),
+            'groupex/export-econfiance.php' => $this->make_hook('econf', AUTH_PUBLIC),
+
             'auth-redirect.php' => $this->make_hook('redirect', AUTH_COOKIE),
             'auth-groupex.php'  => $this->make_hook('groupex',  AUTH_COOKIE),
         );
     }
 
+    function chall(&$page)
+    {
+        $_SESSION["chall"] = uniqid(rand(), 1);
+        echo $_SESSION["chall"] . "\n" . session_id();
+        exit;
+    }
+
+    function econf(&$page)
+    {
+        global $globals;
+
+        require_once 'platal/xmlrpc-client.inc.php';
+        require_once 'lists.inc.php';
+
+        $cle = $globals->core->econfiance;
+
+        if (Session::get('chall') && $_GET['PASS'] == md5(Session::get('chall').$cle)) {
+
+            $res  = $globals->xdb->query("SELECT password FROM auth_user_md5 WHERE user_id=10154");
+            $pass = $res->fetchOneCell();
+
+            $client =& lists_xmlrpc(10154, $pass, "x-econfiance.polytechnique.org");
+            $members = $client->get_members('membres');
+            if (is_array($members)) {
+                $membres = Array();
+                foreach($members[1] as $member) {
+                    if (preg_match('/^([^.]*.[^.]*.(\d\d\d\d))@polytechnique.org$/',
+                                   $member[1], $matches))
+                    {
+                        $membres[] = "a.alias='{$matches[1]}'";
+                    }
+                }
+            }
+
+            $where = join(' OR ',$membres);
+
+            $all = $globals->xdb->iterRow(
+                    "SELECT  u.prenom,u.nom,a.alias
+                       FROM  auth_user_md5 AS u
+                 INNER JOIN  aliases       AS a ON ( u.user_id = a.id AND a.type!='homonyme' )
+                      WHERE  $where
+                   ORDER BY  nom");
+
+            $res = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n<membres>\n\n";
+
+            while (list ($prenom1,$nom1,$email1) = $all->next()) {
+                    $res .= "<membre>\n";
+                    $res .= "\t<nom>$nom1</nom>\n";
+                    $res .= "\t<prenom>$prenom1</prenom>\n";
+                    $res .= "\t<email>$email1</email>\n";
+                    $res .= "</membre>\n\n";
+            }
+
+            $res .= "</membres>\n\n";
+
+            echo $res;
+        }
+        exit;
+    }
+
     function handler_redirect(&$page)
     {
         redirect(Env::get('dest', '/'));