Ignore:
Timestamp:
Sep 30, 2011, 1:50:32 PM (13 years ago)
Author:
Eric
Message:
  • Bug 2447 fixed : Pre-filled text are localized for installation from scratch. If language is not supported by the plugin, the default language remains English.
  • maintain.inc.php refactory : Simplify installation from scratch and make code more readable.
  • Comments in all code are more readable.
Location:
extensions/UserAdvManager/trunk/include
Files:
2 edited

Legend:

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

    r12239 r12271  
    4040
    4141  // Admins, Guests and Adult_Content users are not tracked for Ghost Tracker or Users Tracker
     42  // -----------------------------------------------------------------------------------------
    4243  if (!is_admin() and !is_a_guest() and $user['username'] != "16" and $user['username'] != "18")
    4344  {
     
    4849         
    4950      // Looking for existing entry in last visit table
     51      // ----------------------------------------------
    5052      $query = '
    5153SELECT *
     
    5961      {
    6062        // If not, data are inserted in table
     63        // ----------------------------------
    6164        $query = '
    6265INSERT INTO '.USER_LASTVISIT_TABLE.' (user_id, lastvisit, reminder)
     
    6871      {
    6972        // If yes, data are updated in table
     73        // ---------------------------------
    7074        $query = '
    7175UPDATE '.USER_LASTVISIT_TABLE.'
     
    9397
    9498  // Exclusion of Adult_Content users
     99  // --------------------------------
    95100  if ($register_user['username'] != "16" and $register_user['username'] != "18")
    96101  {
     
    98103    {
    99104      // This is to send an information email and set user to "waiting" group or status until admin validation
     105      // -----------------------------------------------------------------------------------------------------
    100106      $passwd = (isset($_POST['password'])) ? $_POST['password'] : '';
    101107      SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false);
     
    105111    {
    106112      // This is to set user to "waiting" group or status until admin validation
     113      // -----------------------------------------------------------------------
    107114      SetPermission($register_user['id']);// Set to "waiting" group or status until admin validation
    108115    }
     
    110117    {
    111118      // This is to send an information email without validation key
     119      // -----------------------------------------------------------
    112120      $passwd = (isset($_POST['password'])) ? $_POST['password'] : '';
    113121      SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false);
    114122    }
    115123    // Sending registration confirmation by email
     124    // ------------------------------------------
    116125    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'))
    117126    {
     
    144153{
    145154  // Cleanup for ConfirmMail table
     155  // -----------------------------
    146156  DeleteConfirmMail($user_id);
    147157  // Cleanup for LastVisit table
     158  // ---------------------------
    148159  DeleteLastVisit($user_id);
    149160  // Cleanup Redirection settings
     161  // ----------------------------
    150162  DeleteRedir($user_id);
    151163}
     
    162174
    163175  // Exclusion of Adult_Content users
     176  // --------------------------------
    164177  if ($user['username'] != "16" and $user['username'] != "18")
    165178  {
     
    171184
    172185    // Password enforcement control
     186    // ----------------------------
    173187    if (isset($conf_UAM[12]) and $conf_UAM[12] == 'true' and !empty($conf_UAM[13]))
    174188    {
     
    198212
    199213    // Username without forbidden keys
     214    // -------------------------------
    200215    if (isset($conf_UAM[5]) and $conf_UAM[5] == 'true' and !empty($user['username']) and ValidateUsername($user['username']) and !is_admin())
    201216    {
     
    205220
    206221    // Email without forbidden domains
     222    // -------------------------------
    207223    if (isset($conf_UAM[10]) and $conf_UAM[10] == 'true' and !empty($user['email']) and ValidateEmailProvider($user['email']) and !is_admin())
    208224    {
     
    225241
    226242  // Update first redirection parameter
     243  // ----------------------------------
    227244  if ((isset($conf_UAM[20]) and $conf_UAM[20] == 'true'))
    228245  {
     
    242259
    243260  // Special message display for password reset
     261  // ------------------------------------------
    244262  if ((isset($conf_UAM[38]) and $conf_UAM[38] == 'true'))
    245263  {
     
    251269
    252270  // Controls on profile page submission
     271  // -----------------------------------
    253272  if (isset($_POST['validate']) and !is_admin())
    254273  {
    255274    // Email without forbidden domains
     275    // -------------------------------
    256276    if (isset($conf_UAM[10]) and $conf_UAM[10] == 'true' and !empty($_POST['mail_address']))
    257277    {
     
    264284
    265285    // Password reset control
     286    // ----------------------
    266287    if (isset($conf_UAM[38]) and $conf_UAM[38] == 'true' and UAM_check_pwgreset($user['id']))
    267288    {
    268289      // if password not changed then pwdreset filed = true else pwdreset field = false
     290      // ------------------------------------------------------------------------------
    269291      if (!empty($_POST['use_new_pwd']))
    270292      {
     
    286308
    287309      // Password enforcement control
     310      // ----------------------------
    288311      if (isset($conf_UAM[12]) and $conf_UAM[12] == 'true' and !empty($conf_UAM[13]))
    289312      {
     
    301324
    302325    // Sending registration confirmation by email
     326    // ------------------------------------------
    303327    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'))
    304328    {
     
    316340
    317341        // This is to send a new validation key
     342        // ------------------------------------
    318343        if ($_POST['mail_address'] != $current_email and (isset($conf_UAM[1]) and $conf_UAM[1] == 'true'))
    319344       
     
    321346
    322347        // This is to set the user to "waiting" group or status until admin validation
     348        // ---------------------------------------------------------------------------
    323349        if ($_POST['mail_address'] != $current_email and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local'))
    324350       
     
    357383 
    358384  // Performing GhostTracker scheduled tasks
     385  // ---------------------------------------
    359386  if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true'))
    360387  {
     
    363390
    364391  // Performing User validation scheduled tasks
     392  // ------------------------------------------
    365393  if ((isset($conf_UAM[30]) and $conf_UAM[30] == 'true'))
    366394  {
     
    369397
    370398  // Performing redirection to profile page on first login
     399  // -----------------------------------------------------
    371400  if ((isset($conf_UAM[20]) and $conf_UAM[20] == 'true'))
    372401  { 
     
    387416
    388417  // Performing redirection to profile page for password reset
     418  // ---------------------------------------------------------
    389419  if ((isset($conf_UAM[38]) and $conf_UAM[38] == 'true'))
    390420  {
     
    453483  }
    454484
    455   // Ghost accounts auto group, status or privacy level downgrade with or without information email sending and autodeletion if user already reminded
     485  // GhostTracker auto group, status or privacy level downgrade with or without information email sending and autodeletion if user already reminded
     486  // ----------------------------------------------------------------------------------------------------------------------------------------------
    456487  if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true') and ((isset($conf_UAM[25]) and $conf_UAM[25] <> -1) or (isset($conf_UAM[26]) and $conf_UAM[26] <> -1) or (isset($conf_UAM[37]) and $conf_UAM[37] <> -1)))
    457488  {
     
    459490        {
    460491      // Process if a non-admin nor webmaster user is logged
     492      // ---------------------------------------------------
    461493      if (in_array($user['id'], $collection))
    462494        {
    463495        // Check lastvisit reminder state
     496        // ------------------------------
    464497        $query = '
    465498SELECT reminder
     
    479512
    480513        // If user already reminded for ghost account
     514        // ------------------------------------------
    481515        if ($reminder)
    482516        {
    483           // delete account
     517          // Delete account
     518          // --------------
    484519          delete_user($user['id']);
    485520
    486521          // Logged-in user cleanup, session destruction and redirected to custom page
     522          // -------------------------------------------------------------------------
    487523          invalidate_user_cache();
    488524          logout_user();
     
    495531        {
    496532          // Check lastvisit reminder state
     533          // ------------------------------
    497534          $query = '
    498535SELECT reminder
     
    512549
    513550          // If never reminded before
     551          // ------------------------
    514552          if (!$reminder)
    515553          {
    516             // Reset of lastvisit date
     554            // Reset of lastvisit date
     555            // -----------------------
    517556            list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
    518557
     
    525564
    526565          // Auto change group and / or status
     566          // ---------------------------------
    527567            // Delete user from all groups
     568            // ---------------------------
    528569            $query = "
    529570DELETE FROM ".USER_GROUP_TABLE."
     
    538579
    539580            // Change user status
     581            // ------------------
    540582            if ($conf_UAM[26] <> -1)
    541583            {
     
    549591
    550592            // Change user group
     593            // -----------------
    551594            if ($conf_UAM[25] <> -1)
    552595            {
     
    561604
    562605            // Change user privacy level
     606            // -------------------------
    563607            if ($conf_UAM[37] <> -1)
    564608            {
     
    572616
    573617            // Auto send email notification on group / status downgrade
     618            // --------------------------------------------------------
    574619            if (isset($conf_UAM[22]) and $conf_UAM[22] == 'true')
    575620            {
    576621              // Set reminder true
     622              // -----------------
    577623              $query = "
    578624UPDATE ".USER_LASTVISIT_TABLE."
     
    583629           
    584630              // Reset confirmed user status to unvalidated
     631              // ------------------------------------------
    585632                                                  $query = '
    586633UPDATE '.USER_CONFIRM_MAIL_TABLE.'
     
    591638
    592639              // Get users information for email notification
     640              // --------------------------------------------
    593641                                                  $query = '
    594642SELECT id, username, mail_address
     
    603651          elseif ($reminder) // If user already reminded for ghost account
    604652          {
    605             // delete account
     653            // Delete account
     654            // --------------
    606655            delete_user($user_id);
    607656          }
     
    643692
    644693  // Unvalidated accounts auto email sending and autodeletion if user already reminded
     694  // ---------------------------------------------------------------------------------
    645695  if ((isset($conf_UAM[30]) and $conf_UAM[30] == 'true'))
    646696  {
     
    648698        {
    649699      // Process if a non-admin nor webmaster user is logged
     700      // ---------------------------------------------------
    650701      if (in_array($user['id'], $collection))
    651702        {
    652703        // Check ConfirmMail reminder state
     704        // --------------------------------
    653705        $query = '
    654706SELECT reminder
     
    668720
    669721        // If never reminded before, send reminder and set reminder True
     722        // -------------------------------------------------------------
    670723        if (!$reminder and isset($conf_UAM[32]) and $conf_UAM[32] == 'true')
    671724        {
     
    673726         
    674727          // Get current user informations
     728          // -----------------------------
    675729          $query = "
    676730SELECT id, username, mail_address
     
    684738
    685739        // If already reminded before, delete user
     740        // ---------------------------------------
    686741        if ($reminder)
    687742        {
     
    690745
    691746          // Logged-in user cleanup, session destruction and redirected to custom page
     747          // -------------------------------------------------------------------------
    692748          invalidate_user_cache();
    693749          logout_user();
     
    700756        {
    701757          // Check reminder state
     758          // --------------------
    702759          $query = '
    703760SELECT reminder
     
    717774
    718775          // If never reminded before, send reminder and set reminder True
     776          // -------------------------------------------------------------
    719777          if (!$reminder and isset($conf_UAM[32]) and $conf_UAM[32] == 'true')
    720778          {
     
    722780         
    723781            // Get current user informations
     782            // -----------------------------
    724783            $query = "
    725784SELECT id, username, mail_address
     
    733792          elseif ($reminder) // If user already reminded for account validation
    734793          {
    735             // delete account
     794            // Delete account
     795            // --------------
    736796            delete_user($user_id);
    737797          }
     
    756816
    757817// Admin user management
     818// ---------------------
    758819  if (script_basename() == 'admin' and isset($_GET['page']) and $_GET['page'] == 'user_list')
    759820  {
     
    761822    {
    762823      // Email without forbidden domains
     824      // -------------------------------
    763825      if (isset($conf_UAM[10]) and $conf_UAM[10] == 'true' and !empty($_POST['email']) and ValidateEmailProvider($_POST['email']))
    764826      {
     
    824886
    825887// We have to get the user's language in database
     888// ----------------------------------------------
    826889  $query ='
    827890SELECT user_id, language
     
    832895
    833896// Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language
     897// -------------------------------------------------------------------------------------------------------------------------------
    834898  if (empty($data))
    835899  {
    836900// And switch gallery to this language before using personalized and multilangual contents
     901// ---------------------------------------------------------------------------------------
    837902    $language = pwg_get_session_var( 'lang_switch', $user['language'] );
    838903    switch_lang_to($language);
     
    841906  {
    842907// And switch gallery to this language before using personalized and multilangual contents
    843     $language = $data['language']; // Usefull for debugging
     908// ---------------------------------------------------------------------------------------
     909    //$language = $data['language']; // Usefull for debugging
    844910    switch_lang_to($data['language']);
    845911    load_language('plugin.lang', UAM_PATH);
     
    855921      {
    856922        // Management of Extension flags ([username], [mygallery], [myurl])
     923        // ----------------------------------------------------------------
    857924        $patterns[] = '#\[username\]#i';
    858925        $replacements[] = $username;
     
    907974  }
    908975
    909   if ( isset($conf_UAM[1]) and $conf_UAM[1] == 'true' and $confirm)
     976  if ( isset($conf_UAM[1]) and $conf_UAM[1] == 'true' and $confirm) // Add confirmation link ?
    910977  {
    911978    $infos2 = array
     
    915982    );
    916983
    917     if (isset($conf_UAM[9]) and $conf_UAM[9] <> '')
     984    if (isset($conf_UAM[9]) and $conf_UAM[9] <> '') // Add personal text in confirmation email ?
    918985    {
    919986      // Management of Extension flags ([username], [mygallery], [myurl], [Kdays])
     987      // -------------------------------------------------------------------------
    920988      $patterns[] = '#\[username\]#i';
    921989      $replacements[] = $username;
     
    9651033
    9661034// Sending the email with subject and contents
     1035// -------------------------------------------
    9671036  pwg_mail($email, array(
    9681037    'subject' => $subject,
     
    9711040
    9721041// Switching back to default language
     1042// ----------------------------------
    9731043switch_lang_back();
    9741044}
     
    9921062 
    9931063// We have to get the user's language in database
     1064// ----------------------------------------------
    9941065  $query ='
    9951066SELECT user_id, language
     
    10011072 
    10021073// And switch gallery to this language before using personalized and multilangual contents
     1074// ---------------------------------------------------------------------------------------
    10031075  switch_lang_to($data['language']);
    10041076   
     
    10131085      {
    10141086        // Management of Extension flags ([username], [mygallery], [myurl], [Kdays])
     1087        // -------------------------------------------------------------------------
    10151088        $patterns[] = '#\[username\]#i';
    10161089        $replacements[] = $username;
     
    10391112                        }
    10401113
    1041 // Set reminder true     
     1114// Set reminder true
     1115// -----------------     
    10421116      $query = "
    10431117UPDATE ".USER_CONFIRM_MAIL_TABLE."
     
    10551129      {
    10561130        // Management of Extension flags ([username], [mygallery], [myurl], [Kdays])
     1131        // -------------------------------------------------------------------------
    10571132        $patterns[] = '#\[username\]#i';
    10581133        $replacements[] = $username;
     
    10751150      }
    10761151     
    1077 // Set reminder true     
     1152// Set reminder true
     1153// -----------------
    10781154      $query = "
    10791155UPDATE ".USER_CONFIRM_MAIL_TABLE."
     
    10921168
    10931169// Switching back to default language
     1170// ----------------------------------
    10941171switch_lang_back();
    10951172}
     
    11131190
    11141191// We have to get the user's language in database
     1192// ----------------------------------------------
    11151193  $query ='
    11161194SELECT user_id, language
     
    11221200
    11231201// And switch gallery to this language before using personalized and multilangual contents
     1202// ---------------------------------------------------------------------------------------
    11241203  switch_lang_to($data['language']);
    11251204   
     
    11311210  {
    11321211    // Management of Extension flags ([username], [mygallery], [myurl], [days])
     1212    // ------------------------------------------------------------------------
    11331213    $patterns[] = '#\[username\]#i';
    11341214    $replacements[] = $username;
     
    11581238
    11591239// Switching back to default language
     1240// ----------------------------------
    11601241switch_lang_back();
    11611242}
     
    11791260
    11801261// We have to get the user's language in database
     1262// ----------------------------------------------
    11811263  $query ='
    11821264SELECT user_id, language
     
    11871269
    11881270// Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language
     1271// -------------------------------------------------------------------------------------------------------------------------------
    11891272  if (empty($data))
    11901273  {
    11911274// And switch gallery to this language before using personalized and multilangual contents
     1275// ---------------------------------------------------------------------------------------
    11921276    $language = pwg_get_session_var( 'lang_switch', $user['language'] );
    11931277    switch_lang_to($language);
     
    11961280  {
    11971281// And switch gallery to this language before using personalized and multilangual contents
     1282// ---------------------------------------------------------------------------------------
    11981283    $language = $data['language']; // Usefull for debugging
    11991284    switch_lang_to($data['language']);
     
    12061291  {
    12071292    // Management of Extension flags ([username], [mygallery], [myurl])
     1293    // ----------------------------------------------------------------
    12081294    $patterns[] = '#\[username\]#i';
    12091295    $replacements[] = stripslashes($username);
     
    12351321
    12361322// Sending the email with subject and contents
     1323// -------------------------------------------
    12371324  pwg_mail($email, array(
    12381325    'subject' => $subject,
     
    12411328
    12421329// Switching back to default language
     1330// ----------------------------------
    12431331switch_lang_back();
    12441332}
     
    12621350
    12631351// We have to get the user's language in database
     1352// ----------------------------------------------
    12641353  $query ='
    12651354SELECT user_id, language
     
    12701359
    12711360// Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language
     1361// -------------------------------------------------------------------------------------------------------------------------------
    12721362  if (empty($data))
    12731363  {
    12741364// And switch gallery to this language before using personalized and multilangual contents
     1365// ---------------------------------------------------------------------------------------
    12751366    $language = pwg_get_session_var( 'lang_switch', $user['language'] );
    12761367    switch_lang_to($language);
     
    12791370  {
    12801371// And switch gallery to this language before using personalized and multilangual contents
     1372// ---------------------------------------------------------------------------------------
    12811373    $language = $data['language']; // Usefull for debugging
    12821374    switch_lang_to($data['language']);
     
    12851377
    12861378// Retreive users email and user name from id
     1379// ------------------------------------------
    12871380  $query ='
    12881381SELECT id, username, mail_address
     
    12971390  {
    12981391    // Management of Extension flags ([username], [mygallery], [myurl])
     1392    // ----------------------------------------------------------------
    12991393    $patterns[] = '#\[username\]#i';
    13001394    $replacements[] = $result['username'];
     
    13181412
    13191413// Sending the email with subject and contents
     1414// -------------------------------------------
    13201415  pwg_mail($result['mail_address'], array(
    13211416    'subject' => $subject,
     
    13241419
    13251420// Switching back to default language
     1421// ----------------------------------
    13261422switch_lang_back();
    13271423}
     
    13871483
    13881484    // Delete user from all groups
     1485    // ---------------------------
    13891486    $query = "
    13901487DELETE FROM ".USER_GROUP_TABLE."
     
    13991496
    14001497    // Set user unvalidated status
     1498    // ---------------------------
    14011499    if (!is_admin() and $conf_UAM[7] <> -1)
    14021500    {
     
    14101508
    14111509    // Set user unvalidated group
     1510    // --------------------------
    14121511    if (!is_admin() and $conf_UAM[2] <> -1)
    14131512    {
     
    14221521
    14231522    // Set user unvalidated privacy level
     1523    // ----------------------------------
    14241524    if (!is_admin() and $conf_UAM[35] <> -1)
    14251525    {
     
    14511551
    14521552// Groups cleanup
     1553// --------------
    14531554  $query = "
    14541555DELETE FROM ".USER_GROUP_TABLE."
     
    16611762      {
    16621763                                // Verify Confirmmail with time limit ON
     1764        // -------------------------------------
    16631765                                if (isset ($conf_UAM_ConfirmMail[1]))
    16641766                                {
    1665                                         // dates formating and compare
     1767                                        // Dates formating and compare
     1768          // ---------------------------
    16661769                                        $today = date("d-m-Y"); // Get today's date
    16671770                                        list($day, $month, $year) = explode('-', $today); // explode date of today                                               
     
    16761779
    16771780                                        // Condition with the value set for time limit
     1781          // -------------------------------------------
    16781782                                        if ($deltadays <= $conf_UAM_ConfirmMail[1]) // If Nb of days is less than the limit set
    16791783                                        {
    16801784                                                list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
    16811785
    1682             // Update ConfirmMail table
     1786            // Update ConfirmMail table
     1787            // ------------------------
    16831788                                                $query = '
    16841789UPDATE '.USER_CONFIRM_MAIL_TABLE.'
     
    16891794
    16901795            // Update LastVisit table - Force reminder field to false
    1691             // Usefull when a user has been automatically downgraded and revalidate its registration 
     1796            // Usefull when a user has been automatically downgraded and revalidate its registration
     1797            // -------------------------------------------------------------------------------------
    16921798                                                $query = '
    16931799UPDATE '.USER_LASTVISIT_TABLE.'
     
    17391845
    17401846                                                // Refresh user's category cache
     1847            // -----------------------------
    17411848                                                invalidate_user_cache();
    17421849 
     
    17491856                                }
    17501857                                // Verify Confirmmail with time limit OFF
     1858        // --------------------------------------
    17511859                                else
    17521860                                {
    17531861                                        list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
    17541862
    1755           // Update ConfirmMail table
     1863          // Update ConfirmMail table
     1864          // ------------------------
    17561865                                        $query = '
    17571866UPDATE '.USER_CONFIRM_MAIL_TABLE.'
     
    17621871
    17631872          // Update LastVisit table - Force reminder field to false
    1764           // Usefull when a user has been automatically downgraded and revalidate its registration 
     1873          // Usefull when a user has been automatically downgraded and revalidate its registration
     1874          // -------------------------------------------------------------------------------------
    17651875                                        $query = '
    17661876UPDATE '.USER_LASTVISIT_TABLE.'
     
    18191929
    18201930                                        // Refresh user's category cache
     1931          // -----------------------------
    18211932                                        invalidate_user_cache();
    18221933 
     
    20392150         
    20402151        // Get ConfirmMail configuration
     2152  // -----------------------------
    20412153  $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
    20422154  // Get UAM configuration
     2155  // ---------------------
    20432156  $conf_UAM = unserialize($conf['UserAdvManager']);
    20442157 
    20452158  $users = array();
    20462159
    2047         // search users depending expiration date
     2160        // Search users depending expiration date
     2161  // --------------------------------------
    20482162  $query = '
    20492163SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id,
     
    20922206        }
    20932207
    2094         // add group lists
     2208        // Add groups list
     2209  // ---------------
    20952210  $user_ids = array();
    20962211  foreach ($users as $i => $user)
     
    21362251         
    21372252        // Get ConfirmMail configuration
     2253  // -----------------------------
    21382254  $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
    21392255 
     
    21412257
    21422258        // search users depending expiration date
     2259  // --------------------------------------
    21432260  $query = '
    21442261SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id,
     
    21762293  $users = array();
    21772294
    2178         // search users depending expiration date
     2295        // Search users depending expiration date
     2296  // --------------------------------------
    21792297  $query = '
    21802298SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id,
     
    21992317        }
    22002318
    2201         // add group lists
     2319        // Add groups list
     2320  // ---------------
    22022321  $user_ids = array();
    22032322  foreach ($users as $i => $user)
     
    22242343  $users = array();
    22252344 
    2226         // search users depending expiration date and reminder sent
     2345        // Search users depending expiration date and reminder sent
     2346  // --------------------------------------------------------
    22272347  $query = '
    22282348SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id,
     
    22572377  $users = array();
    22582378
    2259         // search users depending expiration date
     2379        // Search users depending expiration date
     2380  // --------------------------------------
    22602381  $query = '
    22612382SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id,
     
    22802401        }
    22812402
    2282         // add group lists
     2403        // Add groups list
     2404  // ---------------
    22832405  $user_ids = array();
    22842406  foreach ($users as $i => $user)
     
    23042426         
    23052427        // Get ConfirmMail configuration
     2428  // -----------------------------
    23062429  $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
    23072430         
    23082431        // Get UAM configuration
     2432  // ---------------------
    23092433  $conf_UAM = unserialize($conf['UserAdvManager']);
    23102434       
     
    23202444        if (!empty($registration_date))
    23212445  {
    2322                 // dates formating and compare
     2446                // Dates formating and compare
     2447    // ---------------------------
    23232448                $today = date("d-m-Y"); // Get today's date
    23242449                list($day, $month, $year) = explode('-', $today); // explode date of today                                               
     
    23332458
    23342459                // Condition with the value set for time limit
     2460    // -------------------------------------------
    23352461                if ($deltadays <= $conf_UAM_ConfirmMail[1]) // If Nb of days is less than the limit set
    23362462                {
     
    23582484
    23592485  // Initialisation des variables - Variables initiation
     2486  // ---------------------------------------------------
    23602487  $points = 0;
    23612488  $point_lowercase = 0;
     
    23642491  $point_characters = 0;
    23652492
    2366   // On récupère la longueur du mot de passe - Getting password lengh   
     2493  // On récupère la longueur du mot de passe - Getting password lengh
     2494  // ----------------------------------------------------------------
    23672495  $length = strlen($password);
    23682496 
     
    23722500    // On sélectionne une à une chaque lettre - Select each letters
    23732501    // $i étant à 0 lors du premier passage de la boucle - $i is 0 at first turn
     2502    // -------------------------------------------------------------------------
    23742503    $letters = $password[$i];
    23752504
     
    23772506    {
    23782507      // On ajoute 1 point pour une minuscule - Adding 1 point to score for a lowercase
     2508      // ------------------------------------------------------------------------------
    23792509                  $points = $points + 1;
    23802510
    23812511                  // On rajoute le bonus pour une minuscule - Adding bonus points for lowercase
     2512      // --------------------------------------------------------------------------
    23822513                  $point_lowercase = 1;
    23832514    }
     
    23852516    {
    23862517      // On ajoute 2 points pour une majuscule - Adding 2 points to score for uppercase
     2518      // ------------------------------------------------------------------------------
    23872519      $points = $points + 2;
    23882520               
    23892521      // On rajoute le bonus pour une majuscule - Adding bonus points for uppercase
     2522      // --------------------------------------------------------------------------
    23902523      $point_uppercase = 2;
    23912524    }
     
    23932526    {
    23942527      // On ajoute 3 points pour un chiffre - Adding 3 points to score for numbers
     2528      // -------------------------------------------------------------------------
    23952529      $points = $points + 3;
    23962530               
    23972531      // On rajoute le bonus pour un chiffre - Adding bonus points for numbers
     2532      // ---------------------------------------------------------------------
    23982533      $point_numbers = 3;
    23992534    }
     
    24012536    {
    24022537      // On ajoute 5 points pour un caractère autre - Adding 5 points to score for special characters
     2538      // --------------------------------------------------------------------------------------------
    24032539      $points = $points + 5;
    24042540               
    24052541      // On rajoute le bonus pour un caractère autre - Adding bonus points for special characters
     2542      // ----------------------------------------------------------------------------------------
    24062543      $point_characters = 5;
    24072544    }
     
    24092546
    24102547  // Calcul du coefficient points/longueur - calculating the coefficient points/length
     2548  // ---------------------------------------------------------------------------------
    24112549  $step1 = $points / $length;
    24122550
    24132551  // Calcul du coefficient de la diversité des types de caractères... - Calculation of the diversity of character types...
     2552  // ---------------------------------------------------------------------------------------------------------------------
    24142553  $step2 = $point_lowercase + $point_uppercase + $point_numbers + $point_characters;
    24152554
    24162555  // Multiplication du coefficient de diversité avec celui de la longueur - Multiplying the coefficient of diversity with that of the length
     2556  // --------------------------------------------------------------------------------------------------------------------------------------------
    24172557  $score = $step1 * $step2;
    24182558
    24192559  // Multiplication du resultat par la longueur de la chaine - Multiplying the result by the length of the string
     2560  // ------------------------------------------------------------------------------------------------------------
    24202561  $finalscore = $score * $length;
    24212562
     
    24862627  }
    24872628// IMPORTANT SECURITY !
     2629// --------------------
    24882630  $plugin = array_map('htmlspecialchars', $plugin);
    24892631
     
    26192761
    26202762  // Query to get informations in database
     2763  // -------------------------------------
    26212764  if (!empty($user_ids))
    26222765  {
     
    26592802 
    26602803  // Initial backup folder creation and file initialisation
     2804  // ------------------------------------------------------
    26612805  if (!is_dir(UAM_PATH.'/include/backup'))
    26622806    mkdir(UAM_PATH.'/include/backup');
     
    26682812
    26692813  // Saving UAM specific tables
     2814  // --------------------------
    26702815  $ListTables = array(USER_CONFIRM_MAIL_TABLE, USER_LASTVISIT_TABLE);
    26712816  $j=0;
     
    27082853 
    27092854  // Saving UAM configuration
     2855  // ------------------------
    27102856  $insertions = "-- -------------------------------------------------------\n";
    27112857  $insertions .= "-- Insert UAM configuration in ".CONFIG_TABLE."\n";
     
    27342880
    27352881  // Download generated dump file
     2882  // ----------------------------
    27362883  if ($download == 'true')
    27372884  {
  • extensions/UserAdvManager/trunk/include/upgradedb.inc.php

    r12247 r12271  
    2929
    3030  // Get current plugin version
     31  // --------------------------
    3132  $plugin =  PluginInfos(UAM_PATH);
    3233  $version = $plugin['version'];
    3334
    3435  // Update plugin version in #_config table
     36  // ---------------------------------------
    3537  $query = '
    3638UPDATE '.CONFIG_TABLE.'
     
    4547// Check #_plugin table consistency
    4648// Only useful if a previous version upgrade has not worked correctly (rare case)
     49// ------------------------------------------------------------------------------
    4750  $query = '
    4851SELECT version
     
    133136{
    134137  // Create missing table
     138  // --------------------
    135139  $query = "
    136140ALTER TABLE ".USER_CONFIRM_MAIL_TABLE."
     
    141145
    142146  // Upgrade plugin configuration
     147  // ----------------------------
    143148        global $conf;
    144149
     
    191196
    192197  // Changing parameter name
     198  // -----------------------
    193199  $q = '
    194200UPDATE '.CONFIG_TABLE.'
     
    206212
    207213  // Upgrading ConfirmMail options
     214  // -----------------------------
    208215  $query = '
    209216SELECT value
     
    235242
    236243  // Upgrading options
     244  // -----------------
    237245  $query = '
    238246SELECT value
     
    289297
    290298  // Upgrading options
     299  // -----------------
    291300  $query = '
    292301SELECT value
     
    313322
    314323  // Insert a new config entry for futur plugin's version check
     324  // ----------------------------------------------------------
    315325  $query = '
    316326INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
     
    329339
    330340  // Upgrading options
     341  // -----------------
    331342  $query = '
    332343SELECT value
     
    352363
    353364  // Create new UAM entry in plugins table
     365  // -------------------------------------
    354366  $uam_new_version = "2.20.0";
    355367
     
    361373  pwg_query($query);
    362374
    363   // Delete old plugin entry in plugins table
     375  // Delete old plugin entry in plugins table
     376  // ----------------------------------------
    364377  $query = '
    365378DELETE FROM '.PLUGINS_TABLE.'
     
    370383  pwg_query($query);
    371384
    372   // rename directory
     385  // Rename directory
     386  // ----------------
    373387  if (!rename(PHPWG_PLUGINS_PATH.'NBC_UserAdvManager', PHPWG_PLUGINS_PATH.'UserAdvManager'))
    374388  {
     
    384398
    385399  // Upgrading options
     400  // -----------------
    386401  $query = '
    387402SELECT value
     
    409424
    410425  // Upgrading options
     426  // -----------------
    411427  $query = '
    412428SELECT value
     
    435451
    436452  // Upgrading options
     453  // -----------------
    437454  $query = '
    438455SELECT value
     
    447464
    448465  // Refactoring all configuration options
     466  // -------------------------------------
    449467  $Newconf_UAM[0] = $Newconf_UAM[0];
    450468  $Newconf_UAM[1] = $Newconf_UAM[1];
     
    484502 
    485503  // unset obsolete conf
     504  // -------------------
    486505  unset ($Newconf_UAM[35]);
    487506  unset ($Newconf_UAM[36]);
     
    501520
    502521  // Upgrading options
     522  // -----------------
    503523  $query = '
    504524SELECT value
     
    522542
    523543  // Piwigo's native tables modifications for password reset function - Add pwdreset column
     544  // --------------------------------------------------------------------------------------
    524545  $query = '
    525546SHOW COLUMNS FROM '.USERS_TABLE.'
Note: See TracChangeset for help on using the changeset viewer.