source: extensions/Register_FluxBB/admin/admin.php @ 22091

Last change on this file since 22091 was 22091, checked in by Eric, 7 years ago

Rebuild version 2.5.6 due to last commit corruption

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