1 | <?php |
---|
2 | |
---|
3 | global $page, $user, $lang, $conf, $template, $errors; |
---|
4 | |
---|
5 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
6 | |
---|
7 | check_status(ACCESS_ADMINISTRATOR); |
---|
8 | |
---|
9 | if(!defined('REGFLUXBB_PATH')) |
---|
10 | { |
---|
11 | define('REGFLUXBB_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
12 | } |
---|
13 | |
---|
14 | include_once (PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
15 | include_once (PHPWG_ROOT_PATH.'/include/constants.php'); |
---|
16 | |
---|
17 | load_language('plugin.lang', REGFLUXBB_PATH); |
---|
18 | |
---|
19 | $conf_Register_FluxBB = unserialize($conf['Register_FluxBB']); |
---|
20 | |
---|
21 | // +-----------------------------------------------------------------------+ |
---|
22 | // | Getting plugin version | |
---|
23 | // +-----------------------------------------------------------------------+ |
---|
24 | $plugin = RegFluxBB_Infos(REGFLUXBB_PATH); |
---|
25 | $version = $plugin['version'] ; |
---|
26 | |
---|
27 | // +-----------------------------------------------------------------------+ |
---|
28 | // | Actions process | |
---|
29 | // +-----------------------------------------------------------------------+ |
---|
30 | if (isset($_GET['action']) and ($_GET['action']=='link_dead')) |
---|
31 | { |
---|
32 | $query = ' |
---|
33 | DELETE FROM '.Register_FluxBB_ID_TABLE.' |
---|
34 | WHERE id_user_FluxBB NOT IN ( |
---|
35 | SELECT id |
---|
36 | FROM '.FluxBB_USERS_TABLE.' |
---|
37 | ) |
---|
38 | OR id_user_pwg NOT IN ( |
---|
39 | SELECT id |
---|
40 | FROM '.USERS_TABLE.' |
---|
41 | ) |
---|
42 | ;'; |
---|
43 | |
---|
44 | $result = pwg_query($query); |
---|
45 | |
---|
46 | Audit_PWG_FluxBB(); |
---|
47 | } |
---|
48 | else if (isset($_GET['action']) and ($_GET['action']=='link_del') and isset($_GET['pwg_id']) and isset($_GET['bb_id'])) |
---|
49 | { |
---|
50 | $query = ' |
---|
51 | DELETE FROM '.Register_FluxBB_ID_TABLE.' |
---|
52 | WHERE id_user_pwg = '.$_GET['pwg_id'].' |
---|
53 | AND id_user_FluxBB = '.$_GET['bb_id'].' |
---|
54 | ;'; |
---|
55 | |
---|
56 | $result = pwg_query($query); |
---|
57 | |
---|
58 | Audit_PWG_FluxBB(); |
---|
59 | } |
---|
60 | else if (isset($_GET['action']) and ($_GET['action']=='new_link') and isset($_GET['pwg_id']) and isset($_GET['bb_id'])) |
---|
61 | { |
---|
62 | FluxBB_Linkuser($_GET['pwg_id'], $_GET['bb_id']); |
---|
63 | |
---|
64 | Audit_PWG_FluxBB(); |
---|
65 | } |
---|
66 | else if (isset($_GET['action']) and ($_GET['action']=='sync_user') and isset($_GET['username'])) |
---|
67 | { |
---|
68 | $query = ' |
---|
69 | SELECT id AS id_pwg, username, password, mail_address |
---|
70 | FROM '.USERS_TABLE.' |
---|
71 | WHERE BINARY username = BINARY "'.pwg_db_real_escape_string($_GET['username']).'" |
---|
72 | AND username NOT IN ("18","16") |
---|
73 | LIMIT 1 |
---|
74 | ;'; |
---|
75 | |
---|
76 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
77 | |
---|
78 | if (!empty($data)) |
---|
79 | { |
---|
80 | FluxBB_Updateuser($data['id_pwg'], stripslashes($data['username']), $data['password'], $data['mail_address']); |
---|
81 | } |
---|
82 | |
---|
83 | Audit_PWG_FluxBB(); |
---|
84 | } |
---|
85 | else if (isset($_GET['action']) and ($_GET['action']=='add_user') and isset($_GET['username'])) |
---|
86 | { |
---|
87 | $query = ' |
---|
88 | SELECT id, username, password, mail_address |
---|
89 | FROM '.USERS_TABLE.' |
---|
90 | WHERE BINARY username = BINARY "'.pwg_db_real_escape_string($_GET['username']).'" |
---|
91 | AND username NOT IN ("18","16") |
---|
92 | LIMIT 1 |
---|
93 | ;'; |
---|
94 | |
---|
95 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
96 | |
---|
97 | if (!empty($data)) |
---|
98 | FluxBB_Adduser($data['id'], stripslashes($data['username']), $data['password'], $data['mail_address']); |
---|
99 | |
---|
100 | Audit_PWG_FluxBB(); |
---|
101 | } |
---|
102 | else if (isset($_GET['action']) and ($_GET['action']=='del_user') and isset($_GET['id'])) |
---|
103 | { |
---|
104 | FluxBB_Deluser( $_GET['id'], true ); |
---|
105 | |
---|
106 | Audit_PWG_FluxBB(); |
---|
107 | } |
---|
108 | |
---|
109 | |
---|
110 | // +------------------------------------------------------------------+ |
---|
111 | // | Plugin settings | |
---|
112 | // +------------------------------------------------------------------+ |
---|
113 | if (isset($_POST['submit']) 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'])) |
---|
114 | { |
---|
115 | $_POST['FluxBB_admin'] = stripslashes($_POST['FluxBB_admin']); |
---|
116 | $_POST['FluxBB_guest'] = stripslashes($_POST['FluxBB_guest']); |
---|
117 | |
---|
118 | /* Configuration controls */ |
---|
119 | // Piwigo's admin username control |
---|
120 | $query = ' |
---|
121 | SELECT username, id |
---|
122 | FROM '.USERS_TABLE.' |
---|
123 | WHERE id = '.$conf['webmaster_id'].' |
---|
124 | ;'; |
---|
125 | |
---|
126 | $pwgadmin = pwg_db_fetch_assoc(pwg_query($query)); |
---|
127 | |
---|
128 | // FluxBB's admin username control |
---|
129 | $query = ' |
---|
130 | SELECT username, id |
---|
131 | FROM '.FluxBB_USERS_TABLE.' |
---|
132 | WHERE id = 2 |
---|
133 | ;'; |
---|
134 | |
---|
135 | $fbbadmin = pwg_db_fetch_assoc(pwg_query($query)); |
---|
136 | |
---|
137 | // FluxBB's Guest username control |
---|
138 | $query = ' |
---|
139 | SELECT username, id |
---|
140 | FROM '.FluxBB_USERS_TABLE.' |
---|
141 | WHERE id = 1 |
---|
142 | ;'; |
---|
143 | |
---|
144 | $fbbguest = pwg_db_fetch_assoc(pwg_query($query)); |
---|
145 | |
---|
146 | // Compute configuration errors |
---|
147 | if (stripslashes($pwgadmin['username']) != $_POST['FluxBB_admin']) |
---|
148 | { |
---|
149 | array_push($page['errors'], l10n('error_config_admin1')); |
---|
150 | } |
---|
151 | if (stripslashes($pwgadmin['username']) != stripslashes($fbbadmin['username'])) |
---|
152 | { |
---|
153 | array_push($page['errors'], l10n('error_config_admin2')); |
---|
154 | } |
---|
155 | if (stripslashes($fbbguest['username']) != stripslashes($_POST['FluxBB_guest'])) |
---|
156 | { |
---|
157 | array_push($page['errors'], l10n('error_config_guest')); |
---|
158 | } |
---|
159 | elseif (count($page['errors']) == 0) |
---|
160 | { |
---|
161 | if (!function_exists('FindAvailableConfirmMailID')) |
---|
162 | { |
---|
163 | $_POST['FluxBB_UAM'] = 'false'; |
---|
164 | $_POST['FluxBB_group'] = '0'; |
---|
165 | |
---|
166 | $newconf_RegFluxBB['REGFLUXBB_VERSION'] = $version; |
---|
167 | $newconf_RegFluxBB['FLUXBB_PREFIX'] = (isset($_POST['FluxBB_prefix']) ? $_POST['FluxBB_prefix'] : ''); |
---|
168 | $newconf_RegFluxBB['FLUXBB_ADMIN'] = (isset($_POST['FluxBB_admin']) ? $_POST['FluxBB_admin'] : ''); |
---|
169 | $newconf_RegFluxBB['FLUXBB_GUEST'] = (isset($_POST['FluxBB_guest']) ? $_POST['FluxBB_guest'] : ''); |
---|
170 | $newconf_RegFluxBB['FLUXBB_DEL_PT'] = (isset($_POST['FluxBB_del_pt']) ? $_POST['FluxBB_del_pt'] : 'false'); |
---|
171 | $newconf_RegFluxBB['FLUXBB_CONFIRM'] = (isset($_POST['FluxBB_confirm']) ? $_POST['FluxBB_confirm'] : 'false'); |
---|
172 | $newconf_RegFluxBB['FLUXBB_DETAIL'] = (isset($_POST['FluxBB_details']) ? $_POST['FluxBB_details'] : 'false'); |
---|
173 | $newconf_RegFluxBB['FLUXBB_UAM_LINK'] = (isset($_POST['FluxBB_UAM']) ? $_POST['FluxBB_UAM'] : 'false'); |
---|
174 | $newconf_RegFluxBB['FLUXBB_GROUP'] = (isset($_POST['FluxBB_group']) ? $_POST['FluxBB_group'] : ''); |
---|
175 | } |
---|
176 | elseif (function_exists('FindAvailableConfirmMailID')) |
---|
177 | { |
---|
178 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
179 | |
---|
180 | if (isset($conf_UAM['CONFIRM_MAIL']) and ($conf_UAM['CONFIRM_MAIL'] == 'true' or $conf_UAM['CONFIRM_MAIL'] == 'local') and isset($conf_UAM['NO_CONFIRM_GROUP']) and $conf_UAM['NO_CONFIRM_GROUP'] != '-1') |
---|
181 | { |
---|
182 | $newconf_RegFluxBB['REGFLUXBB_VERSION'] = $version; |
---|
183 | $newconf_RegFluxBB['FLUXBB_PREFIX'] = (isset($_POST['FluxBB_prefix']) ? $_POST['FluxBB_prefix'] : ''); |
---|
184 | $newconf_RegFluxBB['FLUXBB_ADMIN'] = (isset($_POST['FluxBB_admin']) ? $_POST['FluxBB_admin'] : ''); |
---|
185 | $newconf_RegFluxBB['FLUXBB_GUEST'] = (isset($_POST['FluxBB_guest']) ? $_POST['FluxBB_guest'] : ''); |
---|
186 | $newconf_RegFluxBB['FLUXBB_DEL_PT'] = (isset($_POST['FluxBB_del_pt']) ? $_POST['FluxBB_del_pt'] : 'false'); |
---|
187 | $newconf_RegFluxBB['FLUXBB_CONFIRM'] = (isset($_POST['FluxBB_confirm']) ? $_POST['FluxBB_confirm'] : 'false'); |
---|
188 | $newconf_RegFluxBB['FLUXBB_DETAIL'] = (isset($_POST['FluxBB_details']) ? $_POST['FluxBB_details'] : 'false'); |
---|
189 | $newconf_RegFluxBB['FLUXBB_UAM_LINK'] = (isset($_POST['FluxBB_UAM']) ? $_POST['FluxBB_UAM'] : 'false'); |
---|
190 | $newconf_RegFluxBB['FLUXBB_GROUP'] = (isset($_POST['FluxBB_group']) ? $_POST['FluxBB_group'] : ''); |
---|
191 | } |
---|
192 | else |
---|
193 | { |
---|
194 | $_POST['FluxBB_UAM'] = 'false'; |
---|
195 | $_POST['FluxBB_group'] = '0'; |
---|
196 | |
---|
197 | $newconf_RegFluxBB['REGFLUXBB_VERSION'] = $version; |
---|
198 | $newconf_RegFluxBB['FLUXBB_PREFIX'] = (isset($_POST['FluxBB_prefix']) ? $_POST['FluxBB_prefix'] : ''); |
---|
199 | $newconf_RegFluxBB['FLUXBB_ADMIN'] = (isset($_POST['FluxBB_admin']) ? $_POST['FluxBB_admin'] : ''); |
---|
200 | $newconf_RegFluxBB['FLUXBB_GUEST'] = (isset($_POST['FluxBB_guest']) ? $_POST['FluxBB_guest'] : ''); |
---|
201 | $newconf_RegFluxBB['FLUXBB_DEL_PT'] = (isset($_POST['FluxBB_del_pt']) ? $_POST['FluxBB_del_pt'] : 'false'); |
---|
202 | $newconf_RegFluxBB['FLUXBB_CONFIRM'] = (isset($_POST['FluxBB_confirm']) ? $_POST['FluxBB_confirm'] : 'false'); |
---|
203 | $newconf_RegFluxBB['FLUXBB_DETAIL'] = (isset($_POST['FluxBB_details']) ? $_POST['FluxBB_details'] : 'false'); |
---|
204 | $newconf_RegFluxBB['FLUXBB_UAM_LINK'] = (isset($_POST['FluxBB_UAM']) ? $_POST['FluxBB_UAM'] : 'false'); |
---|
205 | $newconf_RegFluxBB['FLUXBB_GROUP'] = (isset($_POST['FluxBB_group']) ? $_POST['FluxBB_group'] : ''); |
---|
206 | } |
---|
207 | } |
---|
208 | |
---|
209 | $conf['Register_FluxBB'] = serialize($newconf_RegFluxBB); |
---|
210 | |
---|
211 | conf_update_param('Register_FluxBB', pwg_db_real_escape_string($conf['Register_FluxBB'])); |
---|
212 | |
---|
213 | array_push($page['infos'], l10n('save_config')); |
---|
214 | } |
---|
215 | } |
---|
216 | |
---|
217 | |
---|
218 | // +------------------------------------------------------------+ |
---|
219 | // | Migration and Audit | |
---|
220 | // +------------------------------------------------------------+ |
---|
221 | if (isset($_POST['Migration'])) |
---|
222 | { |
---|
223 | array_push($page['infos'], l10n('Mig_Start').'<br><br>'); |
---|
224 | |
---|
225 | array_push($page['infos'], l10n('Mig_Del_Link').'<br><br>'); |
---|
226 | |
---|
227 | $query = 'TRUNCATE '.Register_FluxBB_ID_TABLE.';'; |
---|
228 | $result = pwg_query($query); |
---|
229 | |
---|
230 | $msg_Mig_Del_AllUsers = ''; |
---|
231 | |
---|
232 | $query = ' |
---|
233 | SELECT username, id |
---|
234 | FROM '.FluxBB_USERS_TABLE.' |
---|
235 | ;'; |
---|
236 | |
---|
237 | $result = pwg_query($query); |
---|
238 | |
---|
239 | while ($row = pwg_db_fetch_assoc($result)) |
---|
240 | { |
---|
241 | if((stripslashes($row['username']) != stripslashes($conf_Register_FluxBB['FLUXBB_GUEST'])) and (stripslashes($row['username']) != stripslashes($conf_Register_FluxBB['FLUXBB_ADMIN']))) |
---|
242 | { |
---|
243 | $msg_Mig_Del_AllUsers .= '<br> - '.l10n('Mig_Del_User').stripslashes($row['username']); |
---|
244 | |
---|
245 | FluxBB_Deluser($row['id'], false); |
---|
246 | } |
---|
247 | } |
---|
248 | |
---|
249 | array_push($page['infos'], l10n('Mig_Del_AllUsers').$msg_Mig_Del_AllUsers.'<br><br>'); |
---|
250 | |
---|
251 | $query = ' |
---|
252 | SELECT id, username, password, mail_address |
---|
253 | FROM '.USERS_TABLE.' |
---|
254 | WHERE username NOT IN ("18","16") |
---|
255 | ;'; |
---|
256 | |
---|
257 | $result = pwg_query($query); |
---|
258 | |
---|
259 | $registred = time(); |
---|
260 | $registred_ip = $_SERVER['REMOTE_ADDR']; |
---|
261 | |
---|
262 | $msg_Mig_Add_AllUsers = ''; |
---|
263 | |
---|
264 | while ($row = pwg_db_fetch_assoc($result)) |
---|
265 | { |
---|
266 | if((stripslashes($row['username']) != 'guest') and (stripslashes($row['username']) != stripslashes($conf_Register_FluxBB['FLUXBB_ADMIN']))) |
---|
267 | { |
---|
268 | $msg_Mig_Add_AllUsers .= '<br> - '.l10n('Mig_Add_User').stripslashes($row['username']); |
---|
269 | |
---|
270 | FluxBB_Adduser($row['id'], stripslashes($row['username']), $row['password'], $row['mail_address']); |
---|
271 | } |
---|
272 | } |
---|
273 | |
---|
274 | array_push($page['infos'], l10n('Mig_Add_AllUsers').$msg_Mig_Add_AllUsers.'<br><br>'); |
---|
275 | |
---|
276 | $query = ' |
---|
277 | SELECT id, username, password, mail_address |
---|
278 | FROM '.USERS_TABLE.' |
---|
279 | WHERE username = "'.$conf_Register_FluxBB['FLUXBB_ADMIN'].'" |
---|
280 | AND username NOT IN ("18","16") |
---|
281 | ;'; |
---|
282 | |
---|
283 | $row = pwg_db_fetch_assoc(pwg_query($query)); |
---|
284 | |
---|
285 | if (!empty($row)) |
---|
286 | { |
---|
287 | array_push($page['infos'], l10n('Sync_User').stripslashes($row['username']).'<br><br>'); |
---|
288 | |
---|
289 | FluxBB_Updateuser($row['id'], stripslashes($row['username']), $row['password'], $row['mail_address']); |
---|
290 | } |
---|
291 | |
---|
292 | array_push($page['infos'], l10n('Mig_End')); |
---|
293 | } |
---|
294 | else if (isset($_POST['Audit'])) |
---|
295 | { |
---|
296 | Audit_PWG_FluxBB(); |
---|
297 | } |
---|
298 | |
---|
299 | |
---|
300 | // +--------------------------------------------------------+ |
---|
301 | // | Synch and Audit | |
---|
302 | // +--------------------------------------------------------+ |
---|
303 | if ( isset($_POST['Synchro'])) |
---|
304 | { |
---|
305 | $page_Register_FluxBB_admin = get_admin_plugin_menu_link(__FILE__); |
---|
306 | |
---|
307 | $msg_error_PWG_Dup = ''; |
---|
308 | $msg_error_FluxBB_Dup = ''; |
---|
309 | $msg_error_Link_Break = ''; |
---|
310 | $msg_error_Link_Bad = ''; |
---|
311 | $msg_error_Synchro = ''; |
---|
312 | $msg_ok_Synchro = ''; |
---|
313 | $msg_error_FluxBB2PWG = ''; |
---|
314 | $msg_error_PWG2FluxBB = ''; |
---|
315 | |
---|
316 | |
---|
317 | $query = ' |
---|
318 | SELECT COUNT(*) AS nbr_dup, id, username |
---|
319 | FROM '.USERS_TABLE.' |
---|
320 | WHERE username NOT IN ("18","16") |
---|
321 | GROUP BY BINARY username |
---|
322 | HAVING COUNT(*) > 1 |
---|
323 | ;'; |
---|
324 | |
---|
325 | $result = pwg_query($query); |
---|
326 | |
---|
327 | while($row = pwg_db_fetch_assoc($result)) |
---|
328 | $msg_error_PWG_Dup .= '<br>'.l10n('Error_PWG_Dup').$row['nbr_dup'].' x '.stripslashes($row['username']); |
---|
329 | |
---|
330 | if ($msg_error_PWG_Dup <> '') |
---|
331 | $msg_error_PWG_Dup = l10n('Audit_PWG_Dup').$msg_error_PWG_Dup.'<br>'.l10n('Advise_PWG_Dup'); |
---|
332 | |
---|
333 | $query = ' |
---|
334 | SELECT COUNT(*) AS nbr_dup, username |
---|
335 | FROM '.FluxBB_USERS_TABLE.' |
---|
336 | GROUP BY BINARY username |
---|
337 | HAVING COUNT(*) > 1 |
---|
338 | ;'; |
---|
339 | |
---|
340 | $result = pwg_query($query); |
---|
341 | |
---|
342 | while($row = pwg_db_fetch_assoc($result)) |
---|
343 | { |
---|
344 | $msg_error_FluxBB_Dup .= '<br>'.l10n('Error_FluxBB_Dup').$row['nbr_dup'].' x '.stripslashes($row['username']); |
---|
345 | |
---|
346 | $subquery = ' |
---|
347 | SELECT id, username, email |
---|
348 | FROM '.FluxBB_USERS_TABLE.' |
---|
349 | WHERE BINARY username = BINARY "'.$row['username'].'" |
---|
350 | ;'; |
---|
351 | |
---|
352 | $subresult = pwg_query($subquery); |
---|
353 | |
---|
354 | while($subrow = pwg_db_fetch_assoc($subresult)) |
---|
355 | { |
---|
356 | $msg_error_FluxBB_Dup .= '<br>id:'.$subrow['id'].'='.stripslashes($subrow['username']).' ('.$subrow['email'].')'; |
---|
357 | |
---|
358 | $msg_error_FluxBB_Dup .= ' <a href="'; |
---|
359 | |
---|
360 | $msg_error_FluxBB_Dup .= add_url_params($page_Register_FluxBB_admin, array( |
---|
361 | 'action' => 'del_user', |
---|
362 | 'id' => $subrow['id'], |
---|
363 | )); |
---|
364 | |
---|
365 | $msg_error_FluxBB_Dup .= '" title="'.l10n('Del_User').stripslashes($subrow['username']).'"'; |
---|
366 | |
---|
367 | $msg_error_FluxBB_Dup .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
368 | |
---|
369 | $msg_error_FluxBB_Dup .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_delete.png" alt="'.l10n('Del_User').stripslashes($subrow['username']).'" /></a>'; |
---|
370 | } |
---|
371 | } |
---|
372 | |
---|
373 | if ($msg_error_FluxBB_Dup <> '') |
---|
374 | $msg_error_FluxBB_Dup = l10n('Sync_Check_Dup').$msg_error_FluxBB_Dup.'<br>'.l10n('Advise_FluxBB_Dup'); |
---|
375 | |
---|
376 | if ($msg_error_FluxBB_Dup == '' and $msg_error_PWG_Dup == '') |
---|
377 | { |
---|
378 | $query = ' |
---|
379 | SELECT pwg.id as pwg_id, bb.id as bb_id, pwg.username as pwg_user, pwg.mail_address as pwg_mail |
---|
380 | FROM '.FluxBB_USERS_TABLE.' AS bb, '.USERS_TABLE.' as pwg |
---|
381 | WHERE bb.id NOT in ( |
---|
382 | SELECT id_user_FluxBB |
---|
383 | FROM '.Register_FluxBB_ID_TABLE.' |
---|
384 | ) |
---|
385 | AND pwg.id NOT in ( |
---|
386 | SELECT id_user_pwg |
---|
387 | FROM '.Register_FluxBB_ID_TABLE.' |
---|
388 | ) |
---|
389 | AND pwg.username = bb.username |
---|
390 | AND pwg.username NOT IN ("18","16") |
---|
391 | AND pwg.mail_address = bb.email |
---|
392 | ;'; |
---|
393 | |
---|
394 | $result = pwg_query($query); |
---|
395 | |
---|
396 | while($row = pwg_db_fetch_assoc($result)) |
---|
397 | { |
---|
398 | $msg_error_Link_Break .= '<br>'.l10n('New_Link').stripslashes($row['pwg_user']).' ('.$row['pwg_mail'].')'; |
---|
399 | FluxBB_Linkuser($row['pwg_id'], $row['bb_id']); |
---|
400 | } |
---|
401 | |
---|
402 | if ($msg_error_Link_Break == '') |
---|
403 | array_push($page['infos'], l10n('Sync_Link_Break').'<br>'.l10n('Sync_OK')); |
---|
404 | else |
---|
405 | $msg_error_Link_Break = l10n('Sync_Link_Break').$msg_error_Link_Break; |
---|
406 | |
---|
407 | $query = ' |
---|
408 | 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 |
---|
409 | FROM '.FluxBB_USERS_TABLE.' AS bb |
---|
410 | INNER JOIN '.Register_FluxBB_ID_TABLE.' AS link ON link.id_user_FluxBB = bb.id |
---|
411 | INNER JOIN '.USERS_TABLE.' as pwg ON link.id_user_pwg = pwg.id |
---|
412 | WHERE BINARY pwg.username <> BINARY bb.username |
---|
413 | AND pwg.username NOT IN ("18","16") |
---|
414 | ;'; |
---|
415 | |
---|
416 | $result = pwg_query($query); |
---|
417 | |
---|
418 | while($row = pwg_db_fetch_assoc($result)) |
---|
419 | { |
---|
420 | $msg_error_Link_Bad .= '<br>'.l10n('Link_Del').stripslashes($row['pwg_user']).' ('.$row['pwg_mail'].')'.' -- '.stripslashes($row['bb_user']).' ('.$row['bb_mail'].')'; |
---|
421 | |
---|
422 | $subquery = ' |
---|
423 | DELETE FROM '.Register_FluxBB_ID_TABLE.' |
---|
424 | WHERE id_user_pwg = '.$row['pwg_id'].' |
---|
425 | AND id_user_FluxBB = '.$row['bb_id'].' |
---|
426 | ;'; |
---|
427 | |
---|
428 | $subresult = pwg_query($subquery); |
---|
429 | } |
---|
430 | |
---|
431 | $query = ' |
---|
432 | SELECT COUNT(*) as nbr_dead |
---|
433 | FROM '.Register_FluxBB_ID_TABLE.' AS Link |
---|
434 | WHERE id_user_FluxBB NOT IN ( |
---|
435 | SELECT id |
---|
436 | FROM '.FluxBB_USERS_TABLE.' |
---|
437 | ) |
---|
438 | OR id_user_pwg NOT IN ( |
---|
439 | SELECT id |
---|
440 | FROM '.USERS_TABLE.' |
---|
441 | ) |
---|
442 | ;'; |
---|
443 | |
---|
444 | $Compteur = pwg_db_fetch_assoc(pwg_query($query)); |
---|
445 | |
---|
446 | if (!empty($Compteur) and $Compteur['nbr_dead'] > 0) |
---|
447 | { |
---|
448 | $msg_error_Link_Bad .= '<br>'.l10n('Link_Dead').$Compteur['nbr_dead']; |
---|
449 | |
---|
450 | $query = ' |
---|
451 | DELETE FROM '.Register_FluxBB_ID_TABLE.' |
---|
452 | WHERE id_user_FluxBB NOT IN ( |
---|
453 | SELECT id |
---|
454 | FROM '.FluxBB_USERS_TABLE.' |
---|
455 | ) |
---|
456 | OR id_user_pwg NOT IN ( |
---|
457 | SELECT id |
---|
458 | FROM '.USERS_TABLE.' |
---|
459 | ) |
---|
460 | ;'; |
---|
461 | |
---|
462 | $result = pwg_query($query); |
---|
463 | } |
---|
464 | |
---|
465 | $query = ' |
---|
466 | 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 |
---|
467 | FROM '.FluxBB_USERS_TABLE.' AS bb |
---|
468 | INNER JOIN '.Register_FluxBB_ID_TABLE.' AS link ON link.id_user_FluxBB = bb.id |
---|
469 | INNER JOIN '.USERS_TABLE.' as pwg ON link.id_user_pwg = pwg.id |
---|
470 | WHERE pwg.username NOT IN ("18","16") |
---|
471 | GROUP BY link.id_user_pwg, link.id_user_FluxBB |
---|
472 | HAVING COUNT(*) > 1 |
---|
473 | ;'; |
---|
474 | |
---|
475 | $result = pwg_query($query); |
---|
476 | |
---|
477 | while($row = pwg_db_fetch_assoc($result)) |
---|
478 | { |
---|
479 | $msg_error_Link_Bad .= '<br>'.l10n('Link_Dup').$row['nbr_dup'].' = '.stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).')'; |
---|
480 | |
---|
481 | FluxBB_Linkuser($row['pwg_id'], $row['bb_id']); |
---|
482 | } |
---|
483 | |
---|
484 | if ($msg_error_Link_Bad == '') |
---|
485 | array_push($page['infos'], l10n('Sync_Link_Bad').'<br>'.l10n('Sync_OK')); |
---|
486 | else |
---|
487 | $msg_error_Link_Bad = l10n('Sync_Link_Bad').$msg_error_Link_Bad; |
---|
488 | |
---|
489 | $query = ' |
---|
490 | 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 |
---|
491 | FROM '.FluxBB_USERS_TABLE.' AS FluxBB |
---|
492 | INNER JOIN '.Register_FluxBB_ID_TABLE.' AS link ON link.id_user_FluxBB = FluxBB.id |
---|
493 | INNER JOIN '.USERS_TABLE.' as pwg ON link.id_user_pwg = pwg.id |
---|
494 | AND BINARY pwg.username = BINARY FluxBB.username |
---|
495 | ORDER BY LOWER(pwg.username) |
---|
496 | ;'; |
---|
497 | |
---|
498 | $result = pwg_query($query); |
---|
499 | |
---|
500 | while($row = pwg_db_fetch_assoc($result)) |
---|
501 | { |
---|
502 | if ( ($row['pwg_pwd'] != $row['bb_pwd']) or ($row['pwg_eml'] != $row['bb_eml']) ) |
---|
503 | { |
---|
504 | $msg_error_Synchro .= '<br>'.l10n('Sync_User').stripslashes($row['username']); |
---|
505 | |
---|
506 | $query = ' |
---|
507 | SELECT id, username, password, mail_address |
---|
508 | FROM '.USERS_TABLE.' |
---|
509 | WHERE BINARY id = "'.$row['pwg_id'].'" |
---|
510 | AND "'.$row['username'].'" NOT IN ("18","16") |
---|
511 | ;'; |
---|
512 | |
---|
513 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
514 | |
---|
515 | if (!empty($data)) |
---|
516 | FluxBB_Updateuser($data['id'], stripslashes($data['username']), $data['password'], $data['mail_address']); |
---|
517 | } |
---|
518 | } |
---|
519 | |
---|
520 | if ($msg_error_Synchro == '') |
---|
521 | array_push($page['infos'], l10n('Sync_DataUser').'<br>'.l10n('Sync_OK')); |
---|
522 | else |
---|
523 | $msg_error_Synchro = l10n('Sync_DataUser').$msg_error_Synchro; |
---|
524 | |
---|
525 | $query = ' |
---|
526 | SELECT username, mail_address FROM '.USERS_TABLE.' |
---|
527 | WHERE BINARY username <> BINARY "guest" |
---|
528 | AND username NOT IN ("18","16") |
---|
529 | AND id not in ( |
---|
530 | SELECT id_user_pwg FROM '.Register_FluxBB_ID_TABLE.' |
---|
531 | ) |
---|
532 | AND BINARY username not in ( |
---|
533 | SELECT username FROM '.FluxBB_USERS_TABLE.' |
---|
534 | ) |
---|
535 | ORDER BY LOWER(username) |
---|
536 | ;'; |
---|
537 | |
---|
538 | $result = pwg_query($query); |
---|
539 | |
---|
540 | while($row = pwg_db_fetch_assoc($result)) |
---|
541 | { |
---|
542 | $msg_error_PWG2FluxBB .= '<br>'.l10n('Add_User').stripslashes($row['username']).' ('.$row['mail_address'].')'; |
---|
543 | |
---|
544 | $query = ' |
---|
545 | SELECT id, username, password, mail_address |
---|
546 | FROM '.USERS_TABLE.' |
---|
547 | WHERE BINARY username = BINARY "'.$row['username'].'" |
---|
548 | AND username NOT IN ("18","16") |
---|
549 | LIMIT 1 |
---|
550 | ;'; |
---|
551 | |
---|
552 | $data = pwg_db_fetch_assoc(pwg_query($query)); |
---|
553 | |
---|
554 | if (!empty($data)) |
---|
555 | FluxBB_Adduser($data['id'], stripslashes($data['username']), $data['password'], $data['mail_address']); |
---|
556 | } |
---|
557 | |
---|
558 | if ($msg_error_PWG2FluxBB == '') |
---|
559 | array_push($page['infos'], l10n('Sync_PWG2FluxBB').'<br>'.l10n('Sync_OK')); |
---|
560 | else |
---|
561 | $msg_error_PWG2FluxBB = l10n('Sync_PWG2FluxBB').$msg_error_PWG2FluxBB; |
---|
562 | |
---|
563 | $query = ' |
---|
564 | SELECT id, username, email FROM '.FluxBB_USERS_TABLE.' |
---|
565 | WHERE BINARY username <> BINARY "'.$conf_Register_FluxBB['FLUXBB_GUEST'].'" |
---|
566 | AND id not in ( |
---|
567 | SELECT id_user_FluxBB FROM '.Register_FluxBB_ID_TABLE.' |
---|
568 | ) |
---|
569 | AND BINARY username not in ( |
---|
570 | SELECT username FROM '.USERS_TABLE.' |
---|
571 | ) |
---|
572 | ORDER BY LOWER(username) |
---|
573 | ;'; |
---|
574 | |
---|
575 | $result = pwg_query($query); |
---|
576 | |
---|
577 | while($row = pwg_db_fetch_assoc($result)) |
---|
578 | { |
---|
579 | $msg_error_FluxBB2PWG .= '<br>'.l10n('Error_FluxBB2PWG').stripslashes($row['username']).' ('.$row['email'].')'; |
---|
580 | $msg_error_FluxBB2PWG .= ' <a href="'; |
---|
581 | $msg_error_FluxBB2PWG .= add_url_params($page_Register_FluxBB_admin, array( |
---|
582 | 'action' => 'del_user', |
---|
583 | 'id' => $row['id'], |
---|
584 | )); |
---|
585 | |
---|
586 | $msg_error_FluxBB2PWG .= '" title="'.l10n('Del_User').stripslashes($row['username']).'"'; |
---|
587 | |
---|
588 | $msg_error_FluxBB2PWG .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ? ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' '; |
---|
589 | |
---|
590 | $msg_error_FluxBB2PWG .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_delete.png" alt="'.l10n('Del_User').stripslashes($row['username']).'" /></a>'; |
---|
591 | } |
---|
592 | |
---|
593 | if ($msg_error_FluxBB2PWG == '') |
---|
594 | array_push($page['infos'], l10n('Sync_FluxBB2PWG').'<br>'.l10n('Sync_OK')); |
---|
595 | else |
---|
596 | $msg_error_FluxBB2PWG = l10n('Sync_FluxBB2PWG').$msg_error_FluxBB2PWG; |
---|
597 | } |
---|
598 | else |
---|
599 | $errors[] = l10n('Advise_Check_Dup'); |
---|
600 | |
---|
601 | if ($msg_error_PWG_Dup <> '') |
---|
602 | $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>' ); |
---|
603 | |
---|
604 | if ($msg_error_FluxBB_Dup <> '') |
---|
605 | $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>' ); |
---|
606 | |
---|
607 | if ($msg_error_Link_Break <> '') |
---|
608 | $errors[] = $msg_error_Link_Break . ( ($msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
609 | |
---|
610 | if ($msg_error_Link_Bad <> '') |
---|
611 | $errors[] = $msg_error_Link_Bad . ( ($msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
612 | |
---|
613 | if ($msg_error_Synchro <> '') |
---|
614 | $errors[] = $msg_error_Synchro . ( ($msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
615 | |
---|
616 | if ($msg_error_PWG2FluxBB <> '') |
---|
617 | $errors[] = $msg_error_PWG2FluxBB . ( ($msg_error_FluxBB2PWG == '') ? '' : '<br><br>' ); |
---|
618 | |
---|
619 | if ($msg_error_FluxBB2PWG <> '') |
---|
620 | $errors[] = $msg_error_FluxBB2PWG; |
---|
621 | } |
---|
622 | else if ( isset($_POST['Audit'])) |
---|
623 | { |
---|
624 | Audit_PWG_FluxBB(); |
---|
625 | } |
---|
626 | |
---|
627 | |
---|
628 | // +---------------------------------------------------------------+ |
---|
629 | // | Template init | |
---|
630 | // +---------------------------------------------------------------+ |
---|
631 | $conf_Register_FluxBB = unserialize($conf['Register_FluxBB']); |
---|
632 | |
---|
633 | // If UAM exists and if UAM ConfirmMail is set, we can set this feature |
---|
634 | if (function_exists('FindAvailableConfirmMailID')) |
---|
635 | { |
---|
636 | $conf_UAM = unserialize($conf['UserAdvManager']); |
---|
637 | |
---|
638 | if (isset($conf_UAM['CONFIRM_MAIL']) and ($conf_UAM['CONFIRM_MAIL'] == 'true' or $conf_UAM['CONFIRM_MAIL'] == 'local') and (isset($conf_UAM['NO_CONFIRM_GROUP']) and $conf_UAM['NO_CONFIRM_GROUP'] <> '-1')) |
---|
639 | { |
---|
640 | $UAM_bridge = true; |
---|
641 | } |
---|
642 | else $UAM_bridge = false; |
---|
643 | } |
---|
644 | else $UAM_bridge = false; |
---|
645 | |
---|
646 | // Save last opened paragraph in configuration tab |
---|
647 | // ----------------------------------------------- |
---|
648 | $nb_para=(isset($_POST["nb_para"])) ? $_POST["nb_para"]:""; |
---|
649 | $nb_para2=(isset($_POST["nb_para2"])) ? $_POST["nb_para2"]:""; |
---|
650 | |
---|
651 | $themeconf=$template->get_template_vars('themeconf'); |
---|
652 | $RFBB_theme=$themeconf['id']; |
---|
653 | |
---|
654 | $template->assign( |
---|
655 | array |
---|
656 | ( |
---|
657 | 'nb_para' => $nb_para, |
---|
658 | 'nb_para2' => $nb_para2, |
---|
659 | 'REGFLUXBB_THEME' => $RFBB_theme, |
---|
660 | 'REGFLUXBB_PATH' => REGFLUXBB_PATH, |
---|
661 | 'REGFLUXBB_VERSION' => $conf_Register_FluxBB['REGFLUXBB_VERSION'], |
---|
662 | 'FluxBB_PREFIX' => $conf_Register_FluxBB['FLUXBB_PREFIX'], |
---|
663 | 'FluxBB_ADMIN' => stripslashes($conf_Register_FluxBB['FLUXBB_ADMIN']), |
---|
664 | 'FluxBB_GUEST' => stripslashes($conf_Register_FluxBB['FLUXBB_GUEST']), |
---|
665 | 'FluxBB_DEL_PT_TRUE' => $conf_Register_FluxBB['FLUXBB_DEL_PT'] == 'true' ? 'checked="checked"' : '', |
---|
666 | 'FluxBB_DEL_PT_FALSE' => $conf_Register_FluxBB['FLUXBB_DEL_PT'] == 'false' ? 'checked="checked"' : '', |
---|
667 | 'FluxBB_CONFIRM_TRUE' => $conf_Register_FluxBB['FLUXBB_CONFIRM'] == 'true' ? 'checked="checked"' : '', |
---|
668 | 'FluxBB_CONFIRM_FALSE' => $conf_Register_FluxBB['FLUXBB_CONFIRM'] == 'false' ? 'checked="checked"' : '', |
---|
669 | 'FluxBB_DETAILS_TRUE' => $conf_Register_FluxBB['FLUXBB_DETAIL'] == 'true' ? 'checked="checked"' : '', |
---|
670 | 'FluxBB_DETAILS_FALSE' => $conf_Register_FluxBB['FLUXBB_DETAIL'] == 'false' ? 'checked="checked"' : '', |
---|
671 | 'UAM_BRIDGE' => $UAM_bridge, |
---|
672 | 'FluxBB_UAM_LINK_TRUE' => $conf_Register_FluxBB['FLUXBB_UAM_LINK'] == 'true' ? 'checked="checked"' : '', |
---|
673 | 'FluxBB_UAM_LINK_FALSE'=> $conf_Register_FluxBB['FLUXBB_UAM_LINK'] == 'false' ? 'checked="checked"' : '', |
---|
674 | 'FluxBB_GROUP' => $conf_Register_FluxBB['FLUXBB_GROUP'], |
---|
675 | ) |
---|
676 | ); |
---|
677 | |
---|
678 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/admin.tpl'); |
---|
679 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
680 | ?> |
---|