faa5b76dfca62e2940d68ac3fa64a2fc0bc42262
[mailer.git] / inc / autopurge / purge-unconfirmed.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 05/29/2004 *
4  * ===================                          Last change: 11/26/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : autopurge.php                                    *
8  * -------------------------------------------------------------------- *
9  * Short description : Automatical purging of outdated mail links       *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Auto-Loeschung von veralteten Mail-Links         *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41         die();
42 } // END - if
43
44 // Abort if autopurge is not active or disabled by admin
45 if ((!isExtensionActive('autopurge')) || (getConfig('auto_purge_active') != 'Y')) {
46         // Abort here
47         return false;
48 } // END - if
49
50 // Shall I auto-purge unconfirmed accounts?
51 if (getConfig('autopurge_unconfirmed') == 'Y') {
52         // Init variables and find unconfirmed accounts which I shall auto-purge;
53         $result_uncon = SQL_QUERY("SELECT
54         `userid`, `email`, `joined`
55 FROM
56         `{?_MYSQL_PREFIX?}_user_data`
57 WHERE
58         `status`='UNCONFIRMED' AND `joined` < (UNIX_TIMESTAMP() - {?ap_unconfirmed_time?})
59 ORDER BY
60         `userid` ASC", __FILE__, __LINE__);
61         if (SQL_NUMROWS($result_uncon) > 0) {
62                 // Prepare variable...
63                 $userids = '';
64                 $content['time'] = (getConfig('ap_unconfirmed_time')  / 60 / 60);
65
66                 // Delete inactive accounts
67                 while ($content = merge_array($content, SQL_FETCHARRAY($result_uncon))) {
68                         // Remember userids for the admin
69                         $userids .= $content['userid'] . ', ';
70
71                         // Get date/time from timestamp
72                         $content['joined'] = generateDateTime($content['joined'], 0);
73
74                         // Finnaly delete this inactive account
75                         deleteUserAccount($content['userid'], loadEmailTemplate('member_autopurge_unconfirmed', $content, ''));
76                 } // END - while
77
78                 // Remove last comma
79                 $userids = str_replace(', ', "\n", substr($userids, 0, -2));
80
81                 // Send mail notification to admin
82                 if (getConfig('ap_un_notify') == 'Y') {
83                         sendAdminNotification(getMessage('AUTOPURGE_ADMIN_UNCONFIRMED_SUBJECT'), 'admin_autopurge_unconfirmed', $userids, '');
84                 } // END - if
85         } // END - if
86
87         // Free memory
88         SQL_FREERESULT($result_uncon);
89 } // END - if
90
91 // [EOF]
92 ?>