From 9ad55a40b49ea7dc484b1553039715fbce8086f0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 12 Jul 2011 19:01:06 +0000 Subject: [PATCH] Referal system rewritten, ext-refback continued: - Referal system refactured, it is now much easier to understand - Extension ext-refback does now show the click rate in refback list - BIGINT is now always 20 digits long - Internal TODO closed (unused column 'status') - TODOs.txt updated --- DOCS/TODOs.txt | 23 +- inc/daily/daily_100_bonus.php | 2 +- inc/extensions/ext-booking.php | 4 +- inc/extensions/ext-mediadata.php | 4 +- inc/extensions/ext-user.php | 22 +- inc/functions.php | 4 +- inc/language/de.php | 2 +- inc/libs/refback_functions.php | 313 ++++++++++-------- inc/modules/member/what-refback.php | 6 +- inc/modules/member/what-reflist.php | 2 +- inc/mysql-manager.php | 158 +++++---- inc/wrapper-functions.php | 8 +- install/tables.sql | 16 +- .../de/html/member/member_ref_list_level.tpl | 2 +- .../de/html/member/member_ref_list_row.tpl | 2 +- .../html/member/member_refback_list_level.tpl | 7 +- .../html/member/member_refback_list_row.tpl | 3 + .../member_refback_list_row_deleted.tpl | 3 + templates/de/html/member/member_stats_row.tpl | 2 +- 19 files changed, 323 insertions(+), 260 deletions(-) diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index abac6c9d44..8a9666e927 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -40,7 +40,7 @@ ./inc/extensions/ext-yoomedia.php:121: // @TODO Can this be moved into a database table? ./inc/extensions/ext-yoomedia.php:54:// @TODO Only deprecated when 'ext-network' is ready! setExtensionDeprecated('Y'); ./inc/extensions-functions.php:155: // @TODO Do we still need this? setExtensionUpdateNotes(''); -./inc/extensions-functions.php:1944:// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable' +./inc/extensions-functions.php:1945:// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable' ./inc/extensions-functions.php:425:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) ) ./inc/extensions-functions.php:562: // @TODO Extension is loaded, what next? ./inc/filter/bonus_filter.php:56: // @TODO This query isn't right, it will only update if the user was for a longer time away! @@ -80,10 +80,10 @@ ./inc/libs/task_functions.php:247: // @TODO These can be rewritten to filter ./inc/libs/task_functions.php:51:// @TODO Move all extension-dependent queries into filters ./inc/libs/theme_functions.php:93: // @TODO Can't this be rewritten to an API function? -./inc/libs/user_functions.php:146: // @TODO These two constants are no longer used, maybe we reactivate this code? -./inc/libs/user_functions.php:234:// @TODO Double-check configuration entry here -./inc/libs/user_functions.php:329: // @TODO Make this filter working: $ADDON = runFilterChain('post_login_update', $content); -./inc/libs/user_functions.php:358: // @TODO Make this filter working: $url = runFilterChain('do_login', array('content' => $content, 'addon' => $ADDON)); +./inc/libs/user_functions.php:159: // @TODO These two constants are no longer used, maybe we reactivate this code? +./inc/libs/user_functions.php:250:// @TODO Double-check configuration entry here +./inc/libs/user_functions.php:345: // @TODO Make this filter working: $ADDON = runFilterChain('post_login_update', $content); +./inc/libs/user_functions.php:374: // @TODO Make this filter working: $url = runFilterChain('do_login', array('content' => $content, 'addon' => $ADDON)); ./inc/libs/yoomedia_functions.php:114: $response = YOOMEDIA_QUERY_API('out_textmail.php', true); // @TODO Ask Yoo!Media for test script ./inc/load_config.php:75: // @TODO Rewrite them to avoid this else block ./inc/loader/load-extension.php:13: * @TODO Rewrite this whole file * @@ -163,19 +163,18 @@ ./inc/modules/member/what-payout.php:194: // @TODO Rewrite this to a filter ./inc/modules/member/what-points.php:55:// @TODO Should we rewrite this to a filter? ./inc/modules/member/what-rallyes.php:89: // @TODO Reactivate this: $content['admin'] = '' . $content['login'] . ''; -./inc/modules/member/what-refback.php:124: // @TODO UNUSED: $refRow['status'] = translateUserStatus($refRow['status']); ./inc/modules/member/what-reflinks.php:52:// @TODO Move this into a filter ./inc/modules/member/what-transfer.php:128: // @TODO Rewrite this to a filter ./inc/modules/member/what-unconfirmed.php:144: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() ./inc/modules/member/what-unconfirmed.php:209: // @TODO This 'userid' cannot be saved because of encapsulated EL code ./inc/modules/order.php:74: // @TODO Unused: 2,4 ./inc/monthly/monthly_bonus.php:64: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1267: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1529: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() -./inc/mysql-manager.php:1617: // @TODO Rewrite these lines to a filter -./inc/mysql-manager.php:1641: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:2007: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:2051:// @TODO Fix inconsistency between last_module and getWhat() +./inc/mysql-manager.php:1257: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1520: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() +./inc/mysql-manager.php:1608: // @TODO Rewrite these lines to a filter +./inc/mysql-manager.php:1632: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:2001: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:2045:// @TODO Fix inconsistency between last_module and getWhat() ./inc/mysql-manager.php:371: // @TODO Try to rewrite this to one or more functions ./inc/mysql-manager.php:44:// @TODO Can we cache this? ./inc/purge/purge-inact.php:55: // @TODO Rewrite these if() blocks to a filter diff --git a/inc/daily/daily_100_bonus.php b/inc/daily/daily_100_bonus.php index f51b3dd986..868dce98e0 100644 --- a/inc/daily/daily_100_bonus.php +++ b/inc/daily/daily_100_bonus.php @@ -6,7 +6,7 @@ * -------------------------------------------------------------------- * * File : daily_100_bonus.php * * -------------------------------------------------------------------- * - * Short description : Check for 100% clickrate order * + * Short description : Check for 100% click rate order * * -------------------------------------------------------------------- * * Kurzbeschreibung : Nach Mailbestaetigungen mit 100% Klickrate s. * * -------------------------------------------------------------------- * diff --git a/inc/extensions/ext-booking.php b/inc/extensions/ext-booking.php index 8d649fd4cc..91fa3dbcd6 100644 --- a/inc/extensions/ext-booking.php +++ b/inc/extensions/ext-booking.php @@ -78,7 +78,7 @@ INDEX (`userid`)", // Add the filters registerFilter('post_add_points', 'ADD_BOOKING_RECORD', false, true, isExtensionDryRun()); - registerFilter('sub_points', 'ADD_BOOKING_RECORD', false, true, isExtensionDryRun()); + registerFilter('post_sub_points', 'ADD_BOOKING_RECORD', false, true, isExtensionDryRun()); break; case 'remove': // Do stuff when removing extension @@ -88,7 +88,7 @@ INDEX (`userid`)", // Remove the filters unregisterFilter(__FUNCTION__, __LINE__, 'post_add_points', 'ADD_BOOKING_RECORD', true, isExtensionDryRun()); - unregisterFilter(__FUNCTION__, __LINE__, 'sub_points', 'ADD_BOOKING_RECORD', true, isExtensionDryRun()); + unregisterFilter(__FUNCTION__, __LINE__, 'post_sub_points', 'ADD_BOOKING_RECORD', true, isExtensionDryRun()); break; case 'activate': // Do stuff when admin activates this extension diff --git a/inc/extensions/ext-mediadata.php b/inc/extensions/ext-mediadata.php index 4a7f8c5e27..5f061e8543 100644 --- a/inc/extensions/ext-mediadata.php +++ b/inc/extensions/ext-mediadata.php @@ -56,7 +56,7 @@ switch (getExtensionMode()) { // Add the filters registerFilter('post_add_points', 'UPDATE_MEDIADATA_ENTRY', false, true, isExtensionDryRun()); - registerFilter('sub_points', 'UPDATE_MEDIADATA_ENTRY', false, true, isExtensionDryRun()); + registerFilter('post_sub_points', 'UPDATE_MEDIADATA_ENTRY', false, true, isExtensionDryRun()); break; case 'remove': // Do stuff when removing extension @@ -67,7 +67,7 @@ switch (getExtensionMode()) { // Remove the filters unregisterFilter(__FUNCTION__, __LINE__, 'post_add_points', 'UPDATE_MEDIADATA_ENTRY', true, isExtensionDryRun()); - unregisterFilter(__FUNCTION__, __LINE__, 'sub_points', 'UPDATE_MEDIADATA_ENTRY', true, isExtensionDryRun()); + unregisterFilter(__FUNCTION__, __LINE__, 'post_sub_points', 'UPDATE_MEDIADATA_ENTRY', true, isExtensionDryRun()); break; case 'activate': // Do stuff when admin activates this extension diff --git a/inc/extensions/ext-user.php b/inc/extensions/ext-user.php index 76cebee280..bb56d0cf02 100644 --- a/inc/extensions/ext-user.php +++ b/inc/extensions/ext-user.php @@ -41,10 +41,10 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('0.4.2'); +setThisExtensionVersion('0.4.3'); // Version history array (add more with , '0.0.1' and so on) -setExtensionVersionHistory(array('0.0.0', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2')); +setExtensionVersionHistory(array('0.0.0', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3')); // Keep this extension always active! setExtensionAlwaysActive('Y'); @@ -53,7 +53,7 @@ switch (getExtensionMode()) { case 'register': // Do stuff when installation is running addDropTableSql('user_cats'); addCreateTableSql('user_cats', " -`id` BIGINT(22) NOT NULL AUTO_INCREMENT, +`id` BIGINT(20) NOT NULL AUTO_INCREMENT, `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, `cat_id` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`id`), @@ -63,7 +63,7 @@ INDEX (`cat_id`)", addDropTableSql('user_data'); addCreateTableSql('user_data', " -`userid` BIGINT(22) NOT NULL AUTO_INCREMENT, +`userid` BIGINT(20) NOT NULL AUTO_INCREMENT, `surname` VARCHAR(255) NOT NULL DEFAULT '', `family` VARCHAR(255) NOT NULL DEFAULT '', `street_nr` VARCHAR(255) NOT NULL DEFAULT '', @@ -77,7 +77,7 @@ INDEX (`cat_id`)", `password` VARCHAR(255) NOT NULL DEFAULT '', `max_mails` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, `receive_mails` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, -`refid` BIGINT(22) NOT NULL DEFAULT 0, +`refid` BIGINT(20) NOT NULL DEFAULT 0, `status` ENUM('UNCONFIRMED','CONFIRMED','LOCKED') NOT NULL DEFAULT 'UNCONFIRMED', `user_hash` VARCHAR(255) NULL DEFAULT NULL, `REMOTE_ADDR` VARCHAR(15) NOT NULL DEFAULT '0.0.0.0', @@ -104,8 +104,8 @@ INDEX `status_mails` (`status`, `max_mails`)", addDropTableSql('user_points'); addCreateTableSql('user_points', " -`id` BIGINT(22) NOT NULL AUTO_INCREMENT, -`userid` BIGINT(22) NOT NULL DEFAULT 0, +`id` BIGINT(20) NOT NULL AUTO_INCREMENT, +`userid` BIGINT(20) NOT NULL DEFAULT 0, `ref_depth` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0, `points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000, `locked_points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000, @@ -442,6 +442,14 @@ INDEX (`userid`)", // Add special fix include to fix filters addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='chk_regs' LIMIT 1"); + // Update notes (these will be set as task text!) + setExtensionUpdateNotes("Überflüssiges Menü chk_regs entfernt, dies kann mit list_user übernommen werden."); + break; + + case '0.4.3': // SQL queries for v0.4.3 + // Add special fix include to fix filters + addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `refid` `refid` BIGINT(20) NULL DEFAULT NULL"); + // Update notes (these will be set as task text!) setExtensionUpdateNotes("Überflüssiges Menü chk_regs entfernt, dies kann mit list_user übernommen werden."); break; diff --git a/inc/functions.php b/inc/functions.php index 08fa13dc17..be4eed9d40 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2337,7 +2337,7 @@ function getArrayKeysFromSubStrArray ($heystack, $needles, $offset = 0) { // Determines database column name from given subject and locked function determinePointsColumnFromSubjectLocked ($subject, $locked) { - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',locked=' . intval($locked) . ' - ENTERED!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',locked=' . intval($locked) . ' - ENTERED!'); // Default is 'normal' points $pointsColumn = 'points'; @@ -2360,7 +2360,7 @@ function determinePointsColumnFromSubjectLocked ($subject, $locked) { $pointsColumn = $filterData['column']; // Return it - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',locked=' . intval($locked) . ',pointsColumn=' . $pointsColumn . ' - EXIT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',locked=' . intval($locked) . ',pointsColumn=' . $pointsColumn . ' - EXIT!'); return $pointsColumn; } diff --git a/inc/language/de.php b/inc/language/de.php index 3944de41ff..d82729f717 100644 --- a/inc/language/de.php +++ b/inc/language/de.php @@ -437,7 +437,7 @@ addMessages(array( 'MEMBER_STATS_CONTENT' => "Statistiken versandter Mails", 'MEMBER_EMAIL_END_SEND' => "Vollständig versendet", 'MEMBER_EMAIL_CONFIRMED' => "Bestätigt", - 'MEMBER_EMAIL_PERCENT' => "Klickrate", + 'MEMBER_CLICK_RATE' => "Klickrate", 'MEMBER_NO_MAILS_TO_CONFIRM' => "Keine Mails übrig zum Bestätigen.", 'MEMBER_SID' => "Mail-Id", 'CONFIRM_LINK' => "Bestätigungslink", diff --git a/inc/libs/refback_functions.php b/inc/libs/refback_functions.php index 5856a6aeda..9cb0ac3734 100644 --- a/inc/libs/refback_functions.php +++ b/inc/libs/refback_functions.php @@ -38,11 +38,11 @@ // Some security stuff... if (!defined('__SECURITY')) { die(); -} +} // END - if // Payback refback for refid and reduce it for current user function addRefbackPoints ($userid, $ref, $points, $ref_points) { - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',points=' . $points . ',ref_points=' . $ref_points . ' - ENTERED!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',points=' . $points . ',ref_points=' . $ref_points . ' - ENTERED!'); // Back ref depths $GLOBALS['refback_depth'][$userid][$ref] = $GLOBALS['ref_level']; @@ -59,7 +59,7 @@ function addRefbackPoints ($userid, $ref, $points, $ref_points) { initReferalSystem(); // "Walk" through all refids - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',level=' . $content['level'] . ',percents=' . $content['percents'] . ',points=' . $points . ' - LOOP START!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',level=' . $content['level'] . ',percents=' . $content['percents'] . ',points=' . $points . ' - LOOP START!'); foreach (getArrayFromRefbackLevel($userid, $content['level']) as $refid) { // Skip level zero or if both are the same if ($userid == $refid) { @@ -68,16 +68,23 @@ function addRefbackPoints ($userid, $ref, $points, $ref_points) { // Get refback percents $percents = getRefbackPercents($userid, $refid); - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',refid=' . $refid . ',points=' . $points . ',percents=' . $percents); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',refid=' . $refid . ',points=' . $points . ',percents=' . $percents); // Some percents given? if ($percents > 0) { - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'points=' . $points . ',[percents]=' . $content['percents'] . ',percents=' . $percents . ',level=' . $content['level']); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'points=' . $points . ',[percents]=' . $content['percents'] . ',percents=' . $percents . ',level=' . $content['level']); // Calculate points for refback $refback = $points * ($content['percents'] / 100) * ($percents / 100); // Update refback table ('refid' and 'userid' must be exchanged!) - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_refs` SET `points`=`points`+%s WHERE `userid`=%s AND `refid`=%s LIMIT 1", + SQL_QUERY_ESC("UPDATE + `{?_MYSQL_PREFIX?}_user_refs` +SET + `points`=`points`+%s +WHERE + `userid`=%s AND + `refid`=%s +LIMIT 1", array( $refback, $refid, @@ -91,14 +98,14 @@ function addRefbackPoints ($userid, $ref, $points, $ref_points) { } // END - if // Add points again, but only directly - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refback=' . $refback . ',userid=' . $userid . ',ref=' . $ref . ',refid=' . $refid . ' - UPDATE! (' . SQL_AFFECTEDROWS() . ')'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refback=' . $refback . ',userid=' . $userid . ',ref=' . $ref . ',refid=' . $refid . ' - UPDATE! (' . SQL_AFFECTEDROWS() . ')'); addPointsThroughReferalSystem(sprintf("refback:%s", $refid), $userid, $refback); // Reduce points if refid is found if ($refid == $ref) { // Reduce points here! $return = $points * ($content['percents'] / 100) - $refback; - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'return=' . $return . ' - REDUCED!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'return=' . $return . ' - REDUCED!'); } // END - if } // END - if } // END foreach @@ -111,13 +118,13 @@ function addRefbackPoints ($userid, $ref, $points, $ref_points) { $GLOBALS['ref_level'] = $GLOBALS['refback_depth'][$userid][$ref]; // Return them - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',points=' . $points . ',ref_points=' . $ref_points . ',return=' . $return . ' - EXIT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',points=' . $points . ',ref_points=' . $ref_points . ',return=' . $return . ' - EXIT!'); return $return; } // "Getter" for refback percents function getRefbackPercents ($userid, $ref) { - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ' - ENTERED!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ' - ENTERED!'); // Skip identical ids if ($userid == $ref) { return 0; @@ -136,7 +143,7 @@ function getRefbackPercents ($userid, $ref) { if (SQL_NUMROWS($result) == 1) { // Fetch percents list($GLOBALS['refback_percents'][$userid][$ref]) = SQL_FETCHROW($result); - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',percents=' . $GLOBALS['refback_percents'][$userid][$ref]); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',percents=' . $GLOBALS['refback_percents'][$userid][$ref]); } else { // Debug log logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ' - No entry found. :-('); @@ -147,13 +154,13 @@ function getRefbackPercents ($userid, $ref) { } // END - if // Return percents - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',refback_percents=' . $GLOBALS['refback_percents'][$userid][$ref] . ' - EXIT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',refback_percents=' . $GLOBALS['refback_percents'][$userid][$ref] . ' - EXIT!'); return $GLOBALS['refback_percents'][$userid][$ref]; } // "Getter" for userid array which will return only one entry function getArrayFromRefbackLevel ($refid, $level) { - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . $refid . ',level=' . $level); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . $refid . ',level=' . $level); // Init userids $userIds = array(); @@ -169,11 +176,11 @@ ORDER BY array($refid, $level), __FUNCTION__, __LINE__); // Entries found? - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'numRows=' . SQL_NUMROWS($result)); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'numRows=' . SQL_NUMROWS($result)); if (!SQL_HASZERONUMS($result)) { // Add all while ($content = SQL_FETCHARRAY($result)) { - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . $refid . ',level=' . $level . ',userid=' . $content['userid']); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . $refid . ',level=' . $level . ',userid=' . $content['userid']); $userIds[] = $content['userid']; } // END - while } // END - if @@ -182,137 +189,170 @@ ORDER BY SQL_FREERESULT($result); // Return array - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . $refid . ',userIds()=' . count($userIds) . ' - EXIT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . $refid . ',userIds()=' . count($userIds) . ' - EXIT!'); return $userIds; } // Update "refback table" function updateRefbackTable ($userid) { - // Make it sure referal level zero (member him-/herself) is at least selected - if (empty($GLOBALS['refback_level'])) { - $GLOBALS['refback_level'] = NULL; - } // END - if - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $GLOBALS['refback_level'] . ' - ENTERED!'); - - // Init refid and variables - $GLOBALS['refback_refid'][$GLOBALS['refback_level']] = '0'; - $old = '0'; - $minus = '0'; - - // Check for his referal - $result_refid = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `refid`=%s ORDER BY `userid` ASC", - array(bigintval($userid)), __FUNCTION__, __LINE__); - - // When no entry was updated then we have to create it here - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SQL_NUMROWS()=' . SQL_NUMROWS($result_refid)); - if (!SQL_HASZERONUMS($result_refid)) { - // Load all refids - while (list($GLOBALS['refback_refid'][$GLOBALS['refback_level']]) = SQL_FETCHROW($result_refid)) { - // Remmber userid - $GLOBALS['refback_userid'][$GLOBALS['refback_refid'][$GLOBALS['refback_level']]] = $userid; - - // Refid set? - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']]); - if (($GLOBALS['refback_refid'][$GLOBALS['refback_level']] > 0) && ($GLOBALS['refback_refid'][$GLOBALS['refback_level']] != $userid) && (isset($GLOBALS['refback_refid'][$GLOBALS['refback_level']]))) { - // New userid? - if ((isset($GLOBALS['refback_refid'][$GLOBALS['refback_level']-1])) && (isset($GLOBALS['refback_userid'][$GLOBALS['refback_refid'][$GLOBALS['refback_level']-1]]))) { - // New userid! - $old = $userid; - $userid = $GLOBALS['refback_userid'][$GLOBALS['refback_refid'][$GLOBALS['refback_level']-1]]; - $minus = 1; - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',old=' . $old . ',level=' . $GLOBALS['refback_level'] . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ' - NEW UID!'); - } // END - if + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!'); + // Load all referals + loadRefbackTable($userid); - // Check existence - if (is_null($GLOBALS['refback_level'])) { - // Level is NULL - $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid`=%s AND `level` IS NULL AND `refid`=%s LIMIT 1", - array( - bigintval($userid), - bigintval($GLOBALS['refback_refid'][$GLOBALS['refback_level']]) - ), __FUNCTION__, __LINE__); - } else { - // Level is > 0 - $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid`=%s AND `level`=%s AND `refid`=%s LIMIT 1", - array( - bigintval($userid), - bigintval($GLOBALS['refback_level']), - bigintval($GLOBALS['refback_refid'][$GLOBALS['refback_level']]) - ), __FUNCTION__, __LINE__); - } - - // Do we have no entry? - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $GLOBALS['refback_level'] . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ',minus=' . $minus . ',numRows=' . SQL_NUMROWS($result) . ' - FOUND!'); - if (SQL_HASZERONUMS($result)) { - // Insert this level - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $GLOBALS['refback_level'] . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ' - ADD!'); - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_refs` (`userid`, `level`, `refid`) VALUES (%s,%s,%s)", - array( - bigintval($userid), - $GLOBALS['refback_level'], - bigintval($GLOBALS['refback_refid'][$GLOBALS['refback_level']]) - ), __FUNCTION__, __LINE__); - - // Move to next referal level and count his counter one up! - $GLOBALS['refback_level']++; - updateRefbackTable($GLOBALS['refback_refid'][($GLOBALS['refback_level'] - 1)]); - } // END - if + // Add missing level > 1 + addMissingRefbackLevels($userid); + + // The last step is to flush all userid's entries to the database + flushRefbackTableToDatabase($userid); - // Do we have another level here? - if ((($GLOBALS['refback_level']-$minus) > 0) && ($old > 0)) { - // Restore old one - $userid = $old; - - // Shall we add this as well? - $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid`=%s AND `level`=%s AND `refid`=%s LIMIT 1", - array( - bigintval($userid), - (bigintval($GLOBALS['refback_level']) - $minus), - bigintval($GLOBALS['refback_refid'][$GLOBALS['refback_level']]) - ), __FUNCTION__, __LINE__); - - // Do we have no entry? - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . ($GLOBALS['refback_level'] - $minus) . ',minus=' . $minus . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ',numRows=' . SQL_NUMROWS($result) . ' - BACK!'); - if (SQL_HASZERONUMS($result)) { - // Insert this level - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_refs` (`userid`, `level`, `refid`) VALUES (%s,%s,%s)", - array( - bigintval($userid), - ($GLOBALS['refback_level'] - $minus), - bigintval($GLOBALS['refback_refid'][$GLOBALS['refback_level']]) - ), __FUNCTION__, __LINE__); - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . ($GLOBALS['refback_level'] - $minus) . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ' - RETURNED!'); - } // END - if + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - EXIT!'); +} + +// Loads all referals for given userid +function loadRefbackTable ($userid) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!'); + // Init array + $GLOBALS['refback_refid'][$userid] = array(); + + // Get all level entries from the refsystem table + $result = SQL_QUERY_ESC('SELECT `level` FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `userid`=%s ORDER BY `level` ASC', + array($userid), __FUNCTION__, __LINE__); + + // Do we have entries? + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',SQL_NUMROWS()=' . SQL_NUMROWS($result)); + if (SQL_NUMROWS($result) > 0) { + // Then walk through all levels + while (list($level) = SQL_FETCHROW($result)) { + // Init array + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level); + $GLOBALS['refback_refid'][$userid][$level] = array(); + + // Level is = 1? + if ($level == 1) { + // Load all referals of this user + $result_refs = SQL_QUERY_ESC('SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `refid`=%s ORDER BY `userid` ASC', + array($userid), __FUNCTION__, __LINE__); + + // Do we have entries? + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',SQL_NUMROWS()=' . SQL_NUMROWS($result_refs)); + if (SQL_NUMROWS($result_refs) > 0) { + // Then again walk through all + while (list($refid) = SQL_FETCHROW($result_refs)) { + // Add this refid + $GLOBALS['refback_refid'][$userid][$level][] = $refid; + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . $refid); + // Load the refid's array as well + loadRefbackTable($refid); + } // END - while } // END - if + + // Free result + SQL_FREERESULT($result_refs); } // END - if } // END - while - - // Free memory - SQL_FREERESULT($result_refid); } // END - if - // When he has a referal... - if ((($GLOBALS['refback_refid'][$GLOBALS['refback_level']] == $userid) || ($GLOBALS['refback_refid'][$GLOBALS['refback_level']] == '0')) && (isExtensionInstalledAndNewer('cache', '0.1.2')) && (!isset($GLOBALS['refback_cached']))) { - // Remove cache here - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']] . ' - CACHE!'); - if ($GLOBALS['cache_instance']->loadCacheFile('refback')) $GLOBALS['cache_instance']->removeCacheFile(); - $GLOBALS['refback_cached'] = 1; + // Free result + SQL_FREERESULT($result); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - EXIT!'); +} + +// Adds missing refback levels to the array +function addMissingRefbackLevels ($userid) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!'); + // If the array is gone, you have called this function without calling loadRefbackTable() + if (!isset($GLOBALS['refback_refid'][$userid])) { + // Please fix your code + debug_report_bug(__FUNCTION__, __LINE__, 'Called without calling loadRefbackTable() before! userid=' . $userid); } // END - if + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',count()=' . count($GLOBALS['refback_refid'][$userid])); + + // Now walk through the array, first levels + foreach ($GLOBALS['refback_refid'][$userid] as $level=>$levelArray) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',count()=' . count($levelArray)); + // Next are the users + foreach ($levelArray as $refid) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . $refid); + // Does the refid have an array? + if (isset($GLOBALS['refback_refid'][$refid])) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . $refid . ',count()=' . count($GLOBALS['refback_refid'][$refid])); + // Okay, then walk through here, too + foreach ($GLOBALS['refback_refid'][$refid] as $refLevel=>$refArray) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . $refid . ',refLevel=' . $refLevel . ',count()=' . count($refArray)); + // Also walk through this one + foreach ($refArray as $refRefid) { + // Calculate new level + $newLevel = $level + $refLevel; + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . $refid . ',refLevel=' . $refLevel . ',refRefid=' . $refRefid . ',newLevel=' . $newLevel); + // Is the refRefid not in? + if ((!isset($GLOBALS['refback_refid'][$userid][$newLevel])) || (!in_array($refRefid, $GLOBALS['refback_refid'][$userid][$newLevel]))) { + // Then we must add this ref's refid to the userid's next level + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',newLevel=' . $newLevel . ',refRefid=' . $refRefid . ' - ADDED!'); + $GLOBALS['refback_refid'][$userid][$newLevel][] = $refRefid; + } // END - if + } // END - foreach + } // END - foreach + } // END - foreach + } // END - foreach + } // END - foreach + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - EXIT!'); +} - // "Walk" back here - $GLOBALS['refback_level']--; - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refback_level=' . $GLOBALS['refback_level'] .' - LEVEL!'); +// Flush all entries for given userid to database +function flushRefbackTableToDatabase ($userid) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!'); + // If the array is gone, you have called this function without calling loadRefbackTable() + if (!isset($GLOBALS['refback_refid'][$userid])) { + // Please fix your code + debug_report_bug(__FUNCTION__, __LINE__, 'Called without calling loadRefbackTable() before! userid=' . $userid); + } // END - if + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',count()=' . count($GLOBALS['refback_refid'][$userid])); - // Fix empty refid - if (!isset($GLOBALS['refback_refid'][$GLOBALS['refback_level']-1])) { - $GLOBALS['refback_refid'][$GLOBALS['refback_level']-1] = '0'; + // If no entries are there, skip this whole step + if (count($GLOBALS['refback_refid'][$userid]) == 0) { + // No entries found + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ABORTING...'); + return; } // END - if - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refback_level=' . $GLOBALS['refback_level'] . ',ref=' . $GLOBALS['refback_refid'][$GLOBALS['refback_level']-1] . ' - EXIT!'); + + // Prepare SQL + $SQL = 'INSERT INTO `{?_MYSQL_PREFIX?}_user_refs` (`userid`,`level`,`refid`) VALUES '; + + // Now walk through the array, first levels + foreach ($GLOBALS['refback_refid'][$userid] as $level=>$levelArray) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',count()=' . count($levelArray)); + // Next are the users + foreach ($levelArray as $refid) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . $refid); + // Query the user_refs table + list($count) = SQL_FETCHROW(SQL_QUERY_ESC('SELECT COUNT(`id`) AS `count` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid`=%s AND `level`=%s AND `refid`=%s LIMIT 1', + array( + $userid, + $level, + $refid + ), __FUNCTION__, __LINE__)); + + // Do we have no entry? + if ($count == 0) { + // Then add it to the SQL + $SQL .= '(' . $userid . ',' . $level . ',' . $refid . '),'; + } // END - if + } // END - foreach + } // END - foreach + + // Remove last comma from SQL + $SQL = substr($SQL, 0, -1); + + // And run it + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',SQL=' . $SQL); + SQL_QUERY($SQL, __FUNCTION__, __LINE__); + + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - EXIT!'); } // "Getter" for array for user refs in given level function getArrayFromRefbackUserRefs ($userid, $level) { - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ' - ENTERED!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ' - ENTERED!'); // Default is no refs and no nickname $refs = array(); @@ -324,6 +364,8 @@ function getArrayFromRefbackUserRefs ($userid, $level) { r.`points`, d.`status`, d.`joined`, + d.`mails_confirmed`, + d.`emails_received`, d.`refid` AS `level_refid` FROM `{?_MYSQL_PREFIX?}_user_refs` AS r @@ -342,6 +384,15 @@ ORDER BY if (!SQL_HASZERONUMS($result)) { // Fetch all entries while ($row = SQL_FETCHARRAY($result)) { + // Init click rate + $row['click_rate'] = '0'; + + // Does he have received some mails? + if ($row['emails_received'] > 0) { + // Calculate click rate + $row['click_rate'] = ($row['mails_confirmed'] / $row['emails_received'] * 100); + } // END - if + // Add row $refs[$row['id']] = $row; } // END - while @@ -351,13 +402,13 @@ ORDER BY SQL_FREERESULT($result); // Return result - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refs()=' . count($refs) . ' - EXIT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refs()=' . count($refs) . ' - EXIT!'); return $refs; } // "Getter" for refback entry function getArrayFromUserRefbackData ($id) { - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ' - ENTERED!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ' - ENTERED!'); // Default data is nothing $data = array(); @@ -378,13 +429,13 @@ function getArrayFromUserRefbackData ($id) { SQL_FREERESULT($result); // Return entry - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',data()=' . count($data) . ' - EXIT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',data()=' . count($data) . ' - EXIT!'); return $data; } // Update refback percents (but with some sanity-checks! function updateMemberRefbackPercents ($id, $percents) { - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',percents=' . $percents . ' - ENTERED!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',percents=' . $percents . ' - ENTERED!'); // Default status is failed $status['message'] = '{--MEMBER_REFBACK_ERROR_GENERAL--}'; @@ -443,7 +494,7 @@ function updateMemberRefbackPercents ($id, $percents) { $status['ok'] = true; // Return status array - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',percents=' . $percents . ' - EXIT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',percents=' . $percents . ' - EXIT!'); return $status; } diff --git a/inc/modules/member/what-refback.php b/inc/modules/member/what-refback.php index 1e431f4fb9..fb506673a8 100644 --- a/inc/modules/member/what-refback.php +++ b/inc/modules/member/what-refback.php @@ -118,10 +118,12 @@ if (!SQL_HASZERONUMS($result)) { foreach (getArrayFromRefbackUserRefs(getMemberId(), $content['level']) as $refRow) { // Not-deleted account is default $deleted = false; - if (is_null($refRow['status'])) $deleted = true; + if (is_null($refRow['status'])) { + $deleted = true; + } // END - if // Add/"translate" more content - // @TODO UNUSED: $refRow['status'] = translateUserStatus($refRow['status']); + $refRow['click_rate'] = translateComma($refRow['click_rate'], true, 1); $refRow['joined'] = generateDateTime($refRow['joined'], '3'); // Load row template diff --git a/inc/modules/member/what-reflist.php b/inc/modules/member/what-reflist.php index f8fb335492..f41db9da78 100644 --- a/inc/modules/member/what-reflist.php +++ b/inc/modules/member/what-reflist.php @@ -68,7 +68,7 @@ if (!SQL_HASZERONUMS($result)) { // Check for users ref in this level foreach (getUserReferalPoints(getMemberId(), $content['level']) as $refRow) { // Add/"translate" more content - $refRow['clickrate'] = translateComma($refRow['clickrate'], true, 1); + $refRow['click_rate'] = translateComma($refRow['click_rate'], true, 1); // Load row template $rows .= loadTemplate('member_ref_list_row', true, $refRow); diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 9ffbb0297c..2fd3d23d53 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -155,9 +155,9 @@ function addYouAreHereLink ($accessLevel, $FQFN, $return = false) { $OUT = $prefix . '' . getTitleFromMenu($accessLevel, $search, $type, $ADD) . ''; // Can we close the you-are-here navigation? - //* DEBUG: */ debugOutput(__LINE__.'*'.$type.'/'.getWhat().'*'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'type=' . $type . 'getWhat()=' . getWhat()); if (($type == 'what') || (($type == 'action') && ((!isWhatSet()) || (getWhat() == 'overview')))) { - //* DEBUG: */ debugOutput(__LINE__.'+'.$type.'+'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'type=' . $type); // Add closing div and br-tag $OUT .= ''; $GLOBALS['nav_depth'] = '0'; @@ -208,12 +208,12 @@ ORDER BY `sort` ASC", array($mode), __FUNCTION__, __LINE__); - //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . ':' . getWhat() . '*'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'main_cnt=' . $main_cnt . ',getWhat()=' . getWhat()); if (!SQL_HASZERONUMS($result_main)) { // There are menus available, so we simply display them... :) $GLOBALS['rows'] = ''; while ($content = SQL_FETCHARRAY($result_main)) { - //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . '/' . $content['action'] . ':' . getWhat() . '*'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'main_cnt=' . $main_cnt . ',action=' . $content['action'] . ',getWhat()=' . getWhat()); // Disable the block-mode enableBlockMode(false); @@ -251,7 +251,7 @@ ORDER BY $OUT = ''; // Full file name for checking menu - //* DEBUG: */ debugOutput(__LINE__ . ':!!!!' . $content['sub_what'] . '!!!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sub_what=' . $content['sub_what']); $inc = sprintf("inc/modules/%s/what-%s.php", $mode, $content['sub_what']); if (isIncludeReadable($inc)) { // Mark currently selected menu - open @@ -308,12 +308,12 @@ ORDER BY if (isFileReadable($INC)) { // Load include file if ((!isExtensionActive($content['action'])) || ($content['action'] == 'online')) $GLOBALS['rows'] .= loadTemplate('menu_what_begin', true, $mode); - //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . '/' . $content['action'] . '/' . getWhat().'*'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'main_cnt=' . $main_cnt . ',action=' . $content['action'] . ',getWhat()=' . getWhat()); loadInclude($INC); - //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . '/' . $content['action'] . '/' . getWhat() . '*'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'main_cnt=' . $main_cnt . ',action=' . $content['action'] . ',getWhat()=' . getWhat()); if ((!isExtensionActive($content['action'])) || ($content['action'] == 'online')) $GLOBALS['rows'] .= loadTemplate('menu_what_end', true, $mode); } - //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . '/' . $content['action'] . '/' . $content['sub_what'] . ':' . getWhat() . '*'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'main_cnt=' . $main_cnt . ',action=' . $content['action'] . ',getWhat()=' . getWhat()); } // Free result @@ -322,7 +322,7 @@ ORDER BY // Count one up $main_cnt++; - //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . ':' . getWhat() . '*'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'main_cnt=' . $main_cnt . ',getWhat()=' . getWhat()); if (SQL_NUMROWS($result_main) > $main_cnt) { // Add seperator $GLOBALS['rows'] .= loadTemplate('menu_seperator', true, $mode); @@ -357,7 +357,7 @@ ORDER BY ); // Load main template - //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . '/' . $content['action'] . '/' . $content['sub_what'] . ':' . getWhat() . '*'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'main_cnt=' . $main_cnt . ',getWhat()=' . getWhat()); loadTemplate('menu_table', false, $content); } // END - if } @@ -540,7 +540,7 @@ function isAdmin () { $adminId = getCurrentAdminId(); $passCookie = getAdminMd5(); } // END - if - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $adminId.'/'.$passCookie); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'mainId=' . $adminId . 'passCookie=' . $passCookie); // Abort if admin id is zero if ($adminId == '0') { @@ -674,7 +674,7 @@ function isMenuActionValid ($mode, $action, $what, $updateEntry=false) { $add = ''; if ((!isAdmin()) && ($mode != 'admin')) $add = " AND `locked`='N'"; - //* DEBUG: */ debugOutput(__LINE__ . ':' . $mode . '/' . $action . '/' . $what . '*'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'mode=' . $mode . ',action=' . $action . ',what=' . $what); if (($mode != 'admin') && ($updateEntry === true)) { // Update guest or member menu $sql = SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET `counter`=`counter`+1 WHERE `action`='%s' AND `what`='%s'".$add." LIMIT 1", @@ -724,10 +724,10 @@ function isMenuActionValid ($mode, $action, $what, $updateEntry=false) { // Get action value from mode (admin/guest/member) and what-value function getActionFromModuleWhat ($module, $what) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'module=' . $module . ',what=' . $what); // Init status $data['action'] = ''; - //* DEBUG: */ debugOutput(__LINE__ . '=' . $module . '/'.$what . '/' . getAction() . '='); if (!isExtensionInstalledAndNewer('sql_patches', '0.0.5')) { // sql_patches is missing so choose depending on mode if (isWhatSet()) { @@ -928,7 +928,7 @@ function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatemen // Init count/sum $data['res'] = '0'; - //* DEBUG: */ debugOutput($search.'/'.$tableName.'/'.$lookFor.'/'.$whereStatement.'/'.$add); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'search=' . $search . ',tableName=' . $tableName . ',lookFor=' . $lookFor . ',whereStatement=' . $whereStatement . ',add=' . $add); if ((empty($search)) && ($search != '0')) { // Count or sum whole table? if ($countRows === true) { @@ -948,7 +948,7 @@ function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatemen } } elseif (($countRows === true) || ($lookFor == 'userid')) { // Count rows - //* DEBUG: */ debugOutput('COUNT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'COUNT!'); $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'".$add, array( $lookFor, @@ -959,7 +959,7 @@ function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatemen ), __FUNCTION__, __LINE__); } else { // Add all rows - //* DEBUG: */ debugOutput('SUM!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SUM!'); $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'".$add, array( $lookFor, @@ -986,7 +986,7 @@ function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatemen } // Return value - //* DEBUG: */ debugOutput('ret=' . $data['res']); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'res=' . $data['res']); return $data['res']; } // Getter fro ref level percents @@ -1026,7 +1026,7 @@ function getReferalLevelPercents ($level) { // Initializes the referal system function initReferalSystem () { - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ' Referal system initialized!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ' Referal system initialized!'); $GLOBALS['ref_level'] = NULL; $GLOBALS['ref_system'] = true; } @@ -1040,24 +1040,14 @@ function initReferalSystem () { * points = ... xxx points * refid = inc/modules/guest/what-confirm.php need this * locked = Shall I pay it to normal (false) or locked (true) points ammount? - * paymentMethod = Deprecated parameter, the payment method */ -function addPointsThroughReferalSystem ($subject, $userid, $points, $refid = '0', $paymentMethod = 'INVALID') { - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',userid=' . $userid . ',points=' . $points . ',sendNotify=' . intval($sendNotify) . ',refid=' . $refid . ',paymentMethod=' . $paymentMethod . ' - ENTERED!'); +function addPointsThroughReferalSystem ($subject, $userid, $points, $refid = '0') { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',userid=' . $userid . ',points=' . $points . ',refid=' . $refid . ' - ENTERED!'); // By default nothing has been added $added = false; - // Convert mode to upper-case - $paymentMethod = strtoupper($paymentMethod); - - // Is it not invalid? - if ($paymentMethod != 'INVALID') { - // We are not using this anymore - debug_report_bug(__FUNCTION__, __LINE__, 'subject=' . $subject . ',paymentMethod=' . $paymentMethod . ' - deprecated parameter used.'); - } // END - if - // Determine payment method and notification - $paymentMethod = getPaymentMethodFromSubject($subject); + $paymentMethod = strtoupper(getPaymentMethodFromSubject($subject)); $sendNotify = isPaymentRecipientNotificationEnabled($subject); // When $userid = '0' add points to jackpot @@ -1067,7 +1057,7 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $refid = '0' } // END - if // Check user account - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',points=' . $points); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',points=' . $points); if (fetchUserData($userid)) { // Determine wether the user has some mails to click before he/she gets the points $locked = ifUserPointsLocked($userid); @@ -1080,19 +1070,19 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $refid = '0' // Get percents $per = getReferalLevelPercents($GLOBALS['ref_level']); - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',points='.$points.',depth='.$GLOBALS['ref_level'].',per='.$per.',mode='.$paymentMethod); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',points='.$points.',depth='.$GLOBALS['ref_level'].',per='.$per.',mode='.$paymentMethod); // Some percents found? if ($per > 0) { // Calculate new points $ref_points = $points * $per / 100; - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',points='.$points.',per='.$per.',depth='.$GLOBALS['ref_level'].',ref_points='.$ref_points); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',points='.$points.',per='.$per.',depth='.$GLOBALS['ref_level'].',ref_points='.$ref_points); // Pay refback here if level > 0 and in ref-mode if ((isExtensionActive('refback')) && ($GLOBALS['ref_level'] > 0) && ($per < 100) && ($paymentMethod == 'REFERAL') && (isset($GLOBALS['cache_array']['add_userid'][$userid]))) { - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',data='.$GLOBALS['cache_array']['add_userid'][$userid].',ref_points='.$ref_points.',depth='.$GLOBALS['ref_level'].' - BEFORE!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',data='.$GLOBALS['cache_array']['add_userid'][$userid].',ref_points='.$ref_points.',depth='.$GLOBALS['ref_level'].' - BEFORE!'); $ref_points = addRefbackPoints($GLOBALS['cache_array']['add_userid'][$userid], $userid, $points, $ref_points); - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',data='.$GLOBALS['cache_array']['add_userid'][$userid].',ref_points='.$ref_points.',depth='.$GLOBALS['ref_level'].' - AFTER!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',data='.$GLOBALS['cache_array']['add_userid'][$userid].',ref_points='.$ref_points.',depth='.$GLOBALS['ref_level'].' - AFTER!'); } // END - if // Update points... @@ -1116,7 +1106,7 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $refid = '0' bigintval($GLOBALS['ref_level']) ), __FUNCTION__, __LINE__); } - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'pointsColumn='.$pointsColumn.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$paymentMethod.' - UPDATE! ('.SQL_AFFECTEDROWS().')'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'pointsColumn='.$pointsColumn.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$paymentMethod.' - UPDATE! ('.SQL_AFFECTEDROWS().')'); // No entry updated? if (SQL_HASZEROAFFECTED()) { @@ -1128,12 +1118,12 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $refid = '0' makeZeroToNull($GLOBALS['ref_level']), $ref_points ), __FUNCTION__, __LINE__); - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'data='.$pointsColumn.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$paymentMethod.' - INSERTED! ('.SQL_AFFECTEDROWS().')'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'data='.$pointsColumn.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$paymentMethod.' - INSERTED! ('.SQL_AFFECTEDROWS().')'); } // END - if // Check affected rows $added = SQL_AFFECTEDROWS(); - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added='.intval($added)); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added='.intval($added)); // Prepare data for the filter $filterData = array( @@ -1155,7 +1145,7 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $refid = '0' // Extract $added $added = $filterData['added']; - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added='.intval($added)); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added='.intval($added)); // Points updated, maybe I shall send him an email? if (($sendNotify === true) && (isValidUserId(getUserData('refid'))) && ($locked === false)) { @@ -1192,82 +1182,83 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $refid = '0' // Increase referal level $GLOBALS['ref_level']++; - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ' Referal level increased, ref_level=' . $GLOBALS['ref_level']); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ' Referal level increased, ref_level=' . $GLOBALS['ref_level']); // Maybe there's another ref? if ((isValidUserId(getUserData('refid'))) && ($points > 0) && (getUserData('refid') != $userid) && ($paymentMethod == 'REFERAL')) { // Then let's credit him here... - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . getUserData('refid') . ',points=' . $points . ',ref_points=' . $ref_points . ' - ADVANCE!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . getUserData('refid') . ',points=' . $points . ',ref_points=' . $ref_points . ' - ADVANCE!'); $added = ($added && addPointsThroughReferalSystem(sprintf("%s_ref:%s", $subject, $GLOBALS['ref_level']), getUserData('refid'), $points, getUserData('refid'))); } // END - if } // END - if } // END - if - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',userid=' . $userid . ',points=' . $points . ',sendNotify=' . intval($sendNotify) . ',refid=' . $refid . ',paymentMethod=' . $paymentMethod . ' - EXIT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',userid=' . $userid . ',points=' . $points . ',sendNotify=' . intval($sendNotify) . ',refid=' . $refid . ',paymentMethod=' . $paymentMethod . ' - EXIT!'); return $added; } // Updates the referal counter function updateReferalCounter ($userid) { - // Make it sure referal level zero (member him-/herself) is at least selected + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!'); + // Init referal id + $ref = NULL; + + // Check for his referal + if (fetchUserData($userid)) { + // Get it + $ref = getUserData('refid'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . makeZeroToNull($ref) . ' - FETCHED!'); + } // END - if + + // Init entries if (empty($GLOBALS['cache_array']['ref_level'][$userid])) { $GLOBALS['cache_array']['ref_level'][$userid] = NULL; } // END - if - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',level='.$GLOBALS['cache_array']['ref_level'][$userid]); + if (empty($GLOBALS['cache_array']['ref_level'][$ref])) { + $GLOBALS['cache_array']['ref_level'][$ref] = NULL; + } // END - if + + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . makeZeroToNull($ref)); - // Update counter - if (!is_null($GLOBALS['cache_array']['ref_level'][$userid])) { - // Level is > 0 + // When he has a referal... + if (($ref > 0) && ($ref != $userid)) { + // Move to next referal level and count his counter one up + $GLOBALS['cache_array']['ref_level'][$ref] = $GLOBALS['cache_array']['ref_level'][$userid] + 1; + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref(' . $ref . ')=' . $GLOBALS['cache_array']['ref_level'][$ref] . ' - ADVANCED!'); + + // Update counter SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refsystem` SET `counter`=`counter`+1 WHERE `userid`=%s AND `level`=%s LIMIT 1", array( - bigintval($userid), - bigintval($GLOBALS['cache_array']['ref_level'][$userid]) + bigintval($ref), + bigintval($GLOBALS['cache_array']['ref_level'][$ref]) ), __FUNCTION__, __LINE__); // When no entry was updated then we have to create it here - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'updated=' . SQL_AFFECTEDROWS()); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ref=' . $ref . ',level=' . $GLOBALS['cache_array']['ref_level'][$ref] . ',updated=' . SQL_AFFECTEDROWS()); if (SQL_HASZEROAFFECTED()) { // First count! SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_refsystem` (`userid`, `level`, `counter`) VALUES (%s,%s,1)", array( - bigintval($userid), - makeZeroToNull($GLOBALS['cache_array']['ref_level'][$userid]) + bigintval($ref), + makeZeroToNull($GLOBALS['cache_array']['ref_level'][$ref]) ), __FUNCTION__, __LINE__); - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',SQL_AFFECTEDROWS()=' . SQL_AFFECTEDROWS()); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ref=' . $ref . ',level=' . $GLOBALS['cache_array']['ref_level'][$ref] . ',SQL_AFFECTEDROWS()=' . SQL_AFFECTEDROWS()); } // END - if - } // END - if - // Init referal id - $ref = '0'; - - // Check for his referal - if (fetchUserData($userid)) { - // Get it - $ref = getUserData('refid'); - } // END - if - - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.$userid.',ref='.$ref); - - // When he has a referal... - if (($ref > 0) && ($ref != $userid)) { - // Move to next referal level and count his counter one up! - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ref='.$ref.' - ADVANCE!'); - $GLOBALS['cache_array']['ref_level'][$userid]++; + // Advance to next level updateReferalCounter($ref); } elseif ((($ref == $userid) || ($ref == '0')) && (isExtensionInstalledAndNewer('cache', '0.1.2'))) { // Remove cache here - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ref='.$ref.' - CACHE!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ref=' . makeZeroToNull($ref) . ' - CACHE!'); rebuildCache('refsystem', 'refsystem'); } - // "Walk" back here - $GLOBALS['cache_array']['ref_level'][$userid]--; - // Handle refback here if extension is installed // @TODO Rewrite this to a filter if (isExtensionActive('refback')) { updateRefbackTable($userid); } // END - if + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . makeZeroToNull($ref) . ',level=' . makeZeroToNull($GLOBALS['cache_array']['ref_level'][$ref]) . ' - EXIT!'); } // Sends out mail to all administrators. This function is no longer obsolete @@ -1666,7 +1657,7 @@ function getWhatFromModule ($modCheck) { // Default is empty $what = ''; - //* DEBUG: */ debugOutput(__LINE__.'!'.$modCheck.'!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'modCheck=' . $modCheck); switch ($modCheck) { case 'admin': $what = 'overview'; @@ -1697,7 +1688,10 @@ function getWhatFromModule ($modCheck) { function subtractPoints ($subject, $userid, $points) { // Add points to used points SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `used_points`=`used_points`+%s WHERE `userid`=%s LIMIT 1", - array($points, bigintval($userid)), __FUNCTION__, __LINE__); + array( + $points, + bigintval($userid) + ), __FUNCTION__, __LINE__); // Prepare filter data $filterData = array( @@ -1709,7 +1703,7 @@ function subtractPoints ($subject, $userid, $points) { ); // Insert booking record - $filterData = runFilterChain('sub_points', $filterData); + $filterData = runFilterChain('post_sub_points', $filterData); // Return result return $filterData['added']; @@ -1953,13 +1947,13 @@ ORDER BY // Get unconfirmed mails $row['unconfirmed'] = countSumTotalData($row['refid'], 'user_links', 'id', 'userid', true); - // Init clickrate with zero - $row['clickrate'] = '0'; + // Init click rate with zero + $row['click_rate'] = '0'; // Is at least one mail received? if ($row['emails_received'] > 0) { - // Calculate clickrate - $row['clickrate'] = ($row['mails_confirmed'] / $row['emails_received'] * 100); + // Calculate click rate + $row['click_rate'] = ($row['mails_confirmed'] / $row['emails_received'] * 100); } // END - if // Activity is 'active' by default because if autopurge is not installed diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 4384212523..97fe0ab20a 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -1061,7 +1061,7 @@ function isDebuggingTemplateCache () { // Wrapper for fetchUserData() and getUserData() calls function getFetchedUserData ($keyColumn, $userid, $valueColumn) { - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ' - ENTERED!'); // Is it cached? if (!isset($GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn])) { // Default is 'guest' @@ -1078,7 +1078,7 @@ function getFetchedUserData ($keyColumn, $userid, $valueColumn) { } // END - if // Return it - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyColumn=' . $keyColumn . ',userid=' . $userid . ',valueColumn=' . $valueColumn . ',value=' . $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn] . ' - EXIT!'); return $GLOBALS[__FUNCTION__][$userid][$keyColumn][$valueColumn]; } @@ -2480,7 +2480,7 @@ function generateWrappedUserEmailLink ($email) { // Wrapper to check if user points are locked function ifUserPointsLocked ($userid) { - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ENTERED!'); // Do we have cache? if (!isset($GLOBALS[__FUNCTION__][$userid])) { // Determine it @@ -2488,7 +2488,7 @@ function ifUserPointsLocked ($userid) { } // END - if // Return cache - /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',locked=' . intval($GLOBALS[__FUNCTION__][$userid]) . ' - EXIT!'); return $GLOBALS[__FUNCTION__][$userid]; } diff --git a/install/tables.sql b/install/tables.sql index 401e47f7f5..1756758372 100644 --- a/install/tables.sql +++ b/install/tables.sql @@ -1,6 +1,6 @@ DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_admin_menu`; CREATE TABLE `{?_MYSQL_PREFIX?}_admin_menu` ( - `id` BIGINT(22) NOT NULL AUTO_INCREMENT, + `id` BIGINT(20) NOT NULL AUTO_INCREMENT, `action` VARCHAR(255) NOT NULL DEFAULT '', `what` VARCHAR(255) NULL DEFAULT NULL, `title` VARCHAR(50) NOT NULL DEFAULT '', @@ -21,7 +21,7 @@ CREATE TABLE `{?_MYSQL_PREFIX?}_admins` ( DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_cats`; CREATE TABLE `{?_MYSQL_PREFIX?}_cats` ( - `id` BIGINT(22) NOT NULL AUTO_INCREMENT, + `id` BIGINT(20) NOT NULL AUTO_INCREMENT, `cat` VARCHAR(255) NOT NULL DEFAULT '', `visible` ENUM('Y','N') NOT NULL DEFAULT 'Y', `sort` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, @@ -67,7 +67,7 @@ CREATE TABLE `{?_MYSQL_PREFIX?}_config` ( DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_guest_menu`; CREATE TABLE `{?_MYSQL_PREFIX?}_guest_menu` ( - `id` BIGINT(22) NOT NULL AUTO_INCREMENT, + `id` BIGINT(20) NOT NULL AUTO_INCREMENT, `action` VARCHAR(255) NOT NULL DEFAULT '', `what` VARCHAR(255) NULL DEFAULT NULL, `title` VARCHAR(50) NOT NULL DEFAULT '', @@ -80,7 +80,7 @@ CREATE TABLE `{?_MYSQL_PREFIX?}_guest_menu` ( DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_max_receive`; CREATE TABLE `{?_MYSQL_PREFIX?}_max_receive` ( - `id` BIGINT(22) NOT NULL AUTO_INCREMENT, + `id` BIGINT(20) NOT NULL AUTO_INCREMENT, `value` MEDIUMINT(9) NOT NULL DEFAULT 0, `comment` VARCHAR(255) NOT NULL DEFAULT '', PRIMARY KEY (`id`) @@ -88,7 +88,7 @@ CREATE TABLE `{?_MYSQL_PREFIX?}_max_receive` ( DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_member_menu`; CREATE TABLE `{?_MYSQL_PREFIX?}_member_menu` ( - `id` BIGINT(22) NOT NULL AUTO_INCREMENT, + `id` BIGINT(20) NOT NULL AUTO_INCREMENT, `action` VARCHAR(255) NOT NULL DEFAULT '', `what` VARCHAR(255) NULL DEFAULT NULL, `title` VARCHAR(50) NOT NULL DEFAULT '', @@ -144,11 +144,11 @@ CREATE TABLE `{?_MYSQL_PREFIX?}_pool` ( DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_refbanner`; CREATE TABLE `{?_MYSQL_PREFIX?}_refbanner` ( - `id` BIGINT(22) NOT NULL AUTO_INCREMENT, + `id` BIGINT(20) NOT NULL AUTO_INCREMENT, `url` TEXT NOT NULL, `alternate` TEXT NOT NULL, `visible` ENUM('Y','N') NOT NULL DEFAULT 'Y', - `counter` BIGINT(22) NOT NULL DEFAULT 0, + `counter` BIGINT(20) NOT NULL DEFAULT 0, `clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`id`) ) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci; @@ -163,7 +163,7 @@ CREATE TABLE `{?_MYSQL_PREFIX?}_refdepths` ( DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_refsystem`; CREATE TABLE `{?_MYSQL_PREFIX?}_refsystem` ( - `id` BIGINT(22) NOT NULL AUTO_INCREMENT, + `id` BIGINT(20) NOT NULL AUTO_INCREMENT, `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, `level` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0, `counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, diff --git a/templates/de/html/member/member_ref_list_level.tpl b/templates/de/html/member/member_ref_list_level.tpl index 6062fc8bc4..00d94b74e8 100644 --- a/templates/de/html/member/member_ref_list_level.tpl +++ b/templates/de/html/member/member_ref_list_level.tpl @@ -20,7 +20,7 @@ {--UNCONFIRMED_LINKS--} - {--MEMBER_EMAIL_PERCENT--} + {--MEMBER_CLICK_RATE--} {--MEMBER_REFLIST_ACTIVITY--} diff --git a/templates/de/html/member/member_ref_list_row.tpl b/templates/de/html/member/member_ref_list_row.tpl index 44076c0f0b..15a722a3cc 100644 --- a/templates/de/html/member/member_ref_list_row.tpl +++ b/templates/de/html/member/member_ref_list_row.tpl @@ -12,7 +12,7 @@ {%pipe,translateComma=$content[unconfirmed]%} - $content[clickrate]% + $content[click_rate]% $content[activity] diff --git a/templates/de/html/member/member_refback_list_level.tpl b/templates/de/html/member/member_refback_list_level.tpl index 604e7181ca..f27edbe28d 100644 --- a/templates/de/html/member/member_refback_list_level.tpl +++ b/templates/de/html/member/member_refback_list_level.tpl @@ -1,7 +1,7 @@
- @@ -18,6 +18,9 @@ + @@ -27,7 +30,7 @@ $content[rows] - diff --git a/templates/de/html/member/member_refback_list_row.tpl b/templates/de/html/member/member_refback_list_row.tpl index 78963e44b3..1a9a177cb7 100644 --- a/templates/de/html/member/member_refback_list_row.tpl +++ b/templates/de/html/member/member_refback_list_row.tpl @@ -11,6 +11,9 @@ + diff --git a/templates/de/html/member/member_refback_list_row_deleted.tpl b/templates/de/html/member/member_refback_list_row_deleted.tpl index c10ce3e682..4e7198fddf 100644 --- a/templates/de/html/member/member_refback_list_row_deleted.tpl +++ b/templates/de/html/member/member_refback_list_row_deleted.tpl @@ -11,6 +11,9 @@ + diff --git a/templates/de/html/member/member_stats_row.tpl b/templates/de/html/member/member_stats_row.tpl index 671dcd19b3..27aa7e9c1a 100644 --- a/templates/de/html/member/member_stats_row.tpl +++ b/templates/de/html/member/member_stats_row.tpl @@ -38,7 +38,7 @@ {%pipe,translateComma=$content[clicks]%} -- 2.39.5
+ {--MEMBER_REFBACK_LIST_TITLE_1--}$content[level]{--MEMBER_REFBACK_LIST_TITLE_2--}{%pipe,translateComma=$content[percents]%}{--MEMBER_REFBACK_LIST_TITLE_3--}
{--MEMBER_REFBACK_POINTS--} + {--MEMBER_CLICK_RATE--} + {--MEMBER_JOINED--}
{%pipe,translateComma=$content[points]%} {?POINTS?} + $content[click_rate]% + $content[joined] {%pipe,translateComma=$content[points]%} {?POINTS?} + $content[click_rate]% + $content[joined] - {--MEMBER_EMAIL_PERCENT--}:
+ {--MEMBER_CLICK_RATE--}:
{%pipe,translateComma=$content[percents]%}%