Changeset 8475 for extensions/LCAS


Ignore:
Timestamp:
Jan 5, 2011, 10:45:18 AM (13 years ago)
Author:
LucMorizur
Message:

Ambiguous accounts are logged in only when properly typed in; but not ambiguous accounts will benefit of LCAS.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/LCAS/trunk/include/functions.inc.php

    r8271 r8475  
    825825  global $conf;
    826826
    827   $u_d1 = $username;
    828   $username = LCAS_change_case($username, $rule);
    829   $u_d2 = $username;
     827  $username_c = LCAS_change_case($username, $rule);
    830828
    831829  if (isset($username))
     
    839837    while ($r = pwg_db_fetch_assoc($q))
    840838     $LCAS_users[$r['username']] = LCAS_change_case($r['username'], $rule);
    841      // $LCAS_users est maintenant un tableau associatif où la clé est le compte tel qu'enregistré en DB,
    842      // et la valeur est ce même compte, écrit selon LCAS_change_case() pour la règle en cours
    843      
    844     $user_found = array_search($username, $LCAS_users);
    845     // $user_found vaut false si le username actuellement testé ne fait pas partie des valeurs de $LCAS_users ;
    846     // sinon $user_found vaut la clé dans $LCAS_users, correspondant au compte trouvé.
    847     // Donc le compte tel qu'écrit en DB, mais reconnu tel qu'écrit selon LCAS_change_case() pour la règle en cours
    848    
    849     $username = ($user_found === false) ? $username : $user_found;
    850 
    851     return isset($username) ? $username : '';
     839     // $LCAS_users is now an associative table where the key is the account as
     840     // registered in the DB, and the value is this same account, in lower case
     841
     842    $users_found = array_keys($LCAS_users, $username_c);
     843    // $users_found is now a table of which the values are all the accounts
     844    // which can be written in lowercase the same way as $username
     845    if (count($users_found) != 1) // If ambiguous, don't allow lowercase writing
     846     return $username;            // but normal writing will work
     847    else
     848     return $users_found[0];
    852849  }
    853850}
Note: See TracChangeset for help on using the changeset viewer.