<?php
/************************************************************************
- * MXChange v0.2.1 Start: 10/19/2003 *
- * =============== Last change: 11/12/2004 *
+ * Mailer v0.2.1-FINAL Start: 10/19/2003 *
+ * =================== Last change: 11/12/2004 *
* *
* -------------------------------------------------------------------- *
* File : what-points.php *
* Needs to be in all Files and every File needs "svn propset *
* svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder *
+ * Copyright (c) 2003 - 2009 by Roland Haeder *
* For more information visit: http://www.mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
// Some security stuff...
if (!defined('__SECURITY')) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
- require($INC);
-} elseif (!IS_MEMBER()) {
- LOAD_URL('modules.php?module=index');
+ die();
+} elseif (!isMember()) {
+ redirectToIndexMemberOnlyModule();
}
// Add description as navigation point
-ADD_DESCR('member', __FILE__);
+addMenuDescription('member', __FILE__);
-$result_depths = SQL_QUERY("SELECT level, percents FROM `{!_MYSQL_PREFIX!}_refdepths` ORDER BY level", __FILE__, __LINE__);
+// Query for referal levels and percents
+$result_depths = SQL_QUERY("SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` ORDER BY `level` ASC", __FILE__, __LINE__);
$depths = SQL_NUMROWS($result_depths);
// Add many more rows for the login/turbo/ref/order bonus
// @TODO Should we rewrite this to a filter?
-if (!EXT_IS_ACTIVE('bonus')) $depths += 1;
-if (GET_EXT_VERSION('bonus') >= '0.2.2') $depths += 6;
-if (GET_EXT_VERSION('bonus') >= '0.4.4') $depths += 4;
+if (!isExtensionActive('bonus')) $depths += 1;
+if (isExtensionInstalledAndNewer('bonus', '0.2.2')) $depths += 6;
+if (isExtensionInstalledAndNewer('bonus', '0.4.4')) $depths += 4;
// Remember row count in constant
-define('__ROWS_VALUE', ($depths*2+15));
+$content['rowspan'] = ($depths*2+15);
// Init some vars...
-$TPTS = 0; $TREF = 0; $TLOCK = 0; $OUT = '';
+$totalPoints = '0'; $TREF = '0'; $TLOCK = '0'; $OUT = '';
// Load ref levels
-while ($content = SQL_FETCHARRAY($result_depths)) {
+while ($data = SQL_FETCHARRAY($result_depths)) {
+ // Merge it together
+ $content = merge_array($content, $data);
+
// Initialize ref-count
- $REFS = 0;
+ $REFS = '0';
// Load referal points
- $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__);
+ $result_points = SQL_QUERY_ESC("SELECT `points`, `locked_points` FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s AND `ref_depth`='%s' LIMIT 1", array(getMemberId(), bigintval($content['level'])), __FILE__, __LINE__);
if (SQL_NUMROWS($result_points) == 1) {
- list($points, $locked) = SQL_FETCHROW($result_points);
- SQL_FREERESULT($result_points);
+ list($points, $locked) = SQL_FETCHROW($result_points);
// Also count locked points
- $TPTS += $points; $TLOCK += $locked;
+ $totalPoints += $points; $TLOCK += $locked;
} else {
- $points = "0.00000"; $locked = "0.00000";
+ $points = '0.00000'; $locked = '0.00000';
}
+ // Free result
+ SQL_FREERESULT($result_points);
+
// Load referal counts
- $result_refs = SQL_QUERY_ESC("SELECT counter FROM `{!_MYSQL_PREFIX!}_refsystem` WHERE userid=%s AND level='%s' LIMIT 1",
- array(getUserId(), bigintval($content['level'])), __FILE__, __LINE__);
+ $result_refs = SQL_QUERY_ESC("SELECT `counter` FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `userid`=%s AND `level`='%s' LIMIT 1",
+ array(getMemberId(), bigintval($content['level'])), __FILE__, __LINE__);
if (SQL_NUMROWS($result_refs) == 1) {
list($REFS) = SQL_FETCHROW($result_refs);
- SQL_FREERESULT($result_refs);
$TREF += $REFS;
} else {
- $REFS = 0;
+ $REFS = '0';
}
+ // Free result
+ SQL_FREERESULT($result_refs);
+
// Transfer data to array for template
- $content = array(
- 'lvl' => $content['level'],
- 'per' => TRANSLATE_COMMA($content['percents']),
- 'points' => TRANSLATE_COMMA($points),
- 'refs' => TRANSLATE_COMMA($REFS),
+ $row = array(
+ 'level' => $content['level'],
+ 'percents' => translateComma($content['percents']),
+ 'points' => translateComma($points),
+ 'refs' => translateComma($REFS),
);
// Output row
- $OUT .= LOAD_TEMPLATE("member_points_row", true, $content);
-}
+ $OUT .= loadTemplate('member_points_row', true, $row);
+} // END - while
// Free memory
SQL_FREERESULT($result_depths);
// Put rows to constant for the main template
-define('__REF_LEVEL_ROWS', $OUT);
+$content['rows'] = $OUT;
-$result = SQL_QUERY_ESC("SELECT used_points, ref_payout FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array(getUserId()), __FILE__, __LINE__);
-list($USED, $PAY) = SQL_FETCHROW($result);
-SQL_FREERESULT($result);
+// Fetch user account
+if (!fetchUserData(getMemberId())) {
+ // Something really bad happened
+ debug_report_bug('User account ' . getMemberId() . ' not found.');
+} // END - if
// Initialize variables
-$CONFIRMED = "---"; $SENT = "---"; $RECEIVED = "---";
+$CONFIRMED = '---'; $SENT = '---'; $RECEIVED = '---';
// Only user >= v0.1.2: Fetch confirmed mails counter
-if (GET_EXT_VERSION('user') >= '0.1.2') {
+if (isExtensionInstalledAndNewer('user', '0.1.2')) {
$add = '';
- if (GET_EXT_VERSION('user') >= '0.1.4') {
- $add = ", emails_sent, emails_received";
- }
- $result = SQL_QUERY_ESC("SELECT mails_confirmed".$add." FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__);
- list($CONFIRMED, $SENT, $RECEIVED) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
+ $CONFIRMED = getUserData('mails_confirmed');
+
+ if (getExtensionVersion('user') >= '0.1.4') {
+ $SENT = getUserData('emails_sent');
+ $RECEIVED = getUserData('emails_received');
+ } // END - if
// Please update the user extension if you see 3 dashes
- if (empty($SENT)) $SENT = "---";
- if (empty($RECEIVED)) $RECEIVED = "---";
+ if (empty($SENT)) $SENT = '---';
+ if (empty($RECEIVED)) $RECEIVED = '---';
} else {
// Please update!
- $CONFIRMED = "---";
+ $CONFIRMED = '---';
}
// If TLOCK is 0 add 3 zeros for floating
-if ($TLOCK == "0") $TLOCK = "0.00000";
+if ($TLOCK == '0') $TLOCK = '0.00000';
// Remember several values in constants
-define('__USED_VALUE' , TRANSLATE_COMMA($USED));
-define('__TPTS_VALUE' , TRANSLATE_COMMA($TPTS - $USED));
-define('__TREF_VALUE' , $TREF);
-define('__TLOCK_VALUE', TRANSLATE_COMMA($TLOCK));
+$content['used'] = translateComma(getUserData('used_points'));
+$content['sum'] = translateComma($totalPoints - getUserData('used_points'));
+$content['tref'] = $TREF;
+$content['tlock'] = translateComma($TLOCK);
// Fixes a bug when there is no bonus extension installed
-if (EXT_VERSION_IS_OLDER('bonus', '0.4.4')) setConfigEntry('bonus_active', "X");
+if (isExtensionInstalledAndOlder('bonus', '0.4.4')) setConfigEntry('bonus_active', "X");
-// Display login bonus and turbo-click bonus
-if ((GET_EXT_VERSION('bonus') >= '0.2.2') && (EXT_IS_ACTIVE('bonus')) && (getConfig('bonus_active') == 'Y')) {
- $add = ", 0, 0, 0";
- if (GET_EXT_VERSION('bonus') >= '0.4.4') $add = ", bonus_ref, bonus_order, bonus_stats";
+// Members shall see no special rows here
+$content['special_rows'] = '';
- // Load data
- $result = SQL_QUERY_ESC("SELECT login_bonus, turbo_bonus".$add." FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array(getUserId()), __FILE__, __LINE__);
+// Display login bonus and turbo-click bonus
+if ((isExtensionInstalledAndNewer('bonus', '0.2.2')) && (isExtensionActive('bonus')) && (getConfig('bonus_active') == 'Y')) {
+ // Fetch some data and init others (to avoid a notice here)
+ $content['login'] = getUserData('login_bonus');
+ $content['turbo'] = getUserData('turbo_bonus');
+ $content['ref'] = '0.00000';
+ $content['order'] = '0.00000';
+ $content['stats'] = '0.00000';
+
+ // Get more data if ext-bonus is newer
+ if (getExtensionVersion('bonus') >= '0.4.4') {
+ $content['ref'] = getUserData('bonus_ref');
+ $content['order'] = getUserData('bonus_order');
+ $content['stats'] = getUserData('bonus_stats');
+ } // END - if
- // We don't add this points now. This will be done after each month
- list($login, $turbo, $ref, $order, $stats) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
+ // Total bonus points
+ $content['ttotal'] = translateComma($content['turbo'] + $content['login'] + $content['ref'] + $content['order'] + $content['stats']);
- // Prepare constants
- define('__TURBO_VALUE', TRANSLATE_COMMA($turbo));
- define('__LOGIN_VALUE', TRANSLATE_COMMA($login));
+ // Translate more data
+ $content['turbo'] = translateComma($content['turbo']);
+ $content['login'] = translateComma($content['login']);
- if (GET_EXT_VERSION('bonus') >= '0.4.4') {
+ if (getExtensionVersion('bonus') >= '0.4.4') {
// Add referal, stats and order bonys
- define('__REF_VALUE' , TRANSLATE_COMMA($ref));
- define('__ORDER_VALUE', TRANSLATE_COMMA($order));
- define('__STATS_VALUE', TRANSLATE_COMMA($stats));
- }
-
- // Total bonus points
- define('__TTOTAL_VALUE', TRANSLATE_COMMA($turbo + $login + $ref + $order + $stats));
+ $content['ref'] = translateComma($content['ref']);
+ $content['order'] = translateComma($content['order']);
+ $content['stats'] = translateComma($content['stats']);
+ } // END - if
// Output rows
- define('__SPECIAL_ROWS', LOAD_TEMPLATE("member_points_bonus_rows", true));
-} elseif (getConfig('bonus_active') != "Y") {
+ $content['special_rows'] = loadTemplate('member_points_bonus_rows', true, $content);
+} elseif ((isExtensionActive('bonus')) && (getConfig('bonus_active') != 'Y')) {
// Bonus active rallye deactivated
- define('__SPECIAL_ROWS', LOAD_TEMPLATE("member_points_bonus_disabled", true));
-} elseif ((IS_ADMIN()) && (EXT_VERSION_IS_OLDER('bonus', '0.2.2')) && (EXT_IS_ACTIVE('bonus'))) {
+ $content['special_rows'] = loadTemplate('member_points_bonus_disabled', true);
+} elseif ((isAdmin()) && (isExtensionOlder('bonus', '0.2.2')) && (isExtensionActive('bonus'))) {
// Please upgrade your bonus extension to v0.2.2 or newer!
- define('__SPECIAL_ROWS', LOAD_TEMPLATE("member_points_upgrade"));
-} else {
- // Members shall see no special rows here
- define('__SPECIAL_ROWS', '');
+ $content['special_rows'] = loadTemplate('member_points_upgrade');
}
// Remeber values for the final template
-define('__PAY_VALUE' , $PAY);
-define('__CONFIRMED_VALUE', $CONFIRMED);
-define('__RECEIVE_VALUE' , $RECEIVED);
-define('__SENT_VALUE' , $SENT);
+$content['receive'] = $RECEIVED;
+$content['pay'] = getUserData('ref_payout');
+$content['confirmed'] = $CONFIRMED;
+$content['sent'] = $SENT;
// Load final template
-if (EXT_IS_ACTIVE('user')) {
+if (isExtensionActive('user')) {
// Load template when required extension is there
- LOAD_TEMPLATE("member_points");
-} elseif (IS_ADMIN()) {
+ loadTemplate('member_points', false, $content);
+} elseif (isAdmin()) {
// Missing extension
- addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), 'user');
+ loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('user'));
} else {
// Message for user
- LOAD_TEMPLATE('admin_settings_saved', false, getMessage('PROBLEM_POINTS_OVERVIEW_UNAVAILABLE'));
+ loadTemplate('admin_settings_saved', false, getMessage('PROBLEM_POINTS_OVERVIEW_UNAVAILABLE'));
}
-if (EXT_IS_ACTIVE('payout')) {
+if (isExtensionActive('payout')) {
// Payput extension is installed and active so we can check if the user has enougth points
- PAYOUT_OUTPUT_PAYOUT_LIST(REVERT_COMMA(($TPTS - $USED)));
-}
+ outputPayoutList(convertCommaToDot(($totalPoints - getUserData('used_points'))));
+} // END - if
-//
+// [EOF]
?>