2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 04/20/2004 *
4 * =================== Last change: 06/20/2010 *
6 * -------------------------------------------------------------------- *
7 * File : daily_daily.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Things to do on daily reset *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Dinge, die beim taeglichen Reset erledigt werden *
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 ((!isHtmlOutputMode()) || (!isDailyResetEnabled())) {
37 // Do not execute when script is in non-HTML mode or no daily reset
39 } elseif ((!isExtensionActive('sql_patches')) || (!isExtensionActive('user'))) {
40 if (isDebugModeEnabled()) logDebugMessage(__FILE__, __LINE__, 'Not resetting, needed extension(s) ext-sql_patches/ext-user disabled.');
45 //* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Daily reset started.');
47 // Update user profiles
48 if (isExtensionInstalledAndNewer('order', '0.1.1')) {
51 `{?_MYSQL_PREFIX?}_user_data`
53 `receive_mails`=`max_mails`,
56 `receive_mails` != `max_mails`
57 ' . runFilterChain('user_exclusion_sql', ' ') . '', __FILE__, __LINE__);
61 `{?_MYSQL_PREFIX?}_user_data`
63 `receive_mails`=`max_mails`
65 `receive_mails` != `max_mails`
66 ' . runFilterChain('user_exclusion_sql', ' ') . '', __FILE__, __LINE__);
69 // Transfer points from locked_points to points
70 $result_daily = sqlQuery("SELECT
73 `{?_MYSQL_PREFIX?}_user_data`
77 " . runFilterChain('user_exclusion_sql', ' ') . "
79 `userid` ASC", __FILE__, __LINE__);
81 //* DEBUG: */ debugOutput(basename(__FILE__) . ':payout=0;daily|numRows=' . sqlNumRows($result_daily));
82 if (!ifSqlHasZeroNums($result_daily)) {
86 // Run through all 'locked_(foo)_points columsn
87 foreach (runFilterChain('locked_points_columns_array', array('points')) as $columnName) {
88 // Start checking accounts which are on 0 confirmed-to-go mails
89 while ($content = sqlFetchArray($result_daily)) {
90 //* DEBUG: */ debugOutput(basename(__FILE__) . ':' . $content['userid']);
91 $result_points = sqlQueryEscaped("SELECT
95 `{?_MYSQL_PREFIX?}_user_points`
103 bigintval($content['userid']),
105 ), __FILE__, __LINE__);
107 //* DEBUG: */ debugOutput(basename(__FILE__) . ':payout=0;points|numRows=' . sqlNumRows($result_points));
108 if (!ifSqlHasZeroNums($result_points)) {
109 // Ok transfer points
110 while ($content2 = sqlFetchArray($result_points)) {
112 $content = merge_array($content, $content2);
114 //* DEBUG: */ debugOutput(basename(__FILE__) . ':userid=' . $content['userid'].',depth='.$content['ref_depth'].',columnName=' . $columnName . ',locked='.$content['locked_' . $columnName]);
115 if ($content['ref_depth'] > 0) {
117 addSql(sqlQueryEscaped("UPDATE
118 `{?_MYSQL_PREFIX?}_user_points`
129 $content['locked_' . $columnName],
131 bigintval($content['userid']),
132 $content['ref_depth']
133 ), __FILE__, __LINE__, FALSE)
137 addSql(sqlQueryEscaped("UPDATE
138 `{?_MYSQL_PREFIX?}_user_points`
149 $content['locked_' . $columnName],
151 bigintval($content['userid'])
152 ), __FILE__, __LINE__, FALSE)
156 // Update mediadata as well
157 if (isExtensionInstalledAndNewer('mediadata', '0.0.4')) {
159 updateMediadataEntry(array('total_points'), 'add', $content['locked_' . $columnName]);
165 sqlFreeResult($result_points);
170 runFilterChain('run_sqls');
174 sqlFreeResult($result_daily);
177 //* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Daily reset ended.');