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