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'";
56 $whereStatement2 = getConfig('bonus_ranks');
58 // Shall I keep inactive members away from here? (mostly wanted in an "active-rallye" ...)
59 if (isExtensionActive('autopurge')) {
60 // Use last online stamp only when autopurge for inactive members is activated
61 if (getConfig('ap_inactive_since') > 0) {
62 // Okay, include last online timestamp
63 $whereStatement1 = sprintf("WHERE `status`='CONFIRMED' AND `last_online` >= (UNIX_TIMESTAMP() - %s)", getConfig('ap_inactive_since'));
64 $whereStatement2 = getConfig('bonus_ranks');
68 // Add more bonus points here
70 // @TODO Rewrite this to a filter
71 if (getConfig('bonus_click_yn') == 'Y') $add .= " + `turbo_bonus`";
72 if (getConfig('bonus_login_yn') == 'Y') $add .= " + `login_bonus`";
73 if (getConfig('bonus_order_yn') == 'Y') $add .= " + `bonus_order`";
74 if (getConfig('bonus_stats_yn') == 'Y') $add .= " + `bonus_stats`";
75 if (getConfig('bonus_ref_yn') == 'Y') $add .= " + `bonus_ref`";
77 // Shall we add some entries?
79 $whereStatement1 .= " AND (0" . $add . ") > 0";
82 // Run SQL string to check for accounts
83 $result_main = SQL_QUERY_ESC("SELECT `userid`, `email`, `gender`, `surname`, `family`, (0".$add.") AS points
85 `{?_MYSQL_PREFIX?}_user_data`
86 ".$whereStatement1."".$add."
91 array($whereStatement2), __FILE__, __LINE__);
93 // Some entries were found?
94 if (SQL_NUMROWS($result_main) > 0) {
95 // Load our winners...
96 while ($content = SQL_FETCHARRAY($result_main)) {
97 // Make sure zero points are not mailed
98 if ($content['points'] > 0) {
99 // Add points to user's account directly
100 addPointsDirectly('monthly_bonus', $content['userid'], $content['points']);
102 // Translate gender/points
103 $content['gender'] = translateGender($content['gender']);
104 $content['points'] = translateComma($content['points']);
106 // Load email template and email it away
107 $message = loadEmailTemplate('member_bonus', $content['points'], bigintval($content['userid']));
108 sendEmail($content['email'], getMessage('BONUS_MONTHLY_ONLINE_BONUS'), $message);
113 $result = SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_user_data`
114 SET turbo_bonus=0, login_bonus=0, bonus_order=0, bonus_stats=0, bonus_ref=0", __FILE__, __LINE__);
118 SQL_FREERESULT($result_main);