Ignore:
Timestamp:
Apr 6, 2013, 5:27:15 PM (11 years ago)
Author:
Eric
Message:
  • 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 !
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Register_FluxBB/include/functions.inc.php

    r21901 r22039  
    33include_once (PHPWG_ROOT_PATH.'/include/constants.php');
    44include_once (REGFLUXBB_PATH.'include/constants.php');
    5 
    6 
    7 function 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 = '
    25 SELECT COUNT(*) AS nbr_dup, id, username
    26 FROM '.USERS_TABLE.'
    27 WHERE username NOT IN ("18","16")
    28 GROUP BY BINARY username
    29 HAVING 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 = '
    44 SELECT COUNT(*) AS nbr_dup, username
    45 FROM '.FluxBB_USERS_TABLE.'
    46 GROUP BY BINARY username
    47 HAVING 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 = '
    56 SELECT id, username, email
    57 FROM '.FluxBB_USERS_TABLE.'
    58 WHERE 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 = '
    89 SELECT pwg.id as pwg_id, bb.id as bb_id, pwg.username as pwg_user, pwg.mail_address as pwg_mail
    90 FROM '.FluxBB_USERS_TABLE.' AS bb, '.USERS_TABLE.' as pwg
    91 WHERE bb.id NOT in (
    92   SELECT id_user_FluxBB
    93   FROM '.Register_FluxBB_ID_TABLE.'
    94   )
    95 AND pwg.id NOT in (
    96   SELECT id_user_pwg
    97   FROM '.Register_FluxBB_ID_TABLE.'
    98   )
    99 AND pwg.username = bb.username
    100 AND pwg.username NOT IN ("18","16")
    101 AND 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 = '
    133 SELECT pwg.username as pwg_user, pwg.id as pwg_id, pwg.mail_address as pwg_mail, bb.id as bb_id, bb.username as bb_user, bb.email as bb_mail
    134 FROM '.FluxBB_USERS_TABLE.' AS bb
    135 INNER JOIN '.Register_FluxBB_ID_TABLE.' AS link ON link.id_user_FluxBB = bb.id
    136 INNER JOIN '.USERS_TABLE.' as pwg ON link.id_user_pwg = pwg.id
    137 WHERE pwg.username <> bb.username
    138 AND 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 = '
    177 SELECT COUNT(*) as nbr_dead
    178 FROM '.Register_FluxBB_ID_TABLE.' AS Link
    179 WHERE id_user_FluxBB NOT IN (
    180   SELECT id
    181   FROM '.FluxBB_USERS_TABLE.'
    182   )
    183 OR 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 = '
    209 SELECT COUNT(*) AS nbr_dup, pwg.id AS pwg_id, pwg.username AS pwg_user, bb.username AS bb_user, bb.id AS bb_id
    210 FROM '.FluxBB_USERS_TABLE.' AS bb
    211 INNER JOIN '.Register_FluxBB_ID_TABLE.' AS link ON link.id_user_FluxBB = bb.id
    212 INNER JOIN '.USERS_TABLE.' as pwg ON link.id_user_pwg = pwg.id
    213 WHERE pwg.username NOT IN ("18","16")
    214 GROUP BY link.id_user_pwg, link.id_user_FluxBB
    215 HAVING 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 = '
    247 SELECT 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
    248 FROM '.FluxBB_USERS_TABLE.' AS FluxBB
    249 INNER JOIN '.Register_FluxBB_ID_TABLE.' AS link ON link.id_user_FluxBB = FluxBB.id
    250 INNER JOIN '.USERS_TABLE.' as pwg ON link.id_user_pwg = pwg.id
    251 WHERE BINARY pwg.username = BINARY FluxBB.username
    252 AND pwg.username NOT IN ("18","16")
    253 ORDER 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 = '
    298 SELECT username, mail_address FROM '.USERS_TABLE.'
    299 WHERE BINARY username <> BINARY "guest"
    300 AND username NOT IN ("18","16")
    301 AND id not in (
    302   SELECT id_user_pwg FROM '.Register_FluxBB_ID_TABLE.'
    303   )
    304 AND BINARY username not in (
    305   SELECT username FROM '.FluxBB_USERS_TABLE.'
    306   )
    307 ORDER 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 = '
    338 SELECT id, username, email FROM '.FluxBB_USERS_TABLE.'
    339 WHERE BINARY username <> BINARY "'.$conf_Register_FluxBB['FLUXBB_GUEST'].'"
    340 AND id not in (
    341   SELECT id_user_FluxBB FROM '.Register_FluxBB_ID_TABLE.'
    342   )
    343 AND BINARY username not in (
    344   SELECT username FROM '.USERS_TABLE.'
    345   )
    346 ORDER 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 }
    3975
    3986
     
    40715}
    40816
    409 
     17/**
     18 * Add new registered user in FluxBB user table
     19 */
    41020function Register_FluxBB_Adduser($register_user)
    41121{
     
    41525  if ($register_user['username'] != "16" and $register_user['username'] != "18")
    41626  {
    417     // Warning : FluxBB uses Sha1 hash instead of md5 for Piwigo!
     27    // Warning : FluxBB uses Sha1 hash instead of a salted md5 for Piwigo! // TODO: Reset password
    41828    FluxBB_Adduser($register_user['id'], $register_user['username'], sha1($_POST['password']), $register_user['email']);
    41929  }
    42030}
    42131
    422 
     32/**
     33 * Delete registered user in FluxBB user table
     34 */
    42335function Register_FluxBB_Deluser($user_id)
    42436{
     
    42638}
    42739
    428 
     40/**
     41 * Change user's password in FluxBB user table if a new password is set in Piwigo
     42 */
    42943function Register_FluxBB_InitPage()
    43044{
    43145  global $conf, $user;
    43246
    433   if (isset($_POST['validate']) and !is_admin())
     47  if (isset($_POST['validate']))
    43448  {
    43549    if (!empty($_POST['use_new_pwd']))
     
    44357
    44458      list($username) = pwg_db_fetch_row(pwg_query($query));
    445 
     59      // Warning : FluxBB uses Sha1 hash instead of a salted md5 for Piwigo! // TODO: Reset password
    44660      FluxBB_Updateuser($user['id'], stripslashes($username), sha1($_POST['use_new_pwd']), $_POST['mail_address']);
    44761    }
     
    45064
    45165
     66/**
     67 * Update FluxBB password if user uses "lost password"
     68 */
     69function Register_FluxBB_PasswReset()
     70{
     71  global $page, $user, $conf;
     72
     73  if (isset($_POST['submit']))
     74  {
     75    if ('reset' == $_GET['action'])
     76    {
     77      $user_id = check_password_reset_key($_GET['key']);
     78
     79      $query = '
     80SELECT '.$conf['user_fields']['username'].' AS username, mail_address
     81FROM '.USERS_TABLE.'
     82WHERE '.$conf['user_fields']['id'].' = \''.$user_id.'\'
     83AND '.$conf['user_fields']['username'].' NOT IN ("18","16")
     84;';
     85
     86      list($username,$mail_address) = pwg_db_fetch_row(pwg_query($query));
     87      // Warning : FluxBB uses Sha1 hash instead of a salted md5 for Piwigo! // TODO: Reset password
     88      FluxBB_Updateuser($user_id, stripslashes($username), sha1($_POST['use_new_pwd']), $mail_address);
     89    }
     90  }
     91}
     92
     93/**
     94 * Bridge with UAM confirmation option
     95 */
    45296function UAM_Bridge()
    45397{
     
    527171}
    528172
    529 
     173/**
     174 * Check the username accuracy in FluxBB users table
     175 */
    530176function Register_FluxBB_RegistrationCheck($errors, $user)
    531177{
     
    550196
    551197
     198/**
     199 * Users linking in a dedicated links table
     200 */
    552201function FluxBB_Linkuser($pwg_id, $bb_id)
    553202{
     
    584233
    585234
    586 
     235/**
     236 * Users unlinking in a dedicated links table (on user deletion)
     237 */
    587238function FluxBB_Unlinkuser($bb_id)
    588239{
     
    596247
    597248
    598 
     249/**
     250 * Add new registered user in fluxBB users table
     251 * Called from Register_FluxBB_Adduser()
     252 */
    599253function FluxBB_Adduser($pwg_id, $login, $password, $adresse_mail)
    600254{
     
    734388
    735389
    736 
     390/**
     391 * Search linked users
     392 */
    737393function FluxBB_Searchuser($id_user_pwg)
    738394{
     
    753409
    754410
    755 
     411/**
     412 * Delete user from FluxBB users table
     413 * Called from Register_FluxBB_Deluser()
     414 */
    756415function FluxBB_Deluser($id_user_FluxBB, $SuppTopicsPosts)
    757416{
     
    809468
    810469
    811 
     470/**
     471 * Update user information in FluxBB users table
     472 */
    812473function FluxBB_Updateuser($pwg_id, $username, $password, $adresse_mail)
    813474{
     
    861522}
    862523
    863 
     524/**
     525 * Get plugin information
     526 */
    864527function RegFluxBB_Infos($dir)
    865528{
     
    907570
    908571
     572/**
     573 * Delete obsolete files at plugin update
     574 */
    909575function regfluxbb_obsolete_files()
    910576{
Note: See TracChangeset for help on using the changeset viewer.