]> git.mxchange.org Git - mailer.git/blob - inc/mails/beg_mails.php
Extension ext-network continued:
[mailer.git] / inc / mails / beg_mails.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 11/22/2005 *
4  * ===================                          Last change: 11/22/2005 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : beg_mails.php                                    *
8  * -------------------------------------------------------------------- *
9  * Short description : Sends out reminder mails                         *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Versendet Erinnerungsmails                       *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } elseif ((!isExtensionActive('beg')) || (isExtensionInstalledAndOlder('beg', '0.2.8'))) {
42         return;
43 }
44
45 // Do not execute when script is in CSS mode
46 if (!isHtmlOutputMode()) return;
47
48 // Create timemark from saved month
49 $mark = mktime(0, 0, 0, getLastMonth(), getDay(), getYear());
50 $sql = ''; $mode = '';
51
52 // Shall I sent activation or deactivation mail?
53 $sql = "SELECT `userid`,`email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE (`beg_rallye_enable_notify` ";
54 switch (getBegRallye()) {
55         case 'Y': // Begging rallye is activated
56                 if (isBegRallyeEnableNotifyEnabled()) {
57                         // Okay, let's check for member accounts
58                         $sql .= '= 0 OR (`beg_rallye_enable_notify` > 0 AND `beg_rallye_enable_notify` < `beg_rallye_disable_notify`)';
59                         $mode = 'enable';
60                 } else {
61                         // Do not notify!
62                         $sql = '';
63                 }
64                 break;
65
66         case 'N': // Begging rallye is deactivated
67                 if (isBegRallyeDisableNotifyEnabled()) {
68                         // Okay, let's check for member accounts
69                         $sql .= ' > 0 AND `beg_rallye_disable_notify` < `beg_rallye_enable_notify`';
70                         $mode = 'disable';
71                 } else {
72                         // Do not notify!
73                         $sql = '';
74                 }
75                 break;
76 } // END - switch
77
78 if (!empty($sql)) {
79         // The SQL command needs to be finisched here (only confirmed accounts!)
80         $sql .= ") AND `status`='CONFIRMED' ORDER BY `last_online` ASC";
81
82         // No IP locking setuped by default
83         $content['ip_locker'] = '{--BEG_NO_LIMITATION--}';
84
85         if (getBegIpTimeout() > 0) {
86                 // Create timemark
87                 $content['ip_locker'] = '{%config,createFancyTime=beg_ip_timeout%}';
88         } // END - if
89
90         // Check for accounts to be notified
91         $result_main = SQL_QUERY($sql, __FILE__, __LINE__);
92         if (!SQL_HASZERONUMS($result_main)) {
93                 // Normal notification mails or bonus mails?
94                 $sentBonusMails = ((getBegNotifyBonus() > 0) && ($mode == 'enable') && (isExtensionActive('bonus')));
95
96                 // Load message body for bonus mails
97                 $message = loadEmailTemplate('beg_enable_notify_body', '', '{PER}userid{PER}');
98                 $receiver = ''; $userids = array();
99
100                 // Okay lets notify all users!
101                 while ($row = SQL_FETCHARRAY($result_main)) {
102                         // Merge arrays
103                         $content = merge_array($content, $row);
104
105                         // Update account
106                         SQL_QUERY_ESC("UPDATE
107         `{?_MYSQL_PREFIX?}_user_data`
108 SET
109         `beg_rallye_%s_notify`=UNIX_TIMESTAMP()
110 WHERE
111         `userid`=%s
112 LIMIT 1",
113                                 array(
114                                         $mode,
115                                         $content['userid']
116                                 ), __FILE__, __LINE__);
117
118                         // Load email template and send it to the user!
119                         if ($sentBonusMails === true) {
120                                 // Add userid to queue
121                                 $userids[] = $content['userid'];
122                         } else {
123                                 // Send normal notification mail to the members
124                                 $message = loadEmailTemplate('beg_' . $mode . '_notify', $content, $content['userid']);
125                                 sendEmail($content['userid'], '{--BEG_RALLYE_' . strtoupper($mode) . '_SUBJECT--}', $message);
126                         }
127                 } // END - while
128
129                 // Shall I send out bonus mails?
130                 if ($sentBonusMails === true) {
131                         // Okay, make array to string
132                         $receiver = implode(';', $userids);
133
134                         // Prepare URL
135                         $url = 'modules.php?module=index&amp;what=login';
136
137                         // Insert mail
138                         addBonusMailToQueue('{--BEG_RALLYE_' . strtoupper($mode) . '_SUBJECT--}', $message, $receiver, getBegNotifyBonus(), getBegNotifyWait(), $url, 0, 'normal', SQL_NUMROWS($result_main));
139                 } // END - if
140         } // END - if
141
142         // Free memory
143         SQL_FREERESULT($result_main);
144 } // END - if
145
146 // [EOF]
147 ?>