1 | <?php |
---|
2 | |
---|
3 | /***************************************************************************\ |
---|
4 | * SPIP, Systeme de publication pour l'internet * |
---|
5 | * * |
---|
6 | * Copyright (c) 2001-2009 * |
---|
7 | * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * |
---|
8 | * * |
---|
9 | * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * |
---|
10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
---|
11 | \***************************************************************************/ |
---|
12 | |
---|
13 | if (!defined("_ECRIRE_INC_VERSION")) return; |
---|
14 | |
---|
15 | function formulaires_ajout_inscription_charger_dist() { |
---|
16 | $valeurs = array('nom_adherent_inscription'=>'', 'prenom_inscription'=>'', |
---|
17 | 'adresse_postale_inscription'=>'', 'cp_inscription'=>'1070', |
---|
18 | 'localite_inscription'=>'Anderlecht', 'no_adherent_inscription'=>'', |
---|
19 | 'statut_adherent_inscription'=>'S', 'cotisation_inscription'=>'', |
---|
20 | 'sexe_inscription'=>'', 'tel_inscription'=>'', 'gsm_inscription'=>'', 'email_inscription'=>''); |
---|
21 | |
---|
22 | return $valeurs; |
---|
23 | } |
---|
24 | |
---|
25 | |
---|
26 | function formulaires_ajout_inscription_verifier_dist() { |
---|
27 | |
---|
28 | $erreurs = array(); |
---|
29 | include_spip('inc/filtres'); |
---|
30 | |
---|
31 | if (!$nom = _request('nom_adherent_inscription')) |
---|
32 | $erreurs['nom_adherent_inscription'] = _T("info_obligatoire"); |
---|
33 | |
---|
34 | return $erreurs; |
---|
35 | |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | function formulaires_ajout_inscription_traiter_dist() { |
---|
40 | |
---|
41 | $res = array('message_erreur'=>_T('titre_probleme_technique')); |
---|
42 | |
---|
43 | $nom_adherent = _request('nom_adherent_inscription'); |
---|
44 | $prenom = _request('prenom_inscription'); |
---|
45 | $adresse_postale = _request('adresse_postale_inscription'); |
---|
46 | $code_postal = _request('cp_inscription'); |
---|
47 | $localite = _request('localite_inscription'); |
---|
48 | $no_fichier = _request ('no_adherent_inscription'); |
---|
49 | $statut_adherent = _request ('statut_adherent_inscription'); |
---|
50 | $cotisation = _request ('cotisation_inscription'); |
---|
51 | $sexe = _request ('sexe_inscription'); |
---|
52 | $tel = _request ('tel_inscription'); |
---|
53 | $gsm = _request ('gsm_inscription'); |
---|
54 | $email = _request ('email_inscription'); |
---|
55 | $pseudo = $prenom .' '. $nom_adherent; |
---|
56 | $login = test_login($pseudo, $email); |
---|
57 | |
---|
58 | if ($statut_adherent =="M") $statut="1comite"; else $statut="6forum"; |
---|
59 | |
---|
60 | |
---|
61 | include_spip('base/abstract_sql'); |
---|
62 | |
---|
63 | if ($id_auteur = sql_insertq('spip_auteurs', array( |
---|
64 | 'nom' => $pseudo, |
---|
65 | 'statut' => $statut, |
---|
66 | 'email' => $email, |
---|
67 | 'login' => $login |
---|
68 | ))) { $res = array('message_ok' => "auteur OK", 'id_auteur'=>$id_auteur); |
---|
69 | $pass = creer_pass_pour_auteur($id_auteur); |
---|
70 | |
---|
71 | if ($id_fichier = sql_insertq('fichiers', array( |
---|
72 | |
---|
73 | 'id_auteur' => sql_getfetsel('id_auteur','spip_auteurs','nom='.sql_quote($pseudo)), |
---|
74 | 'nom_adherent' => $nom_adherent, |
---|
75 | 'prenom' => $prenom, |
---|
76 | 'adresse_postale' => $adresse_postale, |
---|
77 | 'code_postal' => $code_postal, |
---|
78 | 'localite' => $localite, |
---|
79 | 'no_fichier' => $no_fichier, |
---|
80 | 'statut_adherent' => $statut_adherent, |
---|
81 | 'cotisation' => $cotisation, |
---|
82 | 'sexe' => $sexe, |
---|
83 | 'telephone' => $tel, |
---|
84 | 'gsm' => $gsm |
---|
85 | ))) |
---|
86 | $res = array('message_ok' => "Enregistrement fichier OK", 'id_fichier'=>$id_fichier);} |
---|
87 | |
---|
88 | return $res; |
---|
89 | } |
---|
90 | |
---|
91 | // http://doc.spip.org/@test_login |
---|
92 | function test_login($nom, $mail) { |
---|
93 | include_spip('inc/charsets'); |
---|
94 | $nom = strtolower(translitteration($nom)); |
---|
95 | $login_base = preg_replace("/[^\w\d_]/", "_", $nom); |
---|
96 | |
---|
97 | // il faut eviter que le login soit vraiment trop court |
---|
98 | if (strlen($login_base) < 3) { |
---|
99 | $mail = strtolower(translitteration(preg_replace('/@.*/', '', $mail))); |
---|
100 | $login_base = preg_replace("/[^\w\d]/", "_", $nom); |
---|
101 | } |
---|
102 | if (strlen($login_base) < 3) |
---|
103 | $login_base = 'user'; |
---|
104 | |
---|
105 | // eviter aussi qu'il soit trop long (essayer d'attraper le prenom) |
---|
106 | if (strlen($login_base) > 10) { |
---|
107 | $login_base = preg_replace("/^(.{4,}(_.{1,7})?)_.*/", |
---|
108 | '\1', $login_base); |
---|
109 | $login_base = substr($login_base, 0,13); |
---|
110 | } |
---|
111 | |
---|
112 | $login = $login_base; |
---|
113 | |
---|
114 | for ($i = 1; ; $i++) { |
---|
115 | if (!sql_countsel('spip_auteurs', "login='$login'")) |
---|
116 | return $login; |
---|
117 | $login = $login_base.$i; |
---|
118 | } |
---|
119 | } |
---|
120 | |
---|
121 | // http://doc.spip.org/@creer_pass_pour_auteur |
---|
122 | function creer_pass_pour_auteur($id_auteur) { |
---|
123 | include_spip('inc/acces'); |
---|
124 | $pass = creer_pass_aleatoire(8, $id_auteur); |
---|
125 | $mdpass = md5($pass); |
---|
126 | $htpass = generer_htpass($pass); |
---|
127 | sql_updateq('spip_auteurs', array('pass'=>$mdpass, 'htpass'=>$htpass),"id_auteur = ".intval($id_auteur)); |
---|
128 | ecrire_acces(); |
---|
129 | |
---|
130 | return $pass; |
---|
131 | } |
---|
132 | |
---|
133 | |
---|
134 | ?> |
---|