Ignore:
Timestamp:
Mar 10, 2013, 2:16:32 AM (12 years ago)
Author:
Eric
Message:

Next version is 2.5.0 :

  • Compliance with Piwigo 2.5
  • Core code refactory : Plugin's configuration vars are now serialized in database
  • Admin panel refactory : No more tabs
  • Admin panel refactory : Clear and dark administration theme compatibility
  • English language reference review and improved
  • Compliance improved with FluxBB 1.5 - Register_FluxBB is still compatible with 1.2 and 1.4 FluxBB forums
  • Update tr_TR, thanks to : LazBoy
  • Update it_IT, thanks to : Ericnet
  • Update pl_PL, thanks to : K.S.
Location:
extensions/Register_FluxBB/include
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/Register_FluxBB/include/constants.php

    r17457 r21424  
    33global $prefixeTable, $conf;
    44
    5 $conf_Register_FluxBB = isset($conf['Register_FluxBB']) ? explode(";" , $conf['Register_FluxBB']) : array();
     5$conf_Register_FluxBB = unserialize($conf['Register_FluxBB']);
    66
    77define('Register_FluxBB_ID_TABLE', $prefixeTable.'Register_FluxBB_id');
     8define('FluxBB_CONFIG_TABLE', $conf_Register_FluxBB['FLUXBB_PREFIX'].'config');
     9define('FluxBB_USERS_TABLE', $conf_Register_FluxBB['FLUXBB_PREFIX'].'users');
     10define('FluxBB_POSTS_TABLE', $conf_Register_FluxBB['FLUXBB_PREFIX'].'posts');
     11define('FluxBB_TOPICS_TABLE', $conf_Register_FluxBB['FLUXBB_PREFIX'].'topics');
     12define('FluxBB_SUBSCRIPTIONS_TABLE', $conf_Register_FluxBB['FLUXBB_PREFIX'].'topic_subscriptions');
    813
    9 if (isset($conf_Register_FluxBB[0]))
    10 {
    11   define('FluxBB_CONFIG_TABLE', $conf_Register_FluxBB[0].'config');
    12   define('FluxBB_USERS_TABLE', $conf_Register_FluxBB[0].'users');
    13   define('FluxBB_POSTS_TABLE', $conf_Register_FluxBB[0].'posts');
    14   define('FluxBB_TOPICS_TABLE', $conf_Register_FluxBB[0].'topics');
    15   define('FluxBB_SUBSCRIPTIONS_TABLE', $conf_Register_FluxBB[0].'topic_subscriptions');
    16 }
    1714?>
  • extensions/Register_FluxBB/include/functions.inc.php

    r17457 r21424  
    33include_once (PHPWG_ROOT_PATH.'/include/constants.php');
    44include_once (REGFLUXBB_PATH.'include/constants.php');
     5
     6
     7function Audit_PWG_FluxBB()
     8{
     9  global $page, $conf, $errors;
     10
     11  $page_Register_FluxBB_admin = get_admin_plugin_menu_link(__FILE__);
     12
     13  $conf_Register_FluxBB = unserialize($conf['Register_FluxBB']);
     14
     15  $msg_error_PWG_Dup = '';
     16  $msg_error_FluxBB_Dup = '';
     17  $msg_error_Link_Break = '';
     18  $msg_error_Link_Bad = '';
     19  $msg_error_Synchro = '';
     20  $msg_ok_Synchro = '';
     21  $msg_error_PWG2FluxBB = '';
     22  $msg_error_FluxBB2PWG = '';
     23
     24  $query = '
     25SELECT COUNT(*) AS nbr_dup, id, username
     26FROM '.USERS_TABLE.'
     27WHERE username NOT IN ("18","16")
     28GROUP BY BINARY username
     29HAVING COUNT(*) > 1
     30;';
     31  $result = pwg_query($query);
     32 
     33  while($row = pwg_db_fetch_assoc($result))
     34    $msg_error_PWG_Dup .= '<br>'.l10n('Error_PWG_Dup').$row['nbr_dup'].' x '.stripslashes($row['username']);
     35
     36  if ($msg_error_PWG_Dup == '')
     37    array_push($page['infos'], l10n('Audit_PWG_Dup').'<br>'.l10n('Audit_OK'));
     38  else
     39    $msg_error_PWG_Dup = l10n('Audit_PWG_Dup').$msg_error_PWG_Dup.'<br>'.l10n('Advise_PWG_Dup');
     40 
     41
     42
     43  $query = '
     44SELECT COUNT(*) AS nbr_dup, username
     45FROM '.FluxBB_USERS_TABLE.'
     46GROUP BY BINARY username
     47HAVING COUNT(*) > 1
     48;';
     49  $result = pwg_query($query);
     50 
     51  while($row = pwg_db_fetch_assoc($result))
     52  {
     53    $msg_error_FluxBB_Dup .= '<br>'.l10n('Error_FluxBB_Dup').$row['nbr_dup'].' x '.stripslashes($row['username']);
     54
     55    $subquery = '
     56SELECT id, username, email
     57FROM '.FluxBB_USERS_TABLE.'
     58WHERE BINARY username = BINARY "'.$row['username'].'"
     59;';
     60    $subresult = pwg_query($subquery);
     61 
     62    while($subrow = pwg_db_fetch_assoc($subresult))
     63    {
     64      $msg_error_FluxBB_Dup .= '<br>id:'.$subrow['id'].'='.stripslashes($subrow['username']).' ('.$subrow['email'].')';
     65 
     66      $msg_error_FluxBB_Dup .= ' <a href="';
     67     
     68      $msg_error_FluxBB_Dup .= add_url_params($page_Register_FluxBB_admin, array(
     69        'action' => 'del_user',
     70        'id' => $subrow['id'],
     71      ));
     72       
     73      $msg_error_FluxBB_Dup .= '" title="'.l10n('Del_User').stripslashes($subrow['username']).'"';
     74       
     75      $msg_error_FluxBB_Dup .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
     76       
     77      $msg_error_FluxBB_Dup .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_delete.png" alt="'.l10n('Del_User').$subrow['username'].'" /></a>';
     78    }
     79  }
     80
     81  if ($msg_error_FluxBB_Dup == '')
     82    array_push($page['infos'], l10n('Audit_FluxBB_Dup').'<br>'.l10n('Audit_OK'));
     83  else
     84    $msg_error_FluxBB_Dup = l10n('Audit_FluxBB_Dup').$msg_error_FluxBB_Dup.'<br>'.l10n('Advise_FluxBB_Dup');
     85 
     86
     87
     88  $query = '
     89SELECT pwg.id as pwg_id, bb.id as bb_id, pwg.username as pwg_user, pwg.mail_address as pwg_mail
     90FROM '.FluxBB_USERS_TABLE.' AS bb, '.USERS_TABLE.' as pwg
     91WHERE bb.id NOT in (
     92  SELECT id_user_FluxBB
     93  FROM '.Register_FluxBB_ID_TABLE.'
     94  )
     95AND pwg.id NOT in (
     96  SELECT id_user_pwg
     97  FROM '.Register_FluxBB_ID_TABLE.'
     98  )
     99AND pwg.username = bb.username
     100AND pwg.username NOT IN ("18","16")
     101AND pwg.mail_address = bb.email
     102;';
     103
     104  $result = pwg_query($query);
     105 
     106  while($row = pwg_db_fetch_assoc($result))
     107  {
     108    $msg_error_Link_Break .= '<br>'.l10n('Error_Link_Break').stripslashes($row['pwg_user']).' ('.$row['pwg_mail'].')';
     109
     110    $msg_error_Link_Break .= ' <a href="';
     111 
     112    $msg_error_Link_Break .= add_url_params($page_Register_FluxBB_admin, array(
     113      'action'   => 'new_link',
     114      'pwg_id' => $row['pwg_id'],
     115      'bb_id' => $row['bb_id'],
     116    ));
     117
     118    $msg_error_Link_Break .= '" title="'.l10n('New_Link').stripslashes($row['pwg_user']).'"';
     119
     120    $msg_error_Link_Break .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
     121
     122    $msg_error_Link_Break .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/link_break.png" alt="'.l10n('New_Link').stripslashes($row['pwg_user']).'" /></a>';
     123  }
     124
     125  if ($msg_error_Link_Break == '')
     126    array_push($page['infos'], l10n('Audit_Link_Break').'<br>'.l10n('Audit_OK'));
     127  else
     128    $msg_error_Link_Break = l10n('Audit_Link_Break').$msg_error_Link_Break;
     129   
     130
     131 
     132  $query = '
     133SELECT 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
     134FROM '.FluxBB_USERS_TABLE.' AS bb
     135INNER JOIN '.Register_FluxBB_ID_TABLE.' AS link ON link.id_user_FluxBB = bb.id
     136INNER JOIN '.USERS_TABLE.' as pwg ON link.id_user_pwg = pwg.id
     137WHERE pwg.username <> bb.username
     138AND pwg.username NOT IN ("18","16")
     139;';
     140
     141  $result = pwg_query($query);
     142 
     143  while($row = pwg_db_fetch_assoc($result))
     144  {
     145    $msg_error_Link_Bad .= '<br>'.l10n('Error_Link_Del').stripslashes($row['pwg_user']).' ('.$row['pwg_mail'].')'.' -- '.stripslashes($row['bb_user']).' ('.$row['bb_mail'].')';
     146
     147    $msg_error_Link_Bad .= ' <a href="';
     148 
     149    $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array(
     150      'action'   => 'link_del',
     151      'pwg_id' => $row['pwg_id'],
     152      'bb_id'  => $row['bb_id'],
     153    ));
     154
     155    $msg_error_Link_Bad .= '" title="'.l10n('Link_Del').stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).'"';
     156
     157    $msg_error_Link_Bad .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
     158
     159    $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>';
     160
     161    $msg_error_Link_Bad .= ' -- <a href="';
     162
     163    $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array(
     164      'action' => 'sync_user',
     165      'username' => stripslashes($row['pwg_user']),
     166    ));
     167
     168    $msg_error_Link_Bad .= '" title="'.l10n('Sync_User').stripslashes($row['pwg_user']).' --> '.stripslashes($row['bb_user']).'"';
     169
     170    $msg_error_Link_Bad .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
     171
     172    $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>';
     173  }
     174
     175
     176  $query = '
     177SELECT COUNT(*) as nbr_dead
     178FROM '.Register_FluxBB_ID_TABLE.' AS Link
     179WHERE id_user_FluxBB NOT IN (
     180  SELECT id
     181  FROM '.FluxBB_USERS_TABLE.'
     182  )
     183OR id_user_pwg NOT IN (
     184  SELECT id
     185  FROM '.USERS_TABLE.'
     186  )
     187;';
     188
     189  $Compteur = pwg_db_fetch_assoc(pwg_query($query));
     190
     191  if (!empty($Compteur) and $Compteur['nbr_dead'] > 0)
     192  {
     193    $msg_error_Link_Bad .= '<br>'.l10n('Error_Link_Dead').$Compteur['nbr_dead'];
     194
     195    $msg_error_Link_Bad .= ' <a href="';
     196
     197    $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array(
     198      'action'   => 'link_dead',
     199    ));
     200
     201    $msg_error_Link_Bad .= '" title="'.l10n('Link_Dead').$Compteur['nbr_dead'].'"';
     202
     203    $msg_error_Link_Bad .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
     204
     205    $msg_error_Link_Bad .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/link_delete.png" alt="'.l10n('Link_Dead').$Compteur['nbr_dead'].'" /></a>';
     206  }
     207
     208  $query = '
     209SELECT COUNT(*) AS nbr_dup, pwg.id AS pwg_id, pwg.username AS pwg_user, bb.username AS bb_user, bb.id AS bb_id
     210FROM '.FluxBB_USERS_TABLE.' AS bb
     211INNER JOIN '.Register_FluxBB_ID_TABLE.' AS link ON link.id_user_FluxBB = bb.id
     212INNER JOIN '.USERS_TABLE.' as pwg ON link.id_user_pwg = pwg.id
     213WHERE pwg.username NOT IN ("18","16")
     214GROUP BY link.id_user_pwg, link.id_user_FluxBB
     215HAVING COUNT(*) > 1
     216;';
     217
     218  $result = pwg_query($query);
     219 
     220  while($row = pwg_db_fetch_assoc($result))
     221  {
     222    $msg_error_Link_Bad .= '<br>'.l10n('Error_Link_Dup').$row['nbr_dup'].' = '.stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).')';
     223
     224    $msg_error_Link_Bad .= ' <a href="';
     225
     226    $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array(
     227      'action'   => 'new_link',
     228      'pwg_id' => $row['pwg_id'],
     229      'bb_id' => $row['bb_id'],
     230    ));
     231
     232    $msg_error_Link_Bad .= '" title="'.l10n('Link_Dup').stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).'"';
     233
     234    $msg_error_Link_Bad .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
     235
     236    $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>';
     237  }
     238
     239  if ($msg_error_Link_Bad == '')
     240    array_push($page['infos'], l10n('Audit_Link_Bad').'<br>'.l10n('Audit_OK'));
     241  else
     242    $msg_error_Link_Bad = l10n('Audit_Link_Bad').$msg_error_Link_Bad;
     243   
     244
     245 
     246  $query = '
     247SELECT 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
     248FROM '.FluxBB_USERS_TABLE.' AS FluxBB
     249INNER JOIN '.Register_FluxBB_ID_TABLE.' AS link ON link.id_user_FluxBB = FluxBB.id
     250INNER JOIN '.USERS_TABLE.' as pwg ON link.id_user_pwg = pwg.id
     251WHERE BINARY pwg.username = BINARY FluxBB.username
     252AND pwg.username NOT IN ("18","16")
     253ORDER BY LOWER(pwg.username)
     254;';
     255
     256  $result = pwg_query($query);
     257 
     258  while($row = pwg_db_fetch_assoc($result))
     259  {
     260    if ( ($row['pwg_pwd'] != $row['bb_pwd']) or ($row['pwg_eml'] != $row['bb_eml']) )
     261    {
     262      $msg_error_Synchro .= '<br>'.l10n('Error_Synchro').stripslashes($row['username']);
     263
     264      $msg_error_Synchro .= ' <a href="';
     265
     266      $msg_error_Synchro .= add_url_params($page_Register_FluxBB_admin, array(
     267        'action' => 'sync_user',
     268        'username' => stripslashes($row['username']),
     269      ));
     270
     271      $msg_error_Synchro .= '" title="'.l10n('Sync_User').stripslashes($row['username']).'"';
     272
     273      $msg_error_Synchro .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
     274
     275      $msg_error_Synchro .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_refresh.png" alt="'.l10n('Sync_User').stripslashes($row['username']).'" /></a>';
     276
     277      if ($row['pwg_pwd'] != $row['bb_pwd'])
     278        $msg_error_Synchro .= '<br>'.l10n('Error_Synchro_Pswd');
     279
     280      if ($row['pwg_eml'] != $row['bb_eml'])
     281        $msg_error_Synchro .= '<br>'.l10n('Error_Synchro_Mail').'<br>-- PWG = '.$row['pwg_eml'].'<br>-- FluxBB = '.$row['bb_eml'];
     282    }
     283    else if ($conf_Register_FluxBB['FLUXBB_DETAIL'] == 'true')
     284      $msg_ok_Synchro .= '<br> - '.stripslashes($row['username']).' ('.$row['pwg_eml'].')'.l10n('Audit_Synchro_OK');
     285  }
     286
     287  if ($msg_error_Synchro <> '')
     288    $msg_error_Synchro = l10n('Audit_Synchro').$msg_error_Synchro;
     289   
     290  if ($msg_ok_Synchro <> '')
     291    if ($msg_error_Synchro <> '')
     292      array_push($page['infos'], l10n('Audit_Synchro').$msg_ok_Synchro.'<br><br>');
     293    else
     294      array_push($page['infos'], l10n('Audit_Synchro').$msg_ok_Synchro.'<br><br>'.l10n('Audit_OK'));
     295
     296
     297  $query = '
     298SELECT username, mail_address FROM '.USERS_TABLE.'
     299WHERE BINARY username <> BINARY "guest"
     300AND username NOT IN ("18","16")
     301AND id not in (
     302  SELECT id_user_pwg FROM '.Register_FluxBB_ID_TABLE.'
     303  )
     304AND BINARY username not in (
     305  SELECT username FROM '.FluxBB_USERS_TABLE.'
     306  )
     307ORDER BY LOWER(username)
     308;';
     309
     310  $result = pwg_query($query);
     311
     312  while($row = pwg_db_fetch_assoc($result))
     313  {
     314    $msg_error_PWG2FluxBB .= '<br>'.l10n('Error_PWG2FluxBB').stripslashes($row['username']).' ('.$row['mail_address'].')';
     315
     316    $msg_error_PWG2FluxBB .= ' <a href="';
     317
     318    $msg_error_PWG2FluxBB .= add_url_params($page_Register_FluxBB_admin, array(
     319      'action' => 'add_user',
     320      'username' => stripslashes($row['username']),
     321    ));
     322
     323    $msg_error_PWG2FluxBB .= '" title="'.l10n('Add_User').stripslashes($row['username']).'" ';
     324
     325    $msg_error_PWG2FluxBB .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
     326
     327    $msg_error_PWG2FluxBB .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_add.png" alt="'.l10n('Add_User').stripslashes($row['username']).'" /></a>';
     328  }
     329
     330  if ($msg_error_PWG2FluxBB == '')
     331    array_push($page['infos'], l10n('Audit_PWG2FluxBB').'<br>'.l10n('Audit_OK'));
     332  else
     333    $msg_error_PWG2FluxBB = l10n('Audit_PWG2FluxBB').$msg_error_PWG2FluxBB;
     334
     335 
     336
     337  $query = '
     338SELECT id, username, email FROM '.FluxBB_USERS_TABLE.'
     339WHERE BINARY username <> BINARY "'.$conf_Register_FluxBB['FLUXBB_GUEST'].'"
     340AND id not in (
     341  SELECT id_user_FluxBB FROM '.Register_FluxBB_ID_TABLE.'
     342  )
     343AND BINARY username not in (
     344  SELECT username FROM '.USERS_TABLE.'
     345  )
     346ORDER BY LOWER(username)
     347;';
     348
     349  $result = pwg_query($query);
     350
     351  while($row = pwg_db_fetch_assoc($result))
     352  {
     353    $msg_error_FluxBB2PWG .= '<br>'.l10n('Error_FluxBB2PWG').stripslashes($row['username']).' ('.$row['email'].')';
     354
     355    $msg_error_FluxBB2PWG .= ' <a href="';
     356
     357    $msg_error_FluxBB2PWG .= add_url_params($page_Register_FluxBB_admin, array(
     358      'action' => 'del_user',
     359      'id' => $row['id'],
     360    ));
     361
     362    $msg_error_FluxBB2PWG .= '" title="'.l10n('Del_User').stripslashes($row['username']).'"';
     363
     364    $msg_error_FluxBB2PWG .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
     365
     366    $msg_error_FluxBB2PWG .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_delete.png" alt="'.l10n('Del_User').stripslashes($row['username']).'" /></a>';
     367  }
     368
     369  if ($msg_error_FluxBB2PWG == '')
     370    array_push($page['infos'], l10n('Audit_FluxBB2PWG').'<br>'.l10n('Audit_OK'));
     371  else
     372    $msg_error_FluxBB2PWG = l10n('Audit_FluxBB2PWG').$msg_error_FluxBB2PWG;
     373
     374
     375
     376  if ($msg_error_PWG_Dup <> '')
     377    $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>' );
     378 
     379  if ($msg_error_FluxBB_Dup <> '')
     380    $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>' );
     381
     382  if ($msg_error_Link_Break <> '')
     383    $errors[] = $msg_error_Link_Break . ( ($msg_error_Link_Bad == '' and $msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' );
     384
     385  if ($msg_error_Link_Bad <> '')
     386    $errors[] = $msg_error_Link_Bad . ( ($msg_error_Synchro == '' and $msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' );
     387
     388  if ($msg_error_Synchro <> '')
     389    $errors[] = $msg_error_Synchro . ( ($msg_error_PWG2FluxBB == '' and $msg_error_FluxBB2PWG == '') ? '' : '<br><br>' );
     390
     391  if ($msg_error_PWG2FluxBB <> '')
     392    $errors[] = $msg_error_PWG2FluxBB . ( ($msg_error_FluxBB2PWG == '') ? '' : '<br><br>' );
     393
     394  if ($msg_error_FluxBB2PWG <> '')
     395    $errors[] = $msg_error_FluxBB2PWG;
     396}
    5397
    6398
     
    47439FROM '.USERS_TABLE.'
    48440WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\'
     441AND '.$conf['user_fields']['username'].' NOT IN ("18","16")
    49442;';
    50443
     
    61454  global $conf, $user;
    62455 
    63   $conf_Register_FluxBB = isset($conf['Register_FluxBB']) ? explode(";" , $conf['Register_FluxBB']) : array();
     456  $conf_Register_FluxBB = unserialize($conf['Register_FluxBB']);
    64457 
    65458  // Check if UAM is installed and if bridge is set - Exception for admins and webmasters
     
    73466  if ($data['status'] <> "admin" and $data['status'] <> "webmaster")
    74467  {
    75     if (function_exists('FindAvailableConfirmMailID') and isset($conf_Register_FluxBB[6]) and $conf_Register_FluxBB[6] == 'true')
     468    if (function_exists('FindAvailableConfirmMailID') and isset($conf_Register_FluxBB['FLUXBB_UAM_LINK']) and $conf_Register_FluxBB['FLUXBB_UAM_LINK'] == 'true')
    76469    {
    77470      $conf_UAM = unserialize($conf['UserAdvManager']);
    78471   
    79472      // Getting unvalidated users group else Piwigo's default group
    80       if (isset($conf_UAM[2]) and $conf_UAM[2] != '-1')
     473      if (isset($conf_UAM['NO_CONFIRM_GROUP']) and $conf_UAM['NO_CONFIRM_GROUP'] != '-1')
    81474      {
    82         $Waitingroup = $conf_UAM[2];
     475        $Waitingroup = $conf_UAM['NO_CONFIRM_GROUP'];
    83476      }
    84477      else
     
    104497
    105498      // Check if logged in user is in a FluxBB's unvalidated group
    106       $query = "
     499      $query = '
    107500SELECT group_id
    108 FROM ".FluxBB_USERS_TABLE."
    109 WHERE id = ".FluxBB_Searchuser($user['id'])."
    110 ;";
     501FROM '.FluxBB_USERS_TABLE.'
     502WHERE id = '.FluxBB_Searchuser($user['id']).'
     503;';
    111504
    112505      $data = pwg_db_fetch_assoc(pwg_query($query));
    113506
    114       // Logged in user switch to the default FluxBB's group if he'is validated
    115       if ($count == 0 and $data['group_id'] = $conf_Register_FluxBB[7])
     507      // Logged in user switch to the default FluxBB's group if he is validated
     508      if ($count == 0 and $data['group_id'] = $conf_Register_FluxBB['FLUXBB_GROUP'])
    116509      {
    117         $query = "
     510        $query = '
    118511SELECT conf_value
    119 FROM ".FluxBB_CONFIG_TABLE."
    120 WHERE conf_name = 'o_default_user_group'
    121 ;";
     512FROM '.FluxBB_CONFIG_TABLE.'
     513WHERE conf_name = "o_default_user_group"
     514;';
    122515
    123516        $o_user_group = pwg_db_fetch_assoc(pwg_query($query));
    124517     
    125         $query = "
    126 UPDATE ".FluxBB_USERS_TABLE."
    127 SET group_id = ".$o_user_group['conf_value']."
    128 WHERE id = ".FluxBB_Searchuser($user['id'])."
    129 ;";
     518        $query = '
     519UPDATE '.FluxBB_USERS_TABLE.'
     520SET group_id = '.$o_user_group['conf_value'].'
     521WHERE id = '.FluxBB_Searchuser($user['id']).'
     522;';
    130523        pwg_query($query);
    131524      }
     
    139532  global $conf;
    140533 
    141   //Because FluxBB is case insensitive on login name, we have to check if a similar login already exists in FluxBB's user table
     534  // Because FluxBB is case insensitive on login name, we have to check if a similar login already exists in FluxBB's user table
    142535  // If "test" user already exists, "TEST" or "Test" (and so on...) can't register
    143   $query = "
     536  $query = '
    144537SELECT username
    145   FROM ".FluxBB_USERS_TABLE."
    146 WHERE LOWER(".stripslashes('username').") = '".strtolower($user['username'])."'
    147 ;";
     538  FROM '.FluxBB_USERS_TABLE.'
     539WHERE LOWER('.stripslashes('username').') = "'.strtolower($user['username']).'"
     540;';
    148541
    149542  $count = pwg_db_num_rows(pwg_query($query));
     
    159552function FluxBB_Linkuser($pwg_id, $bb_id)
    160553{
    161   $query = "
     554  $query = '
    162555SELECT pwg.id as pwg_id, bb.id as bb_id
    163 FROM ".USERS_TABLE." pwg, ".FluxBB_USERS_TABLE." bb
    164 WHERE pwg.id = ".$pwg_id."
    165 AND bb.id = ".$bb_id."
    166 AND pwg.username = bb.username
    167 ;";
     556FROM '.USERS_TABLE.' pwg, '.FluxBB_USERS_TABLE.' bb
     557WHERE pwg.id = '.$pwg_id.'
     558  AND bb.id = '.$bb_id.'
     559  AND pwg.username = bb.username
     560  AND pwg.username NOT IN ("18","16")
     561;';
    168562 
    169563  $data = pwg_db_fetch_row(pwg_query($query));
     
    171565  if (!empty($data))
    172566  {
    173     $subquery = "
    174 DELETE FROM ".Register_FluxBB_ID_TABLE."
    175 WHERE id_user_pwg = '".$pwg_id."'
    176 OR id_user_FluxBB = '".$bb_id."'
    177 ;";
     567    $subquery = '
     568DELETE FROM '.Register_FluxBB_ID_TABLE.'
     569WHERE id_user_pwg = "'.$pwg_id.'"
     570OR id_user_FluxBB = "'.$bb_id.'"
     571;';
    178572
    179573    $subresult = pwg_query($subquery);
    180574
    181     $subquery = "
    182 INSERT INTO ".Register_FluxBB_ID_TABLE."
     575    $subquery = '
     576INSERT INTO '.Register_FluxBB_ID_TABLE.'
    183577  (id_user_pwg, id_user_FluxBB)
    184 VALUES (".$pwg_id.", ".$bb_id.")
    185 ;";
     578VALUES ('.$pwg_id.', '.$bb_id.')
     579;';
    186580
    187581    $subresult = pwg_query($subquery);
     
    193587function FluxBB_Unlinkuser($bb_id)
    194588{
    195   $query = "
    196 DELETE FROM ".Register_FluxBB_ID_TABLE."
    197 WHERE id_user_FluxBB = ".$bb_id."
    198 ;";
     589  $query = '
     590DELETE FROM '.Register_FluxBB_ID_TABLE.'
     591WHERE id_user_FluxBB = '.$bb_id.'
     592;';
    199593
    200594  $result = pwg_query($query);
     
    207601  global $errors, $conf;
    208602
    209   $conf_Register_FluxBB = isset($conf['Register_FluxBB']) ? explode(";" , $conf['Register_FluxBB']) : array();
     603  $conf_Register_FluxBB = unserialize($conf['Register_FluxBB']);
    210604
    211605  $registred = time();
     
    213607 
    214608  // Check if UAM is installed and if bridge is set - Exception for admins and webmasters
    215   if (function_exists('FindAvailableConfirmMailID') and isset($conf_Register_FluxBB[6]) and $conf_Register_FluxBB[6] == 'true')
    216   {
    217     $o_default_user_group = $conf_Register_FluxBB[7];
     609  if (function_exists('FindAvailableConfirmMailID') and isset($conf_Register_FluxBB['FLUXBB_UAM_LINK']) and $conf_Register_FluxBB['FLUXBB_UAM_LINK'] == 'true')
     610  {
     611    $o_default_user_group1 = $conf_Register_FluxBB['FLUXBB_GROUP'];
    218612  }
    219613  else
    220614  {
     615    $query = '
     616SELECT conf_value
     617FROM '.FluxBB_CONFIG_TABLE.'
     618WHERE conf_name = "o_default_user_group"
     619;';
     620
     621    $o_default_user_group = pwg_db_fetch_assoc(pwg_query($query));
     622  }
     623
     624// Check for FluxBB version 1.4.x or higher and get the correct value
     625  $query1 = '
     626SELECT conf_value
     627FROM '.FluxBB_CONFIG_TABLE.'
     628WHERE conf_name = "o_default_timezone"
     629;';
     630
     631  $count1 = pwg_db_num_rows(pwg_query($query1));
     632
     633// Check for FluxBB version 1.2.x and get the correct value
     634  $query2 = '
     635SELECT conf_value
     636FROM '.FluxBB_CONFIG_TABLE.'
     637WHERE conf_name = "o_server_timezone"
     638;';
     639
     640  $count2 = pwg_db_num_rows(pwg_query($query2));
     641 
     642  if ($count1 == 1 and $count2 == 0)
     643  {
     644    $o_default_timezone = pwg_db_fetch_assoc(pwg_query($query1));
     645  }
     646  else if ($count1 == 0 and $count2 == 1)
     647  {
     648    $o_default_timezone = pwg_db_fetch_assoc(pwg_query($query2));
     649  }
     650 
     651 
     652  $query = '
     653SELECT conf_value
     654FROM '.FluxBB_CONFIG_TABLE.'
     655WHERE conf_name = "o_default_lang"
     656;';
     657
     658  $o_default_lang = pwg_db_fetch_assoc(pwg_query($query));
     659 
     660  $query = '
     661SELECT conf_value
     662FROM '.FluxBB_CONFIG_TABLE.'
     663WHERE conf_name = "o_default_style"
     664;';
     665
     666  $o_default_style = pwg_db_fetch_assoc(pwg_query($query));
     667
     668  // Check if UAM is installed and if bridge is set - Exception for admins and webmasters
     669  if (function_exists('FindAvailableConfirmMailID') and isset($conf_Register_FluxBB['FLUXBB_UAM_LINK']) and $conf_Register_FluxBB['FLUXBB_UAM_LINK'] == 'true')
     670  {
    221671    $query = "
    222 SELECT conf_value
    223 FROM ".FluxBB_CONFIG_TABLE."
    224 WHERE conf_name = 'o_default_user_group'
    225 ;";
    226 
    227     $o_default_user_group = pwg_db_fetch_assoc(pwg_query($query));
    228   }
    229 
    230 // Check for FluxBB version 1.4.x and get the correct value
    231   $query1 = "
    232 SELECT conf_value
    233 FROM ".FluxBB_CONFIG_TABLE."
    234 WHERE conf_name = 'o_default_timezone'
    235 ;";
    236 
    237   $count1 = pwg_db_num_rows(pwg_query($query1));
    238 
    239 // Check for FluxBB version 1.2.x and get the correct value
    240   $query2 = "
    241 SELECT conf_value
    242 FROM ".FluxBB_CONFIG_TABLE."
    243 WHERE conf_name = 'o_server_timezone'
    244 ;";
    245 
    246   $count2 = pwg_db_num_rows(pwg_query($query2));
    247  
    248   if ($count1 == 1 and $count2 == 0)
    249   {
    250     $o_default_timezone = pwg_db_fetch_assoc(pwg_query($query1));
    251   }
    252   else if ($count1 == 0 and $count2 == 1)
    253   {
    254     $o_default_timezone = pwg_db_fetch_assoc(pwg_query($query2));
    255   }
    256  
    257  
    258   $query = "
    259 SELECT conf_value
    260 FROM ".FluxBB_CONFIG_TABLE."
    261 WHERE conf_name = 'o_default_lang'
    262 ;";
    263 
    264   $o_default_lang = pwg_db_fetch_assoc(pwg_query($query));
    265  
    266   $query = "
    267 SELECT conf_value
    268 FROM ".FluxBB_CONFIG_TABLE."
    269 WHERE conf_name = 'o_default_style'
    270 ;";
    271 
    272   $o_default_style = pwg_db_fetch_assoc(pwg_query($query));
    273 
    274   $query = "
    275672INSERT INTO ".FluxBB_USERS_TABLE." (
    276   username, 
    277   ". ( isset($o_default_user_group['conf_value']) ? 'group_id' : '' ) .",
    278   password, 
    279   email, 
     673  username,
     674  ". ( isset($o_default_user_group1) ? 'group_id' : '' ) .",
     675  password,
     676  email,
    280677  ". ( isset($o_default_timezone['conf_value']) ? 'timezone' : '' ) .",
    281678  ". ( isset($o_default_lang['conf_value']) ? 'language' : '' ) .",
    282679  ". ( isset($o_default_style['conf_value']) ? 'style' : '' ) .",
    283   registered,
    284   registration_ip,
     680  registered,
     681  registration_ip,
     682  last_visit
     683  )
     684VALUES(
     685  '".pwg_db_real_escape_string($login)."',
     686  ". ( isset($o_default_user_group1) ? "'".$o_default_user_group1."'" : '' ) .",
     687  '".$password."',
     688        '".$adresse_mail."',
     689  ". ( isset($o_default_timezone['conf_value']) ? "'".$o_default_timezone['conf_value']."'" : '' ) .",
     690  ". ( isset($o_default_lang['conf_value']) ? "'".$o_default_lang['conf_value']."'" : '' ) .",
     691  ". ( isset($o_default_style['conf_value']) ? "'".$o_default_style['conf_value']."'" : '' ) .",
     692  '".$registred."',
     693  '".$registred_ip."',
     694  '".$registred."'
     695  );";
     696 
     697    $result = pwg_query($query);
     698  }
     699  else
     700  {
     701    $query = "
     702INSERT INTO ".FluxBB_USERS_TABLE." (
     703  username,
     704  ". ( isset($o_default_user_group['conf_value']) ? 'group_id' : '' ) .",
     705  password,
     706  email,
     707  ". ( isset($o_default_timezone['conf_value']) ? 'timezone' : '' ) .",
     708  ". ( isset($o_default_lang['conf_value']) ? 'language' : '' ) .",
     709  ". ( isset($o_default_style['conf_value']) ? 'style' : '' ) .",
     710  registered,
     711  registration_ip,
    285712  last_visit
    286713  )
     
    298725  )
    299726;";
    300 
    301   $result = pwg_query($query);
     727    $result = pwg_query($query);
     728  }
    302729
    303730  $bb_id = pwg_db_insert_id();
     
    310737function FluxBB_Searchuser($id_user_pwg)
    311738{
    312   $query = "
     739  $query = '
    313740SELECT id_user_FluxBB, id_user_pwg
    314 FROM ".Register_FluxBB_ID_TABLE."
    315 WHERE id_user_pwg = ".$id_user_pwg."
     741FROM '.Register_FluxBB_ID_TABLE.'
     742WHERE id_user_pwg = '.$id_user_pwg.'
    316743LIMIT 1
    317 ;";
     744;';
    318745
    319746  $data = pwg_db_fetch_assoc(pwg_query($query));
     
    331758  global $conf;
    332759
    333   $conf_Register_FluxBB = isset($conf['Register_FluxBB']) ? explode(";" , $conf['Register_FluxBB']) : array();
    334 
    335   $query0 = "
    336 SELECT username, id FROM ".FluxBB_USERS_TABLE."
    337 WHERE id = ".$id_user_FluxBB."
     760  $conf_Register_FluxBB = unserialize($conf['Register_FluxBB']);
     761
     762  $query0 = '
     763SELECT username, id
     764FROM '.FluxBB_USERS_TABLE.'
     765WHERE id = '.$id_user_FluxBB.'
    338766LIMIT 1
    339 ;";
     767;';
    340768
    341769  $data0 = pwg_db_fetch_assoc(pwg_query($query0));
    342770
    343771  // If True, delete related topics and posts
    344   if ($SuppTopicsPosts and $conf_Register_FluxBB[3])
     772  if ($SuppTopicsPosts and $conf_Register_FluxBB['FLUXBB_DEL_PT'])
    345773  {
    346774    // Delete posts and topics of this user
    347     $subquery = "
    348 DELETE FROM ".FluxBB_POSTS_TABLE."
    349 WHERE poster_id = ".$id_user_FluxBB."
    350 ;";
     775    $subquery = '
     776DELETE FROM '.FluxBB_POSTS_TABLE.'
     777WHERE poster_id = '.$id_user_FluxBB.'
     778;';
    351779
    352780    $subresult = pwg_query($subquery);
    353781
    354782    // Delete topics of this user
    355     $subquery = "
    356 DELETE FROM ".FluxBB_TOPICS_TABLE."
    357 WHERE BINARY poster = BINARY '".pwg_db_real_escape_string($data0['username'])."'
    358 ;";
     783    $subquery = '
     784DELETE FROM '.FluxBB_TOPICS_TABLE.'
     785WHERE BINARY poster = BINARY "'.pwg_db_real_escape_string($data0['username']).'"
     786;';
    359787
    360788    $subresult = pwg_query($subquery);
     
    362790
    363791  // Delete user's subscriptions
    364   $subquery = "
    365 DELETE FROM ".FluxBB_SUBSCRIPTIONS_TABLE."
    366 WHERE user_id = ".$id_user_FluxBB."
    367 ;";
     792  $subquery = '
     793DELETE FROM '.FluxBB_SUBSCRIPTIONS_TABLE.'
     794WHERE user_id = '.$id_user_FluxBB.'
     795;';
    368796
    369797  $subresult = pwg_query($subquery);
    370798 
    371799  // Delete user's account
    372   $subquery = "
    373 DELETE FROM ".FluxBB_USERS_TABLE."
    374 WHERE id = ".$id_user_FluxBB."
    375 ;";
     800  $subquery = '
     801DELETE FROM '.FluxBB_USERS_TABLE.'
     802WHERE id = '.$id_user_FluxBB.'
     803;';
    376804
    377805  $subresult = pwg_query($subquery);
     
    386814  include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
    387815
    388   $query = "
     816  $query = '
    389817SELECT id_user_FluxBB as FluxBB_id
    390 FROM ".Register_FluxBB_ID_TABLE."
    391 WHERE id_user_pwg = ".$pwg_id."
    392 ;";
     818FROM '.Register_FluxBB_ID_TABLE.'
     819WHERE id_user_pwg = '.$pwg_id.'
     820;';
    393821
    394822  $row = pwg_db_fetch_assoc(pwg_query($query));
     
    396824  if (!empty($row))
    397825  {
    398     $query = "
    399 UPDATE ".FluxBB_USERS_TABLE."
    400 SET username = '".pwg_db_real_escape_string($username)."', email = '".$adresse_mail."', password = '".$password."'
    401 WHERE id = ".$row['FluxBB_id']."
    402 ;";
     826    $query = '
     827UPDATE '.FluxBB_USERS_TABLE.'
     828SET username = "'.pwg_db_real_escape_string($username).'", email = "'.$adresse_mail.'", password = "'.$password.'"
     829WHERE id = '.$row['FluxBB_id'].'
     830AND "'.pwg_db_real_escape_string($username).'" NOT IN ("18","16")
     831;';
    403832   
    404833    $result = pwg_query($query);
     
    408837  else
    409838  {
    410     $query = "
     839    $query = '
    411840SELECT id as FluxBB_id
    412 FROM ".FluxBB_USERS_TABLE."
    413 WHERE BINARY username = BINARY '".pwg_db_real_escape_string($username)."'
    414 ;";
     841FROM '.FluxBB_USERS_TABLE.'
     842WHERE BINARY username = BINARY "'.pwg_db_real_escape_string($username).'"
     843;';
    415844
    416845    $row = pwg_db_fetch_assoc(pwg_query($query));
     
    418847    if (!empty($row))
    419848    {
    420       $query = "
    421 UPDATE ".FluxBB_USERS_TABLE."
    422 SET username = '".pwg_db_real_escape_string($username)."', email = '".$adresse_mail."', password = '".$password."'
    423 WHERE id = ".$row['FluxBB_id']."
    424 ;";
     849      $query = '
     850UPDATE '.FluxBB_USERS_TABLE.'
     851SET username = "'.pwg_db_real_escape_string($username).'", email = "'.$adresse_mail.'", password = "'.$password.'"
     852WHERE id = '.$row['FluxBB_id'].'
     853AND "'.pwg_db_real_escape_string($username).'" NOT IN ("18","16")
     854;';
    425855     
    426856      $result = pwg_query($query);
     
    475905  return $plugin ;
    476906}
     907
    477908
    478909function regfluxbb_obsolete_files()
     
    493924  }
    494925}
     926
     927
     928/**
     929 * Function to update plugin version number in config table
     930 * Used everytime a new version is updated even if no database
     931 * upgrade is needed
     932 */
     933function RegFluxBB_version_update()
     934{
     935  global $conf;
     936
     937  // Get current plugin version
     938  // --------------------------
     939  $plugin =  PHInfos(REGFLUXBB_PATH);
     940  $version = $plugin['version'];
     941
     942  // Upgrading options
     943  // -----------------
     944  $query = '
     945SELECT value
     946FROM '.CONFIG_TABLE.'
     947WHERE param = "Register_FluxBB"
     948;';
     949
     950  $result = pwg_query($query);
     951  $Conf_RegFluxBB = pwg_db_fetch_assoc($result);
     952
     953  $Newconf_RegFluxBB = unserialize($Conf_RegFluxBB['value']);
     954
     955  $Newconf_RegFluxBB['REGFLUXBB_VERSION'] = $version;
     956
     957  $update_conf = serialize($Newconf_RegFluxBB);
     958
     959  conf_update_param('Register_FluxBB', pwg_db_real_escape_string($update_conf));
     960
     961
     962// Check #_plugin table consistency
     963// Only useful if a previous version upgrade has not worked correctly (rare case)
     964// ------------------------------------------------------------------------------
     965  $query = '
     966SELECT version
     967  FROM '.PLUGINS_TABLE.'
     968WHERE id = "Register_FluxBB"
     969;';
     970 
     971  $data = pwg_db_fetch_assoc(pwg_query($query));
     972 
     973  if (empty($data['version']) or $data['version'] <> $version)
     974  {
     975    $query = '
     976UPDATE '.PLUGINS_TABLE.'
     977SET version="'.$version.'"
     978WHERE id = "Register_FluxBB"
     979LIMIT 1
     980;';
     981
     982    pwg_query($query);
     983  }
     984}
     985
     986
     987/**
     988 * Useful for debugging - 4 vars can be set
     989 * Output result to log.txt file
     990 *
     991 */
     992function RegFluxBBLog($var1, $var2, $var3, $var4)
     993{
     994   $fo=fopen (REGFLUXBB_PATH.'log.txt','a') ;
     995   fwrite($fo,"======================\n") ;
     996   fwrite($fo,'le ' . date('D, d M Y H:i:s') . "\r\n");
     997   fwrite($fo,$var1 ."\r\n") ;
     998   fwrite($fo,$var2 ."\r\n") ;
     999   fwrite($fo,$var3 ."\r\n") ;
     1000   fwrite($fo,$var4 ."\r\n") ;
     1001   fclose($fo) ;
     1002}
    4951003?>
Note: See TracChangeset for help on using the changeset viewer.