1 | <?php |
---|
2 | |
---|
3 | global $user, $lang, $conf, $template, $errors; |
---|
4 | |
---|
5 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
6 | |
---|
7 | if (!defined('REGFLUXBB_PATH')) define('REGFLUXBB_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
8 | |
---|
9 | //ini_set('error_reporting', E_ALL); |
---|
10 | //ini_set('display_errors', true); |
---|
11 | |
---|
12 | include_once (PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
13 | include_once (PHPWG_ROOT_PATH.'/include/constants.php'); |
---|
14 | |
---|
15 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
16 | load_language('plugin.lang', REGFLUXBB_PATH); |
---|
17 | |
---|
18 | // +-----------------------------------------------------------------------+ |
---|
19 | // | Tabssheet | |
---|
20 | // +-----------------------------------------------------------------------+ |
---|
21 | if (!isset($_GET['tab'])) |
---|
22 | $page['tab'] = 'info'; |
---|
23 | else |
---|
24 | $page['tab'] = $_GET['tab']; |
---|
25 | |
---|
26 | $tabsheet = new tabsheet(); |
---|
27 | $tabsheet->add('info', |
---|
28 | l10n('Tab_Info'), |
---|
29 | $my_base_url.'&tab=info'); |
---|
30 | $tabsheet->add('manage', |
---|
31 | l10n('Tab_Manage'), |
---|
32 | $my_base_url.'&tab=manage'); |
---|
33 | $tabsheet->add('Migration', |
---|
34 | l10n('Tab_Migration'), |
---|
35 | $my_base_url.'&tab=Migration'); |
---|
36 | $tabsheet->add('Synchro', |
---|
37 | l10n('Tab_Synchro'), |
---|
38 | $my_base_url.'&tab=Synchro'); |
---|
39 | $tabsheet->select($page['tab']); |
---|
40 | $tabsheet->assign(); |
---|
41 | |
---|
42 | |
---|
43 | $page['infos'] = array(); |
---|
44 | $error = array(); |
---|
45 | |
---|
46 | // +-----------------------------------------------------------------------+ |
---|
47 | // | Getting plugin version | |
---|
48 | // +-----------------------------------------------------------------------+ |
---|
49 | $plugin = RegFluxBB_Infos(REGFLUXBB_PATH); |
---|
50 | $version = $plugin['version'] ; |
---|
51 | |
---|
52 | // +-----------------------------------------------------------------------+ |
---|
53 | // | Functions |
---|
54 | // +-----------------------------------------------------------------------+ |
---|
55 | function Audit_PWG_FluxBB() |
---|
56 | { |
---|
57 | global $page, $conf, $errors; |
---|
58 | |
---|
59 | $conf_Register_FluxBB = isset($conf['Register_FluxBB']) ? explode(";" , $conf['Register_FluxBB']) : array(); |
---|
60 | |
---|
61 | $page_Register_FluxBB_admin = get_admin_plugin_menu_link(__FILE__); |
---|
62 | |
---|
63 | |
---|
64 | |
---|
65 | $msg_error_PWG_Dup = ''; |
---|
66 | $msg_error_FluxBB_Dup = ''; |
---|
67 | $msg_error_Link_Break = ''; |
---|
68 | $msg_error_Link_Bad = ''; |
---|
69 | $msg_error_Synchro = ''; |
---|
70 | $msg_ok_Synchro = ''; |
---|
71 | $msg_error_PWG2FluxBB = ''; |
---|
72 | $msg_error_FluxBB2PWG = ''; |
---|
73 | |
---|
74 | |
---|
75 | |
---|
76 | $query = " |
---|
77 | SELECT COUNT(*) AS nbr_dup, id, username |
---|
78 | FROM ".USERS_TABLE." |
---|
79 | GROUP BY BINARY username |
---|
80 | HAVING COUNT(*) > 1 |
---|
81 | ;"; |
---|
82 | $result = pwg_query($query); |
---|
83 | |
---|
84 | while($row = pwg_db_fetch_assoc($result)) |
---|
85 | $msg_error_PWG_Dup .= '<br>'.l10n('Error_PWG_Dup').$row['nbr_dup'].' x '.stripslashes($row['username']); |
---|
86 | |
---|
87 | if ($msg_error_PWG_Dup == '') |
---|
88 | array_push($page['infos'], l10n('Audit_PWG_Dup').'<br>'.l10n('Audit_OK')); |
---|
89 | else |
---|
90 | $msg_error_PWG_Dup = l10n('Audit_PWG_Dup').$msg_error_PWG_Dup.'<br>'.l10n('Advise_PWG_Dup'); |
---|
91 | |
---|
92 | |
---|
93 | |
---|
94 | $query = " |
---|
95 | SELECT COUNT(*) AS nbr_dup, username |
---|
96 | FROM ".FluxBB_USERS_TABLE." |
---|
97 | GROUP BY BINARY username |
---|
98 | HAVING COUNT(*) > 1 |
---|
99 | ;"; |
---|
100 | $result = pwg_query($query); |
---|
101 | |
---|
102 | while($row = pwg_db_fetch_assoc($result)) |
---|
103 | { |
---|
104 | $msg_error_FluxBB_Dup .= '<br>'.l10n('Error_FluxBB_Dup').$row['nbr_dup'].' x '.stripslashes($row['username']); |
---|
105 | |
---|
106 | $subquery = " |
---|
107 | SELECT id, username, email |
---|
108 | FROM ".FluxBB_USERS_TABLE." |
---|
109 | WHERE BINARY username = BINARY '".$row['username']."' |
---|
110 | ;"; |
---|
111 | $subresult = pwg_query($subquery); |
---|
112 | |
---|
113 | while($subrow = pwg_db_fetch_assoc($subresult)) |
---|
114 | { |
---|
115 | $msg_error_FluxBB_Dup .= '<br>id:'.$subrow['id'].'='.stripslashes($subrow['username']).' ('.$subrow['email'].')'; |
---|
116 | |
---|
117 | if ( !is_adviser() ) |
---|
118 | { |
---|
119 | $msg_error_FluxBB_Dup .= ' <a href="'; |
---|
120 | |
---|
121 | $msg_error_FluxBB_Dup .= add_url_params($page_Register_FluxBB_admin, array( |
---|
122 | 'action' => 'del_user', |
---|
123 | 'id' => $subrow['id'], |
---|
124 | )); |
---|
125 | |
---|
126 | $msg_error_FluxBB_Dup .= '" title="'.l10n('Del_User').stripslashes($subrow['username']).'"'; |
---|
127 | |
---|
128 | $msg_error_FluxBB_Dup .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
129 | |
---|
130 | $msg_error_FluxBB_Dup .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_delete.png" alt="'.l10n('Del_User').$subrow['username'].'" /></a>'; |
---|
131 | } |
---|
132 | } |
---|
133 | } |
---|
134 | |
---|
135 | if ($msg_error_FluxBB_Dup == '') |
---|
136 | array_push($page['infos'], l10n('Audit_FluxBB_Dup').'<br>'.l10n('Audit_OK')); |
---|
137 | else |
---|
138 | $msg_error_FluxBB_Dup = l10n('Audit_FluxBB_Dup').$msg_error_FluxBB_Dup.'<br>'.l10n('Advise_FluxBB_Dup'); |
---|
139 | |
---|
140 | |
---|
141 | |
---|
142 | $query = " |
---|
143 | SELECT pwg.id as pwg_id, bb.id as bb_id, pwg.username as pwg_user, pwg.mail_address as pwg_mail |
---|
144 | FROM ".FluxBB_USERS_TABLE." AS bb, ".USERS_TABLE." as pwg |
---|
145 | WHERE bb.id NOT in ( |
---|
146 | SELECT id_user_FluxBB |
---|
147 | FROM ".Register_FluxBB_ID_TABLE." |
---|
148 | ) |
---|
149 | AND pwg.id NOT in ( |
---|
150 | SELECT id_user_pwg |
---|
151 | FROM ".Register_FluxBB_ID_TABLE." |
---|
152 | ) |
---|
153 | AND pwg.username = bb.username |
---|
154 | AND pwg.mail_address = bb.email |
---|
155 | ;"; |
---|
156 | |
---|
157 | $result = pwg_query($query); |
---|
158 | |
---|
159 | while($row = pwg_db_fetch_assoc($result)) |
---|
160 | { |
---|
161 | $msg_error_Link_Break .= '<br>'.l10n('Error_Link_Break').stripslashes($row['pwg_user']).' ('.$row['pwg_mail'].')'; |
---|
162 | |
---|
163 | if ( !is_adviser() ) |
---|
164 | { |
---|
165 | $msg_error_Link_Break .= ' <a href="'; |
---|
166 | |
---|
167 | $msg_error_Link_Break .= add_url_params($page_Register_FluxBB_admin, array( |
---|
168 | 'action' => 'new_link', |
---|
169 | 'pwg_id' => $row['pwg_id'], |
---|
170 | 'bb_id' => $row['bb_id'], |
---|
171 | )); |
---|
172 | |
---|
173 | $msg_error_Link_Break .= '" title="'.l10n('New_Link').stripslashes($row['pwg_user']).'"'; |
---|
174 | |
---|
175 | $msg_error_Link_Break .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
176 | |
---|
177 | $msg_error_Link_Break .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/link_break.png" alt="'.l10n('New_Link').stripslashes($row['pwg_user']).'" /></a>'; |
---|
178 | } |
---|
179 | } |
---|
180 | |
---|
181 | if ($msg_error_Link_Break == '') |
---|
182 | array_push($page['infos'], l10n('Audit_Link_Break').'<br>'.l10n('Audit_OK')); |
---|
183 | else |
---|
184 | $msg_error_Link_Break = l10n('Audit_Link_Break').$msg_error_Link_Break; |
---|
185 | |
---|
186 | |
---|
187 | |
---|
188 | $query = " |
---|
189 | 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 |
---|
190 | FROM ".FluxBB_USERS_TABLE." AS bb |
---|
191 | INNER JOIN ".Register_FluxBB_ID_TABLE." AS link ON link.id_user_FluxBB = bb.id |
---|
192 | INNER JOIN ".USERS_TABLE." as pwg ON link.id_user_pwg = pwg.id |
---|
193 | WHERE pwg.username <> bb.username |
---|
194 | ;"; |
---|
195 | |
---|
196 | $result = pwg_query($query); |
---|
197 | |
---|
198 | while($row = pwg_db_fetch_assoc($result)) |
---|
199 | { |
---|
200 | $msg_error_Link_Bad .= '<br>'.l10n('Error_Link_Del').stripslashes($row['pwg_user']).' ('.$row['pwg_mail'].')'.' -- '.stripslashes($row['bb_user']).' ('.$row['bb_mail'].')'; |
---|
201 | |
---|
202 | if ( !is_adviser() ) |
---|
203 | { |
---|
204 | $msg_error_Link_Bad .= ' <a href="'; |
---|
205 | |
---|
206 | $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array( |
---|
207 | 'action' => 'link_del', |
---|
208 | 'pwg_id' => $row['pwg_id'], |
---|
209 | 'bb_id' => $row['bb_id'], |
---|
210 | )); |
---|
211 | |
---|
212 | $msg_error_Link_Bad .= '" title="'.l10n('Link_Del').stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).'"'; |
---|
213 | |
---|
214 | $msg_error_Link_Bad .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
215 | |
---|
216 | $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>'; |
---|
217 | |
---|
218 | $msg_error_Link_Bad .= ' -- <a href="'; |
---|
219 | |
---|
220 | $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array( |
---|
221 | 'action' => 'sync_user', |
---|
222 | 'username' => stripslashes($row['pwg_user']), |
---|
223 | )); |
---|
224 | |
---|
225 | $msg_error_Link_Bad .= '" title="'.l10n('Sync_User').stripslashes($row['pwg_user']).' --> '.stripslashes($row['bb_user']).'"'; |
---|
226 | |
---|
227 | $msg_error_Link_Bad .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
228 | |
---|
229 | $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>'; |
---|
230 | } |
---|
231 | } |
---|
232 | |
---|
233 | |
---|
234 | $query = " |
---|
235 | SELECT COUNT(*) as nbr_dead |
---|
236 | FROM ".Register_FluxBB_ID_TABLE." AS Link |
---|
237 | WHERE id_user_FluxBB NOT IN ( |
---|
238 | SELECT id |
---|
239 | FROM ".FluxBB_USERS_TABLE." |
---|
240 | ) |
---|
241 | OR id_user_pwg NOT IN ( |
---|
242 | SELECT id |
---|
243 | FROM ".USERS_TABLE." |
---|
244 | ) |
---|
245 | ;"; |
---|
246 | |
---|
247 | $Compteur = pwg_db_fetch_assoc(pwg_query($query)); |
---|
248 | |
---|
249 | if (!empty($Compteur) and $Compteur['nbr_dead'] > 0) |
---|
250 | { |
---|
251 | $msg_error_Link_Bad .= '<br>'.l10n('Error_Link_Dead').$Compteur['nbr_dead']; |
---|
252 | |
---|
253 | if ( !is_adviser() ) |
---|
254 | { |
---|
255 | $msg_error_Link_Bad .= ' <a href="'; |
---|
256 | |
---|
257 | $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array( |
---|
258 | 'action' => 'link_dead', |
---|
259 | )); |
---|
260 | |
---|
261 | $msg_error_Link_Bad .= '" title="'.l10n('Link_Dead').$Compteur['nbr_dead'].'"'; |
---|
262 | |
---|
263 | $msg_error_Link_Bad .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
264 | |
---|
265 | $msg_error_Link_Bad .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/link_delete.png" alt="'.l10n('Link_Dead').$Compteur['nbr_dead'].'" /></a>'; |
---|
266 | } |
---|
267 | } |
---|
268 | |
---|
269 | $query = " |
---|
270 | 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 |
---|
271 | FROM ".FluxBB_USERS_TABLE." AS bb |
---|
272 | INNER JOIN ".Register_FluxBB_ID_TABLE." AS link ON link.id_user_FluxBB = bb.id |
---|
273 | INNER JOIN ".USERS_TABLE." as pwg ON link.id_user_pwg = pwg.id |
---|
274 | GROUP BY link.id_user_pwg, link.id_user_FluxBB |
---|
275 | HAVING COUNT(*) > 1 |
---|
276 | ;"; |
---|
277 | |
---|
278 | $result = pwg_query($query); |
---|
279 | |
---|
280 | while($row = pwg_db_fetch_assoc($result)) |
---|
281 | { |
---|
282 | $msg_error_Link_Bad .= '<br>'.l10n('Error_Link_Dup').$row['nbr_dup'].' = '.stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).')'; |
---|
283 | |
---|
284 | if ( !is_adviser() ) |
---|
285 | { |
---|
286 | $msg_error_Link_Bad .= ' <a href="'; |
---|
287 | |
---|
288 | $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array( |
---|
289 | 'action' => 'new_link', |
---|
290 | 'pwg_id' => $row['pwg_id'], |
---|
291 | 'bb_id' => $row['bb_id'], |
---|
292 | )); |
---|
293 | |
---|
294 | $msg_error_Link_Bad .= '" title="'.l10n('Link_Dup').stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).'"'; |
---|
295 | |
---|
296 | $msg_error_Link_Bad .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
297 | |
---|
298 | $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>'; |
---|
299 | } |
---|
300 | } |
---|
301 | |
---|
302 | if ($msg_error_Link_Bad == '') |
---|
303 | array_push($page['infos'], l10n('Audit_Link_Bad').'<br>'.l10n('Audit_OK')); |
---|
304 | else |
---|
305 | $msg_error_Link_Bad = l10n('Audit_Link_Bad').$msg_error_Link_Bad; |
---|
306 | |
---|
307 | |
---|
308 | |
---|
309 | $query = " |
---|
310 | 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 |
---|
311 | FROM ".FluxBB_USERS_TABLE." AS FluxBB |
---|
312 | INNER JOIN ".Register_FluxBB_ID_TABLE." AS link ON link.id_user_FluxBB = FluxBB.id |
---|
313 | INNER JOIN ".USERS_TABLE." as pwg ON link.id_user_pwg = pwg.id |
---|
314 | AND BINARY pwg.username = BINARY FluxBB.username |
---|
315 | ORDER BY LOWER(pwg.username) |
---|
316 | ;"; |
---|
317 | |
---|
318 | $result = pwg_query($query); |
---|
319 | |
---|
320 | while($row = pwg_db_fetch_assoc($result)) |
---|
321 | { |
---|
322 | if ( ($row['pwg_pwd'] != $row['bb_pwd']) or ($row['pwg_eml'] != $row['bb_eml']) ) |
---|
323 | { |
---|
324 | $msg_error_Synchro .= '<br>'.l10n('Error_Synchro').stripslashes($row['username']); |
---|
325 | |
---|
326 | if ( !is_adviser() ) |
---|
327 | { |
---|
328 | $msg_error_Synchro .= ' <a href="'; |
---|
329 | |
---|
330 | $msg_error_Synchro .= add_url_params($page_Register_FluxBB_admin, array( |
---|
331 | 'action' => 'sync_user', |
---|
332 | 'username' => stripslashes($row['username']), |
---|
333 | )); |
---|
334 | |
---|
335 | $msg_error_Synchro .= '" title="'.l10n('Sync_User').stripslashes($row['username']).'"'; |
---|
336 | |
---|
337 | $msg_error_Synchro .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
338 | $msg_error_Synchro .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_refresh.png" alt="'.l10n('Sync_User').stripslashes($row['username']).'" /></a>'; |
---|
339 | } |
---|
340 | |
---|
341 | if ($row['pwg_pwd'] != $row['bb_pwd']) |
---|
342 | $msg_error_Synchro .= '<br>'.l10n('Error_Synchro_Pswd'); |
---|
343 | |
---|
344 | if ($row['pwg_eml'] != $row['bb_eml']) |
---|
345 | $msg_error_Synchro .= '<br>'.l10n('Error_Synchro_Mail').'<br>-- PWG = '.$row['pwg_eml'].'<br>-- FluxBB = '.$row['bb_eml']; |
---|
346 | } |
---|
347 | else if ($conf_Register_FluxBB[5] == 'true') |
---|
348 | $msg_ok_Synchro .= '<br> - '.stripslashes($row['username']).' ('.$row['pwg_eml'].')'.l10n('Audit_Synchro_OK'); |
---|
349 | } |
---|
350 | |
---|
351 | if ($msg_error_Synchro <> '') |
---|
352 | $msg_error_Synchro = l10n('Audit_Synchro').$msg_error_Synchro; |
---|
353 | |
---|
354 | if ($msg_ok_Synchro <> '') |
---|
355 | if ($msg_error_Synchro <> '') |
---|
356 | array_push($page['infos'], l10n('Audit_Synchro').$msg_ok_Synchro.'<br><br>'); |
---|
357 | else |
---|
358 | array_push($page['infos'], l10n('Audit_Synchro').$msg_ok_Synchro.'<br><br>'.l10n('Audit_OK')); |
---|
359 | |
---|
360 | |
---|
361 | $query = " |
---|
362 | SELECT username, mail_address FROM ".USERS_TABLE." |
---|
363 | WHERE BINARY username <> BINARY 'guest' |
---|
364 | AND id not in ( |
---|
365 | SELECT id_user_pwg FROM ".Register_FluxBB_ID_TABLE." |
---|
366 | ) |
---|
367 | AND BINARY username not in ( |
---|
368 | SELECT username FROM ".FluxBB_USERS_TABLE." |
---|
369 | ) |
---|
370 | ORDER BY LOWER(username) |
---|
371 | ;"; |
---|
372 | |
---|
373 | $result = pwg_query($query); |
---|
374 | |
---|
375 | while($row = pwg_db_fetch_assoc($result)) |
---|
376 | { |
---|
377 | $msg_error_PWG2FluxBB .= '<br>'.l10n('Error_PWG2FluxBB').stripslashes($row['username']).' ('.$row['mail_address'].')'; |
---|
378 | |
---|
379 | if ( !is_adviser() ) |
---|
380 | { |
---|
381 | $msg_error_PWG2FluxBB .= ' <a href="'; |
---|
382 | |
---|
383 | $msg_error_PWG2FluxBB .= add_url_params($page_Register_FluxBB_admin, array( |
---|
384 | 'action' => 'add_user', |
---|
385 | 'username' => stripslashes($row['username']), |
---|
386 | )); |
---|
387 | |
---|
388 | $msg_error_PWG2FluxBB .= '" title="'.l10n('Add_User').stripslashes($row['username']).'" '; |
---|
389 | |
---|
390 | $msg_error_PWG2FluxBB .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
391 | |
---|
392 | $msg_error_PWG2FluxBB .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_add.png" alt="'.l10n('Add_User').stripslashes($row['username']).'" /></a>'; |
---|
393 | } |
---|
394 | } |
---|
395 | |
---|
396 | if ($msg_error_PWG2FluxBB == '') |
---|
397 | array_push($page['infos'], l10n('Audit_PWG2FluxBB').'<br>'.l10n('Audit_OK')); |
---|
398 | else |
---|
399 | $msg_error_PWG2FluxBB = l10n('Audit_PWG2FluxBB').$msg_error_PWG2FluxBB; |
---|
400 | |
---|
401 | |
---|
402 | |
---|
403 | $query = " |
---|
404 | SELECT id, username, email FROM ".FluxBB_USERS_TABLE." |
---|
405 | WHERE BINARY username <> BINARY '".$conf_Register_FluxBB[2]."' |
---|
406 | AND id not in ( |
---|
407 | SELECT id_user_FluxBB FROM ".Register_FluxBB_ID_TABLE." |
---|
408 | ) |
---|
409 | AND BINARY username not in ( |
---|
410 | SELECT username FROM ".USERS_TABLE." |
---|
411 | ) |
---|
412 | ORDER BY LOWER(username) |
---|
413 | ;"; |
---|
414 | |
---|
415 | $result = pwg_query($query); |
---|
416 | |
---|
417 | while($row = pwg_db_fetch_assoc($result)) |
---|
418 | { |
---|
419 | $msg_error_FluxBB2PWG .= '<br>'.l10n('Error_FluxBB2PWG').stripslashes($row['username']).' ('.$row['email'].')'; |
---|
420 | |
---|
421 | if ( !is_adviser() ) |
---|
422 | { |
---|
423 | $msg_error_FluxBB2PWG .= ' <a href="'; |
---|
424 | |
---|
425 | $msg_error_FluxBB2PWG .= add_url_params($page_Register_FluxBB_admin, array( |
---|
426 | 'action' => 'del_user', |
---|
427 | 'id' => $row['id'], |
---|
428 | )); |
---|
429 | |
---|
430 | $msg_error_FluxBB2PWG .= '" title="'.l10n('Del_User').stripslashes($row['username']).'"'; |
---|
431 | |
---|
432 | $msg_error_FluxBB2PWG .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
433 | |
---|
434 | $msg_error_FluxBB2PWG .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_delete.png" alt="'.l10n('Del_User').stripslashes($row['username']).'" /></a>'; |
---|
435 | } |
---|
436 | } |
---|
437 | |
---|
438 | if ($msg_error_FluxBB2PWG == '') |
---|
439 | array_push($page['infos'], l10n('Audit_FluxBB2PWG').'<br>'.l10n('Audit_OK')); |
---|
440 | else |
---|
441 | $msg_error_FluxBB2PWG = l10n('Audit_FluxBB2PWG').$msg_error_FluxBB2PWG; |
---|
442 | |
---|
443 | |
---|
444 | |
---|
445 | if ($msg_error_PWG_Dup <> '') |
---|
446 | $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>' ); |
---|
447 | |
---|
448 | if ($msg_error_FluxBB_Dup <> '') |
---|
449 | $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>' ); |
---|
450 | |
---|
451 | if ($msg_error_Link_Break <> '') |
---|
452 | $errors[] = $msg_error_Link_Break . ( ($msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
453 | |
---|
454 | if ($msg_error_Link_Bad <> '') |
---|
455 | $errors[] = $msg_error_Link_Bad . ( ($msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
456 | |
---|
457 | if ($msg_error_Synchro <> '') |
---|
458 | $errors[] = $msg_error_Synchro . ( ($msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
459 | |
---|
460 | if ($msg_error_PWG2FluxBB <> '') |
---|
461 | $errors[] = $msg_error_PWG2FluxBB . ( ($msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
462 | |
---|
463 | if ($msg_error_FluxBB2PWG <> '') |
---|
464 | $errors[] = $msg_error_FluxBB2PWG; |
---|
465 | } |
---|
466 | |
---|
467 | |
---|
468 | |
---|
469 | |
---|
470 | // +-----------------------------------------------------------------------+ |
---|
471 | // | Actions process |
---|
472 | // +-----------------------------------------------------------------------+ |
---|
473 | |
---|
474 | if ( isset($_GET['action']) and ($_GET['action']=='link_dead') and !is_adviser() ) |
---|
475 | { |
---|
476 | $query = " |
---|
477 | DELETE FROM ".Register_FluxBB_ID_TABLE." |
---|
478 | WHERE id_user_FluxBB NOT IN ( |
---|
479 | SELECT id |
---|
480 | FROM ".FluxBB_USERS_TABLE." |
---|
481 | ) |
---|
482 | OR id_user_pwg NOT IN ( |
---|
483 | SELECT id |
---|
484 | FROM ".USERS_TABLE." |
---|
485 | ) |
---|
486 | ;"; |
---|
487 | |
---|
488 | $result = pwg_query($query); |
---|
489 | |
---|
490 | Audit_PWG_FluxBB(); |
---|
491 | } |
---|
492 | else if ( isset($_GET['action']) and ($_GET['action']=='link_del') and isset($_GET['pwg_id']) and isset($_GET['bb_id']) and !is_adviser() ) |
---|
493 | { |
---|
494 | $query = " |
---|
495 | DELETE FROM ".Register_FluxBB_ID_TABLE." |
---|
496 | WHERE id_user_pwg = ".$_GET['pwg_id']." |
---|
497 | AND id_user_FluxBB = ".$_GET['bb_id']." |
---|
498 | ;"; |
---|
499 | |
---|
500 | $result = pwg_query($query); |
---|
501 | |
---|
502 | Audit_PWG_FluxBB(); |
---|
503 | } |
---|
504 | else if ( isset($_GET['action']) and ($_GET['action']=='new_link') and isset($_GET['pwg_id']) and isset($_GET['bb_id']) and !is_adviser() ) |
---|
505 | { |
---|
506 | FluxBB_Linkuser($_GET['pwg_id'], $_GET['bb_id']); |
---|
507 | |
---|
508 | Audit_PWG_FluxBB(); |
---|
509 | } |
---|
510 | else if ( isset($_GET['action']) and ($_GET['action']=='sync_user') and isset($_GET['username']) and !is_adviser() ) |
---|
511 | { |
---|
512 | $query = " |
---|
513 | SELECT id AS id_pwg, username, password, mail_address |
---|
514 | FROM ".USERS_TABLE." |
---|
515 | WHERE BINARY username = BINARY '".pwg_db_real_escape_string($_GET['username'])."' |
---|
516 | LIMIT 1 |
---|
517 | ;"; |
---|
518 | |
---|
519 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
520 | |
---|
521 | if (!empty($data)) |
---|
522 | { |
---|
523 | FluxBB_Updateuser($data['id_pwg'], stripslashes($data['username']), $data['password'], $data['mail_address']); |
---|
524 | } |
---|
525 | |
---|
526 | Audit_PWG_FluxBB(); |
---|
527 | } |
---|
528 | else if ( isset($_GET['action']) and ($_GET['action']=='add_user') and isset($_GET['username']) and !is_adviser() ) |
---|
529 | { |
---|
530 | $query = " |
---|
531 | SELECT id, username, password, mail_address |
---|
532 | FROM ".USERS_TABLE." |
---|
533 | WHERE BINARY username = BINARY '".pwg_db_real_escape_string($_GET['username'])."' |
---|
534 | LIMIT 1 |
---|
535 | ;"; |
---|
536 | |
---|
537 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
538 | |
---|
539 | if (!empty($data)) |
---|
540 | FluxBB_Adduser($data['id'], stripslashes($data['username']), $data['password'], $data['mail_address']); |
---|
541 | |
---|
542 | Audit_PWG_FluxBB(); |
---|
543 | } |
---|
544 | else if ( isset($_GET['action']) and ($_GET['action']=='del_user') and isset($_GET['id']) and !is_adviser() ) |
---|
545 | { |
---|
546 | FluxBB_Deluser( $_GET['id'], true ); |
---|
547 | |
---|
548 | Audit_PWG_FluxBB(); |
---|
549 | } |
---|
550 | |
---|
551 | |
---|
552 | // +-----------------------------------------------------------------------+ |
---|
553 | // | Tabssheet select | |
---|
554 | // +-----------------------------------------------------------------------+ |
---|
555 | |
---|
556 | switch ($page['tab']) |
---|
557 | { |
---|
558 | case 'info': |
---|
559 | |
---|
560 | $template->assign( |
---|
561 | array( |
---|
562 | 'REGFLUXBB_PATH' => REGFLUXBB_PATH, |
---|
563 | 'REGFLUXBB_VERSION' => $version, |
---|
564 | ) |
---|
565 | ); |
---|
566 | |
---|
567 | $template->set_filename('plugin_admin_content', dirname(__FILE__).'/template/info.tpl'); |
---|
568 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
569 | |
---|
570 | break; |
---|
571 | |
---|
572 | case 'manage': |
---|
573 | |
---|
574 | if ( isset($_POST['submit']) and !is_adviser() and isset($_POST['FluxBB_prefix']) and isset($_POST['FluxBB_admin']) and isset($_POST['FluxBB_guest']) and isset($_POST['FluxBB_del_pt']) and isset($_POST['FluxBB_confirm']) and isset($_POST['FluxBB_details']) ) |
---|
575 | { |
---|
576 | $conf['Register_FluxBB'] = $_POST['FluxBB_prefix'].';'.addslashes($_POST['FluxBB_admin']).';'.addslashes($_POST['FluxBB_guest']).';'.$_POST['FluxBB_del_pt'].';'.$_POST['FluxBB_confirm'].';'.$_POST['FluxBB_details']; |
---|
577 | |
---|
578 | $query = ' |
---|
579 | UPDATE '.CONFIG_TABLE.' |
---|
580 | SET value="'.$conf['Register_FluxBB'].'" |
---|
581 | WHERE param="Register_FluxBB" |
---|
582 | LIMIT 1 |
---|
583 | ;'; |
---|
584 | |
---|
585 | pwg_query($query); |
---|
586 | |
---|
587 | array_push($page['infos'], l10n('save_config')); |
---|
588 | } |
---|
589 | |
---|
590 | $conf_Register_FluxBB = isset($conf['Register_FluxBB']) ? explode(";" , $conf['Register_FluxBB']) : array(); |
---|
591 | |
---|
592 | $template->assign( |
---|
593 | array |
---|
594 | ( |
---|
595 | 'REGFLUXBB_PATH' => REGFLUXBB_PATH, |
---|
596 | 'REGFLUXBB_VERSION' => $version, |
---|
597 | 'FluxBB_PREFIX' => $conf_Register_FluxBB[0], |
---|
598 | 'FluxBB_ADMIN' => stripslashes($conf_Register_FluxBB[1]), |
---|
599 | 'FluxBB_GUEST' => stripslashes($conf_Register_FluxBB[2]), |
---|
600 | 'FluxBB_DEL_PT_TRUE' => (isset($conf_Register_FluxBB[3]) and $conf_Register_FluxBB[3] == 'true') ? 'checked="checked"' : '' , |
---|
601 | 'FluxBB_DEL_PT_FALSE' => (isset($conf_Register_FluxBB[3]) and $conf_Register_FluxBB[3] == 'false') ? 'checked="checked"' : '' , |
---|
602 | 'FluxBB_CONFIRM_TRUE' => (isset($conf_Register_FluxBB[4]) and $conf_Register_FluxBB[4] == 'true') ? 'checked="checked"' : '' , |
---|
603 | 'FluxBB_CONFIRM_FALSE' => (isset($conf_Register_FluxBB[4]) and $conf_Register_FluxBB[4] == 'false') ? 'checked="checked"' : '' , |
---|
604 | 'FluxBB_DETAILS_TRUE' => (isset($conf_Register_FluxBB[5]) and $conf_Register_FluxBB[5] == 'true') ? 'checked="checked"' : '' , |
---|
605 | 'FluxBB_DETAILS_FALSE' => (isset($conf_Register_FluxBB[5]) and $conf_Register_FluxBB[5] == 'false') ? 'checked="checked"' : '' , |
---|
606 | ) |
---|
607 | ); |
---|
608 | |
---|
609 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/manage.tpl'); |
---|
610 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
611 | |
---|
612 | break; |
---|
613 | |
---|
614 | case 'Migration': |
---|
615 | |
---|
616 | if ( isset($_POST['Migration']) and !is_adviser() ) |
---|
617 | { |
---|
618 | array_push($page['infos'], l10n('Mig_Start').'<br><br>'); |
---|
619 | |
---|
620 | array_push($page['infos'], l10n('Mig_Del_Link').'<br><br>'); |
---|
621 | |
---|
622 | $query = "TRUNCATE ".Register_FluxBB_ID_TABLE.";"; |
---|
623 | $result = pwg_query($query); |
---|
624 | |
---|
625 | |
---|
626 | $msg_Mig_Del_AllUsers = ''; |
---|
627 | |
---|
628 | $query = " |
---|
629 | SELECT username, id |
---|
630 | FROM ".FluxBB_USERS_TABLE." |
---|
631 | ;"; |
---|
632 | |
---|
633 | $result = pwg_query($query); |
---|
634 | |
---|
635 | while ($row = pwg_db_fetch_assoc($result)) |
---|
636 | { |
---|
637 | if((stripslashes($row['username']) != stripslashes($conf_Register_FluxBB[2])) and (stripslashes($row['username']) != stripslashes($conf_Register_FluxBB[1]))) |
---|
638 | { |
---|
639 | $msg_Mig_Del_AllUsers .= '<br> - '.l10n('Mig_Del_User').stripslashes($row['username']); |
---|
640 | |
---|
641 | FluxBB_Deluser($row['id'], false); |
---|
642 | } |
---|
643 | } |
---|
644 | |
---|
645 | array_push($page['infos'], l10n('Mig_Del_AllUsers').$msg_Mig_Del_AllUsers.'<br><br>'); |
---|
646 | |
---|
647 | |
---|
648 | $query = " |
---|
649 | SELECT id, username, password, mail_address |
---|
650 | FROM ".USERS_TABLE." |
---|
651 | ;"; |
---|
652 | |
---|
653 | $result = pwg_query($query); |
---|
654 | |
---|
655 | $registred = time(); |
---|
656 | $registred_ip = $_SERVER['REMOTE_ADDR']; |
---|
657 | |
---|
658 | $msg_Mig_Add_AllUsers = ''; |
---|
659 | |
---|
660 | while ($row = pwg_db_fetch_assoc($result)) |
---|
661 | { |
---|
662 | if((stripslashes($row['username']) != 'guest') and (stripslashes($row['username']) != stripslashes($conf_Register_FluxBB[1]))) |
---|
663 | { |
---|
664 | $msg_Mig_Add_AllUsers .= '<br> - '.l10n('Mig_Add_User').stripslashes($row['username']); |
---|
665 | |
---|
666 | FluxBB_Adduser($row['id'], stripslashes($row['username']), $row['password'], $row['mail_address']); |
---|
667 | } |
---|
668 | } |
---|
669 | |
---|
670 | array_push($page['infos'], l10n('Mig_Add_AllUsers').$msg_Mig_Add_AllUsers.'<br><br>'); |
---|
671 | |
---|
672 | |
---|
673 | $query = " |
---|
674 | SELECT id, username, password, mail_address |
---|
675 | FROM ".USERS_TABLE." |
---|
676 | WHERE username = '".$conf_Register_FluxBB[1]."' |
---|
677 | ;"; |
---|
678 | |
---|
679 | $row = pwg_db_fetch_assoc(pwg_query($query)); |
---|
680 | |
---|
681 | if (!empty($row)) |
---|
682 | { |
---|
683 | array_push($page['infos'], l10n('Sync_User').stripslashes($row['username']).'<br><br>'); |
---|
684 | |
---|
685 | FluxBB_Updateuser($row['id'], stripslashes($row['username']), $row['password'], $row['mail_address']); |
---|
686 | } |
---|
687 | |
---|
688 | array_push($page['infos'], l10n('Mig_End')); |
---|
689 | } |
---|
690 | else if ( isset($_POST['Audit'])) |
---|
691 | { |
---|
692 | Audit_PWG_FluxBB(); |
---|
693 | } |
---|
694 | |
---|
695 | $template->assign( |
---|
696 | array |
---|
697 | ( |
---|
698 | 'REGFLUXBB_PATH' => REGFLUXBB_PATH, |
---|
699 | 'REGFLUXBB_VERSION' => $version, |
---|
700 | ) |
---|
701 | ); |
---|
702 | |
---|
703 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/migration.tpl'); |
---|
704 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
705 | |
---|
706 | break; |
---|
707 | |
---|
708 | case 'Synchro': |
---|
709 | |
---|
710 | if ( isset($_POST['Synchro']) and !is_adviser() ) |
---|
711 | { |
---|
712 | global $page,$conf, $errors; |
---|
713 | |
---|
714 | $conf_Register_FluxBB = isset($conf['Register_FluxBB']) ? explode(";" , $conf['Register_FluxBB']) : array(); |
---|
715 | |
---|
716 | $page_Register_FluxBB_admin = get_admin_plugin_menu_link(__FILE__); |
---|
717 | |
---|
718 | |
---|
719 | $msg_error_PWG_Dup = ''; |
---|
720 | $msg_error_FluxBB_Dup = ''; |
---|
721 | $msg_error_Link_Break = ''; |
---|
722 | $msg_error_Link_Bad = ''; |
---|
723 | $msg_error_Synchro = ''; |
---|
724 | $msg_ok_Synchro = ''; |
---|
725 | $msg_error_FluxBB2PWG = ''; |
---|
726 | $msg_error_PWG2FluxBB = ''; |
---|
727 | |
---|
728 | |
---|
729 | $query = " |
---|
730 | SELECT COUNT(*) AS nbr_dup, id, username |
---|
731 | FROM ".USERS_TABLE." |
---|
732 | GROUP BY BINARY username |
---|
733 | HAVING COUNT(*) > 1 |
---|
734 | ;"; |
---|
735 | |
---|
736 | $result = pwg_query($query); |
---|
737 | |
---|
738 | while($row = pwg_db_fetch_assoc($result)) |
---|
739 | $msg_error_PWG_Dup .= '<br>'.l10n('Error_PWG_Dup').$row['nbr_dup'].' x '.stripslashes($row['username']); |
---|
740 | |
---|
741 | if ($msg_error_PWG_Dup <> '') |
---|
742 | $msg_error_PWG_Dup = l10n('Audit_PWG_Dup').$msg_error_PWG_Dup.'<br>'.l10n('Advise_PWG_Dup'); |
---|
743 | |
---|
744 | |
---|
745 | $query = " |
---|
746 | SELECT COUNT(*) AS nbr_dup, username |
---|
747 | FROM ".FluxBB_USERS_TABLE." |
---|
748 | GROUP BY BINARY username |
---|
749 | HAVING COUNT(*) > 1 |
---|
750 | ;"; |
---|
751 | |
---|
752 | $result = pwg_query($query); |
---|
753 | |
---|
754 | while($row = pwg_db_fetch_assoc($result)) |
---|
755 | { |
---|
756 | $msg_error_FluxBB_Dup .= '<br>'.l10n('Error_FluxBB_Dup').$row['nbr_dup'].' x '.stripslashes($row['username']); |
---|
757 | |
---|
758 | $subquery = " |
---|
759 | SELECT id, username, email |
---|
760 | FROM ".FluxBB_USERS_TABLE." |
---|
761 | WHERE BINARY username = BINARY '".$row['username']."' |
---|
762 | ;"; |
---|
763 | |
---|
764 | $subresult = pwg_query($subquery); |
---|
765 | |
---|
766 | while($subrow = pwg_db_fetch_assoc($subresult)) |
---|
767 | { |
---|
768 | $msg_error_FluxBB_Dup .= '<br>id:'.$subrow['id'].'='.stripslashes($subrow['username']).' ('.$subrow['email'].')'; |
---|
769 | |
---|
770 | if ( !is_adviser() ) |
---|
771 | { |
---|
772 | $msg_error_FluxBB_Dup .= ' <a href="'; |
---|
773 | |
---|
774 | $msg_error_FluxBB_Dup .= add_url_params($page_Register_FluxBB_admin, array( |
---|
775 | 'action' => 'del_user', |
---|
776 | 'id' => $subrow['id'], |
---|
777 | )); |
---|
778 | |
---|
779 | $msg_error_FluxBB_Dup .= '" title="'.l10n('Del_User').stripslashes($subrow['username']).'"'; |
---|
780 | |
---|
781 | $msg_error_FluxBB_Dup .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
782 | |
---|
783 | $msg_error_FluxBB_Dup .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_delete.png" alt="'.l10n('Del_User').stripslashes($subrow['username']).'" /></a>'; |
---|
784 | } |
---|
785 | } |
---|
786 | } |
---|
787 | |
---|
788 | if ($msg_error_FluxBB_Dup <> '') |
---|
789 | $msg_error_FluxBB_Dup = l10n('Sync_Check_Dup').$msg_error_FluxBB_Dup.'<br>'.l10n('Advise_FluxBB_Dup'); |
---|
790 | |
---|
791 | |
---|
792 | if ($msg_error_FluxBB_Dup == '' and $msg_error_PWG_Dup == '') |
---|
793 | { |
---|
794 | $query = " |
---|
795 | SELECT pwg.id as pwg_id, bb.id as bb_id, pwg.username as pwg_user, pwg.mail_address as pwg_mail |
---|
796 | FROM ".FluxBB_USERS_TABLE." AS bb, ".USERS_TABLE." as pwg |
---|
797 | WHERE bb.id NOT in ( |
---|
798 | SELECT id_user_FluxBB |
---|
799 | FROM ".Register_FluxBB_ID_TABLE." |
---|
800 | ) |
---|
801 | AND pwg.id NOT in ( |
---|
802 | SELECT id_user_pwg |
---|
803 | FROM ".Register_FluxBB_ID_TABLE." |
---|
804 | ) |
---|
805 | AND pwg.username = bb.username |
---|
806 | AND pwg.mail_address = bb.email |
---|
807 | ;"; |
---|
808 | |
---|
809 | $result = pwg_query($query); |
---|
810 | |
---|
811 | while($row = pwg_db_fetch_assoc($result)) |
---|
812 | { |
---|
813 | $msg_error_Link_Break .= '<br>'.l10n('New_Link').stripslashes($row['pwg_user']).' ('.$row['pwg_mail'].')'; |
---|
814 | |
---|
815 | FluxBB_Linkuser($row['pwg_id'], $row['bb_id']); |
---|
816 | } |
---|
817 | |
---|
818 | if ($msg_error_Link_Break == '') |
---|
819 | array_push($page['infos'], l10n('Sync_Link_Break').'<br>'.l10n('Sync_OK')); |
---|
820 | else |
---|
821 | $msg_error_Link_Break = l10n('Sync_Link_Break').$msg_error_Link_Break; |
---|
822 | |
---|
823 | |
---|
824 | $query = " |
---|
825 | 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 |
---|
826 | FROM ".FluxBB_USERS_TABLE." AS bb |
---|
827 | INNER JOIN ".Register_FluxBB_ID_TABLE." AS link ON link.id_user_FluxBB = bb.id |
---|
828 | INNER JOIN ".USERS_TABLE." as pwg ON link.id_user_pwg = pwg.id |
---|
829 | WHERE BINARY pwg.username <> BINARY bb.username |
---|
830 | ;"; |
---|
831 | |
---|
832 | $result = pwg_query($query); |
---|
833 | |
---|
834 | while($row = pwg_db_fetch_assoc($result)) |
---|
835 | { |
---|
836 | $msg_error_Link_Bad .= '<br>'.l10n('Link_Del').stripslashes($row['pwg_user']).' ('.$row['pwg_mail'].')'.' -- '.stripslashes($row['bb_user']).' ('.$row['bb_mail'].')'; |
---|
837 | |
---|
838 | $subquery = " |
---|
839 | DELETE FROM ".Register_FluxBB_ID_TABLE." |
---|
840 | WHERE id_user_pwg = ".$row['pwg_id']." |
---|
841 | AND id_user_FluxBB = ".$row['bb_id']." |
---|
842 | ;"; |
---|
843 | |
---|
844 | $subresult = pwg_query($subquery); |
---|
845 | } |
---|
846 | |
---|
847 | |
---|
848 | $query = " |
---|
849 | SELECT COUNT(*) as nbr_dead |
---|
850 | FROM ".Register_FluxBB_ID_TABLE." AS Link |
---|
851 | WHERE id_user_FluxBB NOT IN ( |
---|
852 | SELECT id |
---|
853 | FROM ".FluxBB_USERS_TABLE." |
---|
854 | ) |
---|
855 | OR id_user_pwg NOT IN ( |
---|
856 | SELECT id |
---|
857 | FROM ".USERS_TABLE." |
---|
858 | ) |
---|
859 | ;"; |
---|
860 | |
---|
861 | $Compteur = pwg_db_fetch_assoc(pwg_query($query)); |
---|
862 | |
---|
863 | if ( !empty($Compteur) and $Compteur['nbr_dead'] > 0) |
---|
864 | { |
---|
865 | $msg_error_Link_Bad .= '<br>'.l10n('Link_Dead').$Compteur['nbr_dead']; |
---|
866 | |
---|
867 | $query = " |
---|
868 | DELETE FROM ".Register_FluxBB_ID_TABLE." |
---|
869 | WHERE id_user_FluxBB NOT IN ( |
---|
870 | SELECT id |
---|
871 | FROM ".FluxBB_USERS_TABLE." |
---|
872 | ) |
---|
873 | OR id_user_pwg NOT IN ( |
---|
874 | SELECT id |
---|
875 | FROM ".USERS_TABLE." |
---|
876 | ) |
---|
877 | ;"; |
---|
878 | |
---|
879 | $result = pwg_query($query); |
---|
880 | } |
---|
881 | |
---|
882 | |
---|
883 | $query = " |
---|
884 | 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 |
---|
885 | FROM ".FluxBB_USERS_TABLE." AS bb |
---|
886 | INNER JOIN ".Register_FluxBB_ID_TABLE." AS link ON link.id_user_FluxBB = bb.id |
---|
887 | INNER JOIN ".USERS_TABLE." as pwg ON link.id_user_pwg = pwg.id |
---|
888 | GROUP BY link.id_user_pwg, link.id_user_FluxBB |
---|
889 | HAVING COUNT(*) > 1 |
---|
890 | ;"; |
---|
891 | |
---|
892 | $result = pwg_query($query); |
---|
893 | |
---|
894 | while($row = pwg_db_fetch_assoc($result)) |
---|
895 | { |
---|
896 | $msg_error_Link_Bad .= '<br>'.l10n('Link_Dup').$row['nbr_dup'].' = '.stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).')'; |
---|
897 | |
---|
898 | FluxBB_Linkuser($row['pwg_id'], $row['bb_id']); |
---|
899 | } |
---|
900 | |
---|
901 | if ($msg_error_Link_Bad == '') |
---|
902 | array_push($page['infos'], l10n('Sync_Link_Bad').'<br>'.l10n('Sync_OK')); |
---|
903 | else |
---|
904 | $msg_error_Link_Bad = l10n('Sync_Link_Bad').$msg_error_Link_Bad; |
---|
905 | |
---|
906 | |
---|
907 | $query = " |
---|
908 | SELECT pwg.id as pwg_id, pwg.username as username, pwg.password as pwg_pwd, pwg.mail_address as pwg_eml, FluxBB.id as bb_id, FluxBB.password as bb_pwd, FluxBB.email as bb_eml |
---|
909 | FROM ".FluxBB_USERS_TABLE." AS FluxBB |
---|
910 | INNER JOIN ".Register_FluxBB_ID_TABLE." AS link ON link.id_user_FluxBB = FluxBB.id |
---|
911 | INNER JOIN ".USERS_TABLE." as pwg ON link.id_user_pwg = pwg.id |
---|
912 | AND BINARY pwg.username = BINARY FluxBB.username |
---|
913 | ORDER BY LOWER(pwg.username) |
---|
914 | ;"; |
---|
915 | |
---|
916 | $result = pwg_query($query); |
---|
917 | |
---|
918 | while($row = pwg_db_fetch_assoc($result)) |
---|
919 | { |
---|
920 | if ( ($row['pwg_pwd'] != $row['bb_pwd']) or ($row['pwg_eml'] != $row['bb_eml']) ) |
---|
921 | { |
---|
922 | $msg_error_Synchro .= '<br>'.l10n('Sync_User').stripslashes($row['username']); |
---|
923 | |
---|
924 | $query = " |
---|
925 | SELECT id, username, password, mail_address |
---|
926 | FROM ".USERS_TABLE." |
---|
927 | WHERE BINARY id = '".$row['pwg_id']."' |
---|
928 | ;"; |
---|
929 | |
---|
930 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
931 | |
---|
932 | if (!empty($data)) |
---|
933 | FluxBB_Updateuser($data['id'], stripslashes($data['username']), $data['password'], $data['mail_address']); |
---|
934 | } |
---|
935 | } |
---|
936 | |
---|
937 | if ($msg_error_Synchro == '') |
---|
938 | array_push($page['infos'], l10n('Sync_DataUser').'<br>'.l10n('Sync_OK')); |
---|
939 | else |
---|
940 | $msg_error_Synchro = l10n('Sync_DataUser').$msg_error_Synchro; |
---|
941 | |
---|
942 | |
---|
943 | $query = " |
---|
944 | SELECT username, mail_address FROM ".USERS_TABLE." |
---|
945 | WHERE BINARY username <> BINARY 'guest' |
---|
946 | AND id not in ( |
---|
947 | SELECT id_user_pwg FROM ".Register_FluxBB_ID_TABLE." |
---|
948 | ) |
---|
949 | AND BINARY username not in ( |
---|
950 | SELECT username FROM ".FluxBB_USERS_TABLE." |
---|
951 | ) |
---|
952 | ORDER BY LOWER(username) |
---|
953 | ;"; |
---|
954 | |
---|
955 | $result = pwg_query($query); |
---|
956 | |
---|
957 | while($row = pwg_db_fetch_assoc($result)) |
---|
958 | { |
---|
959 | $msg_error_PWG2FluxBB .= '<br>'.l10n('Add_User').stripslashes($row['username']).' ('.$row['mail_address'].')'; |
---|
960 | |
---|
961 | $query = " |
---|
962 | SELECT id, username, password, mail_address |
---|
963 | FROM ".USERS_TABLE." |
---|
964 | WHERE BINARY username = BINARY '".$row['username']."' |
---|
965 | LIMIT 1 |
---|
966 | ;"; |
---|
967 | |
---|
968 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
969 | |
---|
970 | if (!empty($data)) |
---|
971 | FluxBB_Adduser($data['id'], stripslashes($data['username']), $data['password'], $data['mail_address']); |
---|
972 | } |
---|
973 | |
---|
974 | if ($msg_error_PWG2FluxBB == '') |
---|
975 | array_push($page['infos'], l10n('Sync_PWG2FluxBB').'<br>'.l10n('Sync_OK')); |
---|
976 | else |
---|
977 | $msg_error_PWG2FluxBB = l10n('Sync_PWG2FluxBB').$msg_error_PWG2FluxBB; |
---|
978 | |
---|
979 | |
---|
980 | $query = " |
---|
981 | SELECT id, username, email FROM ".FluxBB_USERS_TABLE." |
---|
982 | WHERE BINARY username <> BINARY '".$conf_Register_FluxBB[2]."' |
---|
983 | AND id not in ( |
---|
984 | SELECT id_user_FluxBB FROM ".Register_FluxBB_ID_TABLE." |
---|
985 | ) |
---|
986 | AND BINARY username not in ( |
---|
987 | SELECT username FROM ".USERS_TABLE." |
---|
988 | ) |
---|
989 | ORDER BY LOWER(username) |
---|
990 | ;"; |
---|
991 | |
---|
992 | $result = pwg_query($query); |
---|
993 | |
---|
994 | while($row = pwg_db_fetch_assoc($result)) |
---|
995 | { |
---|
996 | $msg_error_FluxBB2PWG .= '<br>'.l10n('Error_FluxBB2PWG').stripslashes($row['username']).' ('.$row['email'].')'; |
---|
997 | |
---|
998 | if ( !is_adviser() ) |
---|
999 | { |
---|
1000 | $msg_error_FluxBB2PWG .= ' <a href="'; |
---|
1001 | |
---|
1002 | $msg_error_FluxBB2PWG .= add_url_params($page_Register_FluxBB_admin, array( |
---|
1003 | 'action' => 'del_user', |
---|
1004 | 'id' => $row['id'], |
---|
1005 | )); |
---|
1006 | |
---|
1007 | $msg_error_FluxBB2PWG .= '" title="'.l10n('Del_User').stripslashes($row['username']).'"'; |
---|
1008 | |
---|
1009 | $msg_error_FluxBB2PWG .= $conf_Register_FluxBB[4]=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
1010 | |
---|
1011 | $msg_error_FluxBB2PWG .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_delete.png" alt="'.l10n('Del_User').stripslashes($row['username']).'" /></a>'; |
---|
1012 | } |
---|
1013 | } |
---|
1014 | |
---|
1015 | if ($msg_error_FluxBB2PWG == '') |
---|
1016 | array_push($page['infos'], l10n('Sync_FluxBB2PWG').'<br>'.l10n('Sync_OK')); |
---|
1017 | else |
---|
1018 | $msg_error_FluxBB2PWG = l10n('Sync_FluxBB2PWG').$msg_error_FluxBB2PWG; |
---|
1019 | } |
---|
1020 | else |
---|
1021 | $errors[] = l10n('Advise_Check_Dup'); |
---|
1022 | |
---|
1023 | |
---|
1024 | if ($msg_error_PWG_Dup <> '') |
---|
1025 | $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>' ); |
---|
1026 | |
---|
1027 | if ($msg_error_FluxBB_Dup <> '') |
---|
1028 | $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>' ); |
---|
1029 | |
---|
1030 | if ($msg_error_Link_Break <> '') |
---|
1031 | $errors[] = $msg_error_Link_Break . ( ($msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
1032 | |
---|
1033 | if ($msg_error_Link_Bad <> '') |
---|
1034 | $errors[] = $msg_error_Link_Bad . ( ($msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
1035 | |
---|
1036 | if ($msg_error_Synchro <> '') |
---|
1037 | $errors[] = $msg_error_Synchro . ( ($msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
1038 | |
---|
1039 | if ($msg_error_PWG2FluxBB <> '') |
---|
1040 | $errors[] = $msg_error_PWG2FluxBB . ( ($msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
1041 | |
---|
1042 | if ($msg_error_FluxBB2PWG <> '') |
---|
1043 | $errors[] = $msg_error_FluxBB2PWG; |
---|
1044 | } |
---|
1045 | else if ( isset($_POST['Audit'])) |
---|
1046 | { |
---|
1047 | Audit_PWG_FluxBB(); |
---|
1048 | } |
---|
1049 | |
---|
1050 | $template->assign( |
---|
1051 | array |
---|
1052 | ( |
---|
1053 | 'REGFLUXBB_PATH' => REGFLUXBB_PATH, |
---|
1054 | 'REGFLUXBB_VERSION' => $version, |
---|
1055 | ) |
---|
1056 | ); |
---|
1057 | |
---|
1058 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/synchro.tpl'); |
---|
1059 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
1060 | |
---|
1061 | break; |
---|
1062 | } |
---|
1063 | ?> |
---|