1,513 → 1,519 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU Lesser General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | Lesser General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU Lesser General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: inscription.fonct.php,v 1.2 2004-12-17 17:41:51 alex Exp $ |
// CVS : $Id: inscription.fonct.php,v 1.2 2004-12-17 17:41:51 alex Exp $ |
/** |
* Fonctions du module inscription |
* |
* Fonctions du module inscription |
* |
*@package inscription |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.2 $ $Date: 2004-12-17 17:41:51 $ |
*@version $Revision: 1.2 $ $Date: 2004-12-17 17:41:51 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
|
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
include_once 'ins_wiki.fonct.php' ; |
if (INS_UTILISE_SPIP) include_once 'ins_spip.fonct.php' ; |
require_once 'HTML/QuickForm.php' ; |
require_once 'HTML/QuickForm/checkbox.php' ; |
require_once 'HTML/QuickForm/password.php' ; |
|
// +------------------------------------------------------------------------------------------------------+ |
// | LISTE de FONCTIONS | |
// +------------------------------------------------------------------------------------------------------+ |
|
|
/** |
* |
* @param array les valeurs renvoyés par le formulaire |
* @return |
*/ |
|
function demande_inscription ($valeurs) { |
// On stocke les informations dans un variable de session |
$_SESSION['donnees_inscription'] = $valeurs ; |
|
// On envoie un email de confirmation pour l'utilisateur |
$GLOBALS['ins_url']->addQueryString ('id', session_id()) ; |
mail ($GLOBALS['email'], 'inscription', $GLOBALS['ins_url']->getURL()) ; |
} |
|
/** |
* |
* |
* @return |
*/ |
|
function message_inscription () { |
return INS_MESSAGE_INSCRIPTION ; |
} |
/** |
* Réalise l'insertion dans la base de donnée |
* |
* @param array un tableau de valeur avec en clé les noms des champs du formulaire |
* @return void |
*/ |
|
function AUTH_formulaire_login () { |
//-------------------------------------------------------------------------- |
// Le formulaire |
//-------------------------------------------------------------------------- |
$GLOBALS['ins_url']->addQueryString('action', 'inscription') ; |
$form = new HTML_QuickForm ('inscription', 'post', preg_replace ('/&/', '&', str_replace ('&', '&', $GLOBALS['ins_url']->getURL()))) ; |
$form->addElement ('submit', 'Inscription', INS_INSCRIPTION) ; |
if (INS_FORMULAIRE_STRUCTURE) $form->addElement ('submit', 'structure', INS_INSCRIPTION_STRUCTURE) ; |
$res = "<div class=\"titre1_inscription\">".INS_LAIUS_INSCRIPTION."</div>\n" ; |
$res .= "<div>".INS_LAIUS_INSCRIPTION_2."</div>\n" ; |
$res .= $form->toHTML() ; |
$res .= '<div>'.INS_DEJA_INSCRIT.'</div>' ; |
$GLOBALS['ins_url']->removeQueryString ('action') ; |
$form = new HTML_QuickForm ('inscription', 'post', str_replace ('&', '&', $GLOBALS['ins_url']->getURL())) ; |
$form->addElement ('text', 'username', INS_EMAIL) ; |
$form->addElement ('password', 'password', INS_MOT_DE_PASSE) ; |
$form->addElement('submit', 'valider', INS_VALIDER); |
|
|
$res .= $form->toHTML() ; |
|
$res .= "<div>".INS_TEXTE_PERDU."</div>\n" ; |
return $res; |
} |
|
/** |
* |
* |
* |
* |
* @return string HTML Un message d'erreur avec un lien pour renvoyer le mot de passe |
*/ |
function message_erreur () { |
$res = ''; |
// Si le mot de passe vient juste d'être envoyé, on remet le formulaire de login |
if ($GLOBALS['action'] == 'sendpasswd') { |
$form = new HTML_QuickForm ('inscription', 'post', str_replace ('&', '&', $GLOBALS['ins_url']->getURL())) ; |
$form->addElement ('text', 'username', INS_EMAIL) ; |
$form->addElement ('password', 'password', INS_MOT_DE_PASSE) ; |
$form->addElement('submit', 'valider', INS_VALIDER); |
$res .= $form->toHTML() ; |
} else { |
$res .= "<div class=\"inscription_erreur\">".INS_ERREUR_LOGIN."</div>\n" ; |
$res .= "<div>".INS_SI_PASSE_PERDU."</div>\n" ; |
$res .= "<div>" ; |
$GLOBALS['ins_url']->addQueryString('action', 'sendpasswd') ; |
$res .= "<form action=\"".str_replace ('&', '&', $GLOBALS['ins_url']->getURL())."\" method=\"post\">\n" ; |
$res .= INS_EMAIL." " ; |
$res .= "<input type=\"text\" value=\"".$GLOBALS['username']."\" name=\"username\" size=\"32\" /></li></ul>\n" ; |
$res .= "<div>".INS_INDIQUE_ADRESSE."</div>\n" ; |
$res .= "<input type=\"submit\" value=\"".INS_ENVOIE_PASSE."\" />" ; |
$res .= "</form></div>\n" ; |
} |
// On remet le formulaire d'inscription |
$GLOBALS['ins_url']->addQueryString('action', 'inscription') ; |
$form = new HTML_QuickForm ('inscription', 'post', str_replace ('&', '&', $GLOBALS['ins_url']->getURL())) ; |
$form->addElement ('submit', 'Inscription', INS_INSCRIPTION) ; |
$res .= INS_LAIUS_INSCRIPTION ; |
$res .= $form->toHTML() ; |
return $res; |
} |
|
function insertion($valeur) { |
// =========== Insertion dans l'annuaire gen_annuaire =================== |
|
$id_administrateur = nextId(INS_ANNUAIRE, INS_CHAMPS_ID, $GLOBALS['ins_db']) ; |
$requete = 'insert into '.INS_ANNUAIRE.' set '. |
INS_CHAMPS_ID.'="'.$id_administrateur.'",'. |
requete_annuaire($valeur) ; |
|
$resultat = $GLOBALS['ins_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
|
// ================ Insertion dans SPIP ========================================= |
if (INS_UTILISE_SPIP) { |
inscription_spip($id_administrateur, $valeur) ; |
} |
//inscription_interwikini_users() ; |
|
} |
|
/** |
* Réalise une mise à jour dans la base de donnée |
* |
* @param array un tableau de valeur avec en clé les noms des champs du formulaire |
* @return void |
*/ |
function mise_a_jour($valeur) { |
// ====================Mise à jour dans l'annuaire gen_annuaire ==================== |
$requete = 'update '.INS_ANNUAIRE.' set '. |
requete_annuaire ($valeur). |
'where '.INS_CHAMPS_ID.'="'.$GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID).'"'; |
$resultat = $GLOBALS['ins_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
unset ($resultat) ; |
|
// ========================= Mise à jour dans SPIP ================================ |
if (INS_UTILISE_SPIP) { |
mod_inscription_spip($GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID), $valeur) ; |
} |
} |
|
/** requete_annuaire () - Renvoie une chaine contenant les champs de l'annuaire avec leur valeur suite à le fonction process de QuickForm |
* |
* @return string une requete du type champs="valeur",... |
*/ |
|
function requete_annuaire ($valeur) { |
$req = INS_CHAMPS_NOM.'="'.$valeur['nom'].'",'. |
INS_CHAMPS_PRENOM.'="'.$valeur['prenom'].'",'. |
INS_CHAMPS_MAIL.'="'.$valeur['email'].'",' ; |
if (INS_UTILISE_WIKINI) $req .= INS_CHAMPS_NOM_WIKINI.'="'.$valeur['nomwiki'].'",' ; |
$req .= INS_CHAMPS_PASSE.'="'.md5 ($valeur['mot_de_passe']).'",'. |
INS_CHAMPS_PAYS.'="'.$valeur['pays'].'",'. |
INS_CHAMPS_ADRESSE_1.'="'.$valeur['adresse_1'].'",'. |
INS_CHAMPS_ADRESSE_2.'="'.$valeur['adresse_2'].'",'. |
INS_CHAMPS_DATE_INSCRIPTION.'=NOW(),'. |
INS_CHAMPS_CODE_POSTAL.'="'.$valeur['cp'].'" ' ; |
if (INS_FORMULAIRE_STRUCTURE) { |
$req .= ",".INS_CHAMPS_EST_STRUCTURE.'="'.$valeur['est_structure'].'"' ; |
$req .= ",".INS_CHAMPS_SIGLE_STRUCTURE.'="'.$valeur['sigle_structure'].'"' ; |
} |
|
// traitement du numéro de département pour la france |
if ($valeur[INS_CHAMPS_PAYS] == 'FR') { |
if (preg_match("/^97|98[0-9]*/", $valeur['cp'])) { |
$n_dpt = substr($valeur['cp'], 0, 3) ; |
} else { |
$n_dpt = substr($valeur['cp'], 0, 2) ; |
} |
$req .= ",".INS_CHAMPS_DEPARTEMENT."='$n_dpt'"; |
} |
// Le téléphone et le fax |
if (INS_CHAMPS_TELEPHONE) { |
$req .= ",".INS_CHAMPS_TELEPHONE.'="'.$valeur['telephone'].'"' ; |
} |
if (INS_CHAMPS_FAX) { |
$req .= ",".INS_CHAMPS_FAX.'="'.$valeur['fax'].'"' ; |
} |
if (INS_CHAMPS_STRUCTURE) { |
$req .= ",".INS_CHAMPS_STRUCTURE.'="'.$valeur['structure'].'"' ; |
} |
return $req ; |
} |
|
|
|
/** formulaire_defaults () - Renvoie un tableau avec les valeurs par défaut du formulaire d'inscription |
* |
* @return array Valeurs par défaut du formulaire d'inscription |
*/ |
function formulaire_defaults () { |
$requete = 'select '.INS_ANNUAIRE.'.* '. |
'from '.INS_ANNUAIRE.' '. |
'where '.INS_ANNUAIRE.'.'.INS_CHAMPS_ID.'= "'.$GLOBALS['AUTH']->getAuthData (INS_CHAMPS_ID).'"' ; |
$resultat = $GLOBALS['ins_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ; |
$valeurs_par_defaut = array() ; |
$valeurs_par_defaut['email'] = $ligne[INS_CHAMPS_MAIL]; |
$valeurs_par_defaut['nom'] = $ligne[INS_CHAMPS_NOM]; |
$valeurs_par_defaut['prenom'] = $ligne[INS_CHAMPS_PRENOM] ; |
$valeurs_par_defaut['pays'] = $ligne[INS_CHAMPS_PAYS] ; |
$valeurs_par_defaut['nomwiki'] = $ligne[INS_CHAMPS_LOGIN] ; |
$valeurs_par_defaut['cp'] = $ligne[INS_CHAMPS_CODE_POSTAL] ; |
$valeurs_par_defaut['ville'] = $ligne[INS_CHAMPS_VILLE] ; |
$valeurs_par_defaut['adresse_1'] = $ligne[INS_CHAMPS_ADRESSE_1] ; |
$valeurs_par_defaut['adresse_2'] = $ligne[INS_CHAMPS_ADRESSE_2] ; |
$valeurs_par_defaut['telephone'] = $ligne[INS_CHAMPS_TELEPHONE] ; |
$valeurs_par_defaut['fax'] = $ligne[INS_CHAMPS_FAX] ; |
$valeurs_par_defaut['structure'] = $ligne[INS_CHAMPS_STRUCTURE] ; |
|
return $valeurs_par_defaut ; |
} |
|
|
|
function info() { |
$requete = 'select * from '.INS_ANNUAIRE.' '. |
'where '.INS_ANNUAIRE.'.'.INS_CHAMPS_ID.'="'.$GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID).'"' ; |
|
$resultat = $GLOBALS['ins_db'] -> query ($requete) ; |
if (DB::isError ($resultat)) { |
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ; |
} |
|
$ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC) ; |
$res = "<h1 class=\"inscription_titre1\">".INS_MESSAGE_BIENVENU ; |
$res .= "</h1>\n" ; |
$res .= "<h2 class=\"inscription_titre2\">".INS_FICHE_PERSONNELLE."</h2>\n" ; |
$res .= "<div>".INS_EMAIL." : ".$ligne[INS_CHAMPS_MAIL]."</div>\n" ; |
if ($ligne[INS_CHAMPS_EST_STRUCTURE] == 1) $nom = INS_NOM_STRUCTURE ; else $nom = INS_NOM ; |
$res .= "<div>".$nom." : ".$ligne[INS_CHAMPS_NOM]."</div>" ; |
if ($ligne[INS_CHAMPS_EST_STRUCTURE] == 0) $res .= "<div>".INS_PRENOM." : ".$ligne[INS_CHAMPS_PRENOM]."</div>\n" ; |
if ($ligne[INS_CHAMPS_LOGIN] != "") $res .= "<div>".INS_NOM_WIKI." : ".$ligne[INS_CHAMPS_LOGIN]."</div>\n" ; |
if ($ligne[INS_CHAMPS_ADRESSE_1] != "") $res .= "<div>".INS_ADRESSE." : ".$ligne[INS_CHAMPS_ADRESSE_1]."</div>\n" ; |
if ($ligne[INS_CHAMPS_ADRESSE_2] != "") $res .= "<div> : ".$ligne[INS_CHAMPS_ADRESSE_2]."</div>\n" ; |
if ($ligne[INS_CHAMPS_TELEPHONE] != "") $res .= "<div> : ".$ligne[INS_CHAMPS_TELEPHONE]."</div>\n" ; |
if ($ligne[INS_CHAMPS_FAX] != "") $res .= "<div> : ".$ligne[INS_CHAMPS_FAX]."</div>\n" ; |
if ($ligne[INS_CHAMPS_STRUCTURE] != "") $res .= "<div> : ".$ligne[INS_CHAMPS_STRUCTURE]."</div>\n" ; |
|
return $res ; |
} |
|
function bouton($url) { |
global $GS_GLOBAL ; |
$boutons = new HTML_QuickForm('inscription', 'post', $url) ; ; |
//confirmation() ; |
$buttons[] = &HTML_QuickForm::createElement('submit', 'modifier', INS_MODIFIER_INSCRIPTION); |
$buttons[] = &HTML_QuickForm::createElement('submit', 'supprimer', INS_SUPPRIMER_INSCRIPTION, |
array ("onclick" => "javascript:return confirm('".INS_SUPPRIMER_INSCRIPTION." ?');")); |
$boutons->addGroup($buttons, null, null, ' '); |
return $boutons->toHTML() ; |
} |
|
/** |
* Renvoie un lien pour se déconnex=cter |
* |
* @return string |
*/ |
|
function deconnexion ($url) { |
// Un champs logout |
return "<div><a href=\"$url&logout=1\">".INS_DECONNEXION."</a></div>" ; |
} |
|
/** Renvoie vrai si l'email passé en paramètre n'est pas déjà dans l'annuaire |
* ou si, en cas de modification d'inscription, l'inscrit ne modifie pas son email |
* |
* @return boolean |
*/ |
|
function verif_doublonMail($mail) { |
if (isset ($GLOBALS['AUTH']) && $GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID) != '') { |
$requete_mail = "select ".INS_CHAMPS_MAIL." from ".INS_ANNUAIRE." where ".INS_CHAMPS_ID."=".$GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID) ; |
$resultat_mail = $GLOBALS['ins_db']->query ($requete_mail) ; |
if (DB::isError ($resultat_mail)) { |
die ("Echec de la requete : $requete_mail<br />".$resultat_mail->getMessage()) ; |
} |
$ligne_mail = $resultat_mail->fetchRow(DB_FETCHMODE_ASSOC) ; |
if ($mail == $ligne_mail[INS_CHAMPS_MAIL]) { |
return true ; |
} |
} |
$requete = "select ".INS_CHAMPS_MAIL." from ".INS_ANNUAIRE." where ".INS_CHAMPS_MAIL."= \"$mail\"" ; |
$resultat = $GLOBALS['ins_db']->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ; |
} |
if ($resultat->numRows() == 0) return true ; |
return false ; |
} |
|
|
function envoie_passe() |
{ |
global $SERVER_ADMIN ; |
|
$headers['From'] = $SERVER_ADMIN ; |
$headers['Subject'] = INS_NOUVEAU_MOT_DE_PASSE; |
|
$nouveau_passe = create_new_random(6) ; |
|
$body = INS_NOUVEAU_MOT_DE_PASSE_2.$nouveau_passe ; |
$body .= INS_NOUVEAU_MOT_DE_PASSE_LAIUS ; |
|
// modification du mot de passe dans la base |
$requete = "update ".INS_ANNUAIRE." set ".INS_CHAMPS_PASSE."=MD5(\"$nouveau_passe\") where ".INS_CHAMPS_MAIL."=\"".$GLOBALS['username']."\"" ; |
|
$resultat = $GLOBALS['db']->query($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
|
// création du mail |
if (!mail ($GLOBALS['username'], $headers['Subject'], $body)) { |
return 'erreur lors de l\'envoie de mail' ; |
} |
|
return "<div class=\"titre1_inscription\">".INS_MOT_DE_PASSE_ENVOYE_1." $username.</div>\n". |
"<div><br>".INS_MOT_DE_PASSE_ENVOYE_2."</div>\n"; |
|
} |
|
function envoie_mail() |
{ |
global $SERVER_ADMIN ; |
|
$headers['From'] = $SERVER_ADMIN ; |
$headers['To'] = "<alexandre@tela-botanica.org>" ; |
$headers['Subject'] = INS_MAIL_COORD_SUJET ; |
|
$q = "select *, ".PROJET_CHAMPS_LABEL_PAYS." from ".INS_ANNUAIRE.",".PROJET_PAYS. |
" where ".INS_CHAMPS_MAIL."=\"".$GLOBALS['HTTP_POST_VARS']['email']."\"". |
" and ".PROJET_CHAMPS_ID_PAYS."=".INS_CHAMPS_PAYS; |
|
$r = $GLOBALS['ins_db']->query($q) ; |
if (DB::isError ($r)) { |
die ("echec de la requete sur anuaire") ; |
} |
$row = $r->fetchRow(DB_FETCHMODE_ASSOC) ; |
|
|
$body_entete = INS_MAIL_COORD_CORPS."\n" ; |
$body = "mail : ".$row[INS_CHAMPS_MAIL]."\n" ; |
$body .= "------------------------------------------\n"; |
$body .= INS_NOM.": ".unhtmlentities($row[INS_CHAMPS_NOM])." \n" ; |
$body .= "Prénom : ".unhtmlentities($row[INS_CHAMPS_PRENOM])." \n" ; |
$body .= INS_PAYS." : ".unhtmlentities($row[PROJET_CHAMPS_LABEL_PAYS])." \n" ; |
$body .= "-------------------------------------------\n" ; |
|
/* |
// recherche des administrateurs |
$requete = "select ".INS_CHAMPS_MAIL." from ".INS_ANNUAIRE.", annu_ADMIN where ".INS_CHAMPS_ID. |
"=AA_USER_ID and AA_LEVEL=0"; |
$resultat = $GLOBALS['ins_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
// while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
if (!mail ($headers['To'], $headers['Subject'], $body)) { |
return "<tr><td>Une erreur s'est produite:<br></td></tr>\n" ; |
} |
//}*/ |
} |
|
// For users prior to PHP 4.3.0 you may do this: |
function unhtmlentities ($string) |
{ |
$trans_tbl = get_html_translation_table (HTML_ENTITIES); |
$trans_tbl = array_flip ($trans_tbl); |
return strtr ($string, $trans_tbl); |
} |
|
/* *********************************** |
create_new_random($n,$type) permet de générer un nombre de caractères aléatoires. |
|
ENTREE : |
- $n : créer un 'mot' de $n caractères |
- $type : permet de définir la liste des caractères disponibles |
|
SORTIE : chaine de $n caractères pris dans une liste $type |
*********************************** */ |
|
function create_new_random($n,$type="") |
{ |
$str = ""; |
|
switch ($type){ |
default:{ |
$chaine = "abcdefghkmnpqrstuvwxyzABCDEFGHKLMNPQRSTUVWXYZ23456789"; |
} |
break; |
} |
|
srand((double)microtime()*1000000); |
for($i = 0; $i < $n; $i++){ |
$str .= $chaine[rand()%strlen($chaine)]; |
} |
|
return "$str"; |
} |
|
//============================================================================== |
/** function nextId () Renvoie le prochain identifiant numérique libre d'une table |
* |
* On passe en paramètre le nom de la table et l'identifiant de la base selon PEAR DB |
* |
* @param mixed handler de connexion |
* @param string Nom de la table |
* return interger l'identifiant |
*/ |
|
function nextId ($table, $colonne_identifiant, $db) |
{ |
$requete = "select MAX($colonne_identifiant) as maxi from $table" ; |
$resultat = $GLOBALS['ins_db']->query($requete) ; |
if (DB::isError($resultat)) { |
die (__FILE__ . __LINE__ . $resultat->getMessage() . $requete); |
return $GLOBALS['ins_db']->raiseError($resultat) ; |
} |
|
if ($resultat->numRows() > 1) { |
return $GLOBALS['ins_db']->raiseError("<br/>La table $table a un identifiant non unique<br/>") ; |
} |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; |
return $ligne->maxi + 1 ; |
} |
|
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.1 2004/12/15 13:32:25 alex |
* version initiale |
* |
* Revision 1.2 2004/09/01 16:37:52 alex |
* modification du formulaire |
* |
* Revision 1.1 2004/07/06 15:42:17 alex |
* en cours |
* |
* Revision 1.7 2004/07/06 15:28:41 alex |
* en cours |
* |
* Revision 1.5 2004/07/06 15:22:19 alex |
* en cours |
* |
======= |
* Revision 1.4 2004/06/30 10:00:26 alex |
* modification de l'envoie de mail |
* |
* Revision 1.2 2004/06/23 12:41:51 alex |
* amélioration de la gestion de la perte de mot de passe |
* |
* Revision 1.1 2004/06/18 09:20:47 alex |
* version initiale |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
|
?> |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU Lesser General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | Lesser General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU Lesser General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: inscription.fonct.php,v 1.3 2005-03-21 16:57:30 florian Exp $ |
// CVS : $Id: inscription.fonct.php,v 1.3 2005-03-21 16:57:30 florian Exp $ |
/** |
* Fonctions du module inscription |
* |
* Fonctions du module inscription |
* |
*@package inscription |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.3 $ $Date: 2005-03-21 16:57:30 $ |
*@version $Revision: 1.3 $ $Date: 2005-03-21 16:57:30 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
|
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
include_once 'ins_wiki.fonct.php' ; |
if (INS_UTILISE_SPIP) include_once 'ins_spip.fonct.php' ; |
require_once 'HTML/QuickForm.php' ; |
require_once 'HTML/QuickForm/checkbox.php' ; |
require_once 'HTML/QuickForm/password.php' ; |
|
// +------------------------------------------------------------------------------------------------------+ |
// | LISTE de FONCTIONS | |
// +------------------------------------------------------------------------------------------------------+ |
|
|
/** |
* |
* @param array les valeurs renvoyés par le formulaire |
* @return |
*/ |
|
function demande_inscription($valeurs) { |
// On stocke les informations dans un variable de session |
$_SESSION['donnees_inscription'] = $valeurs ; |
|
// On envoie un email de confirmation pour l'utilisateur |
$GLOBALS['ins_url']->addQueryString('id', session_id()) ; |
mail ($GLOBALS['email'], 'inscription', $GLOBALS['ins_url']->getURL()) ; |
} |
|
/** |
* |
* |
* @return |
*/ |
|
function message_inscription() { |
return INS_MESSAGE_INSCRIPTION ; |
} |
/** |
* Réalise l'insertion dans la base de donnée |
* |
* @param array un tableau de valeur avec en clé les noms des champs du formulaire |
* @return void |
*/ |
|
function AUTH_formulaire_login() { |
//-------------------------------------------------------------------------- |
// Le formulaire |
//-------------------------------------------------------------------------- |
|
$res = '<div class="titre1_inscription"><h2>'.INS_LAIUS_INSCRIPTION.'</h2></div>'."\n" ; |
|
$res .= '<br /><div>'.INS_DEJA_INSCRIT.'</div><br />'."\n" ; |
$GLOBALS['ins_url']->removeQueryString('action') ; |
$form = new HTML_QuickForm('inscription', 'post', str_replace ('&', '&', $GLOBALS['ins_url']->getURL())) ; |
$form->addElement('text', 'username', INS_EMAIL) ; |
$form->addElement('password', 'password', INS_MOT_DE_PASSE) ; |
$form->addElement('submit', 'valider', INS_VALIDER); |
$res .= $form->toHTML()."\n" ; |
$res .= '<div>'.INS_TEXTE_PERDU.'</div><br /><br />'."\n" ; |
|
$GLOBALS['ins_url']->addQueryString('action', 'inscription') ; |
$form = new HTML_QuickForm('inscription', 'post', preg_replace ('/&/', '&', str_replace ('&', '&', $GLOBALS['ins_url']->getURL()))) ; |
$form->addElement('submit', 'Inscription', INS_INSCRIPTION) ; |
if (INS_FORMULAIRE_STRUCTURE) $form->addElement('submit', 'form_structure', INS_INSCRIPTION_STRUCTURE) ; |
$res .= "<div>".INS_LAIUS_INSCRIPTION_2."</div>\n" ; |
$res .= $form->toHTML() ; |
return $res; |
} |
|
/** |
* |
* |
* |
* |
* @return string HTML Un message d'erreur avec un lien pour renvoyer le mot de passe |
*/ |
function message_erreur () { |
$res = ''; |
// Si le mot de passe vient juste d'être envoyé, on remet le formulaire de login |
if ($GLOBALS['action'] == 'sendpasswd') { |
$form = new HTML_QuickForm ('inscription', 'post', str_replace ('&', '&', $GLOBALS['ins_url']->getURL())) ; |
$form->addElement ('text', 'username', INS_EMAIL) ; |
$form->addElement ('password', 'password', INS_MOT_DE_PASSE) ; |
$form->addElement('submit', 'valider', INS_VALIDER); |
$res .= $form->toHTML() ; |
} else { |
$res .= "<div class=\"inscription_erreur\">".INS_ERREUR_LOGIN."</div>\n" ; |
$res .= "<div>".INS_SI_PASSE_PERDU."</div>\n" ; |
$res .= "<div>" ; |
$GLOBALS['ins_url']->addQueryString('action', 'sendpasswd') ; |
$res .= "<form action=\"".str_replace ('&', '&', $GLOBALS['ins_url']->getURL())."\" method=\"post\">\n" ; |
$res .= INS_EMAIL." " ; |
$res .= "<input type=\"text\" value=\"".$GLOBALS['username']."\" name=\"username\" size=\"32\" /></li></ul>\n" ; |
$res .= "<div>".INS_INDIQUE_ADRESSE."</div>\n" ; |
$res .= "<input type=\"submit\" value=\"".INS_ENVOIE_PASSE."\" />" ; |
$res .= "</form></div>\n" ; |
} |
// On remet le formulaire d'inscription |
$GLOBALS['ins_url']->addQueryString('action', 'inscription') ; |
$form = new HTML_QuickForm ('inscription', 'post', str_replace ('&', '&', $GLOBALS['ins_url']->getURL())) ; |
$form->addElement ('submit', 'Inscription', INS_INSCRIPTION) ; |
$res .= INS_LAIUS_INSCRIPTION ; |
$res .= $form->toHTML() ; |
return $res; |
} |
|
function insertion($valeur) { |
// =========== Insertion dans l'annuaire gen_annuaire =================== |
|
$id_administrateur = nextId(INS_ANNUAIRE, INS_CHAMPS_ID, $GLOBALS['ins_db']) ; |
$requete = 'insert into '.INS_ANNUAIRE.' set '. |
INS_CHAMPS_ID.'="'.$id_administrateur.'",'. |
requete_annuaire($valeur) ; |
|
$resultat = $GLOBALS['ins_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
|
// ================ Insertion dans SPIP ========================================= |
if (INS_UTILISE_SPIP) { |
inscription_spip($id_administrateur, $valeur) ; |
} |
//inscription_interwikini_users() ; |
|
} |
|
/** |
* Réalise une mise à jour dans la base de donnée |
* |
* @param array un tableau de valeur avec en clé les noms des champs du formulaire |
* @return void |
*/ |
function mise_a_jour($valeur) { |
// ====================Mise à jour dans l'annuaire gen_annuaire ==================== |
$requete = 'update '.INS_ANNUAIRE.' set '. |
requete_annuaire ($valeur). |
'where '.INS_CHAMPS_ID.'="'.$GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID).'"'; |
$resultat = $GLOBALS['ins_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
unset ($resultat) ; |
|
// ========================= Mise à jour dans SPIP ================================ |
if (INS_UTILISE_SPIP) { |
mod_inscription_spip($GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID), $valeur) ; |
} |
} |
|
/** requete_annuaire () - Renvoie une chaine contenant les champs de l'annuaire avec leur valeur suite à le fonction process de QuickForm |
* |
* @return string une requete du type champs="valeur",... |
*/ |
|
function requete_annuaire($valeur) { |
$req = INS_CHAMPS_NOM.'="'.$valeur['nom'].'",'. |
INS_CHAMPS_PRENOM.'="'.$valeur['prenom'].'",'. |
INS_CHAMPS_MAIL.'="'.$valeur['email'].'",' ; |
if (INS_UTILISE_WIKINI) $req .= INS_CHAMPS_NOM_WIKINI.'="'.$valeur['nomwiki'].'",' ; |
$req .= INS_CHAMPS_PASSE.'="'.md5 ($valeur['mot_de_passe']).'",'. |
INS_CHAMPS_PAYS.'="'.$valeur['pays'].'",'. |
INS_CHAMPS_ADRESSE_1.'="'.$valeur['adresse_1'].'",'. |
INS_CHAMPS_ADRESSE_2.'="'.$valeur['adresse_2'].'",'. |
INS_CHAMPS_DATE_INSCRIPTION.'=NOW(),'. |
INS_CHAMPS_CODE_POSTAL.'="'.$valeur['cp'].'" ' ; |
if (INS_FORMULAIRE_STRUCTURE) { |
$req .= ",".INS_CHAMPS_EST_STRUCTURE.'="'.$valeur['est_structure'].'"' ; |
$req .= ",".INS_CHAMPS_SIGLE_STRUCTURE.'="'.$valeur['sigle_structure'].'"' ; |
} |
|
// traitement du numéro de département pour la france |
if (isset($valeur[INS_CHAMPS_PAYS])) { |
if ($valeur[INS_CHAMPS_PAYS] == 'FR') { |
if (preg_match("/^97|98[0-9]*/", $valeur['cp'])) { |
$n_dpt = substr($valeur['cp'], 0, 3) ; |
} else { |
$n_dpt = substr($valeur['cp'], 0, 2) ; |
} |
$req .= ",".INS_CHAMPS_DEPARTEMENT."='$n_dpt'"; |
}} |
// Le téléphone et le fax |
if (INS_CHAMPS_TELEPHONE) { |
$req .= ",".INS_CHAMPS_TELEPHONE.'="'.$valeur['telephone'].'"' ; |
} |
if (INS_CHAMPS_FAX) { |
$req .= ",".INS_CHAMPS_FAX.'="'.$valeur['fax'].'"' ; |
} |
if (INS_CHAMPS_STRUCTURE) { |
$req .= ",".INS_CHAMPS_STRUCTURE.'="'.$valeur['structure'].'"' ; |
} |
return $req ; |
} |
|
|
|
/** formulaire_defaults () - Renvoie un tableau avec les valeurs par défaut du formulaire d'inscription |
* |
* @return array Valeurs par défaut du formulaire d'inscription |
*/ |
function formulaire_defaults () { |
$requete = 'select '.INS_ANNUAIRE.'.* '. |
'from '.INS_ANNUAIRE.' '. |
'where '.INS_ANNUAIRE.'.'.INS_CHAMPS_ID.'= "'.$GLOBALS['AUTH']->getAuthData (INS_CHAMPS_ID).'"' ; |
$resultat = $GLOBALS['ins_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ; |
$valeurs_par_defaut = array() ; |
$valeurs_par_defaut['email'] = $ligne[INS_CHAMPS_MAIL]; |
$valeurs_par_defaut['nom'] = $ligne[INS_CHAMPS_NOM]; |
$valeurs_par_defaut['prenom'] = $ligne[INS_CHAMPS_PRENOM] ; |
$valeurs_par_defaut['pays'] = $ligne[INS_CHAMPS_PAYS] ; |
if (INS_UTILISE_WIKINI) {$valeurs_par_defaut['nomwiki'] = $ligne[INS_CHAMPS_NOM_WIKINI] ;} |
$valeurs_par_defaut['cp'] = $ligne[INS_CHAMPS_CODE_POSTAL] ; |
$valeurs_par_defaut['ville'] = $ligne[INS_CHAMPS_VILLE] ; |
$valeurs_par_defaut['adresse_1'] = $ligne[INS_CHAMPS_ADRESSE_1] ; |
$valeurs_par_defaut['adresse_2'] = $ligne[INS_CHAMPS_ADRESSE_2] ; |
$valeurs_par_defaut['telephone'] = $ligne[INS_CHAMPS_TELEPHONE] ; |
$valeurs_par_defaut['fax'] = $ligne[INS_CHAMPS_FAX] ; |
$valeurs_par_defaut['structure'] = $ligne[INS_CHAMPS_STRUCTURE] ; |
|
return $valeurs_par_defaut ; |
} |
|
|
|
function info() { |
$requete = 'select * from '.INS_ANNUAIRE.' '. |
'where '.INS_ANNUAIRE.'.'.INS_CHAMPS_ID.'="'.$GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID).'"' ; |
|
$resultat = $GLOBALS['ins_db'] -> query ($requete) ; |
if (DB::isError ($resultat)) { |
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ; |
} |
|
$ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC) ; |
$res = "<br /><h2 class=\"inscription_titre1\">".INS_MESSAGE_BIENVENU ; |
$res .= "</h2><br />\n" ; |
$res .= "<h3 class=\"inscription_titre2\">".INS_FICHE_PERSONNELLE."</h3><br />\n" ; |
$res .= "<div>".INS_EMAIL." : ".$ligne[INS_CHAMPS_MAIL]."</div>\n" ; |
if ($ligne[INS_CHAMPS_EST_STRUCTURE] == 1) $nom = INS_NOM_STRUCTURE ; else $nom = INS_NOM ; |
$res .= "<div>".$nom." : ".$ligne[INS_CHAMPS_NOM]."</div>" ; |
if ($ligne[INS_CHAMPS_EST_STRUCTURE] == 0) $res .= "<div>".INS_PRENOM." : ".$ligne[INS_CHAMPS_PRENOM]."</div>\n" ; |
if (INS_UTILISE_WIKINI) {if ($ligne[INS_CHAMPS_NOM_WIKINI] != "") $res .= "<div>".INS_NOM_WIKI." : ".$ligne[INS_CHAMPS_NOM_WIKINI]."</div>\n" ;} |
if ($ligne[INS_CHAMPS_ADRESSE_1] != "") $res .= "<div>".INS_ADRESSE1." : ".$ligne[INS_CHAMPS_ADRESSE_1]."</div>\n" ; |
if ($ligne[INS_CHAMPS_ADRESSE_2] != "") $res .= "<div>".INS_ADRESSE2." : ".$ligne[INS_CHAMPS_ADRESSE_2]."</div>\n" ; |
if ($ligne[INS_CHAMPS_TELEPHONE] != "") $res .= "<div>".INS_TEL." : ".$ligne[INS_CHAMPS_TELEPHONE]."</div>\n" ; |
if ($ligne[INS_CHAMPS_FAX] != "") $res .= "<div>".INS_FAX." : ".$ligne[INS_CHAMPS_FAX]."</div>\n" ; |
if ($ligne[INS_CHAMPS_STRUCTURE] != "") $res .= "<div>".INS_STRUCTURE." : ".$ligne[INS_CHAMPS_STRUCTURE]."</div>\n" ; |
|
return $res ; |
} |
|
function bouton($url) { |
global $GS_GLOBAL ; |
$boutons = new HTML_QuickForm('inscription', 'post', $url) ; ; |
//confirmation() ; |
$buttons[] = &HTML_QuickForm::createElement('submit', 'modifier', INS_MODIFIER_INSCRIPTION); |
$buttons[] = &HTML_QuickForm::createElement('submit', 'supprimer', INS_SUPPRIMER_INSCRIPTION, |
array ("onclick" => "javascript:return confirm('".INS_SUPPRIMER_INSCRIPTION." ?');")); |
$boutons->addGroup($buttons, null, null, ' '); |
return $boutons->toHTML() ; |
} |
|
/** |
* Renvoie un lien pour se déconnex=cter |
* |
* @return string |
*/ |
|
function deconnexion ($url) { |
// Un champs logout |
return "<div><a href=\"".$url."&logout=1\">".INS_DECONNEXION."</a></div>" ; |
} |
|
/** Renvoie vrai si l'email passé en paramètre n'est pas déjà dans l'annuaire |
* ou si, en cas de modification d'inscription, l'inscrit ne modifie pas son email |
* |
* @return boolean |
*/ |
|
function verif_doublonMail($mail) { |
if (isset ($GLOBALS['AUTH']) && $GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID) != '') { |
$requete_mail = "select ".INS_CHAMPS_MAIL." from ".INS_ANNUAIRE." where ".INS_CHAMPS_ID."=".$GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID) ; |
$resultat_mail = $GLOBALS['ins_db']->query ($requete_mail) ; |
if (DB::isError ($resultat_mail)) { |
die ("Echec de la requete : $requete_mail<br />".$resultat_mail->getMessage()) ; |
} |
$ligne_mail = $resultat_mail->fetchRow(DB_FETCHMODE_ASSOC) ; |
if ($mail == $ligne_mail[INS_CHAMPS_MAIL]) { |
return true ; |
} |
} |
$requete = "select ".INS_CHAMPS_MAIL." from ".INS_ANNUAIRE." where ".INS_CHAMPS_MAIL."= \"$mail\"" ; |
$resultat = $GLOBALS['ins_db']->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ; |
} |
if ($resultat->numRows() == 0) return true ; |
return false ; |
} |
|
|
function envoie_passe() |
{ |
global $SERVER_ADMIN ; |
|
$headers['From'] = $SERVER_ADMIN ; |
$headers['Subject'] = INS_NOUVEAU_MOT_DE_PASSE; |
|
$nouveau_passe = create_new_random(6) ; |
|
$body = INS_NOUVEAU_MOT_DE_PASSE_2.$nouveau_passe ; |
$body .= INS_NOUVEAU_MOT_DE_PASSE_LAIUS ; |
|
// modification du mot de passe dans la base |
$requete = "update ".INS_ANNUAIRE." set ".INS_CHAMPS_PASSE."=MD5(\"$nouveau_passe\") where ".INS_CHAMPS_MAIL."=\"".$GLOBALS['username']."\"" ; |
|
$resultat = $GLOBALS['db']->query($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
|
// création du mail |
if (!mail ($GLOBALS['username'], $headers['Subject'], $body)) { |
return 'erreur lors de l\'envoie de mail' ; |
} |
|
return "<div class=\"titre1_inscription\">".INS_MOT_DE_PASSE_ENVOYE_1." $username.</div>\n". |
"<div><br>".INS_MOT_DE_PASSE_ENVOYE_2."</div>\n"; |
|
} |
|
function envoie_mail() |
{ |
global $SERVER_ADMIN ; |
|
$headers['From'] = $SERVER_ADMIN ; |
$headers['To'] = INS_MAIL_ADMIN_APRES_INSCRIPTION ; |
$headers['Subject'] = INS_MAIL_COORD_SUJET ; |
|
$q = "select *, ".PROJET_CHAMPS_LABEL_PAYS." from ".INS_ANNUAIRE.",".PROJET_PAYS. |
" where ".INS_CHAMPS_MAIL."=\"".$GLOBALS['HTTP_POST_VARS']['email']."\"". |
" and ".PROJET_CHAMPS_ID_PAYS."=".INS_CHAMPS_PAYS; |
|
$r = $GLOBALS['ins_db']->query($q) ; |
if (DB::isError ($r)) { |
die ("echec de la requete sur anuaire") ; |
} |
$row = $r->fetchRow(DB_FETCHMODE_ASSOC) ; |
|
|
$body_entete = INS_MAIL_COORD_CORPS."\n" ; |
$body = "mail : ".$row[INS_CHAMPS_MAIL]."\n" ; |
$body .= "------------------------------------------\n"; |
$body .= INS_NOM.": ".unhtmlentities($row[INS_CHAMPS_NOM])." \n" ; |
$body .= "Prénom : ".unhtmlentities($row[INS_CHAMPS_PRENOM])." \n" ; |
$body .= INS_PAYS." : ".unhtmlentities($row[PROJET_CHAMPS_LABEL_PAYS])." \n" ; |
$body .= "-------------------------------------------\n" ; |
|
/* |
// recherche des administrateurs |
$requete = "select ".INS_CHAMPS_MAIL." from ".INS_ANNUAIRE.", annu_ADMIN where ".INS_CHAMPS_ID. |
"=AA_USER_ID and AA_LEVEL=0"; |
$resultat = $GLOBALS['ins_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
// while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
if (!mail ($headers['To'], $headers['Subject'], $body)) { |
return "<tr><td>Une erreur s'est produite:<br></td></tr>\n" ; |
} |
//}*/ |
} |
|
// For users prior to PHP 4.3.0 you may do this: |
function unhtmlentities ($string) |
{ |
$trans_tbl = get_html_translation_table (HTML_ENTITIES); |
$trans_tbl = array_flip ($trans_tbl); |
return strtr ($string, $trans_tbl); |
} |
|
//============================================================================== |
/** function create_new_random($n,$type) permet de générer un nombre de caractères aléatoires. |
* |
* |
* |
* ENTREE : |
* - $n : créer un 'mot' de $n caractères |
* - $type : permet de définir la liste des caractères disponibles |
* |
* SORTIE : chaine de $n caractères pris dans une liste $type |
*/ |
|
function create_new_random($n,$type="") |
{ |
$str = ""; |
|
switch ($type){ |
default:{ |
$chaine = "abcdefghkmnpqrstuvwxyzABCDEFGHKLMNPQRSTUVWXYZ23456789"; |
} |
break; |
} |
|
srand((double)microtime()*1000000); |
for($i = 0; $i < $n; $i++){ |
$str .= $chaine[rand()%strlen($chaine)]; |
} |
|
return "$str"; |
} |
|
//============================================================================== |
/** function nextId () Renvoie le prochain identifiant numérique libre d'une table |
* |
* On passe en paramètre le nom de la table et l'identifiant de la base selon PEAR DB |
* |
* @param mixed handler de connexion |
* @param string Nom de la table |
* return interger l'identifiant |
*/ |
|
function nextId ($table, $colonne_identifiant) |
{ |
$requete = 'select MAX('.$colonne_identifiant.') as maxi from '.$table ; |
$resultat = $GLOBALS['ins_db']->query($requete) ; |
if (DB::isError($resultat)) { |
die (__FILE__ . __LINE__ . $resultat->getMessage() . $requete); |
return $GLOBALS['ins_db']->raiseError($resultat) ; |
} |
|
if ($resultat->numRows() > 1) { |
return $GLOBALS['ins_db']->raiseError("<br/>La table $table a un identifiant non unique<br/>") ; |
} |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; |
return $ligne->maxi + 1 ; |
} |
|
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.2 2004/12/17 17:41:51 alex |
* ajout du numéro de tel, du fax et de la structure |
* |
* Revision 1.1 2004/12/15 13:32:25 alex |
* version initiale |
* |
* Revision 1.2 2004/09/01 16:37:52 alex |
* modification du formulaire |
* |
* Revision 1.1 2004/07/06 15:42:17 alex |
* en cours |
* |
* Revision 1.7 2004/07/06 15:28:41 alex |
* en cours |
* |
* Revision 1.5 2004/07/06 15:22:19 alex |
* en cours |
* |
======= |
* Revision 1.4 2004/06/30 10:00:26 alex |
* modification de l'envoie de mail |
* |
* Revision 1.2 2004/06/23 12:41:51 alex |
* amélioration de la gestion de la perte de mot de passe |
* |
* Revision 1.1 2004/06/18 09:20:47 alex |
* version initiale |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
|
?> |