9dbd590edf9fe5a04fd75f76f7b654fc16d43a52
[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 - 2008 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')) || (!IS_ADMIN())) {
41         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
42         require($INC);
43 }
44
45 // Add description as navigation point
46 ADD_DESCR('admin', __FILE__);
47
48 // Exclude default referal id if set
49 $EXCLUDE_LIST = '';
50 if (getConfig('def_refid') > 0) {
51         $EXCLUDE_LIST = " AND d.userid != ".getConfig('def_refid')."";
52 } // END - if
53
54 // Check for more extensions
55 // @TODO Rewrite those lines to filter
56 if (EXT_IS_ACTIVE('beg'))                  $EXCLUDE_LIST .= " AND d.userid != ".getConfig('beg_uid')."";
57 if (EXT_IS_ACTIVE('bonus'))                $EXCLUDE_LIST .= " AND d.userid != ".getConfig('bonus_uid')."";
58 if (EXT_IS_ACTIVE('doubler'))              $EXCLUDE_LIST .= " AND d.userid != ".getConfig('doubler_uid')."";
59 if (GET_EXT_VERSION('holiday') >= '0.1.3') $EXCLUDE_LIST .= " AND d.`holiday_active`='N'";
60
61 // Check for all accounts
62 $result = SQL_QUERY_ESC("SELECT DISTINCT d.userid, d.gender, d.surname, d.family, d.email, d.joined, d.last_online, d.ap_notified
63 FROM `{!_MYSQL_PREFIX!}_user_data` AS d
64 WHERE d.`status`='CONFIRMED' AND d.joined < (UNIX_TIMESTAMP() - %s) AND d.last_online < (UNIX_TIMESTAMP() - %s) AND d.ap_notified < (UNIX_TIMESTAMP() - %s)
65 ".$EXCLUDE_LIST."
66 ORDER BY d.userid",
67 array(
68 getConfig('ap_inactive_since'),
69 getConfig('ap_inactive_since'),
70 getConfig('ap_inactive_since')
71 ), __FILE__, __LINE__);
72
73 if (SQL_NUMROWS($result) > 0) {
74         // Ok, we have found some inactive accounts
75         $OUT = ''; $SW = 2;
76         while ($content = SQL_FETCHARRAY($result)) {
77                 // Prepare data for the row template
78                 // @TODO Rewritings: sname->surname,fname->family in templates
79                 $content = array(
80                         'sw'       => $SW,
81                         'uid'      => generateUserProfileLink($content['userid']),
82                         'gender'   => translateGender($content['gender']),
83                         'sname'    => $content['surname'],
84                         'fname'    => $content['family'],
85                         'email'    => "<a href=\"".generateMemberEmailLink($content['email'], "user_data")."\">".$content['email']."</a>",
86                         'joined'   => generateDateTime($content['joined'], '2'),
87                         'last'     => generateDateTime($content['last_online'], '2'),
88                         'notified' => generateDateTime($content['ap_notified'], '2'),
89                 );
90
91                 // Load row template
92                 $OUT .= LOAD_TEMPLATE("admin_list_autopurge_row", true, $content);
93                 $SW = 3 - $SW;
94         }
95
96         // Free memory
97         SQL_FREERESULT($result);
98         // @TODO Rewrite this constant
99         define('__AUTOPURGE_ROWS', $OUT);
100
101         // Load main template
102         LOAD_TEMPLATE("admin_list_autopurge");
103 } else {
104         // All members are active or you don't have any registered
105         LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_AUTOPURGE_ALL_ACTIVE'));
106 }
107
108 //
109 ?>