fb40eb9efaae394d0e80babaf1fb87d6c9f3fc94
[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  *                                                                      *
15  * -------------------------------------------------------------------- *
16  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
17  * For more information visit: http://www.mxchange.org                  *
18  *                                                                      *
19  * This program is free software; you can redistribute it and/or modify *
20  * it under the terms of the GNU General Public License as published by *
21  * the Free Software Foundation; either version 2 of the License, or    *
22  * (at your option) any later version.                                  *
23  *                                                                      *
24  * This program is distributed in the hope that it will be useful,      *
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
27  * GNU General Public License for more details.                         *
28  *                                                                      *
29  * You should have received a copy of the GNU General Public License    *
30  * along with this program; if not, write to the Free Software          *
31  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
32  * MA  02110-1301  USA                                                  *
33  ************************************************************************/
34
35 // Some security stuff...
36 if (!defined('__SECURITY')) {
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38         require($INC);
39 }
40
41 if (($_CONFIG['send_prof_update'] == "Y") && ($_CONFIG['profile_update'] > 0) && ($_CONFIG['resend_profile_update']))
42 {
43         // Ok, we shall send update notifications...
44         $TIMEOUT  = bigintval(time() - $_CONFIG['profile_update']);
45         $TIMEOUT2 = bigintval(time() - $_CONFIG['resend_profile_update']);
46
47         // Load personal data              0      1     2      3        4          5         6
48         $result = SQL_QUERY_ESC("SELECT userid, email, gender, surname, family, last_update, joined
49  FROM "._MYSQL_PREFIX."_user_data
50  WHERE (last_update < %s AND last_update != '0' AND last_profile_sent < %s) OR (last_update='0' AND last_profile_sent='0' AND joined < %s)
51  ORDER BY userid", array($TIMEOUT, $TIMEOUT2, $TIMEOUT), __FILE__, __LINE__);
52         if (SQL_NUMROWS($result) > 0)
53         {
54                 // We need to send-out notifications...
55                 while ($DATA = SQL_FETCHROW($result))
56                 {
57                         $DATA[6] = MAKE_DATETIME($DATA[6], "0");
58                         if (round($DATA[5]) == "0")
59                         {
60                                 // Has never changed his accont
61                                 $DATA[5] = PROFILE_NEVER_CHANGED;
62                         }
63                          else
64                         {
65                                 // Has changed his account
66                                 $DATA[5] = MAKE_DATETIME($DATA[5], "0");
67                         }
68
69                         // Load email template and send mail away
70                         $msg = LOAD_EMAIL_TEMPLATE("profile-updte", "", bigintval($DATA[0]));
71                         SEND_EMAIL($DATA[1], PROFILE_OUTDATED, $msg);
72
73                         // Update profile data
74                         $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET last_profile_sent=UNIX_TIMESTAMP(), notified='Y' WHERE userid=%s LIMIT 1",
75                          array(bigintval($DATA[0])), __FILE__, __LINE__);
76                 }
77         }
78
79         // Free result
80         SQL_FREERESULT($result);
81 }
82 //
83 ?>