302 |
jpm |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This file is part of Papyrus. |
|
|
|
9 |
// | |
|
|
|
10 |
// | Foobar is free software; you can redistribute it and/or modify |
|
|
|
11 |
// | it under the terms of the GNU General Public License as published by |
|
|
|
12 |
// | the Free Software Foundation; either version 2 of the License, or |
|
|
|
13 |
// | (at your option) any later version. |
|
|
|
14 |
// | |
|
|
|
15 |
// | Foobar is distributed in the hope that it will be useful, |
|
|
|
16 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
17 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
|
18 |
// | GNU General Public License for more details. |
|
|
|
19 |
// | |
|
|
|
20 |
// | You should have received a copy of the GNU General Public License |
|
|
|
21 |
// | along with Foobar; if not, write to the Free Software |
|
|
|
22 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
23 |
// +------------------------------------------------------------------------------------------------------+
|
332 |
jpm |
24 |
// CVS : $Id: adau_auth.fonct.php,v 1.2 2005-04-14 13:54:51 jpm Exp $
|
302 |
jpm |
25 |
/**
|
|
|
26 |
* Contient les fonctions de l'appli admin_auth
|
|
|
27 |
*
|
|
|
28 |
*
|
|
|
29 |
*
|
|
|
30 |
*
|
|
|
31 |
*@package Admin_auth
|
|
|
32 |
*@subpackage Fonctions
|
|
|
33 |
//Auteur original :
|
|
|
34 |
*@author Alexandre Granier <alexandre@tela-botanica.org>
|
|
|
35 |
//Autres auteurs :
|
|
|
36 |
*@author Aucun
|
|
|
37 |
*@copyright Tela-Botanica 2000-2004
|
332 |
jpm |
38 |
*@version $Revision: 1.2 $
|
302 |
jpm |
39 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
40 |
*/
|
|
|
41 |
|
|
|
42 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
43 |
// | LISTE de FONCTIONS |
|
|
|
44 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
*
|
|
|
48 |
*
|
|
|
49 |
* @return
|
|
|
50 |
*/
|
332 |
jpm |
51 |
function adau_supprimer_authentification($id_auth, &$db)
|
|
|
52 |
{
|
|
|
53 |
// Recherche l'identifiant de gen_site_auth_bdd à partir de gen_site_auth
|
|
|
54 |
$requete = 'SELECT gsa_ce_auth_bdd FROM gen_site_auth WHERE gsa_id_auth = '.$GLOBALS['id_auth'];
|
302 |
jpm |
55 |
$resultat = $db->query ($requete) ;
|
|
|
56 |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
|
|
|
57 |
$id_auth_bdd = $ligne->gsa_ce_auth_bdd ;
|
|
|
58 |
|
332 |
jpm |
59 |
$requete = 'DELETE FROM gen_site_auth WHERE gsa_id_auth = '.$id_auth;
|
|
|
60 |
$resultat = $db->query($requete);
|
302 |
jpm |
61 |
|
332 |
jpm |
62 |
$requete = 'DELETE FROM gen_site_auth_bdd WHERE gsab_id_auth_bdd = '.$id_auth_bdd;
|
|
|
63 |
$resultat = $db->query($requete);
|
302 |
jpm |
64 |
}
|
|
|
65 |
|
|
|
66 |
/**
|
|
|
67 |
*
|
|
|
68 |
*
|
|
|
69 |
* @return
|
|
|
70 |
*/
|
332 |
jpm |
71 |
function adau_valeurs_par_defaut($id_auth, &$db)
|
|
|
72 |
{
|
|
|
73 |
// Requete sur gen_site_auth
|
|
|
74 |
$requete = 'SELECT * FROM gen_site_auth WHERE gsa_id_auth = '.$id_auth;
|
|
|
75 |
$resultat = $db->query($requete);
|
|
|
76 |
if (DB::isError($resultat)) {
|
|
|
77 |
trigger_error('Échec de la requete : '.$requete.'<br />'.$resultat->getMessage(), E_USER_WARNING);
|
302 |
jpm |
78 |
return ;
|
|
|
79 |
}
|
332 |
jpm |
80 |
$tableau_retour = array();
|
|
|
81 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT);
|
|
|
82 |
$tableau_retour['nom_auth'] = $ligne->gsa_nom;
|
|
|
83 |
$tableau_retour['abreviation'] = $ligne->gsa_abreviation;
|
|
|
84 |
$tableau_retour['id_auth_bdd'] = $ligne->gsa_ce_auth_bdd;
|
|
|
85 |
$tableau_retour['id_auth'] = $ligne->gsa_id_auth;
|
|
|
86 |
unset($requete, $resultat);
|
302 |
jpm |
87 |
|
332 |
jpm |
88 |
// Requete sur gen_site_auth_bdd
|
|
|
89 |
$requete = 'SELECT * FROM gen_site_auth_bdd WHERE gsab_id_auth_bdd = '.$ligne->gsa_ce_auth_bdd;
|
|
|
90 |
unset($ligne);
|
2088 |
drzraf |
91 |
$resultat = $db->query($requete . ' -- ' . __FILE__ . ':' . __LINE__);
|
332 |
jpm |
92 |
if (DB::isError($resultat)) {
|
|
|
93 |
trigger_error('Échec de la requete : '.$requete.'<br />'.$resultat->getMessage(), E_USER_WARNING);
|
302 |
jpm |
94 |
return ;
|
|
|
95 |
}
|
2088 |
drzraf |
96 |
|
332 |
jpm |
97 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT);
|
|
|
98 |
$tableau_retour['dsn'] = $ligne->gsab_dsn;
|
|
|
99 |
$tableau_retour['nom_table'] = $ligne->gsab_nom_table;
|
|
|
100 |
$tableau_retour['champs_login'] = $ligne->gsab_nom_champ_login;
|
|
|
101 |
$tableau_retour['champs_passe'] = $ligne->gsab_nom_champ_mdp;
|
|
|
102 |
$tableau_retour['cryptage'] = $ligne->gsab_cryptage_mdp;
|
|
|
103 |
$tableau_retour['parametres'] = $ligne->gsab_parametres;
|
302 |
jpm |
104 |
|
332 |
jpm |
105 |
return $tableau_retour;
|
302 |
jpm |
106 |
}
|
|
|
107 |
|
|
|
108 |
/**
|
|
|
109 |
*
|
|
|
110 |
*
|
|
|
111 |
* @return
|
|
|
112 |
*/
|
332 |
jpm |
113 |
function insertion ($valeur, &$db)
|
|
|
114 |
{
|
|
|
115 |
$id_auth_bdd = SQL_obtenirNouveauId($db, 'gen_site_auth_bdd', 'gsab_id_auth_bdd');
|
|
|
116 |
$requete = 'INSERT INTO gen_site_auth SET gsa_id_auth = '
|
|
|
117 |
.SQL_obtenirNouveauId($db, 'gen_site_auth', 'gsa_id_auth').', '
|
302 |
jpm |
118 |
.requete_site_auth($valeur)
|
332 |
jpm |
119 |
.', gsa_ce_auth_bdd = '.$id_auth_bdd;
|
2088 |
drzraf |
120 |
$resultat = $db->query($requete . ' -- ' . __FILE__ . ':' . __LINE__);
|
332 |
jpm |
121 |
if (DB::isError($resultat)) {
|
|
|
122 |
trigger_error('Échec de la requete : '.$requete.'<br />'.$resultat->getMessage(), E_USER_WARNING);
|
|
|
123 |
return ;
|
302 |
jpm |
124 |
}
|
332 |
jpm |
125 |
$requete = 'INSERT INTO gen_site_auth_bdd SET gsab_id_auth_bdd = '.$id_auth_bdd.', '.requete_site_auth_bdd($valeur);
|
|
|
126 |
$resultat = $db->query($requete);
|
|
|
127 |
if (DB::isError($resultat)) {
|
|
|
128 |
trigger_error('Échec de la requete : '.$requete.'<br />'.$resultat->getMessage(), E_USER_WARNING);
|
|
|
129 |
return ;
|
302 |
jpm |
130 |
}
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
/**
|
|
|
134 |
*
|
|
|
135 |
*
|
|
|
136 |
* @return
|
|
|
137 |
*/
|
332 |
jpm |
138 |
function mise_a_jour($valeur, &$db)
|
|
|
139 |
{
|
|
|
140 |
$requete = 'UPDATE gen_site_auth SET '.requete_site_auth($valeur).' '.
|
|
|
141 |
'WHERE gsa_id_auth = '.$GLOBALS['id_auth'];
|
|
|
142 |
$resultat = $db->query($requete);
|
|
|
143 |
if (DB::isError($resultat)) {
|
|
|
144 |
trigger_error('Échec de la requete : '.$requete.'<br />'.$resultat->getMessage(), E_USER_WARNING);
|
|
|
145 |
return ;
|
302 |
jpm |
146 |
}
|
332 |
jpm |
147 |
unset($requete);
|
|
|
148 |
// Recherche l'identifiant de gen_site_auth_bdd à partir de gen_site_auth
|
|
|
149 |
$requete = 'SELECT gsa_ce_auth_bdd FROM gen_site_auth WHERE gsa_id_auth = '.$GLOBALS['id_auth'];
|
|
|
150 |
$resultat = $db->query($requete);
|
|
|
151 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT);
|
|
|
152 |
$id_auth_bdd = $ligne->gsa_ce_auth_bdd;
|
302 |
jpm |
153 |
|
332 |
jpm |
154 |
$requete = 'UPDATE gen_site_auth_bdd SET '
|
302 |
jpm |
155 |
.requete_site_auth_bdd($valeur)
|
332 |
jpm |
156 |
.' WHERE gsab_id_auth_bdd = '.$id_auth_bdd;
|
|
|
157 |
$resultat = $db->query($requete);
|
|
|
158 |
if (DB::isError($resultat)) {
|
|
|
159 |
trigger_error('Échec de la requete : '.$requete.'<br />'.$resultat->getMessage(), E_USER_WARNING);
|
|
|
160 |
return ;
|
302 |
jpm |
161 |
}
|
|
|
162 |
}
|
|
|
163 |
|
|
|
164 |
/**
|
|
|
165 |
*
|
|
|
166 |
*
|
|
|
167 |
* @return string un morceau de code SQL
|
|
|
168 |
*/
|
332 |
jpm |
169 |
function requete_site_auth(&$valeur)
|
|
|
170 |
{
|
302 |
jpm |
171 |
return 'gsa_nom="'.$valeur['nom_auth'].'", '
|
|
|
172 |
.'gsa_ce_type_auth=1, '
|
|
|
173 |
.'gsa_abreviation="'.$valeur['abreviation'].'"' ;
|
|
|
174 |
}
|
|
|
175 |
|
|
|
176 |
/**
|
|
|
177 |
*
|
|
|
178 |
*
|
|
|
179 |
* @return
|
|
|
180 |
*/
|
332 |
jpm |
181 |
function requete_site_auth_bdd (&$valeur)
|
|
|
182 |
{
|
302 |
jpm |
183 |
return 'gsab_dsn="'.$valeur['dsn'].'", '
|
|
|
184 |
.'gsab_nom_table="'.$valeur['nom_table'].'", '
|
|
|
185 |
.'gsab_nom_champ_login="'.$valeur['champs_login'].'", '
|
|
|
186 |
.'gsab_nom_champ_mdp="'.$valeur['champs_passe'].'", '
|
|
|
187 |
.'gsab_parametres="'.$valeur['parametres'].'", '
|
|
|
188 |
.'gsab_cryptage_mdp="'.$valeur['cryptage'].'"';
|
|
|
189 |
}
|
|
|
190 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
191 |
// | PIED du PROGRAMME |
|
|
|
192 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
193 |
|
|
|
194 |
|
|
|
195 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
|
|
196 |
*
|
|
|
197 |
* $Log: not supported by cvs2svn $
|
332 |
jpm |
198 |
* Revision 1.1 2005/03/09 10:49:52 jpm
|
|
|
199 |
* Changement d'un nom de fichier.
|
|
|
200 |
*
|
302 |
jpm |
201 |
* Revision 1.2 2004/12/06 12:43:21 alex
|
|
|
202 |
* ajout du champs paramètre dans ls authentification
|
|
|
203 |
*
|
|
|
204 |
* Revision 1.1 2004/12/06 11:31:54 alex
|
|
|
205 |
* version initiale
|
|
|
206 |
*
|
|
|
207 |
*
|
|
|
208 |
* +-- Fin du code ----------------------------------------------------------------------------------------+
|
|
|
209 |
*/
|
|
|
210 |
?>
|