]> git.mxchange.org Git - mailer.git/blobdiff - inc/autopurge/purge-inact.php
Extension ext-coupon continued, a lot improvements applied:
[mailer.git] / inc / autopurge / purge-inact.php
index b598c25d0550ca205e37987bd65546a1d4788032..917ff93dd157f18438735df9bf227c0368a05daf 100644 (file)
@@ -47,7 +47,7 @@ if ((!isExtensionActive('autopurge')) || (!isAutoPurgingActive())) {
 } // END - if
 
 // Shall I look for inactive accounts and autopurge inactive accounts?
-if (getConfig('autopurge_inactive') == 'Y') {
+if (isAutopurgeInactiveEnabled()) {
        // Init SQLs
        initSqls();
 
@@ -55,6 +55,7 @@ if (getConfig('autopurge_inactive') == 'Y') {
        // @TODO Rewrite these if() blocks to a filter
        $EXCLUDE_LIST = '';
        if (isValidUserId(getDefRefid())) $EXCLUDE_LIST .= ' AND `userid` != {?def_refid?}';
+
        // Check for more extensions
        if (isExtensionActive('beg'))     $EXCLUDE_LIST .= ' AND `userid` != {?beg_userid?}';
        if (isExtensionActive('bonus'))   $EXCLUDE_LIST .= ' AND `userid` != {?bonus_userid?}';
@@ -73,9 +74,9 @@ FROM
        `{?_MYSQL_PREFIX?}_user_data`
 WHERE
        `status`='CONFIRMED' AND
-       `joined` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND
-       `last_online` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND
-       `ap_notified` < (UNIX_TIMESTAMP() - {?ap_inactive_since?})
+       (UNIX_TIMESTAMP() - `joined`) >= {?ap_inactive_since?} AND
+       (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?} AND
+       (UNIX_TIMESTAMP() - `ap_notified`) >= {?ap_inactive_since?}
        " . $EXCLUDE_LIST . "
 ORDER BY
        `userid` ASC", __FILE__, __LINE__);
@@ -124,21 +125,21 @@ FROM
        `{?_MYSQL_PREFIX?}_user_data`
 WHERE
        `status`='CONFIRMED' AND
-       `joined` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND
-       `last_online` < (UNIX_TIMESTAMP() - {?ap_inactive_since?}) AND
-       `ap_notified` < (UNIX_TIMESTAMP() - {?ap_inactive_time?})
+       (UNIX_TIMESTAMP() - `joined`) >= {?ap_inactive_since?} AND
+       (UNIX_TIMESTAMP() - `last_online`) >= {?ap_inactive_since?} AND
+       (UNIX_TIMESTAMP() - `ap_notified`) >= {?ap_inactive_time?}
 " . $EXCLUDE_LIST . "
 ORDER BY
        `userid` ASC", __FILE__, __LINE__);
 
        if (!SQL_HASZERONUMS($result_inactive)) {
-               // Prepare variable...
-               $useridsContent = '';
+               // Prepare userid array for admin...
+               $userids = array();
 
                // Delete inactive accounts
                while ($content = SQL_FETCHARRAY($result_inactive)) {
                        // Remember userids for the admin
-                       $useridsContent .= $content['userid'] . ', ';
+                       $useridsContent[] = $content['userid'];
 
                        // Get date/time from timestamp
                        $content['last_online'] = generateDateTime($content['last_online'], 0);
@@ -147,8 +148,8 @@ ORDER BY
                        deleteUserAccount($content['userid'], loadEmailTemplate('member_autopurge_delete', $content['last_online'], ''));
                } // END - while
 
-               // Remove last comma
-               $useridsContent = str_replace(', ', "\n", substr($useridsContent, 0, -2));
+               // Display all userids
+               $useridsContent = implode("\n", $userids);
 
                // Send mail notification to admin
                if (getConfig('ap_in_notify') == 'Y') {