0337d704 |
1 | <?php |
2 | /*************************************************************************** |
5ddeb07c |
3 | * Copyright (C) 2003-2007 Polytechnique.org * |
0337d704 |
4 | * http://opensource.polytechnique.org/ * |
5 | * * |
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. * |
10 | * * |
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. * |
15 | * * |
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 * |
18 | * Foundation, Inc., * |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
20 | ***************************************************************************/ |
21 | |
0337d704 |
22 | /* cree le champs "auth" renvoye au Groupe X */ |
23 | function gpex_make_auth($chlg, $privkey, $datafields) { |
575dd9be |
24 | $fieldarr = explode(",",$datafields); |
0337d704 |
25 | $tohash = "1$chlg$privkey"; |
26 | |
08cce2ff |
27 | $res = XDB::query("SELECT matricule, matricule_ax, promo, |
5d292fd8 |
28 | promo_sortie, flags, deces, nom, |
29 | prenom, nationalite, section, |
30 | naissance |
31 | FROM auth_user_md5 WHERE user_id = {?}", |
cab08090 |
32 | S::v('uid')); |
9f3acd20 |
33 | $personnal_data = $res->fetchOneAssoc(); |
5d292fd8 |
34 | |
35 | foreach ($fieldarr as $val) { |
36 | /* on verifie qu'on n'a pas demandé une variable inexistante ! */ |
cab08090 |
37 | if (S::has($val)) { |
38 | $tohash .= S::v($val); |
37448723 |
39 | $params .= "&$val=".S::v($val); |
9f3acd20 |
40 | } else if (isset($personnal_data[$val])) { |
41 | $tohash .= $personnal_data[$val]; |
37448723 |
42 | $params .= "&$val=".$personnal_data[$val]; |
0337d704 |
43 | } else if ($val == 'username') { |
08cce2ff |
44 | $res = XDB::query("SELECT alias FROM aliases |
5d292fd8 |
45 | WHERE id = {?} AND FIND_IN_SET('bestalias', flags)", |
cab08090 |
46 | S::v('uid')); |
0337d704 |
47 | $min_username = $res->fetchOneCell(); |
48 | $tohash .= $min_username; |
5d292fd8 |
49 | } |
0337d704 |
50 | } |
51 | $tohash .= "1"; |
52 | return md5($tohash); |
53 | } |
54 | |
55 | /* cree les parametres de l'URL de retour avec les champs demandes */ |
56 | function gpex_make_params($chlg, $privkey, $datafields) { |
0337d704 |
57 | $params = "&auth=".gpex_make_auth($chlg, $privkey, $datafields); |
5d292fd8 |
58 | |
08cce2ff |
59 | $res = XDB::query("SELECT matricule, matricule_ax, promo, |
37448723 |
60 | promo_sortie, flags, deces, nom, |
61 | prenom, nationalite, section, |
62 | naissance |
63 | FROM auth_user_md5 WHERE user_id = {?}", |
64 | S::v('uid')); |
9f3acd20 |
65 | $personnal_data = $res->fetchOneAssoc(); |
5d292fd8 |
66 | |
575dd9be |
67 | $fieldarr = explode(",",$datafields); |
5d292fd8 |
68 | |
69 | foreach ($fieldarr as $val) { |
cab08090 |
70 | if (S::has($val)) { |
71 | $tohash .= S::v($val); |
37448723 |
72 | $params .= "&$val=".S::v($val); |
9f3acd20 |
73 | } else if (isset($personnal_data[$val])) { |
37448723 |
74 | $tohash .= $personnal_data[$val]; |
9f3acd20 |
75 | $params .= "&$val=".$personnal_data[$val]; |
0337d704 |
76 | } else if ($val == 'username') { |
08cce2ff |
77 | $res = XDB::query("SELECT alias FROM aliases |
5d292fd8 |
78 | WHERE id = {?} AND FIND_IN_SET('bestalias', flags)", |
cab08090 |
79 | S::v('uid')); |
0337d704 |
80 | $min_username = $res->fetchOneCell(); |
81 | $params .= "&$val=".$min_username; |
5d292fd8 |
82 | } |
0337d704 |
83 | } |
84 | return $params; |
85 | } |
86 | |
0337d704 |
87 | ?> |