More missing config entries added
[mailer.git] / inc / profile-updte.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 02/29/2004 *
4  * ===============                              Last change: 04/12/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : profile-updte.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 - 2008 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         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
43         require($INC);
44 }
45
46 if ((getConfig('send_prof_update') == 'Y') && (getConfig('profile_update') > 0) && (getConfig('resend_profile_update'))) {
47         // Load personal data
48         $result = SQL_QUERY_ESC("SELECT `userid`, `email`, `last_update`, `joined`
49 FROM
50         `{!_MYSQL_PREFIX!}_user_data`
51 WHERE
52         (`last_update` < (UNIX_TIMESTAMP() - %s) AND `last_update` != 0 AND `last_profile_sent` < (UNIX_TIMESTAMP() - %s))
53 OR
54         (`last_update` = 0 AND `last_profile_sent` = 0 AND `joined` < (UNIX_TIMESTAMP() - %s))
55 ORDER BY
56         `userid` ASC",
57                 array(
58                         getConfig('profile_update'),
59                         getConfig('resend_profile_update'),
60                         getConfig('profile_update')
61                 ), __FILE__, __LINE__);
62
63         // Do we have some notifications to sent?
64         if (SQL_NUMROWS($result) > 0) {
65                 // We need to send-out notifications...
66                 while ($content = SQL_FETCHARRAY($result)) {
67                         // Translate timestamp
68                         $content['joined'] = generateDateTime($content['joined'], '0');
69
70                         if (round($content['last_update']) == '0') {
71                                 // Has never changed his accont
72                                 $content['last_update'] = getMessage('PROFILE_NEVER_CHANGED');
73                         } else {
74                                 // Has changed his account
75                                 $content['last_update'] = generateDateTime($content['last_update'], '0');
76                         }
77
78                         // Load email template and send mail away
79                         $message = LOAD_EMAIL_TEMPLATE('profile-updte', '', bigintval($content['userid']));
80                         sendEmail($content['email'], getMessage('PROFILE_OUTDATED'), $message);
81
82                         // Update profile data
83                         SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `last_profile_sent`=UNIX_TIMESTAMP(), `notified`='Y' WHERE `userid`=%s LIMIT 1",
84                                 array(bigintval($content['userid'])), __FILE__, __LINE__);
85                 } // END - while
86         } // END - if
87
88         // Free result
89         SQL_FREERESULT($result);
90 }
91
92 //
93 ?>