1 | <?php |
---|
2 | |
---|
3 | include_once (PHPWG_ROOT_PATH.'/include/constants.php'); |
---|
4 | include_once (REGFLUXBB_PATH.'include/constants.php'); |
---|
5 | |
---|
6 | |
---|
7 | function Audit_PWG_FluxBB() |
---|
8 | { |
---|
9 | global $page, $conf, $errors; |
---|
10 | |
---|
11 | $page_Register_FluxBB_admin = get_admin_plugin_menu_link(__FILE__); |
---|
12 | |
---|
13 | $conf_Register_FluxBB = unserialize($conf['Register_FluxBB']); |
---|
14 | |
---|
15 | $msg_error_PWG_Dup = ''; |
---|
16 | $msg_error_FluxBB_Dup = ''; |
---|
17 | $msg_error_Link_Break = ''; |
---|
18 | $msg_error_Link_Bad = ''; |
---|
19 | $msg_error_Synchro = ''; |
---|
20 | $msg_ok_Synchro = ''; |
---|
21 | $msg_error_PWG2FluxBB = ''; |
---|
22 | $msg_error_FluxBB2PWG = ''; |
---|
23 | |
---|
24 | $query = ' |
---|
25 | SELECT COUNT(*) AS nbr_dup, id, username |
---|
26 | FROM '.USERS_TABLE.' |
---|
27 | WHERE username NOT IN ("18","16") |
---|
28 | GROUP BY BINARY username |
---|
29 | HAVING COUNT(*) > 1 |
---|
30 | ;'; |
---|
31 | $result = pwg_query($query); |
---|
32 | |
---|
33 | while($row = pwg_db_fetch_assoc($result)) |
---|
34 | $msg_error_PWG_Dup .= '<br>'.l10n('Error_PWG_Dup').$row['nbr_dup'].' x '.stripslashes($row['username']); |
---|
35 | |
---|
36 | if ($msg_error_PWG_Dup == '') |
---|
37 | array_push($page['infos'], l10n('Audit_PWG_Dup').'<br>'.l10n('Audit_OK')); |
---|
38 | else |
---|
39 | $msg_error_PWG_Dup = l10n('Audit_PWG_Dup').$msg_error_PWG_Dup.'<br>'.l10n('Advise_PWG_Dup'); |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | $query = ' |
---|
44 | SELECT COUNT(*) AS nbr_dup, username |
---|
45 | FROM '.FluxBB_USERS_TABLE.' |
---|
46 | GROUP BY BINARY username |
---|
47 | HAVING COUNT(*) > 1 |
---|
48 | ;'; |
---|
49 | $result = pwg_query($query); |
---|
50 | |
---|
51 | while($row = pwg_db_fetch_assoc($result)) |
---|
52 | { |
---|
53 | $msg_error_FluxBB_Dup .= '<br>'.l10n('Error_FluxBB_Dup').$row['nbr_dup'].' x '.stripslashes($row['username']); |
---|
54 | |
---|
55 | $subquery = ' |
---|
56 | SELECT id, username, email |
---|
57 | FROM '.FluxBB_USERS_TABLE.' |
---|
58 | WHERE BINARY username = BINARY "'.$row['username'].'" |
---|
59 | ;'; |
---|
60 | $subresult = pwg_query($subquery); |
---|
61 | |
---|
62 | while($subrow = pwg_db_fetch_assoc($subresult)) |
---|
63 | { |
---|
64 | $msg_error_FluxBB_Dup .= '<br>id:'.$subrow['id'].'='.stripslashes($subrow['username']).' ('.$subrow['email'].')'; |
---|
65 | |
---|
66 | $msg_error_FluxBB_Dup .= ' <a href="'; |
---|
67 | |
---|
68 | $msg_error_FluxBB_Dup .= add_url_params($page_Register_FluxBB_admin, array( |
---|
69 | 'action' => 'del_user', |
---|
70 | 'id' => $subrow['id'], |
---|
71 | )); |
---|
72 | |
---|
73 | $msg_error_FluxBB_Dup .= '" title="'.l10n('Del_User').stripslashes($subrow['username']).'"'; |
---|
74 | |
---|
75 | $msg_error_FluxBB_Dup .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
76 | |
---|
77 | $msg_error_FluxBB_Dup .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_delete.png" alt="'.l10n('Del_User').$subrow['username'].'" /></a>'; |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | if ($msg_error_FluxBB_Dup == '') |
---|
82 | array_push($page['infos'], l10n('Audit_FluxBB_Dup').'<br>'.l10n('Audit_OK')); |
---|
83 | else |
---|
84 | $msg_error_FluxBB_Dup = l10n('Audit_FluxBB_Dup').$msg_error_FluxBB_Dup.'<br>'.l10n('Advise_FluxBB_Dup'); |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | $query = ' |
---|
89 | SELECT pwg.id as pwg_id, bb.id as bb_id, pwg.username as pwg_user, pwg.mail_address as pwg_mail |
---|
90 | FROM '.FluxBB_USERS_TABLE.' AS bb, '.USERS_TABLE.' as pwg |
---|
91 | WHERE bb.id NOT in ( |
---|
92 | SELECT id_user_FluxBB |
---|
93 | FROM '.Register_FluxBB_ID_TABLE.' |
---|
94 | ) |
---|
95 | AND pwg.id NOT in ( |
---|
96 | SELECT id_user_pwg |
---|
97 | FROM '.Register_FluxBB_ID_TABLE.' |
---|
98 | ) |
---|
99 | AND pwg.username = bb.username |
---|
100 | AND pwg.username NOT IN ("18","16") |
---|
101 | AND pwg.mail_address = bb.email |
---|
102 | ;'; |
---|
103 | |
---|
104 | $result = pwg_query($query); |
---|
105 | |
---|
106 | while($row = pwg_db_fetch_assoc($result)) |
---|
107 | { |
---|
108 | $msg_error_Link_Break .= '<br>'.l10n('Error_Link_Break').stripslashes($row['pwg_user']).' ('.$row['pwg_mail'].')'; |
---|
109 | |
---|
110 | $msg_error_Link_Break .= ' <a href="'; |
---|
111 | |
---|
112 | $msg_error_Link_Break .= add_url_params($page_Register_FluxBB_admin, array( |
---|
113 | 'action' => 'new_link', |
---|
114 | 'pwg_id' => $row['pwg_id'], |
---|
115 | 'bb_id' => $row['bb_id'], |
---|
116 | )); |
---|
117 | |
---|
118 | $msg_error_Link_Break .= '" title="'.l10n('New_Link').stripslashes($row['pwg_user']).'"'; |
---|
119 | |
---|
120 | $msg_error_Link_Break .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
121 | |
---|
122 | $msg_error_Link_Break .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/link_break.png" alt="'.l10n('New_Link').stripslashes($row['pwg_user']).'" /></a>'; |
---|
123 | } |
---|
124 | |
---|
125 | if ($msg_error_Link_Break == '') |
---|
126 | array_push($page['infos'], l10n('Audit_Link_Break').'<br>'.l10n('Audit_OK')); |
---|
127 | else |
---|
128 | $msg_error_Link_Break = l10n('Audit_Link_Break').$msg_error_Link_Break; |
---|
129 | |
---|
130 | |
---|
131 | |
---|
132 | $query = ' |
---|
133 | SELECT pwg.username as pwg_user, pwg.id as pwg_id, pwg.mail_address as pwg_mail, bb.id as bb_id, bb.username as bb_user, bb.email as bb_mail |
---|
134 | FROM '.FluxBB_USERS_TABLE.' AS bb |
---|
135 | INNER JOIN '.Register_FluxBB_ID_TABLE.' AS link ON link.id_user_FluxBB = bb.id |
---|
136 | INNER JOIN '.USERS_TABLE.' as pwg ON link.id_user_pwg = pwg.id |
---|
137 | WHERE pwg.username <> bb.username |
---|
138 | AND pwg.username NOT IN ("18","16") |
---|
139 | ;'; |
---|
140 | |
---|
141 | $result = pwg_query($query); |
---|
142 | |
---|
143 | while($row = pwg_db_fetch_assoc($result)) |
---|
144 | { |
---|
145 | $msg_error_Link_Bad .= '<br>'.l10n('Error_Link_Del').stripslashes($row['pwg_user']).' ('.$row['pwg_mail'].')'.' -- '.stripslashes($row['bb_user']).' ('.$row['bb_mail'].')'; |
---|
146 | |
---|
147 | $msg_error_Link_Bad .= ' <a href="'; |
---|
148 | |
---|
149 | $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array( |
---|
150 | 'action' => 'link_del', |
---|
151 | 'pwg_id' => $row['pwg_id'], |
---|
152 | 'bb_id' => $row['bb_id'], |
---|
153 | )); |
---|
154 | |
---|
155 | $msg_error_Link_Bad .= '" title="'.l10n('Link_Del').stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).'"'; |
---|
156 | |
---|
157 | $msg_error_Link_Bad .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
158 | |
---|
159 | $msg_error_Link_Bad .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/link_delete.png" alt="'.l10n('Link_Del').stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).'" /></a>'; |
---|
160 | |
---|
161 | $msg_error_Link_Bad .= ' -- <a href="'; |
---|
162 | |
---|
163 | $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array( |
---|
164 | 'action' => 'sync_user', |
---|
165 | 'username' => stripslashes($row['pwg_user']), |
---|
166 | )); |
---|
167 | |
---|
168 | $msg_error_Link_Bad .= '" title="'.l10n('Sync_User').stripslashes($row['pwg_user']).' --> '.stripslashes($row['bb_user']).'"'; |
---|
169 | |
---|
170 | $msg_error_Link_Bad .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
171 | |
---|
172 | $msg_error_Link_Bad .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/arrow_switch.png" alt="'.l10n('Sync_User').stripslashes($row['pwg_user']).' --> '.stripslashes($row['bb_user']).'" /></a>'; |
---|
173 | } |
---|
174 | |
---|
175 | |
---|
176 | $query = ' |
---|
177 | SELECT COUNT(*) as nbr_dead |
---|
178 | FROM '.Register_FluxBB_ID_TABLE.' AS Link |
---|
179 | WHERE id_user_FluxBB NOT IN ( |
---|
180 | SELECT id |
---|
181 | FROM '.FluxBB_USERS_TABLE.' |
---|
182 | ) |
---|
183 | OR id_user_pwg NOT IN ( |
---|
184 | SELECT id |
---|
185 | FROM '.USERS_TABLE.' |
---|
186 | ) |
---|
187 | ;'; |
---|
188 | |
---|
189 | $Compteur = pwg_db_fetch_assoc(pwg_query($query)); |
---|
190 | |
---|
191 | if (!empty($Compteur) and $Compteur['nbr_dead'] > 0) |
---|
192 | { |
---|
193 | $msg_error_Link_Bad .= '<br>'.l10n('Error_Link_Dead').$Compteur['nbr_dead']; |
---|
194 | |
---|
195 | $msg_error_Link_Bad .= ' <a href="'; |
---|
196 | |
---|
197 | $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array( |
---|
198 | 'action' => 'link_dead', |
---|
199 | )); |
---|
200 | |
---|
201 | $msg_error_Link_Bad .= '" title="'.l10n('Link_Dead').$Compteur['nbr_dead'].'"'; |
---|
202 | |
---|
203 | $msg_error_Link_Bad .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
204 | |
---|
205 | $msg_error_Link_Bad .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/link_delete.png" alt="'.l10n('Link_Dead').$Compteur['nbr_dead'].'" /></a>'; |
---|
206 | } |
---|
207 | |
---|
208 | $query = ' |
---|
209 | SELECT COUNT(*) AS nbr_dup, pwg.id AS pwg_id, pwg.username AS pwg_user, bb.username AS bb_user, bb.id AS bb_id |
---|
210 | FROM '.FluxBB_USERS_TABLE.' AS bb |
---|
211 | INNER JOIN '.Register_FluxBB_ID_TABLE.' AS link ON link.id_user_FluxBB = bb.id |
---|
212 | INNER JOIN '.USERS_TABLE.' as pwg ON link.id_user_pwg = pwg.id |
---|
213 | WHERE pwg.username NOT IN ("18","16") |
---|
214 | GROUP BY link.id_user_pwg, link.id_user_FluxBB |
---|
215 | HAVING COUNT(*) > 1 |
---|
216 | ;'; |
---|
217 | |
---|
218 | $result = pwg_query($query); |
---|
219 | |
---|
220 | while($row = pwg_db_fetch_assoc($result)) |
---|
221 | { |
---|
222 | $msg_error_Link_Bad .= '<br>'.l10n('Error_Link_Dup').$row['nbr_dup'].' = '.stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).')'; |
---|
223 | |
---|
224 | $msg_error_Link_Bad .= ' <a href="'; |
---|
225 | |
---|
226 | $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array( |
---|
227 | 'action' => 'new_link', |
---|
228 | 'pwg_id' => $row['pwg_id'], |
---|
229 | 'bb_id' => $row['bb_id'], |
---|
230 | )); |
---|
231 | |
---|
232 | $msg_error_Link_Bad .= '" title="'.l10n('Link_Dup').stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).'"'; |
---|
233 | |
---|
234 | $msg_error_Link_Bad .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
235 | |
---|
236 | $msg_error_Link_Bad .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/link_error.png" alt="'.l10n('Link_Dup').stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).'" /></a>'; |
---|
237 | } |
---|
238 | |
---|
239 | if ($msg_error_Link_Bad == '') |
---|
240 | array_push($page['infos'], l10n('Audit_Link_Bad').'<br>'.l10n('Audit_OK')); |
---|
241 | else |
---|
242 | $msg_error_Link_Bad = l10n('Audit_Link_Bad').$msg_error_Link_Bad; |
---|
243 | |
---|
244 | |
---|
245 | |
---|
246 | $query = ' |
---|
247 | SELECT pwg.username as username, pwg.password as pwg_pwd, pwg.mail_address as pwg_eml, FluxBB.password as bb_pwd, FluxBB.email as bb_eml |
---|
248 | FROM '.FluxBB_USERS_TABLE.' AS FluxBB |
---|
249 | INNER JOIN '.Register_FluxBB_ID_TABLE.' AS link ON link.id_user_FluxBB = FluxBB.id |
---|
250 | INNER JOIN '.USERS_TABLE.' as pwg ON link.id_user_pwg = pwg.id |
---|
251 | WHERE BINARY pwg.username = BINARY FluxBB.username |
---|
252 | AND pwg.username NOT IN ("18","16") |
---|
253 | ORDER BY LOWER(pwg.username) |
---|
254 | ;'; |
---|
255 | |
---|
256 | $result = pwg_query($query); |
---|
257 | |
---|
258 | while($row = pwg_db_fetch_assoc($result)) |
---|
259 | { |
---|
260 | if ( ($row['pwg_pwd'] != $row['bb_pwd']) or ($row['pwg_eml'] != $row['bb_eml']) ) |
---|
261 | { |
---|
262 | $msg_error_Synchro .= '<br>'.l10n('Error_Synchro').stripslashes($row['username']); |
---|
263 | |
---|
264 | $msg_error_Synchro .= ' <a href="'; |
---|
265 | |
---|
266 | $msg_error_Synchro .= add_url_params($page_Register_FluxBB_admin, array( |
---|
267 | 'action' => 'sync_user', |
---|
268 | 'username' => stripslashes($row['username']), |
---|
269 | )); |
---|
270 | |
---|
271 | $msg_error_Synchro .= '" title="'.l10n('Sync_User').stripslashes($row['username']).'"'; |
---|
272 | |
---|
273 | $msg_error_Synchro .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
274 | |
---|
275 | $msg_error_Synchro .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_refresh.png" alt="'.l10n('Sync_User').stripslashes($row['username']).'" /></a>'; |
---|
276 | |
---|
277 | if ($row['pwg_pwd'] != $row['bb_pwd']) |
---|
278 | $msg_error_Synchro .= '<br>'.l10n('Error_Synchro_Pswd'); |
---|
279 | |
---|
280 | if ($row['pwg_eml'] != $row['bb_eml']) |
---|
281 | $msg_error_Synchro .= '<br>'.l10n('Error_Synchro_Mail').'<br>-- PWG = '.$row['pwg_eml'].'<br>-- FluxBB = '.$row['bb_eml']; |
---|
282 | } |
---|
283 | else if ($conf_Register_FluxBB['FLUXBB_DETAIL'] == 'true') |
---|
284 | $msg_ok_Synchro .= '<br> - '.stripslashes($row['username']).' ('.$row['pwg_eml'].')'.l10n('Audit_Synchro_OK'); |
---|
285 | } |
---|
286 | |
---|
287 | if ($msg_error_Synchro <> '') |
---|
288 | $msg_error_Synchro = l10n('Audit_Synchro').$msg_error_Synchro; |
---|
289 | |
---|
290 | if ($msg_ok_Synchro <> '') |
---|
291 | if ($msg_error_Synchro <> '') |
---|
292 | array_push($page['infos'], l10n('Audit_Synchro').$msg_ok_Synchro.'<br><br>'); |
---|
293 | else |
---|
294 | array_push($page['infos'], l10n('Audit_Synchro').$msg_ok_Synchro.'<br><br>'.l10n('Audit_OK')); |
---|
295 | |
---|
296 | |
---|
297 | $query = ' |
---|
298 | SELECT username, mail_address FROM '.USERS_TABLE.' |
---|
299 | WHERE BINARY username <> BINARY "guest" |
---|
300 | AND username NOT IN ("18","16") |
---|
301 | AND id not in ( |
---|
302 | SELECT id_user_pwg FROM '.Register_FluxBB_ID_TABLE.' |
---|
303 | ) |
---|
304 | AND BINARY username not in ( |
---|
305 | SELECT username FROM '.FluxBB_USERS_TABLE.' |
---|
306 | ) |
---|
307 | ORDER BY LOWER(username) |
---|
308 | ;'; |
---|
309 | |
---|
310 | $result = pwg_query($query); |
---|
311 | |
---|
312 | while($row = pwg_db_fetch_assoc($result)) |
---|
313 | { |
---|
314 | $msg_error_PWG2FluxBB .= '<br>'.l10n('Error_PWG2FluxBB').stripslashes($row['username']).' ('.$row['mail_address'].')'; |
---|
315 | |
---|
316 | $msg_error_PWG2FluxBB .= ' <a href="'; |
---|
317 | |
---|
318 | $msg_error_PWG2FluxBB .= add_url_params($page_Register_FluxBB_admin, array( |
---|
319 | 'action' => 'add_user', |
---|
320 | 'username' => stripslashes($row['username']), |
---|
321 | )); |
---|
322 | |
---|
323 | $msg_error_PWG2FluxBB .= '" title="'.l10n('Add_User').stripslashes($row['username']).'" '; |
---|
324 | |
---|
325 | $msg_error_PWG2FluxBB .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
326 | |
---|
327 | $msg_error_PWG2FluxBB .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_add.png" alt="'.l10n('Add_User').stripslashes($row['username']).'" /></a>'; |
---|
328 | } |
---|
329 | |
---|
330 | if ($msg_error_PWG2FluxBB == '') |
---|
331 | array_push($page['infos'], l10n('Audit_PWG2FluxBB').'<br>'.l10n('Audit_OK')); |
---|
332 | else |
---|
333 | $msg_error_PWG2FluxBB = l10n('Audit_PWG2FluxBB').$msg_error_PWG2FluxBB; |
---|
334 | |
---|
335 | |
---|
336 | |
---|
337 | $query = ' |
---|
338 | SELECT id, username, email FROM '.FluxBB_USERS_TABLE.' |
---|
339 | WHERE BINARY username <> BINARY "'.$conf_Register_FluxBB['FLUXBB_GUEST'].'" |
---|
340 | AND id not in ( |
---|
341 | SELECT id_user_FluxBB FROM '.Register_FluxBB_ID_TABLE.' |
---|
342 | ) |
---|
343 | AND BINARY username not in ( |
---|
344 | SELECT username FROM '.USERS_TABLE.' |
---|
345 | ) |
---|
346 | ORDER BY LOWER(username) |
---|
347 | ;'; |
---|
348 | |
---|
349 | $result = pwg_query($query); |
---|
350 | |
---|
351 | while($row = pwg_db_fetch_assoc($result)) |
---|
352 | { |
---|
353 | $msg_error_FluxBB2PWG .= '<br>'.l10n('Error_FluxBB2PWG').stripslashes($row['username']).' ('.$row['email'].')'; |
---|
354 | |
---|
355 | $msg_error_FluxBB2PWG .= ' <a href="'; |
---|
356 | |
---|
357 | $msg_error_FluxBB2PWG .= add_url_params($page_Register_FluxBB_admin, array( |
---|
358 | 'action' => 'del_user', |
---|
359 | 'id' => $row['id'], |
---|
360 | )); |
---|
361 | |
---|
362 | $msg_error_FluxBB2PWG .= '" title="'.l10n('Del_User').stripslashes($row['username']).'"'; |
---|
363 | |
---|
364 | $msg_error_FluxBB2PWG .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
365 | |
---|
366 | $msg_error_FluxBB2PWG .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_delete.png" alt="'.l10n('Del_User').stripslashes($row['username']).'" /></a>'; |
---|
367 | } |
---|
368 | |
---|
369 | if ($msg_error_FluxBB2PWG == '') |
---|
370 | array_push($page['infos'], l10n('Audit_FluxBB2PWG').'<br>'.l10n('Audit_OK')); |
---|
371 | else |
---|
372 | $msg_error_FluxBB2PWG = l10n('Audit_FluxBB2PWG').$msg_error_FluxBB2PWG; |
---|
373 | |
---|
374 | |
---|
375 | |
---|
376 | if ($msg_error_PWG_Dup <> '') |
---|
377 | $errors[] = $msg_error_PWG_Dup . ( ($msg_error_FluxBB_Dup == '' and $msg_error_Link_Break == '' and $msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
378 | |
---|
379 | if ($msg_error_FluxBB_Dup <> '') |
---|
380 | $errors[] = $msg_error_FluxBB_Dup . ( ($msg_error_Link_Break == '' and $msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
381 | |
---|
382 | if ($msg_error_Link_Break <> '') |
---|
383 | $errors[] = $msg_error_Link_Break . ( ($msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
384 | |
---|
385 | if ($msg_error_Link_Bad <> '') |
---|
386 | $errors[] = $msg_error_Link_Bad . ( ($msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
387 | |
---|
388 | if ($msg_error_Synchro <> '') |
---|
389 | $errors[] = $msg_error_Synchro . ( ($msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
390 | |
---|
391 | if ($msg_error_PWG2FluxBB <> '') |
---|
392 | $errors[] = $msg_error_PWG2FluxBB . ( ($msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
393 | |
---|
394 | if ($msg_error_FluxBB2PWG <> '') |
---|
395 | $errors[] = $msg_error_FluxBB2PWG; |
---|
396 | } |
---|
397 | |
---|
398 | |
---|
399 | function Register_FluxBB_admin_menu($menu) |
---|
400 | { |
---|
401 | array_push($menu, array( |
---|
402 | 'NAME' => 'Register FluxBB', |
---|
403 | 'URL' => get_root_url().'admin.php?page=plugin-'.basename(REGFLUXBB_PATH) |
---|
404 | ) |
---|
405 | ); |
---|
406 | return $menu; |
---|
407 | } |
---|
408 | |
---|
409 | |
---|
410 | function Register_FluxBB_Adduser($register_user) |
---|
411 | { |
---|
412 | global $errors, $conf; |
---|
413 | |
---|
414 | // Exclusion of Adult_Content users |
---|
415 | if ($register_user['username'] != "16" and $register_user['username'] != "18") |
---|
416 | { |
---|
417 | // Warning : FluxBB uses Sha1 hash instead of md5 for Piwigo! |
---|
418 | FluxBB_Adduser($register_user['id'], $register_user['username'], sha1($_POST['password']), $register_user['email']); |
---|
419 | } |
---|
420 | } |
---|
421 | |
---|
422 | |
---|
423 | function Register_FluxBB_Deluser($user_id) |
---|
424 | { |
---|
425 | FluxBB_Deluser(FluxBB_Searchuser($user_id), true); |
---|
426 | } |
---|
427 | |
---|
428 | |
---|
429 | function Register_FluxBB_InitPage() |
---|
430 | { |
---|
431 | global $conf, $user; |
---|
432 | |
---|
433 | if (isset($_POST['validate']) and !is_admin()) |
---|
434 | { |
---|
435 | if (!empty($_POST['use_new_pwd'])) |
---|
436 | { |
---|
437 | $query = ' |
---|
438 | SELECT '.$conf['user_fields']['username'].' AS username |
---|
439 | FROM '.USERS_TABLE.' |
---|
440 | WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\' |
---|
441 | AND '.$conf['user_fields']['username'].' NOT IN ("18","16") |
---|
442 | ;'; |
---|
443 | |
---|
444 | list($username) = pwg_db_fetch_row(pwg_query($query)); |
---|
445 | |
---|
446 | FluxBB_Updateuser($user['id'], stripslashes($username), sha1($_POST['use_new_pwd']), $_POST['mail_address']); |
---|
447 | } |
---|
448 | } |
---|
449 | } |
---|
450 | |
---|
451 | |
---|
452 | function UAM_Bridge() |
---|
453 | { |
---|
454 | global $conf, $user; |
---|
455 | |
---|
456 | $conf_Register_FluxBB = unserialize($conf['Register_FluxBB']); |
---|
457 | |
---|
458 | // Check if UAM is installed and if bridge is set - Exception for admins and webmasters |
---|
459 | $query =' |
---|
460 | SELECT user_id, status |
---|
461 | FROM '.USER_INFOS_TABLE.' |
---|
462 | WHERE user_id = '.$user['id'].' |
---|
463 | ;'; |
---|
464 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
465 | |
---|
466 | if ($data['status'] <> "admin" and $data['status'] <> "webmaster") |
---|
467 | { |
---|
468 | if (function_exists('FindAvailableConfirmMailID') and isset($conf_Register_FluxBB['FLUXBB_UAM_LINK']) and $conf_Register_FluxBB['FLUXBB_UAM_LINK'] == 'true') |
---|
469 | { |
---|
470 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
471 | |
---|
472 | // Getting unvalidated users group else Piwigo's default group |
---|
473 | if (isset($conf_UAM['NO_CONFIRM_GROUP']) and $conf_UAM['NO_CONFIRM_GROUP'] != '-1') |
---|
474 | { |
---|
475 | $Waitingroup = $conf_UAM['NO_CONFIRM_GROUP']; |
---|
476 | } |
---|
477 | else |
---|
478 | { |
---|
479 | $query = ' |
---|
480 | SELECT id |
---|
481 | FROM '.GROUPS_TABLE.' |
---|
482 | WHERE is_default = "true" |
---|
483 | LIMIT 1 |
---|
484 | ;'; |
---|
485 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
486 | $Waitingroup = $data['id']; |
---|
487 | } |
---|
488 | |
---|
489 | // check if logged in user is in a Piwigo's validated or unvalidated users group |
---|
490 | $query = ' |
---|
491 | SELECT * |
---|
492 | FROM '.USER_GROUP_TABLE.' |
---|
493 | WHERE user_id = '.$user['id'].' |
---|
494 | AND group_id = '.$Waitingroup.' |
---|
495 | ;'; |
---|
496 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
497 | |
---|
498 | // Check if logged in user is in a FluxBB's unvalidated group |
---|
499 | $query = ' |
---|
500 | SELECT group_id |
---|
501 | FROM '.FluxBB_USERS_TABLE.' |
---|
502 | WHERE id = '.FluxBB_Searchuser($user['id']).' |
---|
503 | ;'; |
---|
504 | |
---|
505 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
506 | |
---|
507 | // Logged in user switch to the default FluxBB's group if he is validated |
---|
508 | if ($count == 0 and $data['group_id'] = $conf_Register_FluxBB['FLUXBB_GROUP']) |
---|
509 | { |
---|
510 | $query = ' |
---|
511 | SELECT conf_value |
---|
512 | FROM '.FluxBB_CONFIG_TABLE.' |
---|
513 | WHERE conf_name = "o_default_user_group" |
---|
514 | ;'; |
---|
515 | |
---|
516 | $o_user_group = pwg_db_fetch_assoc(pwg_query($query)); |
---|
517 | |
---|
518 | $query = ' |
---|
519 | UPDATE '.FluxBB_USERS_TABLE.' |
---|
520 | SET group_id = '.$o_user_group['conf_value'].' |
---|
521 | WHERE id = '.FluxBB_Searchuser($user['id']).' |
---|
522 | ;'; |
---|
523 | pwg_query($query); |
---|
524 | } |
---|
525 | } |
---|
526 | } |
---|
527 | } |
---|
528 | |
---|
529 | |
---|
530 | function Register_FluxBB_RegistrationCheck($errors, $user) |
---|
531 | { |
---|
532 | global $conf; |
---|
533 | |
---|
534 | // Because FluxBB is case insensitive on login name, we have to check if a similar login already exists in FluxBB's user table |
---|
535 | // If "test" user already exists, "TEST" or "Test" (and so on...) can't register |
---|
536 | $query = ' |
---|
537 | SELECT username |
---|
538 | FROM '.FluxBB_USERS_TABLE.' |
---|
539 | WHERE LOWER('.stripslashes('username').') = "'.strtolower($user['username']).'" |
---|
540 | ;'; |
---|
541 | |
---|
542 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
543 | |
---|
544 | if ($count > 0) |
---|
545 | { |
---|
546 | array_push($errors, l10n('this login is already used')); |
---|
547 | } |
---|
548 | return $errors; |
---|
549 | } |
---|
550 | |
---|
551 | |
---|
552 | function FluxBB_Linkuser($pwg_id, $bb_id) |
---|
553 | { |
---|
554 | $query = ' |
---|
555 | SELECT pwg.id as pwg_id, bb.id as bb_id |
---|
556 | FROM '.USERS_TABLE.' pwg, '.FluxBB_USERS_TABLE.' bb |
---|
557 | WHERE pwg.id = '.$pwg_id.' |
---|
558 | AND bb.id = '.$bb_id.' |
---|
559 | AND pwg.username = bb.username |
---|
560 | AND pwg.username NOT IN ("18","16") |
---|
561 | ;'; |
---|
562 | |
---|
563 | $data = pwg_db_fetch_row(pwg_query($query)); |
---|
564 | |
---|
565 | if (!empty($data)) |
---|
566 | { |
---|
567 | $subquery = ' |
---|
568 | DELETE FROM '.Register_FluxBB_ID_TABLE.' |
---|
569 | WHERE id_user_pwg = "'.$pwg_id.'" |
---|
570 | OR id_user_FluxBB = "'.$bb_id.'" |
---|
571 | ;'; |
---|
572 | |
---|
573 | $subresult = pwg_query($subquery); |
---|
574 | |
---|
575 | $subquery = ' |
---|
576 | INSERT INTO '.Register_FluxBB_ID_TABLE.' |
---|
577 | (id_user_pwg, id_user_FluxBB) |
---|
578 | VALUES ('.$pwg_id.', '.$bb_id.') |
---|
579 | ;'; |
---|
580 | |
---|
581 | $subresult = pwg_query($subquery); |
---|
582 | } |
---|
583 | } |
---|
584 | |
---|
585 | |
---|
586 | |
---|
587 | function FluxBB_Unlinkuser($bb_id) |
---|
588 | { |
---|
589 | $query = ' |
---|
590 | DELETE FROM '.Register_FluxBB_ID_TABLE.' |
---|
591 | WHERE id_user_FluxBB = '.$bb_id.' |
---|
592 | ;'; |
---|
593 | |
---|
594 | $result = pwg_query($query); |
---|
595 | } |
---|
596 | |
---|
597 | |
---|
598 | |
---|
599 | function FluxBB_Adduser($pwg_id, $login, $password, $adresse_mail) |
---|
600 | { |
---|
601 | global $errors, $conf; |
---|
602 | |
---|
603 | $conf_Register_FluxBB = unserialize($conf['Register_FluxBB']); |
---|
604 | |
---|
605 | $registred = time(); |
---|
606 | $registred_ip = $_SERVER['REMOTE_ADDR']; |
---|
607 | |
---|
608 | // Check if UAM is installed and if bridge is set - Exception for admins and webmasters |
---|
609 | if (function_exists('FindAvailableConfirmMailID') and isset($conf_Register_FluxBB['FLUXBB_UAM_LINK']) and $conf_Register_FluxBB['FLUXBB_UAM_LINK'] == 'true') |
---|
610 | { |
---|
611 | $o_default_user_group1 = $conf_Register_FluxBB['FLUXBB_GROUP']; |
---|
612 | } |
---|
613 | else |
---|
614 | { |
---|
615 | $query = ' |
---|
616 | SELECT conf_value |
---|
617 | FROM '.FluxBB_CONFIG_TABLE.' |
---|
618 | WHERE conf_name = "o_default_user_group" |
---|
619 | ;'; |
---|
620 | |
---|
621 | $o_default_user_group = pwg_db_fetch_assoc(pwg_query($query)); |
---|
622 | } |
---|
623 | |
---|
624 | // Check for FluxBB version 1.4.x or higher and get the correct value |
---|
625 | $query1 = ' |
---|
626 | SELECT conf_value |
---|
627 | FROM '.FluxBB_CONFIG_TABLE.' |
---|
628 | WHERE conf_name = "o_default_timezone" |
---|
629 | ;'; |
---|
630 | |
---|
631 | $count1 = pwg_db_num_rows(pwg_query($query1)); |
---|
632 | |
---|
633 | // Check for FluxBB version 1.2.x and get the correct value |
---|
634 | $query2 = ' |
---|
635 | SELECT conf_value |
---|
636 | FROM '.FluxBB_CONFIG_TABLE.' |
---|
637 | WHERE conf_name = "o_server_timezone" |
---|
638 | ;'; |
---|
639 | |
---|
640 | $count2 = pwg_db_num_rows(pwg_query($query2)); |
---|
641 | |
---|
642 | if ($count1 == 1 and $count2 == 0) |
---|
643 | { |
---|
644 | $o_default_timezone = pwg_db_fetch_assoc(pwg_query($query1)); |
---|
645 | } |
---|
646 | else if ($count1 == 0 and $count2 == 1) |
---|
647 | { |
---|
648 | $o_default_timezone = pwg_db_fetch_assoc(pwg_query($query2)); |
---|
649 | } |
---|
650 | |
---|
651 | |
---|
652 | $query = ' |
---|
653 | SELECT conf_value |
---|
654 | FROM '.FluxBB_CONFIG_TABLE.' |
---|
655 | WHERE conf_name = "o_default_lang" |
---|
656 | ;'; |
---|
657 | |
---|
658 | $o_default_lang = pwg_db_fetch_assoc(pwg_query($query)); |
---|
659 | |
---|
660 | $query = ' |
---|
661 | SELECT conf_value |
---|
662 | FROM '.FluxBB_CONFIG_TABLE.' |
---|
663 | WHERE conf_name = "o_default_style" |
---|
664 | ;'; |
---|
665 | |
---|
666 | $o_default_style = pwg_db_fetch_assoc(pwg_query($query)); |
---|
667 | |
---|
668 | // Check if UAM is installed and if bridge is set - Exception for admins and webmasters |
---|
669 | if (function_exists('FindAvailableConfirmMailID') and isset($conf_Register_FluxBB['FLUXBB_UAM_LINK']) and $conf_Register_FluxBB['FLUXBB_UAM_LINK'] == 'true') |
---|
670 | { |
---|
671 | $query = " |
---|
672 | INSERT INTO ".FluxBB_USERS_TABLE." ( |
---|
673 | username, |
---|
674 | ". ( isset($o_default_user_group1) ? 'group_id' : '' ) .", |
---|
675 | password, |
---|
676 | email, |
---|
677 | ". ( isset($o_default_timezone['conf_value']) ? 'timezone' : '' ) .", |
---|
678 | ". ( isset($o_default_lang['conf_value']) ? 'language' : '' ) .", |
---|
679 | ". ( isset($o_default_style['conf_value']) ? 'style' : '' ) .", |
---|
680 | registered, |
---|
681 | registration_ip, |
---|
682 | last_visit |
---|
683 | ) |
---|
684 | VALUES( |
---|
685 | '".pwg_db_real_escape_string($login)."', |
---|
686 | ". ( isset($o_default_user_group1) ? "'".$o_default_user_group1."'" : '' ) .", |
---|
687 | '".$password."', |
---|
688 | '".$adresse_mail."', |
---|
689 | ". ( isset($o_default_timezone['conf_value']) ? "'".$o_default_timezone['conf_value']."'" : '' ) .", |
---|
690 | ". ( isset($o_default_lang['conf_value']) ? "'".$o_default_lang['conf_value']."'" : '' ) .", |
---|
691 | ". ( isset($o_default_style['conf_value']) ? "'".$o_default_style['conf_value']."'" : '' ) .", |
---|
692 | '".$registred."', |
---|
693 | '".$registred_ip."', |
---|
694 | '".$registred."' |
---|
695 | );"; |
---|
696 | |
---|
697 | $result = pwg_query($query); |
---|
698 | } |
---|
699 | else |
---|
700 | { |
---|
701 | $query = " |
---|
702 | INSERT INTO ".FluxBB_USERS_TABLE." ( |
---|
703 | username, |
---|
704 | ". ( isset($o_default_user_group['conf_value']) ? 'group_id' : '' ) .", |
---|
705 | password, |
---|
706 | email, |
---|
707 | ". ( isset($o_default_timezone['conf_value']) ? 'timezone' : '' ) .", |
---|
708 | ". ( isset($o_default_lang['conf_value']) ? 'language' : '' ) .", |
---|
709 | ". ( isset($o_default_style['conf_value']) ? 'style' : '' ) .", |
---|
710 | registered, |
---|
711 | registration_ip, |
---|
712 | last_visit |
---|
713 | ) |
---|
714 | VALUES( |
---|
715 | '".pwg_db_real_escape_string($login)."', |
---|
716 | ". ( isset($o_default_user_group['conf_value']) ? "'".$o_default_user_group['conf_value']."'" : '' ) .", |
---|
717 | '".$password."', |
---|
718 | '".$adresse_mail."', |
---|
719 | ". ( isset($o_default_timezone['conf_value']) ? "'".$o_default_timezone['conf_value']."'" : '' ) .", |
---|
720 | ". ( isset($o_default_lang['conf_value']) ? "'".$o_default_lang['conf_value']."'" : '' ) .", |
---|
721 | ". ( isset($o_default_style['conf_value']) ? "'".$o_default_style['conf_value']."'" : '' ) .", |
---|
722 | '".$registred."', |
---|
723 | '".$registred_ip."', |
---|
724 | '".$registred."' |
---|
725 | ) |
---|
726 | ;"; |
---|
727 | $result = pwg_query($query); |
---|
728 | } |
---|
729 | |
---|
730 | $bb_id = pwg_db_insert_id(); |
---|
731 | |
---|
732 | FluxBB_Linkuser($pwg_id, $bb_id); |
---|
733 | } |
---|
734 | |
---|
735 | |
---|
736 | |
---|
737 | function FluxBB_Searchuser($id_user_pwg) |
---|
738 | { |
---|
739 | $query = ' |
---|
740 | SELECT id_user_FluxBB, id_user_pwg |
---|
741 | FROM '.Register_FluxBB_ID_TABLE.' |
---|
742 | WHERE id_user_pwg = '.$id_user_pwg.' |
---|
743 | LIMIT 1 |
---|
744 | ;'; |
---|
745 | |
---|
746 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
747 | |
---|
748 | if (!empty($data)) |
---|
749 | return $data['id_user_FluxBB']; |
---|
750 | else |
---|
751 | return '0'; |
---|
752 | } |
---|
753 | |
---|
754 | |
---|
755 | |
---|
756 | function FluxBB_Deluser($id_user_FluxBB, $SuppTopicsPosts) |
---|
757 | { |
---|
758 | global $conf; |
---|
759 | |
---|
760 | $conf_Register_FluxBB = unserialize($conf['Register_FluxBB']); |
---|
761 | |
---|
762 | $query0 = ' |
---|
763 | SELECT username, id |
---|
764 | FROM '.FluxBB_USERS_TABLE.' |
---|
765 | WHERE id = '.$id_user_FluxBB.' |
---|
766 | LIMIT 1 |
---|
767 | ;'; |
---|
768 | |
---|
769 | $data0 = pwg_db_fetch_assoc(pwg_query($query0)); |
---|
770 | |
---|
771 | // If True, delete related topics and posts |
---|
772 | if ($SuppTopicsPosts and $conf_Register_FluxBB['FLUXBB_DEL_PT']) |
---|
773 | { |
---|
774 | // Delete posts and topics of this user |
---|
775 | $subquery = ' |
---|
776 | DELETE FROM '.FluxBB_POSTS_TABLE.' |
---|
777 | WHERE poster_id = '.$id_user_FluxBB.' |
---|
778 | ;'; |
---|
779 | |
---|
780 | $subresult = pwg_query($subquery); |
---|
781 | |
---|
782 | // Delete topics of this user |
---|
783 | $subquery = ' |
---|
784 | DELETE FROM '.FluxBB_TOPICS_TABLE.' |
---|
785 | WHERE BINARY poster = BINARY "'.pwg_db_real_escape_string($data0['username']).'" |
---|
786 | ;'; |
---|
787 | |
---|
788 | $subresult = pwg_query($subquery); |
---|
789 | } |
---|
790 | |
---|
791 | // Delete user's subscriptions |
---|
792 | $subquery = ' |
---|
793 | DELETE FROM '.FluxBB_SUBSCRIPTIONS_TABLE.' |
---|
794 | WHERE user_id = '.$id_user_FluxBB.' |
---|
795 | ;'; |
---|
796 | |
---|
797 | $subresult = pwg_query($subquery); |
---|
798 | |
---|
799 | // Delete user's account |
---|
800 | $subquery = ' |
---|
801 | DELETE FROM '.FluxBB_USERS_TABLE.' |
---|
802 | WHERE id = '.$id_user_FluxBB.' |
---|
803 | ;'; |
---|
804 | |
---|
805 | $subresult = pwg_query($subquery); |
---|
806 | |
---|
807 | FluxBB_Unlinkuser($id_user_FluxBB); |
---|
808 | } |
---|
809 | |
---|
810 | |
---|
811 | |
---|
812 | function FluxBB_Updateuser($pwg_id, $username, $password, $adresse_mail) |
---|
813 | { |
---|
814 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
815 | |
---|
816 | $query = ' |
---|
817 | SELECT id_user_FluxBB as FluxBB_id |
---|
818 | FROM '.Register_FluxBB_ID_TABLE.' |
---|
819 | WHERE id_user_pwg = '.$pwg_id.' |
---|
820 | ;'; |
---|
821 | |
---|
822 | $row = pwg_db_fetch_assoc(pwg_query($query)); |
---|
823 | |
---|
824 | if (!empty($row)) |
---|
825 | { |
---|
826 | $query = ' |
---|
827 | UPDATE '.FluxBB_USERS_TABLE.' |
---|
828 | SET username = "'.pwg_db_real_escape_string($username).'", email = "'.$adresse_mail.'", password = "'.$password.'" |
---|
829 | WHERE id = '.$row['FluxBB_id'].' |
---|
830 | AND "'.pwg_db_real_escape_string($username).'" NOT IN ("18","16") |
---|
831 | ;'; |
---|
832 | |
---|
833 | $result = pwg_query($query); |
---|
834 | |
---|
835 | FluxBB_Linkuser($pwg_id, $row['FluxBB_id']); |
---|
836 | } |
---|
837 | else |
---|
838 | { |
---|
839 | $query = ' |
---|
840 | SELECT id as FluxBB_id |
---|
841 | FROM '.FluxBB_USERS_TABLE.' |
---|
842 | WHERE BINARY username = BINARY "'.pwg_db_real_escape_string($username).'" |
---|
843 | ;'; |
---|
844 | |
---|
845 | $row = pwg_db_fetch_assoc(pwg_query($query)); |
---|
846 | |
---|
847 | if (!empty($row)) |
---|
848 | { |
---|
849 | $query = ' |
---|
850 | UPDATE '.FluxBB_USERS_TABLE.' |
---|
851 | SET username = "'.pwg_db_real_escape_string($username).'", email = "'.$adresse_mail.'", password = "'.$password.'" |
---|
852 | WHERE id = '.$row['FluxBB_id'].' |
---|
853 | AND "'.pwg_db_real_escape_string($username).'" NOT IN ("18","16") |
---|
854 | ;'; |
---|
855 | |
---|
856 | $result = pwg_query($query); |
---|
857 | |
---|
858 | FluxBB_Linkuser($pwg_id, $row['FluxBB_id']); |
---|
859 | } |
---|
860 | } |
---|
861 | } |
---|
862 | |
---|
863 | |
---|
864 | function RegFluxBB_Infos($dir) |
---|
865 | { |
---|
866 | $path = $dir; |
---|
867 | |
---|
868 | $plg_data = implode( '', file($path.'main.inc.php') ); |
---|
869 | if ( preg_match("|Plugin Name: (.*)|", $plg_data, $val) ) |
---|
870 | { |
---|
871 | $plugin['name'] = trim( $val[1] ); |
---|
872 | } |
---|
873 | if (preg_match("|Version: (.*)|", $plg_data, $val)) |
---|
874 | { |
---|
875 | $plugin['version'] = trim($val[1]); |
---|
876 | } |
---|
877 | if ( preg_match("|Plugin URI: (.*)|", $plg_data, $val) ) |
---|
878 | { |
---|
879 | $plugin['uri'] = trim($val[1]); |
---|
880 | } |
---|
881 | if ($desc = load_language('description.txt', $path.'/', array('return' => true))) |
---|
882 | { |
---|
883 | $plugin['description'] = trim($desc); |
---|
884 | } |
---|
885 | elseif ( preg_match("|Description: (.*)|", $plg_data, $val) ) |
---|
886 | { |
---|
887 | $plugin['description'] = trim($val[1]); |
---|
888 | } |
---|
889 | if ( preg_match("|Author: (.*)|", $plg_data, $val) ) |
---|
890 | { |
---|
891 | $plugin['author'] = trim($val[1]); |
---|
892 | } |
---|
893 | if ( preg_match("|Author URI: (.*)|", $plg_data, $val) ) |
---|
894 | { |
---|
895 | $plugin['author uri'] = trim($val[1]); |
---|
896 | } |
---|
897 | if (!empty($plugin['uri']) and strpos($plugin['uri'] , 'extension_view.php?eid=')) |
---|
898 | { |
---|
899 | list( , $extension) = explode('extension_view.php?eid=', $plugin['uri']); |
---|
900 | if (is_numeric($extension)) $plugin['extension'] = $extension; |
---|
901 | } |
---|
902 | // IMPORTANT SECURITY ! |
---|
903 | $plugin = array_map('htmlspecialchars', $plugin); |
---|
904 | |
---|
905 | return $plugin ; |
---|
906 | } |
---|
907 | |
---|
908 | |
---|
909 | function regfluxbb_obsolete_files() |
---|
910 | { |
---|
911 | if (file_exists(REGFLUXBB_PATH.'obsolete.list') |
---|
912 | and $old_files = file(REGFLUXBB_PATH.'obsolete.list', FILE_IGNORE_NEW_LINES) |
---|
913 | and !empty($old_files)) |
---|
914 | { |
---|
915 | array_push($old_files, 'obsolete.list'); |
---|
916 | foreach($old_files as $old_file) |
---|
917 | { |
---|
918 | $path = REGFLUXBB_PATH.$old_file; |
---|
919 | if (is_file($path)) |
---|
920 | { |
---|
921 | @unlink($path); |
---|
922 | } |
---|
923 | } |
---|
924 | } |
---|
925 | } |
---|
926 | |
---|
927 | |
---|
928 | /** |
---|
929 | * Function to update plugin version number in config table |
---|
930 | * Used everytime a new version is updated even if no database |
---|
931 | * upgrade is needed |
---|
932 | */ |
---|
933 | function RegFluxBB_version_update() |
---|
934 | { |
---|
935 | global $conf; |
---|
936 | |
---|
937 | // Get current plugin version |
---|
938 | // -------------------------- |
---|
939 | $plugin = PHInfos(REGFLUXBB_PATH); |
---|
940 | $version = $plugin['version']; |
---|
941 | |
---|
942 | // Upgrading options |
---|
943 | // ----------------- |
---|
944 | $query = ' |
---|
945 | SELECT value |
---|
946 | FROM '.CONFIG_TABLE.' |
---|
947 | WHERE param = "Register_FluxBB" |
---|
948 | ;'; |
---|
949 | |
---|
950 | $result = pwg_query($query); |
---|
951 | $Conf_RegFluxBB = pwg_db_fetch_assoc($result); |
---|
952 | |
---|
953 | $Newconf_RegFluxBB = unserialize($Conf_RegFluxBB['value']); |
---|
954 | |
---|
955 | $Newconf_RegFluxBB['REGFLUXBB_VERSION'] = $version; |
---|
956 | |
---|
957 | $update_conf = serialize($Newconf_RegFluxBB); |
---|
958 | |
---|
959 | conf_update_param('Register_FluxBB', pwg_db_real_escape_string($update_conf)); |
---|
960 | |
---|
961 | |
---|
962 | // Check #_plugin table consistency |
---|
963 | // Only useful if a previous version upgrade has not worked correctly (rare case) |
---|
964 | // ------------------------------------------------------------------------------ |
---|
965 | $query = ' |
---|
966 | SELECT version |
---|
967 | FROM '.PLUGINS_TABLE.' |
---|
968 | WHERE id = "Register_FluxBB" |
---|
969 | ;'; |
---|
970 | |
---|
971 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
972 | |
---|
973 | if (empty($data['version']) or $data['version'] <> $version) |
---|
974 | { |
---|
975 | $query = ' |
---|
976 | UPDATE '.PLUGINS_TABLE.' |
---|
977 | SET version="'.$version.'" |
---|
978 | WHERE id = "Register_FluxBB" |
---|
979 | LIMIT 1 |
---|
980 | ;'; |
---|
981 | |
---|
982 | pwg_query($query); |
---|
983 | } |
---|
984 | } |
---|
985 | |
---|
986 | |
---|
987 | /** |
---|
988 | * Useful for debugging - 4 vars can be set |
---|
989 | * Output result to log.txt file |
---|
990 | * |
---|
991 | */ |
---|
992 | function RegFluxBBLog($var1, $var2, $var3, $var4) |
---|
993 | { |
---|
994 | $fo=fopen (REGFLUXBB_PATH.'log.txt','a') ; |
---|
995 | fwrite($fo,"======================\n") ; |
---|
996 | fwrite($fo,'le ' . date('D, d M Y H:i:s') . "\r\n"); |
---|
997 | fwrite($fo,$var1 ."\r\n") ; |
---|
998 | fwrite($fo,$var2 ."\r\n") ; |
---|
999 | fwrite($fo,$var3 ."\r\n") ; |
---|
1000 | fwrite($fo,$var4 ."\r\n") ; |
---|
1001 | fclose($fo) ; |
---|
1002 | } |
---|
1003 | ?> |
---|