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