Huge script change, see http://forum.mxchange.org/topic-458.html for details:
[mailer.git] / inc / reset / reset_profile.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 10/24/2009 *
4  * ===============                              Last change: 10/24/2009 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : reset_profile.php                                *
8  * -------------------------------------------------------------------- *
9  * Short description : Sends out notifications to keep profiles updated *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Sendet Erinnerngen aus, damit die Profile        *
12  *                     von den Mitgliedern aktuell gehalten werden      *
13  * -------------------------------------------------------------------- *
14  * $Revision::                                                        $ *
15  * $Date::                                                            $ *
16  * $Tag:: 0.2.1-FINAL                                                 $ *
17  * $Author::                                                          $ *
18  * Needs to be in all Files and every File needs "svn propset           *
19  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
20  * -------------------------------------------------------------------- *
21  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
42         die();
43 } elseif (!isExtensionActive('profile')) {
44         return;
45 }
46
47 // Do not execute when script is in CSS mode or no daily reset
48 if ((getOutputMode() != 0) || (!isResetModeEnabled())) return;
49 //* DEBUG: */ outputHtml(basename(__FILE__)."<br />");
50
51 if ((getConfig('send_prof_update') == 'Y') && (getConfig('profile_update') > 0) && (getConfig('resend_profile_update'))) {
52         // Load personal data
53         $result = SQL_QUERY_ESC("SELECT `userid`, `email`, `last_update`, `joined`
54 FROM
55         `{?_MYSQL_PREFIX?}_user_data`
56 WHERE
57         (`last_update` < (UNIX_TIMESTAMP() - %s) AND `last_update` != 0 AND `last_profile_sent` < (UNIX_TIMESTAMP() - %s))
58 OR
59         (`last_update` = 0 AND `last_profile_sent` = 0 AND `joined` < (UNIX_TIMESTAMP() - %s))
60 ORDER BY
61         `userid` ASC",
62                 array(
63                         getConfig('profile_update'),
64                         getConfig('resend_profile_update'),
65                         getConfig('profile_update')
66                 ), __FILE__, __LINE__);
67
68         // Do we have some notifications to sent?
69         if (SQL_NUMROWS($result) > 0) {
70                 // We need to send-out notifications...
71                 while ($content = SQL_FETCHARRAY($result)) {
72                         // Translate timestamp
73                         $content['joined'] = generateDateTime($content['joined'], '0');
74
75                         if (round($content['last_update']) == '0') {
76                                 // Has never changed his accont
77                                 $content['last_update'] = getMessage('PROFILE_NEVER_CHANGED');
78                         } else {
79                                 // Has changed his account
80                                 $content['last_update'] = generateDateTime($content['last_update'], '0');
81                         }
82
83                         // Load email template and send mail away
84                         $message = loadEmailTemplate('profile-updte', '', bigintval($content['userid']));
85                         sendEmail($content['email'], getMessage('PROFILE_OUTDATED'), $message);
86
87                         // Update profile data
88                         SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `last_profile_sent`=UNIX_TIMESTAMP(), `notified`='Y' WHERE `userid`=%s LIMIT 1",
89                                 array(bigintval($content['userid'])), __FILE__, __LINE__);
90                 } // END - while
91         } // END - if
92
93         // Free result
94         SQL_FREERESULT($result);
95 }
96
97 // [EOF]
98 ?>