Added update_year.sh (still not fully flexible) and updated all years with it.
[mailer.git] / inc / purge / 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 - 2015 by Mailer Developer Team                   *
20  * For more information visit: http://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 = sqlQuery("SELECT
53         `userid`,
54         `email`,
55         `joined`
56 FROM
57         `{?_MYSQL_PREFIX?}_user_data`
58 WHERE
59         `status`='UNCONFIRMED' AND
60         (UNIX_TIMESTAMP() - `joined`) >= {?ap_unconfirmed_time?}
61 ORDER BY
62         `userid` ASC", __FILE__, __LINE__);
63         if (!ifSqlHasZeroNums($result_uncon)) {
64                 // Prepare variable...
65                 $userids = '';
66                 $content['time'] = (getApUnconfirmedTime()  / 60 / 60);
67
68                 // Delete inactive accounts
69                 while ($row = sqlFetchArray($result_uncon)) {
70                         // Merge both arrays
71                         $content = merge_array($content, $row);
72
73                         // Remember userids for the admin
74                         $userids .= $content['userid'] . ', ';
75
76                         // Get date/time from timestamp
77                         $content['joined'] = generateDateTime($content['joined'], 0);
78
79                         // Finnaly delete this inactive account
80                         deleteUserAccount($content['userid'], loadEmailTemplate('member_autopurge_unconfirmed', $content, ''));
81                 } // END - while
82
83                 // Remove last comma
84                 $userids = str_replace(', ', PHP_EOL, substr($userids, 0, -2));
85
86                 // Send mail notification to admin
87                 if (getConfig('ap_un_notify') == 'Y') {
88                         sendAdminNotification('{--ADMIN_AUTOPURGE_UNCONFIRMED_SUBJECT--}', 'admin_purge_unconfirmed', $userids);
89                 } // END - if
90         } // END - if
91
92         // Free memory
93         sqlFreeResult($result_uncon);
94 } // END - if
95
96 // [EOF]
97 ?>