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 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
43 } elseif (!isExtensionActive('beg')) {
47 // Do not execute when script is in CSS mode
48 if (getOutputMode() != 0) return;
50 // Create timemark from saved month
51 $mark = mktime(0, 0, 0, getConfig('last_month'), date('d', time()), date('Y', time()));
52 $sql = ''; $mode = '';
54 // Shall I sent activation or deactivation mail?
55 $sql = "SELECT `userid`, `email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE (`beg_ral_notify` ";
56 switch (getConfig('beg_rallye')) {
57 case 'Y': // Begging rallye is activated
58 if (getConfig('beg_ral_en_notify') == 'Y') {
59 // Okay, let's check for member accounts
60 $sql .= '= 0 OR (`beg_ral_notify` > 0 AND `beg_ral_en_notify` < `beg_ral_di_notify`)';
68 case 'N': // Begging rallye is deactivated
69 if (getConfig('beg_ral_di_notify') == 'Y') {
70 // Okay, let's check for member accounts
71 $sql .= ' > 0 AND `beg_ral_di_notify` < `beg_ral_en_notify`';
81 // The SQL command needs to be finisched here (only confirmed accounts!)
82 $sql .= ") AND `status`='CONFIRMED' ORDER BY `last_online` ASC";
84 // No IP locking setuped by default
85 $content['ip_locker'] = getMessage('BEG_NO_LIMITATION');
87 if (getConfig('beg_ip_timeout') > 0) {
89 $content['ip_locker'] = createFancyTime(getConfig('beg_ip_timeout'));
92 // Check for accounts to be notified
93 $result_main = SQL_QUERY($sql, __FILE__, __LINE__);
94 if (SQL_NUMROWS($result_main) > 0) {
95 // Normal notification mails or bonus mails?
96 $sentBonusMails = ((getConfig('beg_notify_bonus') > 0) && ($mode == "en") && (isExtensionActive('bonus')));
98 // Generate subject line
99 $subject = getMessage('BEG_RALLYE_'.strtoupper($mode).'_NOTIFY');
101 // Load message body for bonus mails
102 $message = loadEmailTemplate('beg_en_notify_body', '', '{PER}userid{PER}');
103 $receiver = ''; $userids = array();
105 // Okay lets notify all users!
106 while ($row = SQL_FETCHARRAY($result_main)) {
108 $content = merge_array($content, $row);
111 SQL_QUERY_ESC("UPDATE
112 `{?_MYSQL_PREFIX?}_user_data`
114 `beg_ral_notify`=UNIX_TIMESTAMP(),
115 `beg_ral_%s_notify`=UNIX_TIMESTAMP()
122 ), __FILE__, __LINE__);
124 // Load email template and send it to the user!
125 if ($sentBonusMails === true) {
126 // Add userid to queue
127 $userids[] = $content['userid'];
129 // Send normal notification mail to the members
130 $message = loadEmailTemplate('beg_' . $mode . '_notify', $content, $content['userid']);
131 sendEmail($content['email'], $subject, $message);
135 // Shall I send out bonus mails?
136 if ($sentBonusMails === true) {
137 // Okay, make array to string
138 $receiver = implode(';', $userids);
141 $url = 'modules.php?module=index&what=login';
144 addBonusMailToQueue($subject, $message, $receiver, getConfig('beg_notify_bonus'), getConfig('beg_notify_wait'), $url, 0, 'normal', SQL_NUMROWS($result_main));
149 SQL_FREERESULT($result_main);