Previous fix fixed, a lot constants rewritten (unfinished)
[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  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 // Add description as navigation point
41 ADD_DESCR("admin", __FILE__);
42
43 // Exclude default referal id if set
44 $EXCLUDE_LIST = "";
45 if (getConfig('def_refid') > 0) {
46         $EXCLUDE_LIST = " AND d.userid != ".getConfig('def_refid')."";
47 } // END - if
48
49 // Check for more extensions
50 if (EXT_IS_ACTIVE("beg"))                  $EXCLUDE_LIST .= " AND d.userid != ".getConfig('beg_uid')."";
51 if (EXT_IS_ACTIVE("bonus"))                $EXCLUDE_LIST .= " AND d.userid != ".getConfig('bonus_uid')."";
52 if (EXT_IS_ACTIVE("doubler"))              $EXCLUDE_LIST .= " AND d.userid != ".getConfig('doubler_uid')."";
53 if (GET_EXT_VERSION("holiday") >= "0.1.3") $EXCLUDE_LIST .= " AND d.holiday_active='N'";
54
55 // Check for all accounts
56 $result = SQL_QUERY_ESC("SELECT DISTINCT d.userid, d.gender, d.surname, d.family, d.email, d.joined, d.last_online, d.ap_notified
57 FROM `{!_MYSQL_PREFIX!}_user_data` AS d
58 WHERE d.status='CONFIRMED' AND d.joined < (UNIX_TIMESTAMP() - %s) AND d.last_online < (UNIX_TIMESTAMP() - %s) AND d.ap_notified < (UNIX_TIMESTAMP() - %s)
59 ".$EXCLUDE_LIST."
60 ORDER BY d.userid", array(getConfig('ap_inactive_since'), getConfig('ap_inactive_since'), getConfig('ap_inactive_since')), __FILE__, __LINE__);
61
62 if (SQL_NUMROWS($result) > 0)
63 {
64         // Ok, we have found some inactive accounts
65         $SW = 2; $OUT = "";
66         while (list($uid, $gender, $sname, $fname, $email, $joined, $last, $notified) = SQL_FETCHROW($result))
67         {
68                 // Prepare data for the row template
69                 $content = array(
70                         'sw'       => $SW,
71                         'uid'      => ADMIN_USER_PROFILE_LINK($uid),
72                         'gender'   => TRANSLATE_GENDER($gender),
73                         'sname'    => $sname,
74                         'fname'    => $fname,
75                         'email'    => "<a href=\"".CREATE_EMAIL_LINK($email, "user_data")."\">".$email."</a>",
76                         'joined'   => MAKE_DATETIME($joined, "2"),
77                         'last'     => MAKE_DATETIME($last, "2"),
78                         'notified' => MAKE_DATETIME($notified, "2"),
79                 );
80
81                 // Load row template
82                 $OUT .= LOAD_TEMPLATE("admin_list_autopurge_row", true, $content);
83                 $SW = 3 - $SW;
84         }
85
86         // Free memory
87         SQL_FREERESULT($result);
88         define('__AUTOPURGE_ROWS', $OUT);
89
90         // Load main template
91         LOAD_TEMPLATE("admin_list_autopurge");
92 }
93  else
94 {
95         // All members are active or you don't have any registered
96         LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_AUTOPURGE_ALL_ACTIVE'));
97 }
98 //
99 ?>