Ignore:
Timestamp:
Sep 16, 2012, 4:58:25 PM (12 years ago)
Author:
Eric
Message:

Check if auto-demotion feature still works : Ok.
Code beautifying : Remplacing tab indents by spaces.

File:
1 edited

Legend:

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

    r17918 r17944  
    1919  array_push($menu,
    2020    array(
    21       'NAME' => $name,
    22       'URL' => get_root_url().'admin.php?page=plugin-'.basename(UAM_PATH)
     21                'NAME' => $name,
     22                'URL' => get_root_url().'admin.php?page=plugin-'.basename(UAM_PATH)
    2323    )
    2424  );
     
    6767    {
    6868
    69       $userid = get_userid($user['username']);
     69                                                $userid = get_userid($user['username']);
    7070         
    7171      // Looking for existing entry in last visit table
     
    524524  {
    525525    if (count($collection) > 0)
    526         {
     526         {
    527527      // Process if a non-admin nor webmaster user is logged
    528528      // ---------------------------------------------------
    529529      if (in_array($user['id'], $collection))
    530         {
     530                        {
    531531        // Check lastvisit reminder state
    532532        // ------------------------------
     
    561561          redirect(UAM_PATH.'GT_del_account.php');
    562562        }
    563         }
     563                }
    564564      else // Process if an admin or webmaster user is logged
    565565      {
     
    603603            // Delete user from all groups
    604604            // ---------------------------
    605             $query = '
     605            if ($conf_UAM[2] <> -1 and $conf_UAM[3] <> -1)
     606            {
     607                        $query = '
    606608DELETE FROM '.USER_GROUP_TABLE.'
    607609WHERE user_id = '.$user_id.'
     
    612614  )
    613615;';
    614             pwg_query($query);
     616                        pwg_query($query);
     617                                                                                                }
    615618
    616619            // Change user status
     
    666669              // Reset confirmed user status to unvalidated
    667670              // ------------------------------------------
    668                                                   $query = '
     671                                                                                                $query = '
    669672UPDATE '.USER_CONFIRM_MAIL_TABLE.'
    670673SET date_check = NULL
    671674WHERE user_id = '.$user_id.'
    672675;';
    673                                                   pwg_query($query);
     676                                                                                                pwg_query($query);
    674677
    675678              // Get users information for email notification
    676679              // --------------------------------------------
    677                                                   $query = '
     680                                                                                                $query = '
    678681SELECT id, username, mail_address
    679682FROM '.USERS_TABLE.'
    680683WHERE id = '.$user_id.'
    681684;';
    682                                                   $data = pwg_db_fetch_assoc(pwg_query($query));
     685                                                                                                $data = pwg_db_fetch_assoc(pwg_query($query));
    683686           
    684687              demotion_mail($user_id, $data['username'], $data['mail_address']);
     
    732735  {
    733736    if (count($collection) > 0)
    734         {
     737                {
    735738      // Process if a non-admin nor webmaster user is logged
    736739      // ---------------------------------------------------
    737740      if (in_array($user['id'], $collection))
    738         {
     741                {
    739742        // Check ConfirmMail reminder state
    740743        // --------------------------------
     
    759762        if (!$reminder and isset($conf_UAM[32]) and $conf_UAM[32] == 'true')
    760763        {
    761                   $typemail = 1;
     764                        $typemail = 1;
    762765         
    763766          // Get current user informations
     
    786789          redirect(UAM_PATH.'USR_del_account.php');
    787790        }
    788         }
     791                }
    789792      else // Process if an admin or webmaster user is logged
    790793      {
     
    913916
    914917  $conf_UAM = unserialize($conf['UserAdvManager']);
    915  
    916         include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
    917  
    918         $infos1_perso = "";
     918
     919                include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
     920
     921                $infos1_perso = "";
    919922  $infos2_perso = "";
    920923  $subject = "";
     
    11551158  $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
    11561159 
    1157         include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
     1160                include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
    11581161 
    11591162// We have to get the user's language in database
     
    11941197      if (isset($conf_UAM_ConfirmMail[2]) and $conf_UAM_ConfirmMail[2] <> '' and isset($conf_UAM_ConfirmMail[3]) and $conf_UAM_ConfirmMail[3] == 'true' and $confirm)
    11951198      {
    1196         // Management of Extension flags ([username], [mygallery], [myurl], [Kdays])
     1199                // Management of Extension flags ([username], [mygallery], [myurl], [Kdays])
    11971200        // -------------------------------------------------------------------------
    11981201        $patterns[] = '#\[username\]#i';
     
    12201223          get_l10n_args('', ''),
    12211224        );       
    1222                         }
     1225                                                }
    12231226
    12241227// Set reminder true
     
    12311234      pwg_query($query);
    12321235     
    1233                 break;
     1236                                break;
    12341237     
    12351238    case 2: //Generating email content for remind without a new key
     
    12911294  ));
    12921295
    1293 // Switching back to default language
    1294 // ----------------------------------
    1295 switch_lang_back();
     1296                // Switching back to default language
     1297                // ----------------------------------
     1298                switch_lang_back();
    12961299}
    12971300
     
    13101313  $subject = "";
    13111314 
    1312         include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
     1315                include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
    13131316
    13141317// We have to get the user's language in database
     
    13741377  ));
    13751378
    1376 // Switching back to default language
    1377 // ----------------------------------
    1378 switch_lang_back();
     1379                // Switching back to default language
     1380                // ----------------------------------
     1381                switch_lang_back();
    13791382}
    13801383
     
    13921395  $conf_UAM = unserialize($conf['UserAdvManager']);
    13931396 
    1394         include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
    1395  
    1396         $custom_txt = "";
    1397   $subject = "";
     1397                include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
     1398 
     1399                $custom_txt = "";
     1400                $subject = "";
    13981401
    13991402// We have to get the user's language in database
    14001403// ----------------------------------------------
    1401   $query ='
     1404  $query = '
    14021405SELECT user_id, language
    14031406FROM '.USER_INFOS_TABLE.'
     
    14791482  ));
    14801483
    1481 // Switching back to default language
    1482 // ----------------------------------
    1483 switch_lang_back();
     1484                // Switching back to default language
     1485                // ----------------------------------
     1486                switch_lang_back();
    14841487}
    14851488
     
    14971500  $conf_UAM = unserialize($conf['UserAdvManager']);
    14981501 
    1499         include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
    1500  
    1501         $custom_txt = "";
     1502                include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
     1503 
     1504                $custom_txt = "";
    15021505  $subject = "";
    15031506
     
    15851588  ));
    15861589
    1587 // Switching back to default language
    1588 // ----------------------------------
    1589 switch_lang_back();
     1590                // Switching back to default language
     1591                // ----------------------------------
     1592                switch_lang_back();
    15901593}
    15911594
     
    17931796    pwg_query($query);
    17941797
    1795                 $query = '
     1798                                $query = '
    17961799UPDATE '.USER_INFOS_TABLE.'
    17971800SET registration_date = "'.$dbnow.'"
    17981801WHERE user_id = '.$user_id.'
    17991802;';
    1800                 pwg_query($query);
     1803                                pwg_query($query);
    18011804   
    18021805    return get_absolute_root_url().UAM_PATH.'ConfirmMail.php?key='.$Confirm_Mail_ID.'&userid='.$user_id;
     
    19321935      if (!empty($registration_date))
    19331936      {
    1934                                 // Verify Confirmmail with time limit ON
    1935         // -------------------------------------
    1936                                 if (isset ($conf_UAM_ConfirmMail[1]))
    1937                                 {
    1938                                         // Dates formating and compare
    1939           // ---------------------------
    1940                                         $today = date("d-m-Y"); // Get today's date
    1941                                         list($day, $month, $year) = explode('-', $today); // explode date of today                                               
    1942                                         $daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp
    1943                        
    1944                                 list($regdate, $regtime) = explode(' ', $registration_date); // Explode date and time from registration date
    1945                                         list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date
    1946                                         $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp
    1947                        
    1948                                         $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps     
    1949                                         $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days
    1950 
    1951                                         // Condition with the value set for time limit
    1952           // -------------------------------------------
    1953                                         if ($deltadays <= $conf_UAM_ConfirmMail[1]) // If Nb of days is less than the limit set
    1954                                         {
    1955                                                 list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
    1956 
    1957             // Update ConfirmMail table
    1958             // ------------------------
    1959                                                 $query = '
     1937                                                                // Verify Confirmmail with time limit ON
     1938                                // -------------------------------------
     1939                                                                if (isset ($conf_UAM_ConfirmMail[1]))
     1940                                                                {
     1941                                                                                // Dates formating and compare
     1942                                        // ---------------------------
     1943                                                                                $today = date("d-m-Y"); // Get today's date
     1944                                                                                list($day, $month, $year) = explode('-', $today); // explode date of today                                               
     1945                                                                        $daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp
     1946
     1947                                                                list($regdate, $regtime) = explode(' ', $registration_date); // Explode date and time from registration date
     1948                                                                                list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date
     1949                                                                                $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp
     1950
     1951                                                                                $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps     
     1952                                                                                $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days
     1953
     1954                                                                                // Condition with the value set for time limit
     1955                                        // -------------------------------------------
     1956                                                                                if ($deltadays <= $conf_UAM_ConfirmMail[1]) // If Nb of days is less than the limit set
     1957                                                                                {
     1958                                                                                                list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
     1959
     1960                                        // Update ConfirmMail table
     1961                                        // ------------------------
     1962                                                                                                $query = '
    19601963UPDATE '.USER_CONFIRM_MAIL_TABLE.'
    19611964SET date_check="'.$dbnow.'", reminder="false"
    19621965WHERE id = "'.$id.'"
    19631966;';
    1964                                                 pwg_query($query);
    1965 
    1966             // Update LastVisit table - Force reminder field to false
    1967             // Usefull when a user has been automatically downgraded and revalidate its registration
    1968             // -------------------------------------------------------------------------------------
    1969                                                 $query = '
     1967                                                                                                pwg_query($query);
     1968
     1969                                        // Update LastVisit table - Force reminder field to false
     1970                                        // Usefull when a user has been automatically downgraded and revalidate its registration
     1971                                        // -------------------------------------------------------------------------------------
     1972                                                                                                $query = '
    19701973UPDATE '.USER_LASTVISIT_TABLE.'
    19711974SET reminder="false"
    19721975WHERE user_id = "'.$data['user_id'].'"
    19731976;';
    1974                                                 pwg_query($query);
     1977                                                                                                pwg_query($query);
    19751978     
    1976                                                 if ($conf_UAM[2] <> -1) // Delete user from unvalidated users group
    1977                                                 {
    1978                                                         $query = '
     1979                                                                                                if ($conf_UAM[2] <> -1) // Delete user from unvalidated users group
     1980                                                                                                {
     1981                                                                                                                $query = '
    19791982DELETE FROM '.USER_GROUP_TABLE.'
    19801983WHERE user_id = '.$data['user_id'].'
    19811984  AND group_id = "'.$conf_UAM[2].'"
    19821985;';
    1983                                                         pwg_query($query);
    1984                                                 }
    1985            
    1986                                                 if ($conf_UAM[3] <> -1) // Add user to validated users group
    1987                                                 {
    1988                                                         $query = '
     1986                                                                                                                pwg_query($query);
     1987                                                                                                }
     1988
     1989                                                                                                if ($conf_UAM[3] <> -1) // Add user to validated users group
     1990                                                                                                {
     1991                                                                                                                $query = '
    19891992INSERT INTO '.USER_GROUP_TABLE.'
    19901993  (user_id, group_id)
     
    19921995  ('.$data['user_id'].', "'.$conf_UAM[3].'")
    19931996;';
    1994                                                         pwg_query($query);
    1995                                                 }
    1996 
    1997                                                 if (($conf_UAM[4] <> -1 or isset($data['status']))) // Change user's status
    1998                                                 {
    1999                                                         $query = '
     1997                                                                                                                pwg_query($query);
     1998                                                                                                }
     1999
     2000                                                                                                if (($conf_UAM[4] <> -1 or isset($data['status']))) // Change user's status
     2001                                                                                                {
     2002                                                                                                                $query = '
    20002003UPDATE '.USER_INFOS_TABLE.'
    20012004SET status = "'.(isset($data['status']) ? $data['status'] : $conf_UAM[4]).'"
    20022005WHERE user_id = '.$data['user_id'].'
    20032006;';
    2004                                                         pwg_query($query);
    2005                                                 }
    2006 
    2007                                                 if (($conf_UAM[36] <> -1 or isset($data['level']))) // Change user's privacy level
    2008                                                 {
    2009                                                         $query = '
     2007                                                                                                                pwg_query($query);
     2008                                                                                                }
     2009
     2010                                                                                                if (($conf_UAM[36] <> -1 or isset($data['level']))) // Change user's privacy level
     2011                                                                                                {
     2012                                                                                                                $query = '
    20102013UPDATE '.USER_INFOS_TABLE.'
    20112014SET level = "'.(isset($data['level']) ? $data['level'] : $conf_UAM[36]).'"
    20122015WHERE user_id = '.$data['user_id'].'
    20132016;';
    2014                                                         pwg_query($query);
    2015                                                 }
    2016 
    2017                                                 // Refresh user's category cache
    2018             // -----------------------------
    2019                                                 invalidate_user_cache();
    2020  
    2021                                                 return true;
    2022                                         }
    2023                                         elseif ($deltadays > $conf_UAM_ConfirmMail[1]) // If timelimit exeeds
    2024                                         {
    2025                                                 return false;
    2026                                         }
    2027                                 }
    2028                                 // Verify Confirmmail with time limit OFF
    2029         // --------------------------------------
    2030                                 else
    2031                                 {
    2032                                         list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
    2033 
    2034           // Update ConfirmMail table
    2035           // ------------------------
    2036                                         $query = '
     2017                                                                                                                pwg_query($query);
     2018                                                                                                }
     2019
     2020                                                                                                // Refresh user's category cache
     2021                                                // -----------------------------
     2022                                                                                                invalidate_user_cache();
     2023
     2024                                                                                                return true;
     2025                                                                                }
     2026                                                                                elseif ($deltadays > $conf_UAM_ConfirmMail[1]) // If timelimit exeeds
     2027                                                                                {
     2028                                                                                                return false;
     2029                                                                                }
     2030                                                                }
     2031                                                                // Verify Confirmmail with time limit OFF
     2032                                // --------------------------------------
     2033                                                                else
     2034                                                                {
     2035                                                                                list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
     2036
     2037                                // Update ConfirmMail table
     2038                                // ------------------------
     2039                                                                                $query = '
    20372040UPDATE '.USER_CONFIRM_MAIL_TABLE.'
    20382041SET date_check="'.$dbnow.'"
    20392042WHERE id = "'.$id.'"
    20402043;';
    2041                                         pwg_query($query);
    2042 
    2043           // Update LastVisit table - Force reminder field to false
    2044           // Usefull when a user has been automatically downgraded and revalidate its registration
    2045           // -------------------------------------------------------------------------------------
    2046                                         $query = '
     2044                                                                                pwg_query($query);
     2045
     2046                                // Update LastVisit table - Force reminder field to false
     2047                                // Usefull when a user has been automatically downgraded and revalidate its registration
     2048                                // -------------------------------------------------------------------------------------
     2049                                                                                $query = '
    20472050UPDATE '.USER_LASTVISIT_TABLE.'
    20482051SET reminder="false"
    20492052WHERE user_id = "'.$data['user_id'].'"
    20502053;';
    2051           pwg_query($query);
    2052      
    2053                                         if ($conf_UAM[2] <> -1) // Delete user from unvalidated users group
    2054                                         {
    2055                                                 $query = '
     2054                                pwg_query($query);
     2055
     2056                                                                                if ($conf_UAM[2] <> -1) // Delete user from unvalidated users group
     2057                                                                                {
     2058                                                                                                $query = '
    20562059DELETE FROM '.USER_GROUP_TABLE.'
    20572060WHERE user_id = '.$data['user_id'].'
    20582061AND group_id = "'.$conf_UAM[2].'"
    20592062;';
    2060                                                 pwg_query($query);
    2061                                         }
    2062    
    2063                                         if ($conf_UAM[3] <> -1)
    2064                                         {
    2065                                                 $query = '
     2063                                                                                                pwg_query($query);
     2064                                                                                }
     2065
     2066                                                                                if ($conf_UAM[3] <> -1)
     2067                                                                                {
     2068                                                                                                $query = '
    20662069DELETE FROM '.USER_GROUP_TABLE.'
    20672070WHERE user_id = '.$data['user_id'].'
    20682071AND group_id = "'.$conf_UAM[3].'"
    20692072;';
    2070                                                 pwg_query($query);
    2071 
    2072                                                 $query = '
     2073                                                                                                pwg_query($query);
     2074
     2075                                                                                                $query = '
    20732076INSERT INTO '.USER_GROUP_TABLE.'
    20742077  (user_id, group_id)
     
    20762079  ('.$data['user_id'].', "'.$conf_UAM[3].'")
    20772080;';
    2078                                                 pwg_query($query);
    2079                                         }
    2080 
    2081                                         if (($conf_UAM[4] <> -1 or isset($data['status']))) // Change user's status
    2082                                         {
    2083                                                 $query = '
     2081                                                                                                pwg_query($query);
     2082                                                                                }
     2083
     2084                                                                                if (($conf_UAM[4] <> -1 or isset($data['status']))) // Change user's status
     2085                                                                                {
     2086                                                                                                $query = '
    20842087UPDATE '.USER_INFOS_TABLE.'
    20852088SET status = "'.(isset($data['status']) ? $data['status'] : $conf_UAM[4]).'"
    20862089WHERE user_id = '.$data['user_id'].'
    20872090;';
    2088                                                 pwg_query($query);
    2089                                         }
    2090 
    2091                                         if (($conf_UAM[36] <> -1 or isset($data['level']))) // Change user's privacy level
    2092                                         {
    2093                                                 $query = '
     2091                                                                                                pwg_query($query);
     2092                                                                                }
     2093
     2094                                                                                if (($conf_UAM[36] <> -1 or isset($data['level']))) // Change user's privacy level
     2095                                                                                {
     2096                                                                                                $query = '
    20942097UPDATE '.USER_INFOS_TABLE.'
    20952098SET level = "'.(isset($data['level']) ? $data['level'] : $conf_UAM[36]).'"
    20962099WHERE user_id = '.$data['user_id'].'
    20972100;';
    2098                                                 pwg_query($query);
    2099                                         }
    2100 
    2101                                         // Refresh user's category cache
    2102           // -----------------------------
    2103                                         invalidate_user_cache();
    2104  
    2105                                         return true;
     2101                                                                                                pwg_query($query);
     2102                                                                                }
     2103
     2104                                                                                // Refresh user's category cache
     2105                                // -----------------------------
     2106                                                                                invalidate_user_cache();
     2107
     2108                                                                                return true;
     2109                                                                }
     2110                                                }
    21062111                                }
    2107                         }
     2112    else if (!empty($data) and !is_null($data['date_check']))
     2113    {
     2114      return false;
     2115    }
    21082116                }
    2109     else if (!empty($data) and !is_null($data['date_check']))
    2110     {
    2111       return false;
    2112     }
    2113         }
    21142117  else
    21152118    return false;
     
    22472250  $conf_UAM = unserialize($conf['UserAdvManager']);
    22482251 
    2249         if (isset($email) and isset($conf_UAM[11]) and $conf_UAM[11] <> '')
    2250         {
    2251                 $conf_MailExclusion = preg_split("/[\s,]+/",$conf_UAM[11]);
    2252                 for ($i = 0 ; $i < count($conf_MailExclusion) ; $i++)
     2252                if (isset($email) and isset($conf_UAM[11]) and $conf_UAM[11] <> '')
    22532253                {
    2254                         $pattern = '/'.$conf_MailExclusion[$i].'/i';
    2255                         if (preg_match($pattern, $email))
    2256       {
    2257                         return true;
    2258       }
     2254                                $conf_MailExclusion = preg_split("/[\s,]+/",$conf_UAM[11]);
     2255                                for ($i = 0 ; $i < count($conf_MailExclusion) ; $i++)
     2256                                {
     2257                                                $pattern = '/'.$conf_MailExclusion[$i].'/i';
     2258                                                if (preg_match($pattern, $email))
     2259      {
     2260                return true;
     2261      }
     2262                                }
    22592263                }
    2260         }
    22612264  else
    22622265  {
     
    22742277function get_unvalid_user_list()
    22752278{
    2276         global $conf, $page;
     2279                global $conf, $page;
    22772280         
    2278         // Get ConfirmMail configuration
     2281                // Get ConfirmMail configuration
    22792282  // -----------------------------
    22802283  $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
     
    22852288  $users = array();
    22862289
    2287         // Search users depending expiration date
     2290                // Search users depending expiration date
    22882291  // --------------------------------------
    22892292  $query = '
     
    23042307  OR TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) < "'.$conf_UAM_ConfirmMail[1].'")';
    23052308
    2306         if ($conf_UAM[2] <> '-1' and $conf_UAM[7] == '-1')
     2309                if ($conf_UAM[2] <> '-1' and $conf_UAM[7] == '-1')
    23072310  {
    23082311    $query.= '
     
    23192322  AND ug.group_id = '.$conf_UAM[2];
    23202323  }
     2324
    23212325  $query.= '
    23222326ORDER BY ui.registration_date ASC
    23232327;';
    23242328
    2325         $result = pwg_query($query);
     2329                $result = pwg_query($query);
    23262330     
    23272331  while ($row = pwg_db_fetch_assoc($result))
    23282332  {
    2329         $user = $row;
     2333                $user = $row;
    23302334    $user['groups'] = array();
    23312335
    23322336    array_push($users, $user);
    2333         }
    2334 
    2335         // Add groups list
     2337                }
     2338
     2339                // Add groups list
    23362340  // ---------------
    23372341  $user_ids = array();
    23382342  foreach ($users as $i => $user)
    23392343  {
    2340         $user_ids[$i] = $user['id'];
    2341         }
    2342        
    2343         $user_nums = array_flip($user_ids);
     2344                $user_ids[$i] = $user['id'];
     2345                }
     2346
     2347                $user_nums = array_flip($user_ids);
    23442348
    23452349  if (count($user_ids) > 0)
    23462350  {
    2347         $query = '
     2351                $query = '
    23482352SELECT user_id, group_id
    23492353  FROM '.USER_GROUP_TABLE.'
     
    23512355;';
    23522356       
    2353                 $result = pwg_query($query);
     2357                                $result = pwg_query($query);
    23542358       
    23552359    while ($row = pwg_db_fetch_assoc($result))
    23562360    {
    2357         array_push(
    2358         $users[$user_nums[$row['user_id']]]['groups'],
     2361                array_push(
     2362                $users[$user_nums[$row['user_id']]]['groups'],
    23592363        $row['group_id']
    2360                         );
     2364                                                );
     2365                                }
    23612366                }
    2362         }
    2363 
    2364         return $users;
     2367
     2368                return $users;
    23652369}
    23662370
     
    23752379function get_unvalid_user_autotasks()
    23762380{
    2377         global $conf, $page;
     2381                global $conf, $page;
    23782382         
    2379         // Get ConfirmMail configuration
     2383                // Get ConfirmMail configuration
    23802384  // -----------------------------
    23812385  $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
     
    23832387  $users = array();
    23842388
    2385         // search users depending expiration date
     2389                // search users depending expiration date
    23862390  // --------------------------------------
    23872391  $query = '
     
    23952399ORDER BY ui.registration_date ASC;';
    23962400
    2397         $result = pwg_query($query);
    2398      
     2401                $result = pwg_query($query);
     2402
    23992403  while ($row = pwg_db_fetch_assoc($result))
    24002404  {
    24012405    array_push($users, $row);
    2402         }
    2403 
    2404         return $users;
     2406                }
     2407
     2408                return $users;
    24052409}
    24062410
     
    24142418function get_ghost_user_list()
    24152419{
    2416         global $conf, $page;
     2420                global $conf, $page;
    24172421
    24182422  $conf_UAM = unserialize($conf['UserAdvManager']);
    2419  
     2423
    24202424  $users = array();
    24212425
    2422         // Search users depending expiration date
     2426                // Search users depending expiration date
    24232427  // --------------------------------------
    24242428  $query = '
     
    24342438ORDER BY lv.lastvisit ASC;';
    24352439
    2436         $result = pwg_query($query);
     2440                $result = pwg_query($query);
    24372441     
    24382442  while ($row = pwg_db_fetch_assoc($result))
    24392443  {
    2440         $user = $row;
     2444                $user = $row;
    24412445    $user['groups'] = array();
    24422446
    24432447    array_push($users, $user);
    2444         }
    2445 
    2446         // Add groups list
     2448                }
     2449
     2450                // Add groups list
    24472451  // ---------------
    24482452  $user_ids = array();
     
    24502454  {
    24512455        $user_ids[$i] = $user['id'];
    2452         }
    2453 
    2454         return $users;
     2456                }
     2457
     2458                return $users;
    24552459}
    24562460
     
    24642468function get_ghosts_autotasks()
    24652469{
    2466         global $conf, $page;
     2470                global $conf, $page;
    24672471
    24682472  $conf_UAM = unserialize($conf['UserAdvManager']);
     
    24702474  $users = array();
    24712475 
    2472         // Search users depending expiration date and reminder sent
     2476                // Search users depending expiration date and reminder sent
    24732477  // --------------------------------------------------------
    24742478  $query = '
     
    24812485ORDER BY lv.lastvisit ASC;';
    24822486
    2483         $result = pwg_query($query);
     2487                $result = pwg_query($query);
    24842488     
    2485   while ($row = pwg_db_fetch_assoc($result))
     2489                while ($row = pwg_db_fetch_assoc($result))
    24862490  {
    24872491    array_push($users, $row);
    2488         }
    2489  
    2490         return $users;
     2492                }
     2493 
     2494                return $users;
    24912495}
    24922496
     
    25002504function get_user_list()
    25012505{
    2502         global $conf, $page;
     2506                global $conf, $page;
    25032507 
    25042508  $users = array();
    25052509
    2506         // Search users depending expiration date with exclusion of Adult_Content generic users
     2510                // Search users depending expiration date with exclusion of Adult_Content generic users
    25072511  // ------------------------------------------------------------------------------------
    25082512  $query = '
     
    25202524;';
    25212525
    2522         $result = pwg_query($query);
     2526                $result = pwg_query($query);
    25232527     
    25242528  while ($row = pwg_db_fetch_assoc($result))
    25252529  {
    2526         $user = $row;
     2530                $user = $row;
    25272531    $user['groups'] = array();
    25282532
    25292533    array_push($users, $user);
    2530         }
    2531 
    2532         // Add groups list
     2534                }
     2535
     2536                // Add groups list
    25332537  // ---------------
    25342538  $user_ids = array();
    25352539  foreach ($users as $i => $user)
    25362540  {
    2537         $user_ids[$i] = $user['id'];
    2538         }
    2539 
    2540         return $users;
     2541                        $user_ids[$i] = $user['id'];
     2542                }
     2543
     2544                return $users;
    25412545}
    25422546
     
    25542558        global $conf, $page;
    25552559         
    2556         // Get ConfirmMail configuration
     2560                // Get ConfirmMail configuration
    25572561  // -----------------------------
    25582562  $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
    25592563         
    2560         // Get UAM configuration
     2564                // Get UAM configuration
    25612565  // ---------------------
    25622566  $conf_UAM = unserialize($conf['UserAdvManager']);
    25632567       
    2564         $query = '
     2568                $query = '
    25652569SELECT registration_date
    25662570  FROM '.USER_INFOS_TABLE.'
    25672571WHERE user_id = '.$id.'
    25682572;';
    2569         list($registration_date) = pwg_db_fetch_row(pwg_query($query));
     2573                list($registration_date) = pwg_db_fetch_row(pwg_query($query));
    25702574
    25712575//              Time limit process             
    25722576// ******************************************** 
    2573         if (!empty($registration_date))
    2574   {
    2575                 // Dates formating and compare
    2576     // ---------------------------
    2577                 $today = date("d-m-Y"); // Get today's date
    2578                 list($day, $month, $year) = explode('-', $today); // explode date of today                                               
    2579                 $daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp
     2577                if (!empty($registration_date))
     2578  {
     2579                                // Dates formating and compare
     2580                // ---------------------------
     2581                                $today = date("d-m-Y"); // Get today's date
     2582                                list($day, $month, $year) = explode('-', $today); // explode date of today                                               
     2583                        $daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp
    25802584               
    2581           list($regdate, $regtime) = explode(' ', $registration_date); // Explode date and time from registration date
    2582                 list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date
    2583                 $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp
     2585                list($regdate, $regtime) = explode(' ', $registration_date); // Explode date and time from registration date
     2586                                list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date
     2587                                $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp
    25842588                       
    2585                 $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps     
    2586                 $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days
    2587 
    2588                 // Condition with the value set for time limit
     2589                                $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps     
     2590                                $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days
     2591
     2592                                // Condition with the value set for time limit
    25892593    // -------------------------------------------
    2590                 if ($deltadays <= $conf_UAM_ConfirmMail[1]) // If Nb of days is less than the limit set
    2591                 {
    2592                         return false;
     2594                                if ($deltadays <= $conf_UAM_ConfirmMail[1]) // If Nb of days is less than the limit set
     2595                                {
     2596                                                return false;
     2597                                }
     2598                                else
     2599                                {
     2600                                                return true;
     2601                                }
    25932602                }
    2594                 else
    2595                 {
    2596                         return true;
    2597                 }
    2598         }
    25992603}
    26002604
     
    26092613 * Thanx to MathieuGut from http://m-gut.developpez.com
    26102614 */
    2611 function testpassword($password) // Le mot de passe passé en paramètre - $password given by user
    2612 {
    2613 
    2614   // Initialisation des variables - Variables initiation
    2615   // ---------------------------------------------------
     2615function testpassword($password) // $password given by user
     2616{
     2617
     2618  // Variables initiation
     2619  // --------------------
    26162620  $points = 0;
    26172621  $point_lowercase = 0;
     
    26202624  $point_characters = 0;
    26212625
    2622   // On récupère la longueur du mot de passe - Getting password lengh
    2623   // ----------------------------------------------------------------
     2626  // Getting password lengh
     2627  // ----------------------
    26242628  $length = strlen($password);
    2625  
    2626   // On fait une boucle pour lire chaque lettre - Loop to read password characters
     2629
     2630  // Loop to read password characters
    26272631  for($i = 0; $i < $length; $i++)
    26282632  {
    2629     // On sélectionne une à une chaque lettre - Select each letters
    2630     // $i étant à 0 lors du premier passage de la boucle - $i is 0 at first turn
    2631     // -------------------------------------------------------------------------
     2633    // Select each letters
     2634    // $i is 0 at first turn
     2635    // ---------------------
    26322636    $letters = $password[$i];
    26332637
    26342638    if ($letters>='a' && $letters<='z')
    26352639    {
    2636       // On ajoute 1 point pour une minuscule - Adding 1 point to score for a lowercase
    2637       // ------------------------------------------------------------------------------
    2638                   $points = $points + 1;
    2639 
    2640                   // On rajoute le bonus pour une minuscule - Adding bonus points for lowercase
    2641       // --------------------------------------------------------------------------
     2640      // Adding 1 point to score for a lowercase
     2641      // ---------------------------------------
     2642                                $points = $points + 1;
     2643
     2644                                // Adding bonus points for lowercase
     2645      // ---------------------------------
    26422646                  $point_lowercase = 1;
    26432647    }
    26442648    else if ($letters>='A' && $letters <='Z')
    26452649    {
    2646       // On ajoute 2 points pour une majuscule - Adding 2 points to score for uppercase
    2647       // ------------------------------------------------------------------------------
     2650      // Adding 2 points to score for uppercase
     2651      // --------------------------------------
    26482652      $points = $points + 2;
    26492653               
    2650       // On rajoute le bonus pour une majuscule - Adding bonus points for uppercase
    2651       // --------------------------------------------------------------------------
     2654      // Adding bonus points for uppercase
     2655      // ---------------------------------
    26522656      $point_uppercase = 2;
    26532657    }
    26542658    else if ($letters>='0' && $letters<='9')
    26552659    {
    2656       // On ajoute 3 points pour un chiffre - Adding 3 points to score for numbers
    2657       // -------------------------------------------------------------------------
     2660      // Adding 3 points to score for numbers
     2661      // ------------------------------------
    26582662      $points = $points + 3;
    26592663               
    2660       // On rajoute le bonus pour un chiffre - Adding bonus points for numbers
    2661       // ---------------------------------------------------------------------
     2664      // Adding bonus points for numbers
     2665      // -------------------------------
    26622666      $point_numbers = 3;
    26632667    }
    26642668    else
    26652669    {
    2666       // On ajoute 5 points pour un caractère autre - Adding 5 points to score for special characters
    2667       // --------------------------------------------------------------------------------------------
     2670      // Adding 5 points to score for special characters
     2671      // -----------------------------------------------
    26682672      $points = $points + 5;
    26692673               
    2670       // On rajoute le bonus pour un caractère autre - Adding bonus points for special characters
    2671       // ----------------------------------------------------------------------------------------
     2674      // Adding bonus points for special characters
     2675      // ------------------------------------------
    26722676      $point_characters = 5;
    26732677    }
    26742678  }
    26752679
    2676   // Calcul du coefficient points/longueur - calculating the coefficient points/length
    2677   // ---------------------------------------------------------------------------------
     2680  // Calculating the coefficient points/length
     2681  // -----------------------------------------
    26782682  $step1 = $points / $length;
    26792683
    2680   // Calcul du coefficient de la diversité des types de caractères... - Calculation of the diversity of character types...
    2681   // ---------------------------------------------------------------------------------------------------------------------
     2684  // Calculation of the diversity of character types...
     2685  // --------------------------------------------------
    26822686  $step2 = $point_lowercase + $point_uppercase + $point_numbers + $point_characters;
    26832687
    2684   // Multiplication du coefficient de diversité avec celui de la longueur - Multiplying the coefficient of diversity with that of the length
    2685   // --------------------------------------------------------------------------------------------------------------------------------------------
     2688  // Multiplying the coefficient of diversity with that of the length
     2689  // ----------------------------------------------------------------
    26862690  $score = $step1 * $step2;
    26872691
    2688   // Multiplication du resultat par la longueur de la chaine - Multiplying the result by the length of the string
    2689   // ------------------------------------------------------------------------------------------------------------
     2692  // Multiplying the result by the length of the string
     2693  // --------------------------------------------------
    26902694  $finalscore = $score * $length;
    26912695
     
    28982902  $ListTables = array(USER_CONFIRM_MAIL_TABLE, USER_LASTVISIT_TABLE);
    28992903  $j=0;
    2900  
     2904
    29012905  while($j < count($ListTables))
    29022906  {
Note: See TracChangeset for help on using the changeset viewer.