0337d704 |
1 | <?php |
2 | /*************************************************************************** |
50a40a33 |
3 | * Copyright (C) 2003-2006 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) { |
24 | global $globals; |
575dd9be |
25 | $fieldarr = explode(",",$datafields); |
0337d704 |
26 | $tohash = "1$chlg$privkey"; |
27 | |
5d292fd8 |
28 | $res = $globals->xdb->query("SELECT matricule, matricule_ax, promo, |
29 | promo_sortie, flags, deces, nom, |
30 | prenom, nationalite, section, |
31 | naissance |
32 | FROM auth_user_md5 WHERE user_id = {?}", |
33 | Session::getInt('uid')); |
9f3acd20 |
34 | $personnal_data = $res->fetchOneAssoc(); |
5d292fd8 |
35 | |
36 | foreach ($fieldarr as $val) { |
37 | /* on verifie qu'on n'a pas demandé une variable inexistante ! */ |
38 | if (Session::has($val)) { |
39 | $tohash .= Session::get($val); |
9f3acd20 |
40 | } else if (isset($personnal_data[$val])) { |
41 | $tohash .= $personnal_data[$val]; |
0337d704 |
42 | } else if ($val == 'username') { |
5d292fd8 |
43 | $res = $globals->xdb->query("SELECT alias FROM aliases |
44 | WHERE id = {?} AND FIND_IN_SET('bestalias', flags)", |
45 | Session::getInt('uid')); |
0337d704 |
46 | $min_username = $res->fetchOneCell(); |
47 | $tohash .= $min_username; |
5d292fd8 |
48 | } |
0337d704 |
49 | } |
50 | $tohash .= "1"; |
51 | return md5($tohash); |
52 | } |
53 | |
54 | /* cree les parametres de l'URL de retour avec les champs demandes */ |
55 | function gpex_make_params($chlg, $privkey, $datafields) { |
56 | global $globals; |
57 | $params = "&auth=".gpex_make_auth($chlg, $privkey, $datafields); |
5d292fd8 |
58 | |
59 | $res = $globals->xdb->query("SELECT matricule, matricule_ax, promo, |
60 | promo_sortie, flags, deces, nom, |
61 | prenom, nationalite, section, |
62 | naissance |
63 | FROM auth_user_md5 WHERE user_id = {?}", |
64 | Session::getInt('uid')); |
9f3acd20 |
65 | $personnal_data = $res->fetchOneAssoc(); |
5d292fd8 |
66 | |
575dd9be |
67 | $fieldarr = explode(",",$datafields); |
5d292fd8 |
68 | |
69 | foreach ($fieldarr as $val) { |
70 | if (Session::has($val)) { |
71 | $tohash .= Session::get($val); |
9f3acd20 |
72 | } else if (isset($personnal_data[$val])) { |
73 | $params .= "&$val=".$personnal_data[$val]; |
0337d704 |
74 | } else if ($val == 'username') { |
5d292fd8 |
75 | $res = $globals->xdb->query("SELECT alias FROM aliases |
76 | WHERE id = {?} AND FIND_IN_SET('bestalias', flags)", |
77 | Session::getInt('uid')); |
0337d704 |
78 | $min_username = $res->fetchOneCell(); |
79 | $params .= "&$val=".$min_username; |
5d292fd8 |
80 | } |
0337d704 |
81 | } |
82 | return $params; |
83 | } |
84 | |
0337d704 |
85 | ?> |