e5525387b103ba084d69fb68d36a119bf0bd00ce
[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  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.mxchange.org                  *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
43 // Abort if autopurge is not active or disabled by admin
44 if ((!isExtensionActive('autopurge')) || (!isAutoPurgingActive())) {
45         // Abort here
46         return false;
47 } // END - if
48
49 // Shall I auto-purge unconfirmed accounts?
50 if (getConfig('autopurge_unconfirmed') == 'Y') {
51         // Init variables and find unconfirmed accounts which I shall auto-purge;
52         $result_uncon = SQL_QUERY("SELECT
53         `userid`, `email`, `joined`
54 FROM
55         `{?_MYSQL_PREFIX?}_user_data`
56 WHERE
57         `status`='UNCONFIRMED' AND `joined` < (UNIX_TIMESTAMP() - {?ap_unconfirmed_time?})
58 ORDER BY
59         `userid` ASC", __FILE__, __LINE__);
60         if (!SQL_HASZERONUMS($result_uncon)) {
61                 // Prepare variable...
62                 $userids = '';
63                 $content['time'] = (getApUnconfirmedTime()  / 60 / 60);
64
65                 // Delete inactive accounts
66                 while ($row = SQL_FETCHARRAY($result_uncon)) {
67                         // Merge both arrays
68                         $content = merge_array($content, $row);
69
70                         // Remember userids for the admin
71                         $userids .= $content['userid'] . ', ';
72
73                         // Get date/time from timestamp
74                         $content['joined'] = generateDateTime($content['joined'], 0);
75
76                         // Finnaly delete this inactive account
77                         deleteUserAccount($content['userid'], loadEmailTemplate('member_autopurge_unconfirmed', $content, ''));
78                 } // END - while
79
80                 // Remove last comma
81                 $userids = str_replace(', ', "\n", substr($userids, 0, -2));
82
83                 // Send mail notification to admin
84                 if (getConfig('ap_un_notify') == 'Y') {
85                         sendAdminNotification('{--ADMIN_AUTOPURGE_UNCONFIRMED_SUBJECT--}', 'admin_autopurge_unconfirmed', $userids);
86                 } // END - if
87         } // END - if
88
89         // Free memory
90         SQL_FREERESULT($result_uncon);
91 } // END - if
92
93 // [EOF]
94 ?>