2 /************************************************************************
3 * MXChange v0.2.1 Start: 10/19/2003 *
4 * =============== Last change: 11/12/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-points.php *
8 * -------------------------------------------------------------------- *
9 * Short description : All your collected points... *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Alle Ihrer gesammelten Punkte *
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 - 2008 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')) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
43 } elseif (!IS_MEMBER()) {
44 LOAD_URL("modules.php?module=index");
47 // Add description as navigation point
48 ADD_DESCR("member", __FILE__);
50 $result_depths = SQL_QUERY("SELECT level, percents FROM `{!_MYSQL_PREFIX!}_refdepths` ORDER BY level", __FILE__, __LINE__);
51 $depths = SQL_NUMROWS($result_depths);
53 // Add many more rows for the login/turbo/ref/order bonus
54 // @TODO Should we rewrite this to a filter?
55 if (!EXT_IS_ACTIVE("bonus")) $depths += 1;
56 if (GET_EXT_VERSION("bonus") >= "0.2.2") $depths += 6;
57 if (GET_EXT_VERSION("bonus") >= "0.4.4") $depths += 4;
59 // Remember row count in constant
60 define('__ROWS_VALUE', ($depths*2+15));
63 $TPTS = 0; $TREF = 0; $TLOCK = 0; $OUT = "";
66 while ($content = SQL_FETCHARRAY($result_depths)) {
67 // Initialize ref-count
70 // Load referal points
71 $result_points = SQL_QUERY_ESC("SELECT points, locked_points FROM `{!_MYSQL_PREFIX!}_user_points` WHERE userid=%s AND ref_depth=%d LIMIT 1", array(getUserId(), bigintval($content['level'])), __FILE__, __LINE__);
72 if (SQL_NUMROWS($result_points) == 1) {
73 list($points, $locked) = SQL_FETCHROW($result_points);
74 SQL_FREERESULT($result_points);
75 // Also count locked points
76 $TPTS += $points; $TLOCK += $locked;
78 $points = "0.00000"; $locked = "0.00000";
81 // Load referal counts
82 $result_refs = SQL_QUERY_ESC("SELECT counter FROM `{!_MYSQL_PREFIX!}_refsystem` WHERE userid=%s AND level='%s' LIMIT 1",
83 array(getUserId(), bigintval($content['level'])), __FILE__, __LINE__);
84 if (SQL_NUMROWS($result_refs) == 1) {
85 list($REFS) = SQL_FETCHROW($result_refs);
86 SQL_FREERESULT($result_refs);
92 // Transfer data to array for template
94 'lvl' => $content['level'],
95 'per' => TRANSLATE_COMMA($content['percents']),
96 'points' => TRANSLATE_COMMA($points),
97 'refs' => TRANSLATE_COMMA($REFS),
101 $OUT .= LOAD_TEMPLATE("member_points_row", true, $content);
105 SQL_FREERESULT($result_depths);
107 // Put rows to constant for the main template
108 define('__REF_LEVEL_ROWS', $OUT);
110 $result = SQL_QUERY_ESC("SELECT used_points, ref_payout FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
111 array(getUserId()), __FILE__, __LINE__);
112 list($USED, $PAY) = SQL_FETCHROW($result);
113 SQL_FREERESULT($result);
115 // Initialize variables
116 $CONFIRMED = "---"; $SENT = "---"; $RECEIVED = "---";
118 // Only user >= v0.1.2: Fetch confirmed mails counter
119 if (GET_EXT_VERSION("user") >= "0.1.2") {
121 if (GET_EXT_VERSION("user") >= "0.1.4") {
122 $ADD = ", emails_sent, emails_received";
124 $result = SQL_QUERY_ESC("SELECT mails_confirmed".$ADD." FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__);
125 list($CONFIRMED, $SENT, $RECEIVED) = SQL_FETCHROW($result);
126 SQL_FREERESULT($result);
128 // Please update the user extension if you see 3 dashes
129 if (empty($SENT)) $SENT = "---";
130 if (empty($RECEIVED)) $RECEIVED = "---";
136 // If TLOCK is 0 add 3 zeros for floating
137 if ($TLOCK == "0") $TLOCK = "0.00000";
139 // Remember several values in constants
140 define('__USED_VALUE' , TRANSLATE_COMMA($USED));
141 define('__TPTS_VALUE' , TRANSLATE_COMMA($TPTS - $USED));
142 define('__TREF_VALUE' , $TREF);
143 define('__TLOCK_VALUE', TRANSLATE_COMMA($TLOCK));
145 // Fixes a bug when there is no bonus extension installed
146 if (EXT_VERSION_IS_OLDER("bonus", "0.4.4")) setConfigEntry('bonus_active', "X");
148 // Display login bonus and turbo-click bonus
149 if ((GET_EXT_VERSION("bonus") >= "0.2.2") && (EXT_IS_ACTIVE("bonus")) && (getConfig('bonus_active') == "Y")) {
151 if (GET_EXT_VERSION("bonus") >= "0.4.4") $ADD = ", bonus_ref, bonus_order, bonus_stats";
154 $result = SQL_QUERY_ESC("SELECT login_bonus, turbo_bonus".$ADD." FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
155 array(getUserId()), __FILE__, __LINE__);
157 // We don't add this points now. This will be done after each month
158 list($login, $turbo, $ref, $order, $stats) = SQL_FETCHROW($result);
159 SQL_FREERESULT($result);
162 define('__TURBO_VALUE', TRANSLATE_COMMA($turbo));
163 define('__LOGIN_VALUE', TRANSLATE_COMMA($login));
165 if (GET_EXT_VERSION("bonus") >= "0.4.4") {
166 // Add referal, stats and order bonys
167 define('__REF_VALUE' , TRANSLATE_COMMA($ref));
168 define('__ORDER_VALUE', TRANSLATE_COMMA($order));
169 define('__STATS_VALUE', TRANSLATE_COMMA($stats));
172 // Total bonus points
173 define('__TTOTAL_VALUE', TRANSLATE_COMMA($turbo + $login + $ref + $order + $stats));
176 define('__SPECIAL_ROWS', LOAD_TEMPLATE("member_points_bonus_rows", true));
177 } elseif (getConfig('bonus_active') != "Y") {
178 // Bonus active rallye deactivated
179 define('__SPECIAL_ROWS', LOAD_TEMPLATE("member_points_bonus_disabled", true));
180 } elseif ((IS_ADMIN()) && (EXT_VERSION_IS_OLDER("bonus", "0.2.2")) && (EXT_IS_ACTIVE("bonus"))) {
181 // Please upgrade your bonus extension to v0.2.2 or newer!
182 define('__SPECIAL_ROWS', LOAD_TEMPLATE("member_points_upgrade"));
184 // Members shall see no special rows here
185 define('__SPECIAL_ROWS', "");
188 // Remeber values for the final template
189 define('__PAY_VALUE' , $PAY);
190 define('__CONFIRMED_VALUE', $CONFIRMED);
191 define('__RECEIVE_VALUE' , $RECEIVED);
192 define('__SENT_VALUE' , $SENT);
194 // Load final template
195 if (EXT_IS_ACTIVE("user")) {
196 // Load template when required extension is there
197 LOAD_TEMPLATE("member_points");
198 } elseif (IS_ADMIN()) {
200 addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "user");
203 LOAD_TEMPLATE("admin_settings_saved", false, getMessage('PROBLEM_POINTS_OVERVIEW_UNAVAILABLE'));
206 if (EXT_IS_ACTIVE("payout")) {
207 // Payput extension is installed and active so we can check if the user has enougth points
208 PAYOUT_OUTPUT_PAYOUT_LIST(REVERT_COMMA(($TPTS - $USED)));