- // Now let's have a look for inactive accounts we want to delete we newly use the same exclude list
- // here for e.g. excluding holiday users
- $time = bigintval(time() - $_CONFIG['ap_in_time']);
- $result_inactive = SQL_QUERY_ESC("SELECT d.userid, d.email, d.last_online
-FROM "._MYSQL_PREFIX."_user_data AS d, "._MYSQL_PREFIX."_config AS c
-WHERE status='CONFIRMED' AND joined < %s AND last_online< %s AND ap_notified < %s
-".$EXCLUDE_LIST."
-ORDER BY userid",
- array($since, $since, $time), __FILE__, __LINE__);
- if (SQL_NUMROWS($result_inactive) > 0)
- {
- // Prepare variable...
- $UIDs = "";
-
- // Delete inactive accounts
- while (list($uid, $email, $last) = SQL_FETCHROW($result_inactive))
- {
- // Remember userids for the admin
- $UIDs .= $uid.", ";
-
- // Get date/time from timestamp
- $last = MAKE_DATETIME($last, "0");
-
- // Finnaly delete this inactive account
- DELETE_USER_ACCOUNT(bigintval($uid), LOAD_EMAIL_TEMPLATE("member_autopurge_delete", $last, ""));
- }
-
- // Remove last comma
- $UIDs = str_replace(", ", "\n", substr($UIDs, 0, -2));
-
- // Send mail notification to admin
- if ($_CONFIG['ap_un_mail'] == "Y")
- {
- SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_DELETE_SUBJECT, "admin_autopurge_delete", $UIDs, "");
- }
- }
-
- // Free memory
- SQL_FREERESULT($result_inactive);
-}
-
-// Shall I auto-purge unconfirmed accounts?
-if ($_CONFIG['ap_unconfirmed'] == "Y")
-{
- // Init variables and find unconfirmed accounts which I shall auto-purge
- $time = bigintval(time() - $_CONFIG['ap_un_time']);
- $result_uncon = SQL_QUERY_ESC("SELECT userid, email, joined FROM "._MYSQL_PREFIX."_user_data WHERE status='UNCONFIRMED' AND joined < %s ORDER BY userid",
- array($time), __FILE__, __LINE__);
- if (SQL_NUMROWS($result_uncon) > 0)
- {
- // Prepare variable...
- $UIDs = "";
- define('__UNCONFIRMED_TIME' , ($_CONFIG['ap_un_time'] / 60 / 60));
-
- // Delete inactive accounts
- while (list($uid, $email, $joined) = SQL_FETCHROW($result_uncon))
- {
- // Remember userids for the admin
- $UIDs .= $uid.", ";
-
- // Get date/time from timestamp
- $joined = MAKE_DATETIME($joined, "0");
-
- // Finnaly delete this inactive account
- DELETE_USER_ACCOUNT($uid, LOAD_EMAIL_TEMPLATE("member_autopurge_unconfirmed", $joined, ""));
- }
-
- // Remove last comma
- $UIDs = str_replace(", ", "\n", substr($UIDs, 0, -2));
-
- // Send mail notification to admin
- if ($_CONFIG['ap_un_mail'] == "Y")
- {
- SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_UNCONFIRMED_SUBJECT, "admin_autopurge_unconfirmed", $UIDs, "");
- }
- }
-
- // Free memory
- SQL_FREERESULT($result_uncon);
-}
-
-// Check version (must be > 0.0)
-if ((GET_EXT_VERSION("task") > "0.0") && ($_CONFIG['ap_tasks'] == "Y"))
-{
- // Purge deleted tasks (no notification to admin)
- $since = bigintval(time() - $_CONFIG['ap_tasks_time']);
- $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_task_system WHERE status='DELETED' AND task_created <= %s",
- array($since), __FILE__, __LINE__);
- $DELETED = SQL_AFFECTEDROWS();
-
- if (($DELETED > 0) && ($_CONFIG['ap_tasks_mail'] == "Y"))
- {
- // Send out email to admin
- SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_TASKS_SUBJECT, "admin_autopurge_tsks", $DELETED, "");
- }
-}
-
-// Search for mails from deleted members?
-if ($_CONFIG['ap_del_mails']) {
- // Okay, let's check for them...
- $since = bigintval(time() - $_CONFIG['ap_dm_timeout']);
- $result_mails = SQL_QUERY_ESC("SELECT sender FROM "._MYSQL_PREFIX."_pool WHERE data_type='DELETED' AND timestamp <= %s ORDER BY sender",
- array($since), __FILE__, __LINE__);
-
- // Reset counter...
- $DELETED = 0;
-
- // Do we have "purged" mails?
- if (SQL_NUMROWS($result_mails) > 0) {
- // Okay, check for their sender's
- while(list($sender) = SQL_FETCHROW($result_mails)) {
- // Check now...
- $fount = SQL_NUMROWS(SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array(bigintval($sender)), __FILE__, __LINE__));
- if ($found == 0) {
- // Okay we found some mails!
- $result_remove = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_pool WHERE sender=%s",
- array(bigintval($sender)), __FILE__, __LINE__);
- $DELETED += SQL_AFFECTEDROWS();
-
- // Reset query (to prevent possible errors) ...
- $since = bigintval(time() - $_CONFIG['ap_dm_timeout']);
- $result_mails = SQL_QUERY_ESC("SELECT sender FROM "._MYSQL_PREFIX."_pool WHERE data_type='DELETED' AND timestamp <= %s ORDER BY sender",
- array($since), __FILE__, __LINE__);
- }
- }
- }
-
- // Free memory
- SQL_FREERESULT($result_mails);
-
- // Now let's check for stats entries as well
- $since = bigintval(time() - $_CONFIG['ap_dm_timeout']);
- $result_mails = SQL_QUERY_ESC("SELECT sender FROM "._MYSQL_PREFIX."_pool WHERE data_type='DELETED' AND timestamp <= %s ORDER BY sender",
- array($since), __FILE__, __LINE__);
-
- // Do we have "purged" mails?
- if (SQL_NUMROWS($result_mails) > 0) {
- // Okay, check for their sender's
- while(list($sender) = SQL_FETCHROW($result_mails)) {
- // Check now...
- $found = SQL_NUMROWS(SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array(bigintval($sender)), __FILE__, __LINE__));
- if ($found == 0) {
- // Okay we found some mails!
- $result_remove = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_stats WHERE sender=%s", array(bigintval($sender)), __FILE__, __LINE__);
- $DELETED += SQL_AFFECTEDROWS();
-
- // Reset query (to prevent possible errors) ...
- $since = bigintval(time() - $_CONFIG['ap_dm_timeout']);
- $result_mails = SQL_QUERY_ESC("SELECT sender FROM "._MYSQL_PREFIX."_user_stats WHERE data_type='DELETED' AND timestamp_send <= %s ORDER BY sender",
- array($since), __FILE__, __LINE__);
- }
- }
- }
-
- // Free memory
- SQL_FREERESULT($result_mails);
-
- // Do we have deleted mails and the admin want's to receive a notification
- if (($DELETED > 0) && ($_CONFIG['ap_dm_notify'] == "Y")) {
- // Send out email to admin
- SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_DEL_MAILS_SUBJECT, "admin_autopurge_del_mails", $DELETED, "");
- }
-}