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

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