2 /***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 /* cree le champs "auth" renvoye au Groupe X */
23 function gpex_make_auth($chlg, $privkey, $datafields) {
24 $fieldarr = explode(",",$datafields);
25 $tohash = "1$chlg$privkey";
27 $res = XDB
::query("SELECT matricule, matricule_ax, promo,
28 promo_sortie, flags, deces, nom,
29 prenom, nationalite, section,
31 FROM auth_user_md5 WHERE user_id = {?}",
33 $personnal_data = $res->fetchOneAssoc();
35 foreach ($fieldarr as $val) {
36 /* on verifie qu'on n'a pas demandé une variable inexistante ! */
38 $tohash .= S
::v($val);
39 } else if (isset($personnal_data[$val])) {
40 $tohash .= $personnal_data[$val];
41 } else if ($val == 'username') {
42 $res = XDB
::query("SELECT alias FROM aliases
43 WHERE id = {?} AND FIND_IN_SET('bestalias', flags)",
45 $min_username = $res->fetchOneCell();
46 $tohash .= $min_username;
53 /* cree les parametres de l'URL de retour avec les champs demandes */
54 function gpex_make_params($chlg, $privkey, $datafields) {
55 $params = "&auth=".gpex_make_auth($chlg, $privkey, $datafields);
57 $res = XDB
::query("SELECT matricule, matricule_ax, promo,
58 promo_sortie, flags, deces, nom,
59 prenom, nationalite, section,
61 FROM auth_user_md5 WHERE user_id = {?}",
63 $personnal_data = $res->fetchOneAssoc();
65 $fieldarr = explode(",",$datafields);
67 foreach ($fieldarr as $val) {
69 $tohash .= S
::v($val);
70 } else if (isset($personnal_data[$val])) {
71 $params .= "&$val=".$personnal_data[$val];
72 } else if ($val == 'username') {
73 $res = XDB
::query("SELECT alias FROM aliases
74 WHERE id = {?} AND FIND_IN_SET('bestalias', flags)",
76 $min_username = $res->fetchOneCell();
77 $params .= "&$val=".$min_username;