2 /************************************************************************
3 * MXChange v0.2.1 Start: 11/14/2004 *
4 * =============== Last change: 11/19/2004 *
6 * -------------------------------------------------------------------- *
7 * File : monthly_bonus.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Monthly bonus from click-bonus *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Monatlicher Bonus von Klick-Verguetung *
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 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
42 } elseif (!isExtensionActive('bonus')) {
46 // Do not execute when script is in CSS mode or no daily reset
47 if ((getOutputMode() == 1) || (!isResetModeEnabled())) return;
48 //* DEBUG: */ outputHtml(basename(__FILE__)."<br />");
50 // Get current month (2 digits)
51 $curr = date('m', time());
53 if (($curr != getConfig('last_month')) && (getConfig('bonus_ranks') > 0) && (getOutputMode() != 1)) {
54 // Extension 'autopurge' is inactive or purging of inactive accounts is deactivated
55 $whereStatement1 = "WHERE `status`='CONFIRMED'";
57 // Shall I keep inactive members away from here? (mostly wanted in an "active-rallye" ...)
58 if (isExtensionActive('autopurge')) {
59 // Use last online stamp only when autopurge for inactive members is activated
60 if (getConfig('ap_inactive_since') > 0) {
61 // Okay, include last online timestamp
62 $whereStatement1 = "WHERE `status`='CONFIRMED' AND `last_online` >= (UNIX_TIMESTAMP() - {?ap_inactive_since?})";
66 // Add more bonus points here
68 // @TODO Rewrite this to a filter
69 if (getConfig('bonus_click_yn') == 'Y') $add .= ' + `turbo_bonus`';
70 if (getConfig('bonus_login_yn') == 'Y') $add .= ' + `login_bonus`';
71 if (getConfig('bonus_order_yn') == 'Y') $add .= ' + `bonus_order`';
72 if (getConfig('bonus_stats_yn') == 'Y') $add .= ' + `bonus_stats`';
73 if (getConfig('bonus_ref_yn') == 'Y') $add .= ' + `bonus_ref`';
75 // Shall we add some entries?
77 $whereStatement1 .= ' AND (0' . $add . ') > 0';
80 // Run SQL string to check for accounts
81 $result_main = SQL_QUERY("SELECT
82 `userid`, `email`, `gender`, `surname`, `family`, (0" . $add . ") AS points
84 `{?_MYSQL_PREFIX?}_user_data`
85 " . $whereStatement1 . "
89 LIMIT {?bonus_ranks?}", __FILE__, __LINE__);
91 // Some entries were found?
92 if (SQL_NUMROWS($result_main) > 0) {
93 // Load our winners...
94 while ($content = SQL_FETCHARRAY($result_main)) {
95 // Make sure zero points are not mailed
96 if ($content['points'] > 0) {
97 // Add points to user's account directly
98 addPointsDirectly('monthly_bonus', $content['userid'], $content['points']);
100 // Translate gender/points
101 $content['gender'] = translateGender($content['gender']);
102 $content['points'] = translateComma($content['points']);
104 // Load email template and email it away
105 $message = loadEmailTemplate('member_bonus', $content, bigintval($content['userid']));
106 sendEmail($content['email'], getMessage('BONUS_MONTHLY_ONLINE_BONUS'), $message);
110 // Reset all accounts
111 $result = SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data`
117 `bonus_ref`=0', __FILE__, __LINE__);
121 SQL_FREERESULT($result_main);