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_LOGGED_IN()) {
39 LOAD_URL("modules.php?module=index");
42 // Add description as navigation point
43 ADD_DESCR("member", basename(__FILE__));
45 OPEN_TABLE("100%", "member_content member_content_align", "");
46 $result_depths = SQL_QUERY("SELECT level, percents FROM "._MYSQL_PREFIX."_refdepths ORDER BY level", __FILE__, __LINE__);
47 $depths = SQL_NUMROWS($result_depths);
49 // Add many more rows for the login/turbo/ref/order bonus
50 if (!EXT_IS_ACTIVE("bonus")) $depths += 1;
51 if (GET_EXT_VERSION("bonus") >= "0.2.2") $depths += 6;
52 if (GET_EXT_VERSION("bonus") >= "0.4.4") $depths += 4;
54 // Remember row count in constant
55 define('__ROWS_VALUE', ($depths*2+15));
58 $TPTS = "0"; $TREF = "0"; $TLOCK = "0"; $OUT = "";
61 while (list($lvl, $per) = SQL_FETCHROW($result_depths)) {
62 // Initialize ref-count
65 // Load referral points
66 $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__);
67 if (SQL_NUMROWS($result_points) == 1) {
68 list($points, $LOCKED) = SQL_FETCHROW($result_points);
69 SQL_FREERESULT($result_points);
70 // Also count locked points
71 $TPTS += $points; $TLOCK += $LOCKED;
73 $points = "0.00000"; $LOCKED = "0.00000";
76 // Load referral counts
77 $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__);
78 if (SQL_NUMROWS($result_refs) == 1) {
79 list($REFS) = SQL_FETCHROW($result_refs);
80 SQL_FREERESULT($result_refs);
86 // Transfer data to array for template
90 'points' => TRANSLATE_COMMA($points),
95 $OUT .= LOAD_TEMPLATE("member_points_row", true, $content);
99 SQL_FREERESULT($result_depths);
101 // Put rows to constant for the main template
102 define('__REF_LEVEL_ROWS', $OUT);
104 $result = SQL_QUERY_ESC("SELECT used_points, ref_payout FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
105 array($GLOBALS['userid']), __FILE__, __LINE__);
106 list($USED, $PAY) = SQL_FETCHROW($result);
107 SQL_FREERESULT($result);
109 // Initialize variables
110 $CONFIRMED = "---"; $SENT = "---"; $RECEIVED = "---";
112 // Only user >= v0.1.2: Fetch confirmed mails counter
113 if (GET_EXT_VERSION("user") >= "0.1.2") {
115 if (GET_EXT_VERSION("user") >= "0.1.4") {
116 $ADD = ", emails_sent, emails_received";
118 $result = SQL_QUERY_ESC("SELECT mails_confirmed".$ADD." FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
119 list($CONFIRMED, $SENT, $RECEIVED) = SQL_FETCHROW($result);
120 SQL_FREERESULT($result);
122 // Please update the user extension if you see 3 dashes
123 if (empty($SENT)) $SENT = "---";
124 if (empty($RECEIVED)) $RECEIVED = "---";
130 // If TLOCK is 0 add 3 zeros for floating
131 if ($TLOCK == "0") $TLOCK = "0.00000";
133 // Remember several values in constants
134 define('__USED_VALUE' , TRANSLATE_COMMA($USED));
135 define('__TPTS_VALUE' , TRANSLATE_COMMA($TPTS - $USED));
136 define('__TREF_VALUE' , $TREF);
137 define('__TLOCK_VALUE', TRANSLATE_COMMA($TLOCK));
139 // Fixes a bug when there is no bonus extension installed
140 if (GET_EXT_VERSION("bonus") < "0.4.4") $_CONFIG['bonus_active'] = "X";
142 // Display login bonus and turbo-click bonus
143 if ((GET_EXT_VERSION("bonus") >= "0.2.2") && (EXT_IS_ACTIVE("bonus")) && ($_CONFIG['bonus_active'] == "Y")) {
145 if (GET_EXT_VERSION("bonus") >= "0.4.4") $ADD = ", bonus_ref, bonus_order, bonus_stats";
148 $result = SQL_QUERY_ESC("SELECT login_bonus, turbo_bonus".$ADD." FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
149 array($GLOBALS['userid']), __FILE__, __LINE__);
151 // We don't add this points now. This will be done after each month
152 list($login, $turbo, $ref, $order, $stats) = SQL_FETCHROW($result);
153 SQL_FREERESULT($result);
156 define('__TURBO_VALUE', TRANSLATE_COMMA($turbo));
157 define('__LOGIN_VALUE', TRANSLATE_COMMA($login));
159 if (GET_EXT_VERSION("bonus") >= "0.4.4") {
160 // Add referral, stats and order bonys
161 define('__REF_VALUE' , TRANSLATE_COMMA($ref));
162 define('__ORDER_VALUE', TRANSLATE_COMMA($order));
163 define('__STATS_VALUE', TRANSLATE_COMMA($stats));
166 // Total bonus points
167 define('__TTOTAL_VALUE', TRANSLATE_COMMA($turbo + $login + $ref + $order + $stats));
170 define('__SPECIAL_ROWS', LOAD_TEMPLATE("member_points_bonus_rows", true));
171 } elseif ($_CONFIG['bonus_active'] == "N") {
172 // Bonus active rallye deactivated
173 define('__SPECIAL_ROWS', LOAD_TEMPLATE("member_points_bonus_disabled", true));
174 } elseif ((IS_ADMIN()) && (GET_EXT_VERSION("bonus") < "0.2.2") && (EXT_IS_ACTIVE("bonus"))) {
175 // Please upgrade your bonus extension to v0.2.2 or newer!
176 define('__SPECIAL_ROWS', LOAD_TEMPLATE("member_points_upgrade"));
178 // Members shall see no special rows here
179 define('__SPECIAL_ROWS', "");
182 // Remeber values for the final template
183 define('__PAY_VALUE' , $PAY);
184 define('__CONFIRMED_VALUE', $CONFIRMED);
185 define('__RECEIVE_VALUE' , $RECEIVED);
186 define('__SENT_VALUE' , $SENT);
188 // Load final template
189 if (EXT_IS_ACTIVE("user")) {
190 // Load template when required extension is there
191 LOAD_TEMPLATE("member_points");
192 } elseif (IS_ADMIN()) {
194 ADD_FATAL(sprintf(EXTENSION_PROBLEM_NOT_INSTALLED, "user"));
197 LOAD_TEMPLATE("admin_settings_saved", false, PROBLEM_POINTS_OVERVIEW_UNAVAILABLE);
200 if (EXT_IS_ACTIVE("payout")) {
201 // Payput extension is installed and active so we can check if the user has enougth points
202 PAYOUT_OUTPUT_PAYOUT_LIST(str_replace(",", ".", ($TPTS - $USED)));