Huge script change, see http://forum.mxchange.org/topic-458.html for details:
[mailer.git] / inc / modules / admin / what-list_autopurge.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 06/26/2004 *
4  * ================                             Last change: 06/26/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-list_autopurge.php                          *
8  * -------------------------------------------------------------------- *
9  * Short description : Find inactive accounts and just list them        *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Inaktive Accounts finden und dann auflisten      *
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')) || (!isAdmin())) {
41         die();
42 } // END - if
43
44 // Add description as navigation point
45 addMenuDescription('admin', __FILE__);
46
47 // Exclude default referal id if set
48 $EXCLUDE_LIST = '';
49 if (getConfig('def_refid') > 0) {
50         $EXCLUDE_LIST = " AND d.userid != ".getConfig('def_refid')."";
51 } // END - if
52
53 // Check for more extensions
54 // @TODO Rewrite those lines to filter
55 if (isExtensionActive('beg'))                  $EXCLUDE_LIST .= " AND d.userid != ".getConfig('beg_userid')."";
56 if (isExtensionActive('bonus'))                $EXCLUDE_LIST .= " AND d.userid != ".getConfig('bonus_userid')."";
57 if (isExtensionActive('doubler'))              $EXCLUDE_LIST .= " AND d.userid != ".getConfig('doubler_userid')."";
58 if (isExtensionInstalledAndNewer('holiday', '0.1.3')) $EXCLUDE_LIST .= " AND d.holiday_active='N'";
59
60 // Check for all accounts
61 $result = SQL_QUERY_ESC("SELECT
62         d.userid, d.gender, d.surname, d.family, d.email, d.joined, d.last_online, d.ap_notified
63 FROM
64         `{?_MYSQL_PREFIX?}_user_data` AS d
65 WHERE
66         d.`status`='CONFIRMED' AND
67         d.joined < (UNIX_TIMESTAMP() - %s) AND
68         d.last_online < (UNIX_TIMESTAMP() - %s) AND
69         d.ap_notified < (UNIX_TIMESTAMP() - %s)
70         ".$EXCLUDE_LIST."
71 ORDER BY
72         d.userid ASC",
73         array(
74                 getConfig('ap_inactive_since'),
75                 getConfig('ap_inactive_since'),
76                 getConfig('ap_inactive_since')
77         ), __FILE__, __LINE__);
78
79 if (SQL_NUMROWS($result) > 0) {
80         // Ok, we have found some inactive accounts
81         $OUT = ''; $SW = 2;
82         while ($content = SQL_FETCHARRAY($result)) {
83                 // Prepare data for the row template
84                 // @TODO Rewritings: surname->surname,family->family in templates
85                 $content = array(
86                         'sw'          => $SW,
87                         'userid'      => generateUserProfileLink($content['userid']),
88                         'gender'      => translateGender($content['gender']),
89                         'surname'     => $content['surname'],
90                         'family'      => $content['family'],
91                         'email'       => "<a href=\"".generateEmailLink($content['email'], 'user_data')."\">".$content['email']."</a>",
92                         'joined'      => generateDateTime($content['joined'], '2'),
93                         'last_online' => generateDateTime($content['last_online'], '2'),
94                         'notified'    => generateDateTime($content['ap_notified'], '2'),
95                 );
96
97                 // Load row template
98                 $OUT .= loadTemplate('admin_list_autopurge_row', true, $content);
99                 $SW = 3 - $SW;
100         }
101
102         // Free memory
103         SQL_FREERESULT($result);
104         $content['rows'] = $OUT;
105
106         // Load main template
107         loadTemplate('admin_list_autopurge', false, $content);
108 } else {
109         // All members are active or you don't have any registered
110         loadTemplate('admin_settings_saved', false, getMessage('ADMIN_AUTOPURGE_ALL_ACTIVE'));
111 }
112
113 // [EOF]
114 ?>