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 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the Free Software *
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
32 ************************************************************************/
34 // Some security stuff...
35 if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38 } elseif (!IS_MEMBER()) {
39 LOAD_URL("modules.php?module=index");
42 // Add description as navigation point
43 ADD_DESCR("member", basename(__FILE__));
45 $result_depths = SQL_QUERY("SELECT level, percents FROM "._MYSQL_PREFIX."_refdepths ORDER BY level", __FILE__, __LINE__);
46 $depths = SQL_NUMROWS($result_depths);
48 // Add many more rows for the login/turbo/ref/order bonus
49 if (!EXT_IS_ACTIVE("bonus")) $depths += 1;
50 if (GET_EXT_VERSION("bonus") >= "0.2.2") $depths += 6;
51 if (GET_EXT_VERSION("bonus") >= "0.4.4") $depths += 4;
53 // Remember row count in constant
54 define('__ROWS_VALUE', ($depths*2+15));
57 $TPTS = 0; $TREF = 0; $TLOCK = 0; $OUT = "";
60 while (list($lvl, $per) = SQL_FETCHROW($result_depths)) {
61 // Initialize ref-count
64 // Load referral points
65 $result_points = SQL_QUERY_ESC("SELECT points, locked_points FROM "._MYSQL_PREFIX."_user_points WHERE userid=%s AND ref_depth=%s LIMIT 1", array($GLOBALS['userid'], bigintval($lvl)), __FILE__, __LINE__);
66 if (SQL_NUMROWS($result_points) == 1) {
67 list($points, $LOCKED) = SQL_FETCHROW($result_points);
68 SQL_FREERESULT($result_points);
69 // Also count locked points
70 $TPTS += $points; $TLOCK += $LOCKED;
72 $points = "0.00000"; $LOCKED = "0.00000";
75 // Load referral counts
76 $result_refs = SQL_QUERY_ESC("SELECT counter FROM "._MYSQL_PREFIX."_refsystem WHERE userid=%s AND level='%s' LIMIT 1", array($GLOBALS['userid'], bigintval($lvl)), __FILE__, __LINE__);
77 if (SQL_NUMROWS($result_refs) == 1) {
78 list($REFS) = SQL_FETCHROW($result_refs);
79 SQL_FREERESULT($result_refs);
85 // Transfer data to array for template
89 'points' => TRANSLATE_COMMA($points),
94 $OUT .= LOAD_TEMPLATE("member_points_row", true, $content);
98 SQL_FREERESULT($result_depths);
100 // Put rows to constant for the main template
101 define('__REF_LEVEL_ROWS', $OUT);
103 $result = SQL_QUERY_ESC("SELECT used_points, ref_payout FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
104 array($GLOBALS['userid']), __FILE__, __LINE__);
105 list($USED, $PAY) = SQL_FETCHROW($result);
106 SQL_FREERESULT($result);
108 // Initialize variables
109 $CONFIRMED = "---"; $SENT = "---"; $RECEIVED = "---";
111 // Only user >= v0.1.2: Fetch confirmed mails counter
112 if (GET_EXT_VERSION("user") >= "0.1.2") {
114 if (GET_EXT_VERSION("user") >= "0.1.4") {
115 $ADD = ", emails_sent, emails_received";
117 $result = SQL_QUERY_ESC("SELECT mails_confirmed".$ADD." FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
118 list($CONFIRMED, $SENT, $RECEIVED) = SQL_FETCHROW($result);
119 SQL_FREERESULT($result);
121 // Please update the user extension if you see 3 dashes
122 if (empty($SENT)) $SENT = "---";
123 if (empty($RECEIVED)) $RECEIVED = "---";
129 // If TLOCK is 0 add 3 zeros for floating
130 if ($TLOCK == "0") $TLOCK = "0.00000";
132 // Remember several values in constants
133 define('__USED_VALUE' , TRANSLATE_COMMA($USED));
134 define('__TPTS_VALUE' , TRANSLATE_COMMA($TPTS - $USED));
135 define('__TREF_VALUE' , $TREF);
136 define('__TLOCK_VALUE', TRANSLATE_COMMA($TLOCK));
138 // Fixes a bug when there is no bonus extension installed
139 if (GET_EXT_VERSION("bonus") < "0.4.4") $_CONFIG['bonus_active'] = "X";
141 // Display login bonus and turbo-click bonus
142 if ((GET_EXT_VERSION("bonus") >= "0.2.2") && (EXT_IS_ACTIVE("bonus")) && ($_CONFIG['bonus_active'] == "Y")) {
144 if (GET_EXT_VERSION("bonus") >= "0.4.4") $ADD = ", bonus_ref, bonus_order, bonus_stats";
147 $result = SQL_QUERY_ESC("SELECT login_bonus, turbo_bonus".$ADD." FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
148 array($GLOBALS['userid']), __FILE__, __LINE__);
150 // We don't add this points now. This will be done after each month
151 list($login, $turbo, $ref, $order, $stats) = SQL_FETCHROW($result);
152 SQL_FREERESULT($result);
155 define('__TURBO_VALUE', TRANSLATE_COMMA($turbo));
156 define('__LOGIN_VALUE', TRANSLATE_COMMA($login));
158 if (GET_EXT_VERSION("bonus") >= "0.4.4") {
159 // Add referral, stats and order bonys
160 define('__REF_VALUE' , TRANSLATE_COMMA($ref));
161 define('__ORDER_VALUE', TRANSLATE_COMMA($order));
162 define('__STATS_VALUE', TRANSLATE_COMMA($stats));
165 // Total bonus points
166 define('__TTOTAL_VALUE', TRANSLATE_COMMA($turbo + $login + $ref + $order + $stats));
169 define('__SPECIAL_ROWS', LOAD_TEMPLATE("member_points_bonus_rows", true));
170 } elseif ($_CONFIG['bonus_active'] == "N") {
171 // Bonus active rallye deactivated
172 define('__SPECIAL_ROWS', LOAD_TEMPLATE("member_points_bonus_disabled", true));
173 } elseif ((IS_ADMIN()) && (GET_EXT_VERSION("bonus") < "0.2.2") && (EXT_IS_ACTIVE("bonus"))) {
174 // Please upgrade your bonus extension to v0.2.2 or newer!
175 define('__SPECIAL_ROWS', LOAD_TEMPLATE("member_points_upgrade"));
177 // Members shall see no special rows here
178 define('__SPECIAL_ROWS', "");
181 // Remeber values for the final template
182 define('__PAY_VALUE' , $PAY);
183 define('__CONFIRMED_VALUE', $CONFIRMED);
184 define('__RECEIVE_VALUE' , $RECEIVED);
185 define('__SENT_VALUE' , $SENT);
187 // Load final template
188 if (EXT_IS_ACTIVE("user")) {
189 // Load template when required extension is there
190 LOAD_TEMPLATE("member_points");
191 } elseif (IS_ADMIN()) {
193 ADD_FATAL(sprintf(EXTENSION_PROBLEM_NOT_INSTALLED, "user"));
196 LOAD_TEMPLATE("admin_settings_saved", false, PROBLEM_POINTS_OVERVIEW_UNAVAILABLE);
199 if (EXT_IS_ACTIVE("payout")) {
200 // Payput extension is installed and active so we can check if the user has enougth points
201 PAYOUT_OUTPUT_PAYOUT_LIST(str_replace(",", ".", ($TPTS - $USED)));