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 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
24 |
// CVS : $Id: adau_auth.fonct.php,v 1.1 2005-03-09 10:49:52 jpm Exp $
|
|
|
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
|
|
|
38 |
*@version $Revision: 1.1 $
|
|
|
39 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
40 |
*/
|
|
|
41 |
|
|
|
42 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
43 |
// | LISTE de FONCTIONS |
|
|
|
44 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
*
|
|
|
48 |
*
|
|
|
49 |
* @return
|
|
|
50 |
*/
|
|
|
51 |
|
|
|
52 |
function adau_supprimer_authentification($id_auth, &$db) {
|
|
|
53 |
|
|
|
54 |
// on recherche l'identifiant de gen_site_auth_bdd à partir de gen_site_auth
|
|
|
55 |
$requete = "select gsa_ce_auth_bdd from gen_site_auth where gsa_id_auth=".$GLOBALS['id_auth'] ;
|
|
|
56 |
$resultat = $db->query ($requete) ;
|
|
|
57 |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
|
|
|
58 |
$id_auth_bdd = $ligne->gsa_ce_auth_bdd ;
|
|
|
59 |
|
|
|
60 |
$requete = "delete from gen_site_auth where gsa_id_auth=$id_auth" ;
|
|
|
61 |
$resultat = $db->query ($requete) ;
|
|
|
62 |
|
|
|
63 |
$requete = "delete from gen_site_auth_bdd where gsab_id_auth_bdd=$id_auth_bdd" ;
|
|
|
64 |
$resultat = $db->query ($requete) ;
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
/**
|
|
|
68 |
*
|
|
|
69 |
*
|
|
|
70 |
* @return
|
|
|
71 |
*/
|
|
|
72 |
|
|
|
73 |
function adau_valeurs_par_defaut ($id_auth, &$db) {
|
|
|
74 |
// requete sur gen_site_auth
|
|
|
75 |
|
|
|
76 |
$requete = "select * from gen_site_auth where gsa_id_auth=$id_auth" ;
|
|
|
77 |
$resultat = $db->query ($requete) ;
|
|
|
78 |
if (DB::isError ($resultat)) {
|
|
|
79 |
trigger_error("Echec de la requete : $requete<br />".$resultat->getMessage(), E_USER_WARNING) ;
|
|
|
80 |
return ;
|
|
|
81 |
}
|
|
|
82 |
$tableau_retour = array () ;
|
|
|
83 |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
|
|
|
84 |
$tableau_retour['nom_auth'] = $ligne->gsa_nom ;
|
|
|
85 |
$tableau_retour['abreviation'] = $ligne->gsa_abreviation ;
|
|
|
86 |
$tableau_retour['id_auth_bdd'] = $ligne->gsa_ce_auth_bdd ;
|
|
|
87 |
$tableau_retour['id_auth'] = $ligne->gsa_id_auth ;
|
|
|
88 |
unset ($requete, $resultat) ;
|
|
|
89 |
|
|
|
90 |
// requete sur gen_site_auth_bdd
|
|
|
91 |
$requete = "select * from gen_site_auth_bdd where gsab_id_auth_bdd=$ligne->gsa_ce_auth_bdd" ;
|
|
|
92 |
unset ($ligne) ;
|
|
|
93 |
$resultat = $db->query ($requete) ;
|
|
|
94 |
if (DB::isError ($resultat)) {
|
|
|
95 |
trigger_error("Echec de la requete : $requete<br />".$resultat->getMessage(),E_USER_WARNING) ;
|
|
|
96 |
return ;
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
|
|
|
100 |
$tableau_retour['dsn'] = $ligne->gsab_dsn ;
|
|
|
101 |
$tableau_retour['nom_table'] = $ligne->gsab_nom_table ;
|
|
|
102 |
$tableau_retour['champs_login'] = $ligne->gsab_nom_champ_login ;
|
|
|
103 |
$tableau_retour['champs_passe'] = $ligne->gsab_nom_champ_mdp ;
|
|
|
104 |
$tableau_retour['cryptage'] = $ligne->gsab_cryptage_mdp ;
|
|
|
105 |
$tableau_retour['parametres'] = $ligne->gsab_parametres ;
|
|
|
106 |
|
|
|
107 |
return $tableau_retour ;
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
/**
|
|
|
111 |
*
|
|
|
112 |
*
|
|
|
113 |
* @return
|
|
|
114 |
*/
|
|
|
115 |
|
|
|
116 |
function insertion ($valeur, &$db) {
|
|
|
117 |
$id_auth_bdd = SQL_obtenirNouveauId ($db, 'gen_site_auth_bdd', 'gsab_id_auth_bdd') ;
|
|
|
118 |
$requete = "insert into gen_site_auth set gsa_id_auth="
|
|
|
119 |
.SQL_obtenirNouveauId($db, 'gen_site_auth', 'gsa_id_auth').","
|
|
|
120 |
.requete_site_auth($valeur)
|
|
|
121 |
.', gsa_ce_auth_bdd='.$id_auth_bdd ;
|
|
|
122 |
$resultat = $db->query ($requete) ;
|
|
|
123 |
if (DB::isError ($resultat)) {
|
|
|
124 |
trigger_error("Echec de la requete : $requete<br />".$resultat->getMessage(),E_USER_WARNING) ;
|
|
|
125 |
}
|
|
|
126 |
$requete = "insert into gen_site_auth_bdd set gsab_id_auth_bdd=$id_auth_bdd, "
|
|
|
127 |
.requete_site_auth_bdd($valeur) ;
|
|
|
128 |
$resultat = $db->query ($requete) ;
|
|
|
129 |
if (DB::isError ($resultat)) {
|
|
|
130 |
trigger_error("Echec de la requete : $requete<br />".$resultat->getMessage(),E_USER_WARNING) ;
|
|
|
131 |
}
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
/**
|
|
|
135 |
*
|
|
|
136 |
*
|
|
|
137 |
* @return
|
|
|
138 |
*/
|
|
|
139 |
|
|
|
140 |
function mise_a_jour ($valeur, &$db) {
|
|
|
141 |
$requete = "update gen_site_auth set ".requete_site_auth($valeur)
|
|
|
142 |
.' where gsa_id_auth='.$GLOBALS['id_auth'] ;
|
|
|
143 |
$resultat = $db->query ($requete) ;
|
|
|
144 |
if (DB::isError ($resultat)) {
|
|
|
145 |
trigger_error("Echec de la requete : $requete<br />".$resultat->getMessage(),E_USER_WARNING) ;
|
|
|
146 |
}
|
|
|
147 |
unset ($requete) ;
|
|
|
148 |
// on 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 ;
|
|
|
153 |
|
|
|
154 |
$requete = "update gen_site_auth_bdd set "
|
|
|
155 |
.requete_site_auth_bdd($valeur)
|
|
|
156 |
.' where gsab_id_auth_bdd='.$id_auth_bdd ;
|
|
|
157 |
$resultat = $db->query ($requete) ;
|
|
|
158 |
if (DB::isError ($resultat)) {
|
|
|
159 |
trigger_error("Echec de la requete : $requete<br />".$resultat->getMessage(),E_USER_WARNING) ;
|
|
|
160 |
}
|
|
|
161 |
}
|
|
|
162 |
|
|
|
163 |
/**
|
|
|
164 |
*
|
|
|
165 |
*
|
|
|
166 |
* @return string un morceau de code SQL
|
|
|
167 |
*/
|
|
|
168 |
|
|
|
169 |
function requete_site_auth (&$valeur) {
|
|
|
170 |
return 'gsa_nom="'.$valeur['nom_auth'].'", '
|
|
|
171 |
.'gsa_ce_type_auth=1, '
|
|
|
172 |
.'gsa_abreviation="'.$valeur['abreviation'].'"' ;
|
|
|
173 |
}
|
|
|
174 |
|
|
|
175 |
/**
|
|
|
176 |
*
|
|
|
177 |
*
|
|
|
178 |
* @return
|
|
|
179 |
*/
|
|
|
180 |
|
|
|
181 |
function requete_site_auth_bdd (&$valeur) {
|
|
|
182 |
return 'gsab_dsn="'.$valeur['dsn'].'", '
|
|
|
183 |
.'gsab_nom_table="'.$valeur['nom_table'].'", '
|
|
|
184 |
.'gsab_nom_champ_login="'.$valeur['champs_login'].'", '
|
|
|
185 |
.'gsab_nom_champ_mdp="'.$valeur['champs_passe'].'", '
|
|
|
186 |
.'gsab_parametres="'.$valeur['parametres'].'", '
|
|
|
187 |
.'gsab_cryptage_mdp="'.$valeur['cryptage'].'"';
|
|
|
188 |
}
|
|
|
189 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
190 |
// | PIED du PROGRAMME |
|
|
|
191 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
192 |
|
|
|
193 |
|
|
|
194 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
|
|
195 |
*
|
|
|
196 |
* $Log: not supported by cvs2svn $
|
|
|
197 |
* Revision 1.2 2004/12/06 12:43:21 alex
|
|
|
198 |
* ajout du champs paramètre dans ls authentification
|
|
|
199 |
*
|
|
|
200 |
* Revision 1.1 2004/12/06 11:31:54 alex
|
|
|
201 |
* version initiale
|
|
|
202 |
*
|
|
|
203 |
*
|
|
|
204 |
* +-- Fin du code ----------------------------------------------------------------------------------------+
|
|
|
205 |
*/
|
|
|
206 |
?>
|