2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 11/22/2005 *
4 * =================== Last change: 11/22/2005 *
6 * -------------------------------------------------------------------- *
7 * File : beg_mails.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Sends out reminder mails *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Versendet Erinnerungsmails *
12 * -------------------------------------------------------------------- *
13 * Copyright (c) 2003 - 2009 by Roland Haeder *
14 * Copyright (c) 2009 - 2013 by Mailer Developer Team *
15 * For more information visit: http://mxchange.org *
17 * This program is free software; you can redistribute it and/or modify *
18 * it under the terms of the GNU General Public License as published by *
19 * the Free Software Foundation; either version 2 of the License, or *
20 * (at your option) any later version. *
22 * This program is distributed in the hope that it will be useful, *
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
25 * GNU General Public License for more details. *
27 * You should have received a copy of the GNU General Public License *
28 * along with this program; if not, write to the Free Software *
29 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
31 ************************************************************************/
33 // Some security stuff...
34 if (!defined('__SECURITY')) {
36 } elseif ((!isExtensionActive('beg')) || (isExtensionInstalledAndOlder('beg', '0.2.8'))) {
37 // Do not execute script on missing/out-dated extension ext-beg
39 } elseif (!isHtmlOutputMode()) {
40 // Do not execute script if not in HTML mode
44 // Create timemark from saved month
45 $mark = mktime(0, 0, 0, getLastMonthly(), getDay(), getYear());
46 $sql = ''; $mode = '';
48 // Shall I sent activation or deactivation mail?
49 $sql = "SELECT `d`.`userid`, `d`.`email` FROM `{?_MYSQL_PREFIX?}_user_data` AS `d` WHERE (`d`.`beg_rallye_enable_notify` ";
50 switch (getBegRallye()) {
51 case 'Y': // Begging rallye is activated
52 if (isBegRallyeEnableNotifyEnabled()) {
53 // Okay, let's check for member accounts
54 $sql .= '= 0 OR (`d`.`beg_rallye_enable_notify` > 0 AND `d`.`beg_rallye_enable_notify` < `d`.`beg_rallye_disable_notify`)';
62 case 'N': // Begging rallye is deactivated
63 if (isBegRallyeDisableNotifyEnabled()) {
64 // Okay, let's check for member accounts
65 $sql .= ' > 0 AND `d`.`beg_rallye_disable_notify` < `d`.`beg_rallye_enable_notify`';
75 // The SQL command needs to be finisched here (only confirmed accounts!)
76 $sql .= ')' . runFilterChain('user_exclusion_sql', " AND `d`.`status`='CONFIRMED'") . ' ORDER BY `d`.`last_online` ASC';
78 // No IP locking setuped by default
79 $content['ip_locker'] = '{--BEG_NO_LIMITATION--}';
81 if (getBegIpTimeout() > 0) {
83 $content['ip_locker'] = '{%config,createFancyTime=beg_ip_timeout%}';
86 // Check for accounts to be notified
87 $result_main = sqlQuery($sql, __FILE__, __LINE__);
88 if (!ifSqlHasZeroNums($result_main)) {
89 // Normal notification mails or bonus mails?
90 $sentBonusMails = ((getBegNotifyBonus() > 0) && ($mode == 'enable') && (isExtensionActive('bonus')));
92 // Load message body for bonus mails
93 $message = loadEmailTemplate('beg_enable_notify_body', '', '{PER}userid{PER}');
94 $receiver = ''; $userids = array();
96 // Okay lets notify all users!
97 while ($row = sqlFetchArray($result_main)) {
99 $content = merge_array($content, $row);
102 sqlQueryEscaped("UPDATE
103 `{?_MYSQL_PREFIX?}_user_data`
105 `beg_rallye_%s_notify`=UNIX_TIMESTAMP()
112 ), __FILE__, __LINE__);
114 // Load email template and send it to the user!
115 if ($sentBonusMails === TRUE) {
116 // Add userid to queue
117 array_push($userids, $content['userid']);
119 // Send normal notification mail to the members
120 $message = loadEmailTemplate('beg_' . $mode . '_notify', $content, $content['userid']);
121 sendEmail($content['userid'], '{--BEG_RALLYE_' . strtoupper($mode) . '_SUBJECT--}', $message);
125 // Shall I send out bonus mails?
126 if ($sentBonusMails === TRUE) {
127 // Okay, make array to string
128 $receiver = implode(';', $userids);
131 $url = 'modules.php?module=index&what=login';
134 addBonusMailToQueue('{--BEG_RALLYE_' . strtoupper($mode) . '_SUBJECT--}', $message, $receiver, getBegNotifyBonus(), getBegNotifyWait(), $url, 0, 'normal', sqlNumRows($result_main));
139 sqlFreeResult($result_main);