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 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2012 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
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. *
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. *
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, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
41 } elseif ((!isExtensionActive('beg')) || (isExtensionInstalledAndOlder('beg', '0.2.8'))) {
42 // Do not execute script on missing/out-dated extension ext-beg
44 } elseif (!isHtmlOutputMode()) {
45 // Do not execute script if not in HTML mode
49 // Create timemark from saved month
50 $mark = mktime(0, 0, 0, getLastMonth(), getDay(), getYear());
51 $sql = ''; $mode = '';
53 // Shall I sent activation or deactivation mail?
54 $sql = "SELECT `userid`,`email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE (`beg_rallye_enable_notify` ";
55 switch (getBegRallye()) {
56 case 'Y': // Begging rallye is activated
57 if (isBegRallyeEnableNotifyEnabled()) {
58 // Okay, let's check for member accounts
59 $sql .= '= 0 OR (`beg_rallye_enable_notify` > 0 AND `beg_rallye_enable_notify` < `beg_rallye_disable_notify`)';
67 case 'N': // Begging rallye is deactivated
68 if (isBegRallyeDisableNotifyEnabled()) {
69 // Okay, let's check for member accounts
70 $sql .= ' > 0 AND `beg_rallye_disable_notify` < `beg_rallye_enable_notify`';
80 // The SQL command needs to be finisched here (only confirmed accounts!)
81 $sql .= ')' . runFilterChain('user_exclusion_sql', " AND `status`='CONFIRMED'") . ' ORDER BY `last_online` ASC';
83 // No IP locking setuped by default
84 $content['ip_locker'] = '{--BEG_NO_LIMITATION--}';
86 if (getBegIpTimeout() > 0) {
88 $content['ip_locker'] = '{%config,createFancyTime=beg_ip_timeout%}';
91 // Check for accounts to be notified
92 $result_main = SQL_QUERY($sql, __FILE__, __LINE__);
93 if (!SQL_HASZERONUMS($result_main)) {
94 // Normal notification mails or bonus mails?
95 $sentBonusMails = ((getBegNotifyBonus() > 0) && ($mode == 'enable') && (isExtensionActive('bonus')));
97 // Load message body for bonus mails
98 $message = loadEmailTemplate('beg_enable_notify_body', '', '{PER}userid{PER}');
99 $receiver = ''; $userids = array();
101 // Okay lets notify all users!
102 while ($row = SQL_FETCHARRAY($result_main)) {
104 $content = merge_array($content, $row);
107 SQL_QUERY_ESC("UPDATE
108 `{?_MYSQL_PREFIX?}_user_data`
110 `beg_rallye_%s_notify`=UNIX_TIMESTAMP()
117 ), __FILE__, __LINE__);
119 // Load email template and send it to the user!
120 if ($sentBonusMails === true) {
121 // Add userid to queue
122 array_push($userids, $content['userid']);
124 // Send normal notification mail to the members
125 $message = loadEmailTemplate('beg_' . $mode . '_notify', $content, $content['userid']);
126 sendEmail($content['userid'], '{--BEG_RALLYE_' . strtoupper($mode) . '_SUBJECT--}', $message);
130 // Shall I send out bonus mails?
131 if ($sentBonusMails === true) {
132 // Okay, make array to string
133 $receiver = implode(';', $userids);
136 $url = 'modules.php?module=index&what=login';
139 addBonusMailToQueue('{--BEG_RALLYE_' . strtoupper($mode) . '_SUBJECT--}', $message, $receiver, getBegNotifyBonus(), getBegNotifyWait(), $url, 0, 'normal', SQL_NUMROWS($result_main));
144 SQL_FREERESULT($result_main);