1 | <?php |
---|
2 | |
---|
3 | function FluxBB_Linkuser($pwg_id, $bb_id) |
---|
4 | { |
---|
5 | include_once (PHPWG_ROOT_PATH.'/include/constants.php'); |
---|
6 | include_once (Register_FluxBB_PATH.'include/constants.php'); |
---|
7 | |
---|
8 | $query = " |
---|
9 | SELECT pwg.id as pwg_id, bb.id as bb_id |
---|
10 | FROM ".USERS_TABLE." pwg, ".FluxBB_USERS_TABLE." bb |
---|
11 | WHERE pwg.id = ".$pwg_id." |
---|
12 | AND bb.id = ".$bb_id." |
---|
13 | AND pwg.username = bb.username |
---|
14 | ;"; |
---|
15 | |
---|
16 | $data = mysql_fetch_array(pwg_query($query)); |
---|
17 | |
---|
18 | if (!empty($data)) |
---|
19 | { |
---|
20 | $subquery = " |
---|
21 | DELETE FROM ".Register_FluxBB_ID_TABLE." |
---|
22 | WHERE id_user_pwg = '".$pwg_id."' |
---|
23 | OR id_user_FluxBB = '".$bb_id."' |
---|
24 | ;"; |
---|
25 | |
---|
26 | $subresult = pwg_query($subquery); |
---|
27 | |
---|
28 | $subquery = " |
---|
29 | INSERT INTO ".Register_FluxBB_ID_TABLE." |
---|
30 | (id_user_pwg, id_user_FluxBB) |
---|
31 | VALUES (".$pwg_id.", ".$bb_id.") |
---|
32 | ;"; |
---|
33 | |
---|
34 | $subresult = pwg_query($subquery); |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | |
---|
40 | function FluxBB_Unlinkuser($bb_id) |
---|
41 | { |
---|
42 | include_once (PHPWG_ROOT_PATH.'/include/constants.php'); |
---|
43 | include_once (Register_FluxBB_PATH.'include/constants.php'); |
---|
44 | |
---|
45 | $query = " |
---|
46 | DELETE FROM ".Register_FluxBB_ID_TABLE." |
---|
47 | WHERE id_user_FluxBB = ".$bb_id." |
---|
48 | ;"; |
---|
49 | |
---|
50 | $result = pwg_query($query); |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | |
---|
55 | function FluxBB_Adduser($pwg_id, $login, $password, $adresse_mail) |
---|
56 | { |
---|
57 | include_once (PHPWG_ROOT_PATH.'/include/constants.php'); |
---|
58 | include_once (Register_FluxBB_PATH.'include/constants.php'); |
---|
59 | |
---|
60 | global $conf; |
---|
61 | |
---|
62 | $conf_Register_FluxBB = isset($conf['Register_FluxBB']) ? explode(";" , $conf['Register_FluxBB']) : array(); |
---|
63 | |
---|
64 | $registred = time(); |
---|
65 | $registred_ip = $_SERVER['REMOTE_ADDR']; |
---|
66 | |
---|
67 | $query = " |
---|
68 | SELECT conf_value |
---|
69 | FROM ".FluxBB_CONFIG_TABLE." |
---|
70 | WHERE conf_name = 'o_default_user_group' |
---|
71 | ;"; |
---|
72 | |
---|
73 | $o_default_user_group = mysql_fetch_array(pwg_query($query)); |
---|
74 | |
---|
75 | $query = " |
---|
76 | SELECT conf_value |
---|
77 | FROM ".FluxBB_CONFIG_TABLE." |
---|
78 | WHERE conf_name = 'o_server_timezone' |
---|
79 | ;"; |
---|
80 | |
---|
81 | $o_server_timezone = mysql_fetch_array(pwg_query($query)); |
---|
82 | |
---|
83 | $query = " |
---|
84 | SELECT conf_value |
---|
85 | FROM ".FluxBB_CONFIG_TABLE." |
---|
86 | WHERE conf_name = 'o_default_lang' |
---|
87 | ;"; |
---|
88 | |
---|
89 | $o_default_lang = mysql_fetch_array(pwg_query($query)); |
---|
90 | |
---|
91 | $query = " |
---|
92 | SELECT conf_value |
---|
93 | FROM ".FluxBB_CONFIG_TABLE." |
---|
94 | WHERE conf_name = 'o_default_style' |
---|
95 | ;"; |
---|
96 | |
---|
97 | $o_default_style = mysql_fetch_array(pwg_query($query)); |
---|
98 | |
---|
99 | $query = ' |
---|
100 | INSERT INTO '.FluxBB_USERS_TABLE." ( |
---|
101 | username, |
---|
102 | ". ( isset($o_default_user_group['conf_value']) ? 'group_id' : '' ) .", |
---|
103 | password, |
---|
104 | email, |
---|
105 | ". ( isset($o_server_timezone['conf_value']) ? 'timezone' : '' ) .", |
---|
106 | ". ( isset($o_default_lang['conf_value']) ? 'language' : '' ) .", |
---|
107 | ". ( isset($o_default_style['conf_value']) ? 'style' : '' ) .", |
---|
108 | registered, |
---|
109 | registration_ip, |
---|
110 | last_visit |
---|
111 | ) |
---|
112 | VALUES( |
---|
113 | '".mysql_real_escape_string($login)."', |
---|
114 | ". ( isset($o_default_user_group['conf_value']) ? "'".$o_default_user_group['conf_value']."'" : '' ) .", |
---|
115 | '".$password."', |
---|
116 | '".$adresse_mail."', |
---|
117 | ". ( isset($o_server_timezone['conf_value']) ? "'".$o_server_timezone['conf_value']."'" : '' ) .", |
---|
118 | ". ( isset($o_default_lang['conf_value']) ? "'".$o_default_lang['conf_value']."'" : '' ) .", |
---|
119 | ". ( isset($o_default_style['conf_value']) ? "'".$o_default_style['conf_value']."'" : '' ) .", |
---|
120 | '".$registred."', |
---|
121 | '".$registred_ip."', |
---|
122 | '".$registred."' |
---|
123 | ) |
---|
124 | ;"; |
---|
125 | |
---|
126 | $result = pwg_query($query); |
---|
127 | |
---|
128 | $bb_id = mysql_insert_id(); |
---|
129 | |
---|
130 | FluxBB_Linkuser($pwg_id, $bb_id); |
---|
131 | } |
---|
132 | |
---|
133 | |
---|
134 | |
---|
135 | function FluxBB_Searchuser($id_user_pwg) |
---|
136 | { |
---|
137 | include_once (PHPWG_ROOT_PATH.'/include/constants.php'); |
---|
138 | include_once (Register_FluxBB_PATH.'include/constants.php'); |
---|
139 | |
---|
140 | $query = " |
---|
141 | SELECT id_user_FluxBB, id_user_pwg FROM ".Register_FluxBB_ID_TABLE." |
---|
142 | WHERE id_user_pwg = ".$id_user_pwg." |
---|
143 | LIMIT 1 |
---|
144 | ;"; |
---|
145 | |
---|
146 | $data = mysql_fetch_array(pwg_query($query)); |
---|
147 | |
---|
148 | if (!empty($data)) |
---|
149 | return $data['id_user_FluxBB']; |
---|
150 | else |
---|
151 | return '0'; |
---|
152 | } |
---|
153 | |
---|
154 | |
---|
155 | |
---|
156 | function FluxBB_Deluser($id_user_FluxBB, $SuppTopicsPosts) |
---|
157 | { |
---|
158 | include_once (PHPWG_ROOT_PATH.'/include/constants.php'); |
---|
159 | include_once (Register_FluxBB_PATH.'include/constants.php'); |
---|
160 | |
---|
161 | global $conf; |
---|
162 | |
---|
163 | $conf_Register_FluxBB = isset($conf['Register_FluxBB']) ? explode(";" , $conf['Register_FluxBB']) : array(); |
---|
164 | |
---|
165 | $query0 = " |
---|
166 | SELECT username, id FROM ".FluxBB_USERS_TABLE." |
---|
167 | WHERE id = ".$id_user_FluxBB." |
---|
168 | LIMIT 1 |
---|
169 | ;"; |
---|
170 | |
---|
171 | $data0 = mysql_fetch_array(pwg_query($query0)); |
---|
172 | |
---|
173 | // Si égale à VRAI, suppression de tous les posts et topics |
---|
174 | if ($SuppTopicsPosts and $conf_Register_FluxBB[3]) |
---|
175 | { |
---|
176 | // Suppression des posts de cet utilisateur |
---|
177 | $subquery = " |
---|
178 | DELETE FROM ".FluxBB_POSTS_TABLE." |
---|
179 | WHERE poster_id = ".$id_user_FluxBB." |
---|
180 | ;"; |
---|
181 | |
---|
182 | $subresult = pwg_query($subquery); |
---|
183 | |
---|
184 | // Suppression des topics de cet utilisateur |
---|
185 | $subquery = " |
---|
186 | DELETE FROM ".FluxBB_TOPICS_TABLE." |
---|
187 | WHERE BINARY poster = BINARY '".mysql_real_escape_string($data0['username'])."' |
---|
188 | ;"; |
---|
189 | |
---|
190 | $subresult = pwg_query($subquery); |
---|
191 | } |
---|
192 | |
---|
193 | // Suppression des abonnements de l'utilisateur |
---|
194 | $subquery = " |
---|
195 | DELETE FROM ".FluxBB_SUBSCRIPTIONS_TABLE." |
---|
196 | WHERE user_id = ".$id_user_FluxBB." |
---|
197 | ;"; |
---|
198 | |
---|
199 | $subresult = pwg_query($subquery); |
---|
200 | |
---|
201 | // Suppression du compte utilisateur |
---|
202 | $subquery = " |
---|
203 | DELETE FROM ".FluxBB_USERS_TABLE." |
---|
204 | WHERE id = ".$id_user_FluxBB." |
---|
205 | ;"; |
---|
206 | |
---|
207 | $subresult = pwg_query($subquery); |
---|
208 | |
---|
209 | FluxBB_Unlinkuser($id_user_FluxBB); |
---|
210 | } |
---|
211 | |
---|
212 | |
---|
213 | |
---|
214 | function FluxBB_Updateuser($pwg_id, $username, $password, $adresse_mail) |
---|
215 | { |
---|
216 | include_once (PHPWG_ROOT_PATH.'/include/constants.php'); |
---|
217 | include_once (Register_FluxBB_PATH.'include/constants.php'); |
---|
218 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
219 | |
---|
220 | $query = " |
---|
221 | SELECT id_user_FluxBB as FluxBB_id |
---|
222 | FROM ".Register_FluxBB_ID_TABLE." |
---|
223 | WHERE id_user_pwg = ".$pwg_id." |
---|
224 | ;"; |
---|
225 | |
---|
226 | $row = mysql_fetch_array(pwg_query($query)); |
---|
227 | |
---|
228 | if (!empty($row)) |
---|
229 | { |
---|
230 | $query = " |
---|
231 | UPDATE ".FluxBB_USERS_TABLE." |
---|
232 | SET username = '".mysql_real_escape_string($username)."', email = '".$adresse_mail."', password = '".$password."' |
---|
233 | WHERE id = ".$row['FluxBB_id']." |
---|
234 | ;"; |
---|
235 | |
---|
236 | $result = pwg_query($query); |
---|
237 | |
---|
238 | FluxBB_Linkuser($pwg_id, $row['FluxBB_id']); |
---|
239 | } |
---|
240 | else |
---|
241 | { |
---|
242 | $query = " |
---|
243 | SELECT id as FluxBB_id |
---|
244 | FROM ".FluxBB_USERS_TABLE." |
---|
245 | WHERE BINARY username = BINARY '".mysql_real_escape_string($username)."' |
---|
246 | ;"; |
---|
247 | |
---|
248 | $row = mysql_fetch_array(pwg_query($query)); |
---|
249 | |
---|
250 | if (!empty($row)) |
---|
251 | { |
---|
252 | $query = " |
---|
253 | UPDATE ".FluxBB_USERS_TABLE." |
---|
254 | SET username = '".mysql_real_escape_string($username)."', email = '".$adresse_mail."', password = '".$password."' |
---|
255 | WHERE id = ".$row['FluxBB_id']." |
---|
256 | ;"; |
---|
257 | |
---|
258 | $result = pwg_query($query); |
---|
259 | |
---|
260 | FluxBB_Linkuser($pwg_id, $row['FluxBB_id']); |
---|
261 | } |
---|
262 | } |
---|
263 | } |
---|
264 | ?> |
---|