From: x2000habouzit Date: Wed, 12 Jul 2006 22:31:47 +0000 (+0000) Subject: migrate e-confiance things into auth.php X-Git-Tag: xorg/0.9.11~445 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=d5749a28dfcae4ab1bf4d2bda39ce248e2bbfb71;p=platal.git migrate e-confiance things into auth.php git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@455 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/htdocs/groupex/donne-chall.php b/htdocs/groupex/donne-chall.php deleted file mode 100644 index 8720106..0000000 --- a/htdocs/groupex/donne-chall.php +++ /dev/null @@ -1,30 +0,0 @@ - diff --git a/htdocs/groupex/export-econfiance.php b/htdocs/groupex/export-econfiance.php deleted file mode 100644 index d508c23..0000000 --- a/htdocs/groupex/export-econfiance.php +++ /dev/null @@ -1,71 +0,0 @@ -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 = "\n\n\n\n"; - - while (list ($prenom1,$nom1,$email1) = $all->next()) { - $res .= "\n"; - $res .= "\t$nom1\n"; - $res .= "\t$prenom1\n"; - $res .= "\t$email1\n"; - $res .= "\n\n"; - } - - $res .= "\n\n"; - - echo $res; -} - -?> diff --git a/modules/auth.php b/modules/auth.php index b1dae86..34c2b30 100644 --- a/modules/auth.php +++ b/modules/auth.php @@ -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 = "\n\n\n\n"; + + while (list ($prenom1,$nom1,$email1) = $all->next()) { + $res .= "\n"; + $res .= "\t$nom1\n"; + $res .= "\t$prenom1\n"; + $res .= "\t$email1\n"; + $res .= "\n\n"; + } + + $res .= "\n\n"; + + echo $res; + } + exit; + } + function handler_redirect(&$page) { redirect(Env::get('dest', '/'));