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

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

Next version is 2.5.3:
Bug fixed - MySql error after installation from scratch - Part 2 : Add controls on FluxBB table prefix

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