From 387e32f3c72f5efad7dfd67e471de639d423ebb6 Mon Sep 17 00:00:00 2001 From: quix0r Date: Fri, 15 Jul 2011 01:21:46 +0000 Subject: [PATCH] Refback and referal points hopefully fixed: - All userids are now initialized NULL and not '0' - Template added for deleted bonus mails - Handling of refback and referal points now fully fixed (I hope so) - Several debug lines extended with more debugging data - TODOs.txt updated --- .gitattributes | 1 + DOCS/TODOs.txt | 17 ++-- inc/extensions/ext-surfbar.php | 2 +- inc/filter-functions.php | 1 + inc/filter/mediadata_filter.php | 4 +- inc/filter/online_filter.php | 2 +- inc/filters.php | 6 +- inc/functions.php | 2 +- inc/language/bonus_de.php | 2 + inc/language/mailid_de.php | 1 + inc/libs/doubler_functions.php | 6 +- inc/libs/mediadata_functions.php | 20 ++--- inc/libs/refback_functions.php | 88 +++++++++++-------- inc/libs/surfbar_functions.php | 8 +- inc/libs/user_functions.php | 6 +- inc/modules/guest/what-login.php | 4 +- inc/mysql-manager.php | 4 +- inc/purge/purge-general.php | 3 +- inc/referal-functions.php | 63 +++++++------ inc/template-functions.php | 2 +- inc/wrapper-functions.php | 5 +- mailid_top.php | 27 ++++-- show_bonus.php | 3 +- .../de/html/mailid/mailid_points_failed2.tpl | 14 +++ templates/de/html/show_bonus_msg.tpl | 29 ++++-- theme/default/css/mailid.css | 2 +- 26 files changed, 193 insertions(+), 129 deletions(-) create mode 100644 templates/de/html/mailid/mailid_points_failed2.tpl diff --git a/.gitattributes b/.gitattributes index 850311d11a..576fc54534 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1635,6 +1635,7 @@ templates/de/html/mailid/mailid_frames.tpl svneol=native#text/plain templates/de/html/mailid/mailid_points_done.tpl svneol=native#text/plain templates/de/html/mailid/mailid_points_done2.tpl svneol=native#text/plain templates/de/html/mailid/mailid_points_failed.tpl svneol=native#text/plain +templates/de/html/mailid/mailid_points_failed2.tpl svneol=native#text/plain templates/de/html/mailid/mailid_points_locked.tpl svneol=native#text/plain templates/de/html/mailid/mailid_points_locked2.tpl svneol=native#text/plain templates/de/html/mailid/mailid_timer.tpl svneol=native#text/plain diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 755bab4c48..cf8ac019ab 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -66,7 +66,7 @@ ./inc/libs/admins_functions.php:474: // @TODO This can be, somehow, rewritten ./inc/libs/bonus_functions.php:194: // @TODO Move this HTML to a template ./inc/libs/doubler_functions.php:44:// @TODO Lame description -./inc/libs/doubler_functions.php:91: // @TODO Can't this be moved into EL? +./inc/libs/doubler_functions.php:93: // @TODO Can't this be moved into EL? ./inc/libs/mailid_functions.php:47: // @TODO Rewrite this to a dynamic include or so ./inc/libs/rallye_functions.php:439: // @TODO Deprecated variable and global statement, please try to rewrite this ./inc/libs/rallye_functions.php:704:// @TODO This function does not load min_users, min_prices, please encapsulate loading rallye data with e.g. getRallyeDataFromId() @@ -76,8 +76,8 @@ ./inc/libs/register_functions.php:290: // @TODO Rewrite these all to a single filter ./inc/libs/sponsor_functions.php:159: // @TODO Rewrite this to API function ./inc/libs/sponsor_functions.php:430: // @TODO Rewrite this to API function -./inc/libs/surfbar_functions.php:1621: // @TODO This can be somehow rewritten -./inc/libs/surfbar_functions.php:729:// @TODO Can't we use our new expression language instead of this ugly code? +./inc/libs/surfbar_functions.php:1623: // @TODO This can be somehow rewritten +./inc/libs/surfbar_functions.php:731:// @TODO Can't we use our new expression language instead of this ugly code? ./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? @@ -169,11 +169,11 @@ ./inc/modules/member/what-unconfirmed.php:227: // @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:1249: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() -./inc/mysql-manager.php:1313: // @TODO Rewrite these lines to a filter -./inc/mysql-manager.php:1337: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1596: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1640:// @TODO Fix inconsistency between last_module and getWhat() +./inc/mysql-manager.php:1251: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() +./inc/mysql-manager.php:1315: // @TODO Rewrite these lines to a filter +./inc/mysql-manager.php:1339: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1598: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1642:// @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 @@ -201,7 +201,6 @@ ./mailid_top.php:192: // @TODO Rewrite this to a filter ./mailid_top.php:227: // @TODO Rewrite these blocks to filter ./network-check.php:54:// @TODO Add processing of request here -./show_bonus.php:105: // @TODO No more needed? $content['points'] = translateComma($content['points']); ./view.php:68: // @TODO No banner found, output some default banner ./templates/de/html/admin/admin_add_country.tpl:23: ./templates/de/html/admin/admin_admins_contct_form.tpl:4: diff --git a/inc/extensions/ext-surfbar.php b/inc/extensions/ext-surfbar.php index 3c1902ebff..199fcef0cd 100644 --- a/inc/extensions/ext-surfbar.php +++ b/inc/extensions/ext-surfbar.php @@ -55,7 +55,7 @@ switch (getExtensionMode()) { addDropTableSql('surfbar_urls'); addCreateTableSql('surfbar_urls', " `url_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, -`url_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, +`url_userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL, `url` VARCHAR(255) NOT NULL DEFAULT '', `url_last_salt` VARCHAR(255) NOT NULL DEFAULT '', `url_views_total` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, diff --git a/inc/filter-functions.php b/inc/filter-functions.php index d4d890b7c5..615bdba025 100644 --- a/inc/filter-functions.php +++ b/inc/filter-functions.php @@ -275,6 +275,7 @@ function runFilterChain ($filterName, $filterData = null) { } // END - if // Default return value + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'filterName=' . $filterName . ',count()=' . count($GLOBALS['cache_array']['filter']['chains'][$filterName])); $returnValue = $filterData; // Then run all filters diff --git a/inc/filter/mediadata_filter.php b/inc/filter/mediadata_filter.php index 4b28c25e3a..3194c66b01 100644 --- a/inc/filter/mediadata_filter.php +++ b/inc/filter/mediadata_filter.php @@ -43,11 +43,11 @@ if (!defined('__SECURITY')) { // Filter for updating media data function FILTER_UPDATE_MEDIADATA_ENTRY ($filterData) { // Execute the filter function - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added[' . gettype($filterData['added']) . ']=' . intval($filterData['added']) . ' - Called!'); $filterData['added'] = ($filterData['added'] === true && updateMediadataEntry(array('total_points'), $filterData['mode'], $filterData['points'])); // Return data - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added[' . gettype($filterData['added']) . ']=' . intval($filterData['added']) . ' - Done!'); return $filterData; } diff --git a/inc/filter/online_filter.php b/inc/filter/online_filter.php index e438cc3651..9c4855ab18 100644 --- a/inc/filter/online_filter.php +++ b/inc/filter/online_filter.php @@ -56,7 +56,7 @@ function FILTER_UPDATE_ONLINE_LIST ($filterData) { } // END - if // Initialize variables - $userid = '0'; + $userid = NULL; $isMember = convertBooleanToYesNo(isMember()); $isAdmin = convertBooleanToYesNo(isAdmin()); $action = getActionFromModuleWhat(getModule(), getWhat()); diff --git a/inc/filters.php b/inc/filters.php index b0ed40a050..3cd5180845 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -971,9 +971,11 @@ function FILTER_FLUSH_TEMPLATE_CACHE () { } // Filter for loading user data -function FILTER_FETCH_USER_DATA ($userid = 0) { +function FILTER_FETCH_USER_DATA ($userid = NULL) { // Is the userid not set? Then use member id - if (($userid == '0') || (is_null($userid))) $userid = getMemberId(); + if (!isValidUserId($userid)) { + $userid = getMemberId(); + } // END - if // Get user data if (!fetchUserData($userid)) { diff --git a/inc/functions.php b/inc/functions.php index 2dddd0d30f..a14ad08390 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1406,7 +1406,7 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0 } // Send notification to admin -function sendAdminNotification ($subject, $templateName, $content = array(), $userid = '0') { +function sendAdminNotification ($subject, $templateName, $content = array(), $userid = NULL) { if ((isExtensionInstalledAndNewer('admins', '0.4.1')) && (function_exists('sendAdminsEmails'))) { // Send new way /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'admins=Y,subject=' . $subject . ',templateName=' . $templateName); diff --git a/inc/language/bonus_de.php b/inc/language/bonus_de.php index 27fcdab34e..d5de40d6bc 100644 --- a/inc/language/bonus_de.php +++ b/inc/language/bonus_de.php @@ -122,6 +122,8 @@ addMessages(array( 'ADMIN_NO_NOTIFICATIONS' => "Keine Benachrichtigungen gefunden.", 'ADMIN_LINKS_BONUS_MAIL_TITLE' => "Bonus-Mail %s:", 'ADMIN_EDIT_BONUS_EMAIL_TITLE' => "Daten der Bonus-Mail Nr. %s ändern", + 'MONTHLY_BONUS_RALLYE_GOOD_LUCK' => "Wir wünschen allen Mitgliedern viel Glück bei der monatlichen Aktiv-Rallye!", + 'MONTHLY_BONUS_RALLYE_RANKS_NOTE' => "Es können nur die ersten {?bonus_ranks?} die Aktiv-Rallye gewinnen. Der Rechtsweg ist ausgeschlossen.", // Switches 'ADMIN_CONFIG_BONUS_RALLYE_IS_ACTIVE' => "Ist die Aktiv-Rallye aktiv?", diff --git a/inc/language/mailid_de.php b/inc/language/mailid_de.php index 9e4dd19166..ebbf09cb85 100644 --- a/inc/language/mailid_de.php +++ b/inc/language/mailid_de.php @@ -47,6 +47,7 @@ addMessages(array( 'MEMBER_THANX_POINTS_ADDED' => "Vielen Dank für die Bestätigung der Mail. Die {%%pipe,translateComma=%s%%} {?POINTS?} wurden Ihnen gerade gutgeschrieben.", 'MEMBER_THANX_POINTS_LOCKED' => "Vielen Dank für die Bestätigung der Mail. Die {%%pipe,translateComma=%s%%} {?POINTS?} werden Ihnen bald gutgeschrieben.", 'MEMBER_POINTS_NOT_ADDED' => "Falscher Bestätigungscode eingegeben! Die {%%pipe,translateComma=%s%%} {?POINTS?} wurden dem Versender wieder gutgeschrieben.", + 'MEMBER_POINTS_NOT_ADDED2' =>"Falscher Bestätigungscode eingegeben! Die {%%pipe,translateComma=%s%%} {?POINTS?} wurden Ihnen nicht gutgeschrieben.", 'MEMBER_ENTER_CODE' => "Code eingeben", 'MEMBER_TIME_COUNTER_1' => "Gutschrift der {?POINTS?} erfolgt in ", 'MEMBER_TIME_COUNTER_2' => " ...", diff --git a/inc/libs/doubler_functions.php b/inc/libs/doubler_functions.php index 94148e21bc..f5f7a23353 100644 --- a/inc/libs/doubler_functions.php +++ b/inc/libs/doubler_functions.php @@ -42,7 +42,7 @@ if (!defined('__SECURITY')) { // Generates a HTML table based on given data // @TODO Lame description -function generateDoublerTable ($userid = '0', $done = 'N', $ref = 'N', $sort = 'ASC') { +function generateDoublerTable ($userid = NULL, $done = 'N', $ref = 'N', $sort = 'ASC') { $add = ''; $DT_MODE = '0'; if (isValidUserId($userid)) { // Load entries only from a single user @@ -72,7 +72,9 @@ function generateDoublerTable ($userid = '0', $done = 'N', $ref = 'N', $sort = ' FROM `{?_MYSQL_PREFIX?}_doubler` WHERE - `completed`='%s' AND `is_ref`='%s'" . $add . " + `completed`='%s' AND + `is_ref`='%s' + " . $add . " ORDER BY `timemark` %s LIMIT %s", diff --git a/inc/libs/mediadata_functions.php b/inc/libs/mediadata_functions.php index 60b713ae1d..546d44a18c 100644 --- a/inc/libs/mediadata_functions.php +++ b/inc/libs/mediadata_functions.php @@ -42,8 +42,9 @@ if (!defined('__SECURITY')) { // Update an entry function updateMediadataEntry ($keys_array, $mode, $value) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keys_array[]=' . gettype($keys_array) . ',mode=' . $mode . ',value=' . $value . ' - ENTERED!'); // Default is nothing added/updated - $added = null; + $added = false; // Do we have entries? if (is_array($keys_array) && ($value > 0)) { @@ -55,8 +56,9 @@ function updateMediadataEntry ($keys_array, $mode, $value) { FROM `{?_MYSQL_PREFIX?}_mediadata` WHERE - `media_key` = '%s' + `media_key`='%s' LIMIT 1", array($key), __FUNCTION__, __LINE__); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',SQL_NUMROWS()=' . SQL_NUMROWS($result_media)); if (SQL_NUMROWS($result_media) == 0) { // Not found so we create it (mode will be ignored here!) SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_mediadata` (`media_key`, `media_value`) VALUES ('%s', '%s')", @@ -79,16 +81,9 @@ LIMIT 1", array($key), __FUNCTION__, __LINE__); } } - // Check affected rows - if (is_null($added)) { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added='.intval($added)); - $added = (!SQL_HASZEROAFFECTED()); - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added='.intval($added)); - } else { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added='.intval($added)); - $added = ($added && (!SQL_HASZEROAFFECTED())); - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added='.intval($added)); - } + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added=' . intval($added)); + $added = (!SQL_HASZEROAFFECTED()); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added=' . intval($added)); } // END - foreach } // END - if @@ -99,6 +94,7 @@ LIMIT 1", array($key), __FUNCTION__, __LINE__); } // END - if // Return result + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keys_array[]=' . gettype($keys_array) . ',mode=' . $mode . ',value=' . $value . ',added=' . intval($added) . ' - EXIT!'); return $added; } diff --git a/inc/libs/refback_functions.php b/inc/libs/refback_functions.php index 59336045ee..5938bd79bf 100644 --- a/inc/libs/refback_functions.php +++ b/inc/libs/refback_functions.php @@ -55,38 +55,42 @@ function addRefbackPoints ($userid, $ref, $points, $ref_points) { // "Walk" through all level while ($content = SQL_FETCHARRAY($result_refs)) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'level=' . $content['level'] . ',percents=' . $content['percents'] . ' - LOOP START!'); // Reset ref depths initReferalSystem(); - // "Walk" through all refids - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',level=' . $content['level'] . ',percents=' . $content['refback_percents'] . ',points=' . $points . ' - LOOP START!'); - foreach (getArrayFromRefbackLevel($userid, $content['level']) as $refid) { - // Skip level zero or if both are the same - if ($userid == $refid) { - continue; - } // END - if + // Init array + $refids = getArrayFromRefbackLevel($userid, $content['level']); - // Get refback percents - $percents = getRefbackPercents($userid, $refid); - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',refid=' . $refid . ',points=' . $points . ',percents=' . $percents); + // "Walk" through all refids + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ',level=' . $content['level'] . ',percents=' . $content['percents'] . ',points=' . $points . ' - LOOP START!'); + foreach ($refids as $refid) { + /* + * Get refback percents, do not swap $refid and $userid by the next + * call. If you do so, you will check the wrong direction, $userid + * is always bigger than $refid. + */ + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . makeNullToZero($refid) . ' - CALLING getRefbackPercents()'); + $content['refback_percents'] = getRefbackPercents($refid, $userid); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . makeNullToZero($refid) . ',refback_percents=' . $content['refback_percents']); // Some percents given? - if ($percents > 0) { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'points=' . $points . ',refback_percents=' . $content['refback_percents'] . ',percents=' . $percents . ',level=' . $content['level']); + if ($content['refback_percents'] > 0) { // Calculate points for refback - $refback = $points * ($content['refback_percents'] / 100) * ($percents / 100); + $refbackPoints = $points * ($content['percents'] / 100) * ($content['refback_percents'] / 100); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'points=' . $points . ',percents=' . $content['percents'] . ',refback_percents=' . $content['refback_percents'] . ',level=' . $content['level'] . ',refback_points=' . $refbackPoints); // Update refback table ('refid' and 'userid' must be exchanged!) - SQL_QUERY_ESC("UPDATE + SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_user_refs` SET `refback_points`=`refback_points`+%s WHERE `userid`=%s AND `refid`=%s -LIMIT 1", +LIMIT 1', array( - $refback, + $refbackPoints, $refid, $userid ), __FUNCTION__, __LINE__); @@ -94,17 +98,18 @@ LIMIT 1", // Something must have been updated if (SQL_HASZEROAFFECTED()) { // Please report this bug - debug_report_bug(__FUNCTION__, __LINE__, 'Nothing has been updated in user_refs,userid=' . $userid . ',refid=' . $refid . ',refback=' . $refback); + debug_report_bug(__FUNCTION__, __LINE__, 'Nothing has been updated in user_refs,userid=' . $userid . ',refid=' . makeNullToZero($refid) . ',refbackPoints=' . $refbackPoints); } // END - if // Add points again, but only directly - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refback=' . $refback . ',userid=' . $userid . ',ref=' . $ref . ',refid=' . $refid . ' - UPDATE! (' . SQL_AFFECTEDROWS() . ')'); - addPointsThroughReferalSystem(sprintf("refback:%s", $refid), $userid, $refback); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refbackPoints=' . $refbackPoints . ',userid=' . $userid . ',ref=' . $ref . ',refid=' . makeNullToZero($refid) . ' - REFBACK-UPDATE! (' . SQL_AFFECTEDROWS() . ')'); + addPointsThroughReferalSystem(sprintf("refback:%s", $refid), $userid, $refbackPoints); // Reduce points if refid is found + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . $refid . ',ref=' . $ref . ' - REDUCING?'); if ($refid == $ref) { // Reduce points here! - $return = $points * ($content['refback_percents'] / 100) - $refback; + $return = $points * ($content['percents'] / 100) - $refbackPoints; //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'return=' . $return . ' - REDUCED!'); } // END - if } // END - if @@ -122,31 +127,40 @@ LIMIT 1", return $return; } -// "Getter" for refback percents -function getRefbackPercents ($userid, $ref) { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ' - ENTERED!'); - // Skip identical ids - if ($userid == $ref) { +/** + * "Getter" for refback percents + * + * @param $userid "Current" user's userid + * @param $refid $userid has this userid as referal + * @return $percents Refback percents $userid has given to $refid + */ +function getRefbackPercents ($userid, $refid) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . $refid . ' - ENTERED!'); + if ((!isValidUserId($userid)) || (!isValidUserId($refid))) { + // userid and/or refid is invalid + debug_report_bug(__FUNCTION__, __LINE__, 'userid=' . makeNullToZero($userid) . ', refid=' . makeNullToZero($refid) . ' - Both must be > 0'); + } elseif ($userid == $refid) { + // Skip identical ids return 0; } // END - if // Is it cached? - if (!isset($GLOBALS['refback_percents'][$userid][$ref])) { + if (!isset($GLOBALS['refback_percents'][$userid][$refid])) { // Default is zero - $GLOBALS['refback_percents'][$userid][$ref] = '0'; + $GLOBALS['refback_percents'][$userid][$refid] = '0'; // Get percents from database $result = SQL_QUERY_ESC("SELECT `refback_percents` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid`=%s AND `refid`=%s LIMIT 1", - array($ref, $userid), __FUNCTION__, __LINE__); + array($userid, $refid), __FUNCTION__, __LINE__); // Entry found? (Should be!) 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]); + list($GLOBALS['refback_percents'][$userid][$refid]) = SQL_FETCHROW($result); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . $refid . ',percents=' . $GLOBALS['refback_percents'][$userid][$refid]); } else { - // Debug log - logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',ref=' . $ref . ' - No entry found. :-('); + // Please report all findings + debug_report_bug(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . $refid . ' - No entry found. :-('); } // Free result @@ -154,13 +168,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!'); - return $GLOBALS['refback_percents'][$userid][$ref]; + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . $refid . ',refback_percents=' . $GLOBALS['refback_percents'][$userid][$refid] . ' - EXIT!'); + return $GLOBALS['refback_percents'][$userid][$refid]; } // "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=' . makeNullToZero($refid) . ',level=' . $level . ' - ENTERED!'); // Init userids $userIds = array(); @@ -181,7 +195,7 @@ ORDER BY 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=' . makeNullToZero($refid) . ',level=' . $level . ',userid=' . $content['userid']); $userIds[] = $content['userid']; } // END - while } // END - if @@ -190,7 +204,7 @@ ORDER BY SQL_FREERESULT($result); // Return array - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . $refid . ',userIds()=' . count($userIds) . ' - EXIT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . makeNullToZero($refid) . ',userIds()=' . count($userIds) . ' - EXIT!'); return $userIds; } diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 9072b7439a..9a8edbbb8d 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -653,7 +653,9 @@ function SURFBAR_INSERT_URL_BY_ARRAY ($urlData) { $userid = bigintval($urlData['url_userid']); // Is the id set? - if (empty($userid)) $userid = '0'; + if (empty($userid)) { + $userid = NULL; + } // END - if // Just run the insert query for now SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_urls` (`url_userid`, `url`, `url_status`, `url_views_max`, `url_views_allowed`, `url_fixed_reload`) VALUES (%s,'%s','%s',%s,%s,%s)", @@ -974,13 +976,13 @@ LIMIT 1", } // Check wether the user is allowed to book more URLs -function SURFBAR_IF_USER_BOOK_MORE_URLS ($userid = '0') { +function SURFBAR_IF_USER_BOOK_MORE_URLS ($userid = NULL) { // Is this admin and userid is zero or does the user has some URLs left to book? return ((($userid == '0') && (isAdmin())) || (SURFBAR_GET_TOTAL_USER_URLS($userid, '', array('REJECTED')) < getSurfbarMaxOrder())); } // Get total amount of URLs of given status for current user -function SURFBAR_GET_TOTAL_USER_URLS ($userid = '0', $status = '', $exclude = '') { +function SURFBAR_GET_TOTAL_USER_URLS ($userid = NULL, $status = '', $exclude = '') { // Is the user 0 and user is logged in? if (($userid == '0') && (isMember())) { // Then use this userid diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index 7ae54fa9dd..601ca42eb0 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -472,7 +472,7 @@ function doNewUserPassword ($email, $userid) { } // Get timestamp for given stats type and data -function getEpocheTimeFromUserStats ($statsType, $statsData, $userid = '0') { +function getEpocheTimeFromUserStats ($statsType, $statsData, $userid = NULL) { // Default timestamp is zero $data['inserted'] = '0'; @@ -548,7 +548,7 @@ function doConfirmUserAccount ($hash) { ); // Initialize the user id - $userid = '0'; + $userid = NULL; // Search for an unconfirmed or confirmed account $result = SQL_QUERY_ESC("SELECT `userid`, `refid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `user_hash`='%s' AND (`status`='UNCONFIRMED' OR `status`='CONFIRMED') LIMIT 1", @@ -587,7 +587,7 @@ LIMIT 1", sendEmail($userid, '{--GUEST_THANX_CONFIRM--}', $message); // Maybe he got "referaled"? - if (($refid > 0) && ($refid != $userid)) { + if ((isValidUserId($refid)) && ($refid != $userid)) { // Select the referal userid if (fetchUserData($refid)) { // Update ref counter... diff --git a/inc/modules/guest/what-login.php b/inc/modules/guest/what-login.php index 3cad847ee1..1129585e3b 100644 --- a/inc/modules/guest/what-login.php +++ b/inc/modules/guest/what-login.php @@ -71,7 +71,7 @@ if ((isMemberIdSet()) && (isSessionVariableSet('u_hash'))) { } } elseif (isPostRequestParameterSet('new_pass')) { // New password requested - $userid = '0'; + $userid = NULL; if (isPostRequestParameterSet('email')) { // Email is set $userid = SQL_ESCAPE(postRequestParameter('email')); @@ -87,7 +87,7 @@ if ((isMemberIdSet()) && (isSessionVariableSet('u_hash'))) { } // END - if } else { // Not logged in - $userid = '0'; + $userid = NULL; $hash = ''; } diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 4c79c47edd..d54e46a233 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -451,10 +451,12 @@ function fetchUserData ($value, $column = 'userid') { debug_report_bug(__FUNCTION__, __LINE__, 'User id ' . $value . ' is invalid.'); } elseif (isUserDataValid()) { // Use cache, so it is fine + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ' is valid, using cache #1'); return true; } } elseif (isUserDataValid()) { // Using cache is fine + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ' is valid, using cache #2'); return true; } @@ -1621,7 +1623,7 @@ function reduceRecipientReceivedMails ($column, $id, $count) { } // Creates a new task -function createNewTask ($subject, $notes, $taskType, $userid = '0', $adminId = '0', $strip = true) { +function createNewTask ($subject, $notes, $taskType, $userid = NULL, $adminId = '0', $strip = true) { // Insert the task data into the database SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_task_system` (`assigned_admin`, `userid`, `status`, `task_type`, `subject`, `text`, `task_created`) VALUES (%s,%s,'NEW','%s','%s','%s', UNIX_TIMESTAMP())", array( diff --git a/inc/purge/purge-general.php b/inc/purge/purge-general.php index 30c18977e4..b37bce0613 100644 --- a/inc/purge/purge-general.php +++ b/inc/purge/purge-general.php @@ -66,7 +66,8 @@ ORDER BY s.userid ASC', __FILE__, __LINE__); if (!SQL_HASZERONUMS($result)) { // Start deleting procedure - $userid = '0'; $points = '0'; + $userid = NULL; + $points = '0'; while ($content = SQL_FETCHARRAY($result)) { // Check if confirmation links are purged or not $result_links = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s LIMIT 1", diff --git a/inc/referal-functions.php b/inc/referal-functions.php index ac0299e6d9..384f1a8a88 100644 --- a/inc/referal-functions.php +++ b/inc/referal-functions.php @@ -83,17 +83,15 @@ function getReferalLevelPercents ($level) { } /** - * * Dynamic referal and points system, can also send mails! * * subject = Subject line, write in lower-case letters and underscore is allowed * userid = Referal id wich should receive... * 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? */ function addPointsThroughReferalSystem ($subject, $userid, $points, $refid = NULL) { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',userid=' . $userid . ',points=' . $points . ',refid=' . $refid . ' - ENTERED!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',userid=' . $userid . ',points=' . $points . ',refid=' . makeNullToZero($refid) . ' - ENTERED!'); // By default nothing has been added $added = false; @@ -101,14 +99,17 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $refid = NUL $paymentMethod = strtoupper(getPaymentMethodFromSubject($subject)); $sendNotify = isPaymentRecipientNotificationEnabled($subject); - // When $userid = '0' add points to jackpot - if (($userid == '0') && ($paymentMethod == 'DIRECT') && (isExtensionActive('jackpot'))) { + // When $userid is NULL add points to jackpot + if ((!isValidUserId($userid)) && ($paymentMethod == 'DIRECT') && (isExtensionActive('jackpot'))) { // Add points to jackpot only in DIRECT mode return addPointsToJackpot($points); } // END - if + // Set userid as current + setCurrentUserId($userid); + // Check user account - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',points=' . $points); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',points=' . $points . ',paymentMethod=' . $paymentMethod . ',sendNotify=' . intval($sendNotify)); if (fetchUserData($userid)) { // Determine wether the user has some mails to click before he/she gets the points $locked = ifUserPointsLocked($userid); @@ -116,24 +117,21 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $refid = NUL // Detect database column $pointsColumn = determinePointsColumnFromSubjectLocked($subject, $locked); - // This is the user and his ref - $GLOBALS['cache_array']['add_userid'][getUserData('refid')] = $userid; - // 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=' . makeNullToZero($GLOBALS['ref_level']) . ',per=' . $per . ',mode=' . $paymentMethod . ',pointsColumn=' . $pointsColumn . ',locked=' . intval($locked) . ',refid=' . getUserData('refid')); // 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); // 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!'); - $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 . ',refid=' . makeNullToZero(getUserData('refid')) . ',points=' . $points . ',paymentMethod=' . $paymentMethod); + if (($userid != $refid) && ($paymentMethod == 'REFERAL') && (isValidUserId(getUserData('refid'))) && (isExtensionActive('refback'))) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . makeNullToZero(getUserData('refid')) . ',ref_points=' . $ref_points . ',depth=' . makeNullToZero($GLOBALS['ref_level']) . ' - BEFORE!'); + $ref_points = addRefbackPoints($userid, getUserData('refid'), $points, $ref_points); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . makeNullToZero(getUserData('refid')) . ',ref_points=' . $ref_points . ',depth=' . makeNullToZero($GLOBALS['ref_level']) . ' - AFTER!'); } // END - if // Update points... @@ -157,7 +155,7 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $refid = NUL 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='.makeNullToZero($GLOBALS['ref_level']).',mode='.$paymentMethod.' - UPDATE! ('.SQL_AFFECTEDROWS().')'); // No entry updated? if (SQL_HASZEROAFFECTED()) { @@ -169,12 +167,12 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $refid = NUL 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='.makeNullToZero($GLOBALS['ref_level']).',mode='.$paymentMethod.' - INSERTED! ('.SQL_AFFECTEDROWS().')'); } // END - if // Check affected rows - $added = SQL_AFFECTEDROWS(); - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added='.intval($added)); + $added = (SQL_AFFECTEDROWS() == 1); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added=' . intval($added) . ' - BEFORE FILTER'); // Prepare data for the filter $filterData = array( @@ -196,7 +194,7 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $refid = NUL // Extract $added $added = $filterData['added']; - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added='.intval($added)); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'added=' . intval($added) . ' - AFTER FILTER'); // Points updated, maybe I shall send him an email? if (($sendNotify === true) && (isValidUserId(getUserData('refid'))) && ($locked === false)) { @@ -231,20 +229,27 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $refid = NUL } // END - if } - // Increase referal level - $GLOBALS['ref_level']++; - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ' Referal level increased, ref_level=' . $GLOBALS['ref_level']); + // Increase referal level, if payment method is REFERAL + if ($paymentMethod == 'REFERAL') { + // Increase it + $GLOBALS['ref_level']++; + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Referal level increased, ref_level=' . makeNullToZero($GLOBALS['ref_level']) . ',points=' . $points . ',refid=' . makeNullToZero(getUserData('refid')) . ',userid=' . $userid . ',paymentMethod=' . $paymentMethod); + } elseif (isDebugModeEnabled()) { + // Not increasing referal level, DIRECT payment method + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Referal level *NOT* increased, ref_level=' . makeNullToZero($GLOBALS['ref_level']) . ',points=' . $points . ',refid=' . makeNullToZero(getUserData('refid')) . ',userid=' . $userid . ',paymentMethod=' . $paymentMethod); + } // Maybe there's another ref? + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'points=' . $points . ',refid(var|data)=' . makeNullToZero($refid) . '|' . makeNullToZero(getUserData('refid')) . ',userid=' . $userid . ',paymentMethod=' . $paymentMethod); 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!'); - $added = ($added && addPointsThroughReferalSystem(sprintf("%s_ref:%s", $subject, $GLOBALS['ref_level']), getUserData('refid'), $points, getUserData('refid'))); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . makeNullToZero(getUserData('refid')) . ',points=' . $points . ',ref_points=' . $ref_points . ',added[' . gettype($added) . ']=' . intval($added) . ' - ADVANCE!'); + $added = ($added && addPointsThroughReferalSystem(sprintf("%s_ref:%s", $subject, $GLOBALS['ref_level']), getUserData('refid'), $points, getFetchedUserData('userid', getUserData('refid'), '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=' . makeNullToZero($refid) . ',paymentMethod=' . $paymentMethod . ' - EXIT!'); return $added; } @@ -585,15 +590,15 @@ function addMissingReferalLevels ($userid) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . $refid); // Does the refid have an array? if (isset($GLOBALS['referal_refid'][$refid])) { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . $refid . ',count()=' . count($GLOBALS['referal_refid'][$refid])); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . makeNullToZero($refid) . ',count()=' . count($GLOBALS['referal_refid'][$refid])); // Okay, then walk through here, too foreach ($GLOBALS['referal_refid'][$refid] as $refLevel=>$refArray) { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . $refid . ',refLevel=' . $refLevel . ',count()=' . count($refArray)); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . makeNullToZero($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); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . makeNullToZero($refid) . ',refLevel=' . $refLevel . ',refRefid=' . $refRefid . ',newLevel=' . $newLevel); // Is the refRefid not in? if ((!isset($GLOBALS['referal_refid'][$userid][$newLevel])) || (!in_array($refRefid, $GLOBALS['referal_refid'][$userid][$newLevel]))) { // Then we must add this ref's refid to the userid's next level diff --git a/inc/template-functions.php b/inc/template-functions.php index 382e4a6c9c..6e2e473066 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -437,7 +437,7 @@ function detectExtraTemplatePath ($template) { } // Loads an email template and compiles it -function loadEmailTemplate ($template, $content = array(), $userid = '0', $loadUserData = true) { +function loadEmailTemplate ($template, $content = array(), $userid = NULL, $loadUserData = true) { // @TODO $DATA is deprecated and should be avoided and replaced with $content global $DATA; diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 4e235f5017..46822ca578 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -949,6 +949,7 @@ function initUserData () { } // END - if // Init the user + unset($GLOBALS['is_userdata_valid'][getCurrentUserId()]); $GLOBALS['user_data'][getCurrentUserId()] = array(); } @@ -1009,7 +1010,9 @@ function getUserDataArray () { // in, but you should use isMember() if you want to find that out. function isUserDataValid () { // User id should not be zero so abort here - if (!isCurrentUserIdSet()) return false; + if (!isCurrentUserIdSet()) { + return false; + } // END - if // Is it cached? if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) { diff --git a/mailid_top.php b/mailid_top.php index b88616de73..54f17d5ad3 100644 --- a/mailid_top.php +++ b/mailid_top.php @@ -176,10 +176,10 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr if ($isValid === true) { if (($time == '0') && ($payment > 0)) $time = 1; if (($time > 0) && ($payment > 0)) { - $img_code = '0'; + $realCode = '0'; if (!empty($code)) { - // Generate code - $img_code = generateRandomCode(getCodeLength(), $code, $userId, $urlId); + // Generate code (the user sees in the CAPTCHA) + $realCode = generateRandomCode(getCodeLength(), $code, $userId, $urlId); } // END - if // @TODO Rewrite this to a filter @@ -227,7 +227,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr // @TODO Rewrite these blocks to filter if (isExtensionInstalledAndNewer('user', '0.1.2')) { // Update counter - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET mails_confirmed=mails_confirmed + 1 WHERE `userid`=%s LIMIT 1", + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `mails_confirmed`=`mails_confirmed`+1 WHERE `userid`=%s LIMIT 1", array($userId), __FILE__, __LINE__); // Update random confirmed as well? @@ -239,10 +239,10 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr } // END - if // Insert stats record - insertUserStatsRecord($userId, $type, $stats_data); + //insertUserStatsRecord($userId, $type, $stats_data); // Right code entered? - if (bigintval(postRequestParameter('gfx_check')) == $img_code) { + if (bigintval(postRequestParameter('gfx_check')) == $realCode) { // Set HTTP status to okay setHttpStatus('200 OK'); @@ -300,8 +300,17 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr // Wrong image code! So add points to sender's account addPointsThroughReferalSystem('mailid_payback', $sender, $payment); + // Add payment points + $content['points'] = $payment; + // Load template loadTemplate('mailid_points_failed', false, $content); + } else { + // Add payment points (again) + $content['points'] = $payment; + + // Load template + loadTemplate('mailid_points_failed2', false, $content); } // Remove link from table @@ -310,7 +319,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr break; case 'img': - generateImageOrCode($img_code); + generateImageOrCode($realCode); break; case 'confirm': @@ -323,11 +332,11 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr $content['banner'] = loadTemplate('mailid_banner', true); if (getCodeLength() > 0) { // Generate Code - $content['image'] = generateCaptchaCode($code, $type, $urlId, $userId); + $content['image'] = generateCaptchaCode($realCode, $type, $urlId, $userId); $templ = 'mailid_enter_code'; } else { // Disabled code - $content['gfx'] = $img_code; + $content['gfx'] = $realCode; $templ = 'mailid_confirm_buttom'; } diff --git a/show_bonus.php b/show_bonus.php index 319b15d722..90b0024e5c 100644 --- a/show_bonus.php +++ b/show_bonus.php @@ -78,7 +78,7 @@ if ((isValidUserId(getRequestParameter('userid'))) && (getRequestParameter('d') if (!empty($t)) { // Check for data $result = SQL_QUERY_ESC("SELECT - d.`gender`, d.`surname`, d.`family`, b.`level`, b.`points` + d.`userid`, b.`level`, b.`points` FROM `{?_MYSQL_PREFIX?}_user_data` AS d INNER JOIN @@ -102,7 +102,6 @@ LIMIT 1", $content = SQL_FETCHARRAY($result); // Prepare constants for the pre-template - // @TODO No more needed? $content['points'] = translateComma($content['points']); $content['mailid'] = bigintval(getRequestParameter('d')); $content['rows'] = addBonusRanks(bigintval(getRequestParameter('d')), $t, bigintval(getRequestParameter('userid'))); diff --git a/templates/de/html/mailid/mailid_points_failed2.tpl b/templates/de/html/mailid/mailid_points_failed2.tpl new file mode 100644 index 0000000000..b9b4c5c97f --- /dev/null +++ b/templates/de/html/mailid/mailid_points_failed2.tpl @@ -0,0 +1,14 @@ +
+ + + + + +
+ {%message,MEMBER_POINTS_NOT_ADDED2=$content[points]%} + + +
+
diff --git a/templates/de/html/show_bonus_msg.tpl b/templates/de/html/show_bonus_msg.tpl index d5953d6305..8f7343e108 100644 --- a/templates/de/html/show_bonus_msg.tpl +++ b/templates/de/html/show_bonus_msg.tpl @@ -1,19 +1,29 @@ -
- Hallo {%pipe,translateGender=$content[gender]%} $content[surname] $content[family]! +
+ +
+ Hallo {%user,gender,translateGender=$content[userid]%} {%user,surname=$content[userid]%} {%user,family=$content[userid]%}!
+
{%message,MEMBER_BONUS_SHOW_TITLE=$content[mailid]%}:
+ - - - + + + $content[rows]
{--BONUS_RANK--}:{--_USERID--}:{?POINTS?}: + {--BONUS_RANK--}: + + {--_USERID--}: + + {?POINTS?}: +
@@ -22,11 +32,12 @@ $content[rankings]
-
+
- Wir wünschen allen Gewinnern viel Glück bei der monatlichen Aktiv-Rallye! + {--MONTHLY_BONUS_RALLYE_GOOD_LUCK--}
- Es können nur die ersten {?bonus_ranks?} die Aktiv-Rallye gewinnen. Der Rechtsweg ist ausgeschlossen. + {--MONTHLY_BONUS_RALLYE_RANKS_NOTE--}
+
diff --git a/theme/default/css/mailid.css b/theme/default/css/mailid.css index a528ee0618..37d260b8c0 100644 --- a/theme/default/css/mailid.css +++ b/theme/default/css/mailid.css @@ -1,4 +1,4 @@ -.mailid_table { +table.mailid_table { background-color: #ddeedd; width: 100%; height: 100%; -- 2.39.2