Changeset 7968

Show
Ignore:
Timestamp:
12/01/10 22:13:07 (3 years ago)
Author:
Eric
Message:

Bug 2046 fixed : Piwigo's login case sensitivity works again with UAM

Files:
1 modified

Legend:

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

    r7656 r7968  
    33load_language('plugin.lang', UAM_PATH); 
    44 
    5 /* Function called from main.inc.php to send validation email */ 
     5/** 
     6 * Triggered on get_admin_plugin_menu_links 
     7 *  
     8 * Plugin's administration menu  
     9 */ 
     10function UAM_admin_menu($menu) 
     11{ 
     12// +-----------------------------------------------------------------------+ 
     13// |                      Getting plugin name                              | 
     14// +-----------------------------------------------------------------------+ 
     15  $plugin =  PluginInfos(UAM_PATH); 
     16  $name = $plugin['name']; 
     17   
     18  array_push($menu, 
     19    array( 
     20      'NAME' => $name, 
     21      'URL'  => get_admin_plugin_menu_link(UAM_PATH.'/admin/UAM_admin.php') 
     22    ) 
     23  ); 
     24 
     25  return $menu; 
     26} 
     27 
     28/** 
     29 * Triggered on loc_begin_index 
     30 *  
     31 * Initiating GhostTracker 
     32 */ 
     33function UAM_GhostTracker() 
     34{ 
     35  global $conf, $user; 
     36 
     37  $conf_UAM = unserialize($conf['UserAdvManager']); 
     38 
     39  // Admins, Guests and Adult_Content users are not tracked for Ghost Tracker or Users Tracker 
     40  if (!is_admin() and !is_a_guest() and $user['username'] != "16" and $user['username'] != "18") 
     41  { 
     42    if ((isset($conf_UAM[16]) and $conf_UAM[16] == 'true') or (isset($conf_UAM[19]) and $conf_UAM[19] == 'true')) 
     43    { 
     44 
     45      $userid = get_userid($user['username']); 
     46           
     47      // Looking for existing entry in last visit table 
     48      $query = ' 
     49SELECT * 
     50FROM '.USER_LASTVISIT_TABLE.' 
     51WHERE user_id = '.$userid.' 
     52;'; 
     53         
     54      $count = pwg_db_num_rows(pwg_query($query)); 
     55          
     56      if ($count == 0) 
     57      { 
     58        // If not, data are inserted in table 
     59        $query = ' 
     60INSERT INTO '.USER_LASTVISIT_TABLE.' (user_id, lastvisit, reminder) 
     61VALUES ('.$userid.', now(), "false") 
     62;'; 
     63        pwg_query($query); 
     64      } 
     65      else if ($count > 0) 
     66      { 
     67        // If yes, data are updated in table 
     68        $query = ' 
     69UPDATE '.USER_LASTVISIT_TABLE.' 
     70SET lastvisit = now(), reminder = "false" 
     71WHERE user_id = '.$userid.' 
     72LIMIT 1 
     73;'; 
     74        pwg_query($query); 
     75      } 
     76    } 
     77  } 
     78} 
     79 
     80/** 
     81 * Triggered on register_user 
     82 *  
     83 * Additional controls on user registration 
     84 */ 
     85function UAM_Adduser($register_user) 
     86{ 
     87  global $conf; 
     88 
     89  $conf_UAM = unserialize($conf['UserAdvManager']); 
     90 
     91  // Exclusion of Adult_Content users 
     92  if ($register_user['username'] != "16" and $register_user['username'] != "18") 
     93  { 
     94    if ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')) 
     95    { 
     96      // This is to send an information email and set user to "waiting" group or status until admin validation 
     97      $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; 
     98      SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false); 
     99      setgroup($register_user['id']);// Set to "waiting" group or status until admin validation 
     100    } 
     101    elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'false') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')) 
     102    { 
     103      // This is to set user to "waiting" group or status until admin validation 
     104      setgroup($register_user['id']);// Set to "waiting" group or status until admin validation 
     105    } 
     106    elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'false')) 
     107    { 
     108      // This is to send an information email without validation key 
     109      $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; 
     110      SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false); 
     111    } 
     112    // Sending registration confirmation by email 
     113    elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true' or $conf_UAM[0] == 'false') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'true')) 
     114    { 
     115      if (is_admin() and isset($conf_UAM[20]) and $conf_UAM[20] == 'true') 
     116      { 
     117        $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; 
     118        SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true);  
     119      } 
     120      elseif (is_admin() and isset($conf_UAM[20]) and $conf_UAM[20] == 'false') 
     121      { 
     122        $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; 
     123        SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false); 
     124      } 
     125      elseif (!is_admin()) 
     126      { 
     127        $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; 
     128        SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true); 
     129      } 
     130    } 
     131  } 
     132} 
     133 
     134/** 
     135 * Triggered on delete_user 
     136 *  
     137 * Database cleanup on user deletion 
     138 */ 
     139function UAM_Deluser($user_id) 
     140{ 
     141  // Cleanup for ConfirmMail table 
     142  DeleteConfirmMail($user_id); 
     143  // Cleanup for LastVisit table 
     144  DeleteLastVisit($user_id); 
     145  // Cleanup Redirection settings 
     146  DeleteRedir($user_id); 
     147} 
     148 
     149/** 
     150 * Triggered on register_user_check 
     151 *  
     152 * Additional controls on user registration check 
     153 */ 
     154function UAM_RegistrationCheck($err, $user) 
     155{ 
     156  global $errors, $conf; 
     157 
     158  // Exclusion of Adult_Content users 
     159  if ($user['username'] != "16" and $user['username'] != "18") 
     160  { 
     161 
     162// *********************************************************** 
     163// We need to reset the standard Piwigo's register controls    
     164// because the call of register_user_check trigger resets them 
     165// *********************************************************** 
     166 
     167    // ********************************** 
     168    // Standard Piwigo's username control 
     169    // ********************************** 
     170    if ($_POST['login'] == '') 
     171    { 
     172      return l10n('reg_err_login1'); 
     173    } 
     174    if (preg_match('/^.* $/', $_POST['login'])) 
     175    { 
     176      return l10n('reg_err_login2'); 
     177    } 
     178    if (preg_match('/^ .*$/', $_POST['login'])) 
     179    { 
     180      return l10n('reg_err_login3'); 
     181    } 
     182    if (get_userid($_POST['login'])) 
     183    { 
     184      return l10n('reg_err_login5'); 
     185    } 
     186 
     187    if ($conf['insensitive_case_logon'] == true) 
     188    { 
     189      $login_error = validate_login_case($_POST['login']); 
     190      if ($login_error != '') 
     191      { 
     192        return l10n($login_error); 
     193      } 
     194    } 
     195 
     196    if (script_basename() == 'admin' and isset($_GET['page']) and $_GET['page'] == 'user_list') // not the same email variable if we are on users registration page or on admin's user registration page 
     197    { 
     198      // Email doblons check 
     199      $atom   = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]';   // before  arobase 
     200      $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name 
     201      $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i'; 
     202   
     203      if (!preg_match($regex, $_POST['email'])) 
     204      { 
     205        return l10n('reg_err_mail_address'); 
     206      } 
     207     
     208      $query = ' 
     209SELECT count(*) 
     210FROM '.USERS_TABLE.' 
     211WHERE upper('.$conf['user_fields']['email'].') = upper(\''.$_POST['email'].'\') 
     212;'; 
     213      list($count) = pwg_db_fetch_row(pwg_query($query)); 
     214      if ($count != 0) 
     215      { 
     216        return l10n('reg_err_mail_address_dbl'); 
     217      } 
     218    } 
     219 
     220    if (script_basename() == 'register') // not the same email variable if we are on users registration page or on admin's user registration page 
     221    { 
     222      // Email doblons check 
     223      $atom   = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]';   // before  arobase 
     224      $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name 
     225      $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i'; 
     226   
     227      if (!preg_match($regex, $_POST['mail_address'])) 
     228      { 
     229        return l10n('reg_err_mail_address'); 
     230      } 
     231     
     232      $query = ' 
     233SELECT count(*) 
     234FROM '.USERS_TABLE.' 
     235WHERE upper('.$conf['user_fields']['email'].') = upper(\''.$_POST['mail_address'].'\') 
     236;'; 
     237      list($count) = pwg_db_fetch_row(pwg_query($query)); 
     238      if ($count != 0) 
     239      { 
     240        return l10n('reg_err_mail_address_dbl'); 
     241      } 
     242    } 
     243// ****************************************** 
     244// End of Piwigo's standard register controls 
     245// ****************************************** 
     246 
     247 
     248// ****************************************** 
     249// Here begins the advanced register controls 
     250// ****************************************** 
     251    $PasswordCheck = 0; 
     252 
     253    $conf_UAM = unserialize($conf['UserAdvManager']); 
     254 
     255    // Password enforcement control 
     256    if (isset($conf_UAM[13]) and $conf_UAM[13] == 'true' and !empty($conf_UAM[14])) 
     257    { 
     258      if (!empty($user['password']) and !is_admin()) 
     259      { 
     260        $PasswordCheck = testpassword($user['password']); 
     261   
     262        if ($PasswordCheck < $conf_UAM[14]) 
     263        { 
     264          $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck); 
     265          return($lang['reg_err_pass'] = l10n_args($message).$conf_UAM[14]); 
     266        } 
     267      } 
     268      else if (!empty($user['password']) and is_admin() and isset($conf_UAM[15]) and $conf_UAM[15] == 'true') 
     269      { 
     270        $PasswordCheck = testpassword($user['password']); 
     271   
     272        if ($PasswordCheck < $conf_UAM[14]) 
     273        { 
     274          $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck); 
     275          return($lang['reg_err_pass'] = l10n_args($message).$conf_UAM[14]); 
     276        } 
     277      } 
     278    } 
     279 
     280    // Username without forbidden keys 
     281    if (isset($conf_UAM[6]) and $conf_UAM[6] == 'true' and !empty($_POST['login']) and ValidateUsername($_POST['login']) and !is_admin()) 
     282    { 
     283      $_POST['login'] = ''; 
     284      return($lang['reg_err_login1'] = l10n('reg_err_login6')."'".$conf_UAM[7]."'"); 
     285    } 
     286 
     287    // Email without forbidden domains 
     288    if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($_POST['mail_address']) and ValidateEmailProvider($_POST['mail_address']) and !is_admin()) 
     289    { 
     290      $_POST['mail_address'] = ''; 
     291      return($lang['reg_err_login1'] = l10n('reg_err_login7')."'".$conf_UAM[12]."'"); 
     292    } 
     293  } 
     294} 
     295 
     296/** 
     297 * Triggered on loc_begin_profile 
     298 */ 
     299function UAM_Profile_Init() 
     300{ 
     301  global $conf, $user, $template; 
     302 
     303  $conf_UAM = unserialize($conf['UserAdvManager']); 
     304     
     305  if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true')) 
     306  { 
     307    $user_idsOK = array(); 
     308    if (!check_consult($user['id'], $user_idsOK)) 
     309    { 
     310      $user_idsOK[] = $user['id']; 
     311 
     312      $query = " 
     313UPDATE ".CONFIG_TABLE." 
     314SET value = \"".implode(',', $user_idsOK)."\" 
     315WHERE param = 'UserAdvManager_Redir';"; 
     316           
     317      pwg_query($query); 
     318    } 
     319  } 
     320 
     321  if (isset($_POST['validate']) and !is_admin()) 
     322  { 
     323    // Email without forbidden domains 
     324    if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($_POST['mail_address'])) 
     325    { 
     326      if (ValidateEmailProvider($_POST['mail_address'])) 
     327      { 
     328        $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[12]."'"); 
     329        unset($_POST['validate']); 
     330      } 
     331    } 
     332 
     333    $typemail = 3; 
     334 
     335    if (!empty($_POST['use_new_pwd'])) 
     336    { 
     337      $typemail = 2; 
     338 
     339      // Password enforcement control 
     340      if (isset($conf_UAM[13]) and $conf_UAM[13] == 'true' and !empty($conf_UAM[14])) 
     341      { 
     342        $PasswordCheck = testpassword($_POST['use_new_pwd']); 
     343 
     344        if ($PasswordCheck < $conf_UAM[14]) 
     345        { 
     346          $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck); 
     347          $template->append('errors', l10n_args($message).$conf_UAM[14]); 
     348          unset($_POST['use_new_pwd']); 
     349          unset($_POST['validate']); 
     350        } 
     351      } 
     352    } 
     353 
     354    // Sending registration confirmation by email 
     355    if ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') or (isset($conf_UAM[1]) and $conf_UAM[1] == 'true') or (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')) 
     356    { 
     357      $confirm_mail_need = false; 
     358 
     359      if (!empty($_POST['mail_address'])) 
     360      { 
     361        $query = ' 
     362SELECT '.$conf['user_fields']['email'].' AS email 
     363FROM '.USERS_TABLE.' 
     364WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\' 
     365;'; 
     366 
     367        list($current_email) = pwg_db_fetch_row(pwg_query($query)); 
     368 
     369        // This is to send a new validation key 
     370        if ($_POST['mail_address'] != $current_email and (isset($conf_UAM[1]) and $conf_UAM[1] == 'true')) 
     371         
     372          $confirm_mail_need = true; 
     373 
     374        // This is to set the user to "waiting" group or status until admin validation 
     375        if ($_POST['mail_address'] != $current_email and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')) 
     376         
     377          setgroup($register_user['id']);// Set to "waiting" group or status until admin validation 
     378          $confirm_mail_need = false; 
     379      } 
     380         
     381      if ((!empty($_POST['use_new_pwd']) and (isset($conf_UAM[0]) and $conf_UAM[0] == 'true') or $confirm_mail_need)) 
     382      { 
     383        $query = ' 
     384SELECT '.$conf['user_fields']['username'].' 
     385FROM '.USERS_TABLE.' 
     386WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\' 
     387;'; 
     388         
     389        list($username) = pwg_db_fetch_row(pwg_query($query)); 
     390        SendMail2User($typemail, $user['id'], $username, $_POST['use_new_pwd'], $_POST['mail_address'], $confirm_mail_need); 
     391      } 
     392    } 
     393  } 
     394} 
     395 
     396/** 
     397 * Triggered on login_success 
     398 *  
     399 * redirects a visitor (except for admins, webmasters and generic statuses) to his profile.php page 
     400 *  
     401 * Thx to LucMorizur 
     402 */ 
     403function UAM_RedirectToProfile() 
     404{ 
     405  global $conf, $user; 
     406   
     407  $conf_UAM = unserialize($conf['UserAdvManager']); 
     408   
     409  $query =' 
     410SELECT user_id, status 
     411FROM '.USER_INFOS_TABLE.' 
     412WHERE user_id = '.$user['id'].' 
     413;'; 
     414  $data = pwg_db_fetch_assoc(pwg_query($query)); 
     415   
     416  if ($data['status'] <> "admin" and $data['status'] <> "webmaster" and $data['status'] <> "generic") 
     417  { 
     418    if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true')) 
     419    { 
     420      $user_idsOK = array(); 
     421      if (!check_consult($user['id'], $user_idsOK)) 
     422        redirect(PHPWG_ROOT_PATH.'profile.php'); 
     423    } 
     424  } 
     425} 
     426 
     427/** 
     428 * Triggered on login_success 
     429 *  
     430 * Executes optional post-login tasks like GhostTracker auto tasks 
     431 *  
     432 */ 
     433function UAM_Tasks() 
     434{ 
     435  global $conf, $user; 
     436   
     437  $conf_UAM = unserialize($conf['UserAdvManager']); 
     438 
     439  // Ghost accounts auto deletion 
     440  if ((isset($conf_UAM[22]) and $conf_UAM[22] == 'true') and (isset($conf_UAM[23]) and $conf_UAM[23] == 'true')) 
     441  { 
     442     
     443  } 
     444 
     445  // Ghost accounts auto group or status downgrade with or without information email sending 
     446  if ((isset($conf_UAM[22]) and $conf_UAM[22] == 'true') and (isset($conf_UAM[23]) and $conf_UAM[23] == 'false') and ((isset($conf_UAM[27]) and $conf_UAM[27] <> -1) or (isset($conf_UAM[28]) and $conf_UAM[28] <> -1))) 
     447  { 
     448     
     449  } 
     450} 
     451 
     452/** 
     453 * Triggered on init 
     454 *  
     455 * Check for forbidden email domains in admin's users management panel 
     456 */ 
     457function UAM_InitPage() 
     458{ 
     459  load_language('plugin.lang', UAM_PATH); 
     460  global $conf, $template, $page, $lang, $errors; 
     461 
     462  $conf_UAM = unserialize($conf['UserAdvManager']); 
     463 
     464// Admin user management 
     465  if (script_basename() == 'admin' and isset($_GET['page']) and $_GET['page'] == 'user_list') 
     466  { 
     467    if (isset($_POST['submit_add'])) 
     468    { 
     469      // Email without forbidden domains 
     470      if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($_POST['email']) and ValidateEmailProvider($_POST['email'])) 
     471      { 
     472        $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[12]."'"); 
     473        unset($_POST['submit_add']); 
     474      } 
     475    } 
     476  } 
     477} 
     478 
     479/** 
     480 * Triggered on user_comment_check 
     481 *  
     482 * checks if author is mandatory and set on comments post 
     483 * 
     484 * @param : comment action, comment 
     485 *  
     486 * @return : comment action 
     487 *  
     488 */ 
     489function UAM_CheckEmptyCommentAuthor($comment_action, $comm) 
     490{ 
     491  load_language('plugin.lang', UAM_PATH); 
     492  global $infos, $conf, $template; 
     493 
     494  $conf_UAM = unserialize($conf['UserAdvManager']); 
     495 
     496// User creation OR update 
     497  if (isset($conf_UAM[5]) and $conf_UAM[5] == 'true' and $conf['comments_forall'] == 'true' and $comm['author'] == 'guest') 
     498  { 
     499    $comment_action = 'reject'; 
     500 
     501    array_push($infos, l10n('UAM_Empty Author')); 
     502  } 
     503 
     504  return $comment_action; 
     505} 
     506 
     507/** 
     508 * Function called from main.inc.php to send validation email 
     509 * 
     510 * @param : Type of email, user id, username, email address, confirmation (optional) 
     511 *  
     512 */ 
    6513function SendMail2User($typemail, $id, $username, $password, $email, $confirm) 
    7514{ 
     515  // Only available for next Piwigo release (bug in switch_lang function) 
    8516  global $conf; 
    9517 
     
    15523  $infos2_perso = ""; 
    16524 
    17 /* We have to get the user's language in database */ 
     525// We have to get the user's language in database 
    18526  $query =' 
    19527SELECT user_id, language 
     
    23531  $data = pwg_db_fetch_assoc(pwg_query($query)); 
    24532 
    25 /* Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language */ 
     533// Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language 
    26534  if (empty($data)) 
    27535  { 
    28 /* And switch gallery to this language before using personalized and multilangual contents */ 
     536// And switch gallery to this language before using personalized and multilangual contents 
    29537    $language = pwg_get_session_var( 'lang_switch', $user['language'] ); 
    30538    switch_lang_to($language); 
     
    32540  else 
    33541  { 
    34 /* And switch gallery to this language before using personalized and multilangual contents */ 
    35     $language = $data['language']; /* Usefull for debugging */ 
     542// And switch gallery to this language before using personalized and multilangual contents 
     543    $language = $data['language']; // Usefull for debugging 
    36544    switch_lang_to($data['language']); 
    37545    load_language('plugin.lang', UAM_PATH); 
     
    98606  } 
    99607 
    100 /* ******************************************************** */ 
    101 /* **** Pending code since to find how to make it work **** */ 
    102 /* ******************************************************** */ 
     608// ******************************************************** 
     609// **** Pending code since to find how to make it work **** 
     610// ******************************************************** 
    103611// Testing if FCK Editor is used. Then decoding htmlchars to avoid problems with pwg_mail() 
    104612/*$areas = array(); 
     
    123631 
    124632 
    125 /* Sending the email with subject and contents */ 
     633// Sending the email with subject and contents 
    126634  pwg_mail($email, array( 
    127635    'subject' => $subject, 
     
    129637  )); 
    130638 
    131 /* ********************** */ 
    132 /* Email sending debugger */ 
    133 /* This is only to trace  */ 
    134 /* the send of emails for */ 
    135 /* debugging              */ 
    136 /* ********************** */ 
     639// ********************** 
     640// Email sending debugger 
     641// This is only to trace  
     642// the send of emails for 
     643// debugging              
     644// ********************** 
    137645//$content = (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "").get_absolute_root_url();    
    138646//MailLog($email,$subject,$content,$language); 
    139 /* ********************** */ 
    140  
    141 /* Switching back to default language */ 
     647// ********************** 
     648 
     649// Switching back to default language 
    142650switch_lang_back(); 
    143651} 
    144652 
    145  
    146 /* Function called from UAM_admin.php to resend validation email with or without new validation key */ 
     653/** 
     654 * Function called from UAM_admin.php to resend validation email with or without new validation key 
     655 * 
     656 * @param : Type of email, user id, username, email address, confirmation (optional) 
     657 *  
     658 */ 
    147659function ResendMail2User($typemail, $user_id, $username, $email, $confirm) 
    148660{ 
    149   /* Only available for next Piwigo release (bug in switch_lang function) */ 
     661  // Only available for next Piwigo release (bug in switch_lang function) 
    150662  global $conf; 
    151663 
     
    159671  $infos2_perso = ""; 
    160672   
    161 /* We have to get the user's language in database */ 
     673// We have to get the user's language in database 
    162674  $query =' 
    163675SELECT user_id, language 
     
    168680  $language = $data['language']; 
    169681   
    170 /* And switch gallery to this language before using personalized and multilangual contents */ 
     682// And switch gallery to this language before using personalized and multilangual contents 
    171683  switch_lang_to($data['language']); 
    172684    
     
    193705                        } 
    194706 
    195 /* Set reminder true */       
     707// Set reminder true       
    196708      $query = " 
    197709UPDATE ".USER_CONFIRM_MAIL_TABLE." 
     
    215727      } 
    216728       
    217 /* Set reminder true */       
     729// Set reminder true       
    218730      $query = " 
    219731UPDATE ".USER_CONFIRM_MAIL_TABLE." 
     
    231743  )); 
    232744 
    233 /* ********************** */ 
    234 /* Email sending debugger */ 
    235 /* This is only to trace  */ 
    236 /* the send of emails for */ 
    237 /* debugging              */ 
    238 /* ********************** */ 
     745// ********************** 
     746// Email sending debugger 
     747// This is only to trace  
     748// the send of emails for 
     749// debugging              
     750// ********************** 
    239751//$content = ($infos1."\n\n").(isset($infos2) ? l10n_args($infos2)."\n\n" : "").get_absolute_root_url(); 
    240752//MailLog($email,$subject,$content,$language); 
    241 /* ********************** */ 
    242  
    243 /* Switching back to default language */ 
     753// ********************** 
     754 
     755// Switching back to default language 
    244756switch_lang_back(); 
    245757} 
    246758 
    247  
    248 /* Function called from UAM_admin.php to send a reminder mail for ghost users */ 
     759/** 
     760 * Function called from UAM_admin.php to send a reminder mail for ghost users 
     761 * 
     762 * @param : User id, username, email address 
     763 *  
     764 */ 
    249765function ghostreminder($user_id, $username, $email) 
    250766{ 
    251   /* Only available for next Piwigo release (bug in switch_lang function) */ 
     767  // Only available for next Piwigo release (bug in switch_lang function) 
    252768  global $conf; 
    253769 
     
    258774        $infos1_perso = ""; 
    259775 
    260 /* We have to get the user's language in database */ 
     776// We have to get the user's language in database 
    261777  $query =' 
    262778SELECT user_id, language 
     
    267783  $language = $data['language']; 
    268784 
    269 /* And switch gallery to this language before using personalized and multilangual contents */ 
     785// And switch gallery to this language before using personalized and multilangual contents 
    270786  switch_lang_to($data['language']); 
    271787    
     
    293809  )); 
    294810 
    295 /* ********************** */ 
    296 /* Email sending debugger */ 
    297 /* This is only to trace  */ 
    298 /* the send of emails for */ 
    299 /* debugging              */ 
    300 /* ********************** */ 
     811// ********************** 
     812// Email sending debugger 
     813// This is only to trace  
     814// the send of emails for 
     815// debugging              
     816// ********************** 
    301817//$content = get_user_language_desc($conf_UAM[19])."\n\n";   
    302818//MailLog($email,$subject,$content,$language); 
    303 /* ********************** */ 
    304  
    305 /* Switching back to default language */ 
     819// ********************** 
     820 
     821// Switching back to default language 
    306822switch_lang_back(); 
    307823} 
    308824 
    309  
    310 /* Function called from functions AddConfirmMail and ResetConfirmMail for validation key generation */ 
     825/** 
     826 * Function called from functions AddConfirmMail and ResetConfirmMail for validation key generation 
     827 *  
     828 * @return : validation key 
     829 *  
     830 */ 
    311831function FindAvailableConfirmMailID() 
    312832{ 
     
    326846} 
    327847 
    328  
    329 /* Function called from functions SendMail2User to process unvalidated users and generate validation key link */ 
     848/** 
     849 * Function called from functions SendMail2User to process unvalidated users and generate validation key link 
     850 * 
     851 * @param : User id, email address 
     852 *  
     853 * @return : Build validation key in URL 
     854 *  
     855 */ 
    330856function AddConfirmMail($user_id, $email) 
    331857{ 
     
    390916} 
    391917 
    392  
    393 /* Function called from main.inc.php to set group to new users if manual validation is set */ 
     918/** 
     919 * Function called from main.inc.php to set group to new users if manual validation is set 
     920 * 
     921 * @param : User id 
     922 *  
     923 *  
     924 */ 
    394925function setgroup($user_id) 
    395926{ 
     
    431962} 
    432963 
    433  
    434 /* Function called from UAM_admin.php to reset validation key */ 
     964/** 
     965 * Function called from UAM_admin.php to reset validation key 
     966 * 
     967 * @param : User id 
     968 *  
     969 * @return : Build validation key in URL 
     970 *  
     971 */ 
    435972function ResetConfirmMail($user_id) 
    436973{ 
     
    461998} 
    462999 
    463  
    464 /* Function called from function_UserAdvManager.inc.php to reset last visit date after sending a reminder */ 
     1000/** 
     1001 * Function called from functions.inc.php to reset last visit date after sending a reminder 
     1002 * 
     1003 * @param : User id 
     1004 *  
     1005 */ 
    4651006function resetlastvisit($user_id) 
    4661007{ 
     
    4781019 
    4791020 
    480 /* Function called from main.inc.php - Triggered on user deletion */ 
     1021/** 
     1022 * Function called from main.inc.php - Triggered on user deletion 
     1023 *  
     1024 */ 
    4811025function DeleteConfirmMail($user_id) 
    4821026{ 
     
    4881032} 
    4891033 
    490 /* Function called from main.inc.php - Triggered on user deletion */ 
     1034/** 
     1035 * Function called from main.inc.php - Triggered on user deletion 
     1036 *  
     1037 */ 
    4911038function DeleteLastVisit($user_id) 
    4921039{ 
     
    4981045} 
    4991046 
    500  
    501 /* Function called from main.inc.php - Triggered on user deletion */ 
     1047/** 
     1048 * Function called from main.inc.php - Triggered on user deletion 
     1049 * 
     1050 * @param : User id 
     1051 *  
     1052 */ 
    5021053function DeleteRedir($user_id) 
    5031054{ 
     
    5241075} 
    5251076 
    526  
    527 /* Function called from ConfirmMail.php to verify validation key used by user according time limit */ 
    528 /* Return true is key validation is OK else return false */ 
     1077/** 
     1078 * Function called from ConfirmMail.php to verify validation key used by user according time limit 
     1079 * Return true is key validation is OK else return false 
     1080 * 
     1081 * @param : User id 
     1082 *  
     1083 * @return : Bool 
     1084 *  
     1085 */ 
    5291086function VerifyConfirmMail($id) 
    5301087{ 
     
    5621119      list($registration_date) = pwg_db_fetch_row(pwg_query($query)); 
    5631120 
    564 /*              Time limit process              */ 
    565 /* ******************************************** */   
     1121//              Time limit process              
     1122// ********************************************   
    5661123      if (!empty($registration_date)) 
    5671124      { 
     
    6941251} 
    6951252 
    696 /* Function called from UAM_admin.php to force users validation by admin */ 
     1253/** 
     1254 * Function called from UAM_admin.php to force users validation by admin 
     1255 * 
     1256 * @param : User id 
     1257 *  
     1258 * @return : Bool 
     1259 *  
     1260 */ 
    6971261function ForceValidation($id) 
    6981262{ 
     
    7741338} 
    7751339 
    776  
    777 /* Function called from main.inc.php - Check if username matches forbidden caracters */ 
     1340/** 
     1341 * Function called from main.inc.php - Check if username matches forbidden caracters 
     1342 * 
     1343 * @param : User login 
     1344 *  
     1345 * @return : Bool 
     1346 *  
     1347 */ 
    7781348function ValidateUsername($login) 
    7791349{ 
     
    8001370} 
    8011371 
    802  
    803 /* Function called from main.inc.php - Check if user's email is in excluded email providers list */ 
    804 /* Doesn't work on call - Must be copied in main.inc.php to work */ 
     1372/** 
     1373 * Function called from main.inc.php - Check if user's email is in excluded email providers list 
     1374 * Doesn't work on call - Must be copied in main.inc.php to work 
     1375 * 
     1376 * @param : Email address 
     1377 *  
     1378 * @return : Bool 
     1379 *  
     1380 */ 
    8051381function ValidateEmailProvider($email) 
    8061382{ 
     
    8281404} 
    8291405 
    830  
    831 /* Function called from UserAdvManager.php - Get unvalidated users according time limit */ 
     1406/** 
     1407 * Function called from UAM_admin.php - Get unvalidated users according time limit 
     1408 *  
     1409 * @return : List of users 
     1410 *  
     1411 */ 
    8321412function get_unvalid_user_list() 
    8331413{ 
    8341414        global $conf, $page; 
    8351415           
    836         /* Get ConfirmMail configuration */ 
     1416        // Get ConfirmMail configuration 
    8371417  $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); 
    838   /* Get UAM configuration */ 
     1418  // Get UAM configuration 
    8391419  $conf_UAM = unserialize($conf['UserAdvManager']); 
    8401420   
    8411421  $users = array(); 
    8421422 
    843         /* search users depending expiration date */ 
     1423        // search users depending expiration date 
    8441424  $query = ' 
    8451425SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, 
     
    8891469        } 
    8901470 
    891         /* add group lists */ 
     1471        // add group lists 
    8921472  $user_ids = array(); 
    8931473  foreach ($users as $i => $user) 
     
    9201500} 
    9211501 
    922  
    923 /* Function called from UserAdvManager.php - Get ghost users */ 
     1502/** 
     1503 * Function called from UAM_admin.php - Get ghost users 
     1504 *  
     1505 * @return : List of users 
     1506 *  
     1507 */ 
    9241508function get_ghost_user_list() 
    9251509{ 
     
    9301514  $users = array(); 
    9311515 
    932         /* search users depending expiration date */ 
     1516        // search users depending expiration date 
    9331517  $query = ' 
    9341518SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, 
     
    9531537        } 
    9541538 
    955         /* add group lists */ 
     1539        // add group lists 
    9561540  $user_ids = array(); 
    9571541  foreach ($users as $i => $user) 
     
    9631547} 
    9641548 
    965  
    966 /* Function called from UserAdvManager.php - Get all users to display the number of days since their last visit */ 
     1549/** 
     1550 * Function called from UAM_admin.php - Get all users to display the number of days since their last visit 
     1551 *  
     1552 * @return : List of users 
     1553 *  
     1554 */ 
    9671555function get_user_list() 
    9681556{ 
     
    9711559  $users = array(); 
    9721560 
    973         /* search users depending expiration date */ 
     1561        // search users depending expiration date 
    9741562  $query = ' 
    9751563SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, 
     
    9941582        } 
    9951583 
    996         /* add group lists */ 
     1584        // add group lists 
    9971585  $user_ids = array(); 
    9981586  foreach ($users as $i => $user) 
     
    10041592} 
    10051593 
    1006  
    1007 /* Function called from UserAdvManager.php - to determine who is expired or not and giving a different display color */ 
     1594/** 
     1595 * Function called from UAM_admin.php - to determine who is expired or not and giving a different display color 
     1596 * 
     1597 * @param : user id 
     1598 *  
     1599 * @return : Bool 
     1600 *  
     1601 */ 
    10081602function expiration($id) 
    10091603{ 
    10101604        global $conf, $page; 
    10111605           
    1012         /* Get ConfirmMail configuration */ 
     1606        // Get ConfirmMail configuration 
    10131607  $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); 
    10141608           
    1015         /* Get UAM configuration */ 
     1609        // Get UAM configuration 
    10161610  $conf_UAM = unserialize($conf['UserAdvManager']); 
    10171611         
     
    10231617        list($registration_date) = pwg_db_fetch_row(pwg_query($query)); 
    10241618 
    1025 /*              Time limit process              */ 
    1026 /* ******************************************** */   
     1619//              Time limit process              
     1620// ********************************************   
    10271621        if (!empty($registration_date)) 
    10281622  { 
     
    10551649 * Returns a password's score for password complexity check 
    10561650 * 
    1057  * @param password filled by user 
     1651 * @param : password filled by user 
     1652 *  
     1653 * @return : Score calculation 
    10581654 *  
    10591655 * Thanx to MathieuGut from http://m-gut.developpez.com 
     
    11281724} 
    11291725 
    1130 /* Function called from maintain.inc.php - to check if database upgrade is needed */ 
     1726/** 
     1727 * Function called from maintain.inc.php - to check if database upgrade is needed 
     1728 *  
     1729 * @param : table name 
     1730 *  
     1731 * @return : boolean 
     1732 *  
     1733 */ 
    11311734function table_exist($table) 
    11321735{ 
     
    11351738} 
    11361739 
    1137 /* Email sending debugger function */ 
     1740// Email sending debugger function 
    11381741function MailLog($to, $subject, $content, $language) 
    11391742{ 
     
    11481751} 
    11491752 
    1150  
    1151 /* Function called from UAM_admin.php and main.inc.php to get the plugin version and name */ 
     1753/** 
     1754 * Function called from UAM_admin.php and main.inc.php to get the plugin version and name 
     1755 * 
     1756 * @param : plugin directory 
     1757 *  
     1758 * @return : plugin's version and name 
     1759 *  
     1760 */ 
    11521761function PluginInfos($dir) 
    11531762{ 
     
    12131822} 
    12141823 
    1215  
    1216 // check_consult - Thx to LucMorizur 
    1217 // checks if a user id is registered as having already 
    1218 // visited his profile.php page. 
    1219 // @uid        : the user id 
    1220 // @user_idsOK : (returned) array of all users ids having already visited 
    1221 //               their profile.php pages 
    1222 // 
    1223 // @returns    : true or false whether the users has already visited his 
    1224 //               profile.php page or not 
     1824/** 
     1825 * check_consult - Thx to LucMorizur 
     1826 * checks if a user id is registered as having already 
     1827 * visited his profile.php page. 
     1828 *  
     1829 * @uid        : the user id 
     1830 *  
     1831 * @user_idsOK : (returned) array of all users ids having already visited 
     1832 *               their profile.php pages 
     1833 *  
     1834 * @returns    : true or false whether the users has already visited his 
     1835 *               profile.php page or not 
     1836 *  
     1837 */ 
    12251838function check_consult($uid, &$user_idsOK) 
    12261839{