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
./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()
./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?
./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
./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: <!-- @TODO Rewrite this selection box to our generic functions //-->
./templates/de/html/admin/admin_admins_contct_form.tpl:4: <!-- @TODO Shouldn't we add a title here? //-->
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,
} // 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
// 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;
}
} // END - if
// Initialize variables
- $userid = '0';
+ $userid = NULL;
$isMember = convertBooleanToYesNo(isMember());
$isAdmin = convertBooleanToYesNo(isAdmin());
$action = getActionFromModuleWhat(getModule(), getWhat());
}
// 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)) {
}
// 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);
'ADMIN_NO_NOTIFICATIONS' => "Keine Benachrichtigungen gefunden.",
'ADMIN_LINKS_BONUS_MAIL_TITLE' => "Bonus-Mail <span class=\"data\">%s</span>:",
'ADMIN_EDIT_BONUS_EMAIL_TITLE' => "Daten der Bonus-Mail Nr. <span class=\"data\">%s</span> ä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 <span class=\"data\">{?bonus_ranks?}</span> die Aktiv-Rallye gewinnen. Der Rechtsweg ist ausgeschlossen.",
// Switches
'ADMIN_CONFIG_BONUS_RALLYE_IS_ACTIVE' => "Ist die Aktiv-Rallye aktiv?",
'MEMBER_THANX_POINTS_ADDED' => "Vielen Dank für die Bestätigung der Mail. Die <span class=\"data\">{%%pipe,translateComma=%s%%}</span> {?POINTS?} wurden Ihnen gerade gutgeschrieben.",
'MEMBER_THANX_POINTS_LOCKED' => "Vielen Dank für die Bestätigung der Mail. Die <span class=\"data\">{%%pipe,translateComma=%s%%}</span> {?POINTS?} werden Ihnen bald gutgeschrieben.",
'MEMBER_POINTS_NOT_ADDED' => "Falscher Bestätigungscode eingegeben! Die <span class=\"data\">{%%pipe,translateComma=%s%%}</span> {?POINTS?} wurden dem Versender wieder gutgeschrieben.",
+ 'MEMBER_POINTS_NOT_ADDED2' =>"Falscher Bestätigungscode eingegeben! Die <span class=\"data\">{%%pipe,translateComma=%s%%}</span> {?POINTS?} wurden Ihnen nicht gutgeschrieben.",
'MEMBER_ENTER_CODE' => "Code eingeben",
'MEMBER_TIME_COUNTER_1' => "Gutschrift der {?POINTS?} erfolgt in <span class=\"data\">",
'MEMBER_TIME_COUNTER_2' => "</span> ...",
// 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
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",
// 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)) {
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')",
}
}
- // 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
} // END - if
// Return result
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keys_array[]=' . gettype($keys_array) . ',mode=' . $mode . ',value=' . $value . ',added=' . intval($added) . ' - EXIT!');
return $added;
}
// "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__);
// 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
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
} // 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();
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
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;
}
$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)",
}
// 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
}
// 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';
);
// 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",
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...
}
} elseif (isPostRequestParameterSet('new_pass')) {
// New password requested
- $userid = '0';
+ $userid = NULL;
if (isPostRequestParameterSet('email')) {
// Email is set
$userid = SQL_ESCAPE(postRequestParameter('email'));
} // END - if
} else {
// Not logged in
- $userid = '0';
+ $userid = NULL;
$hash = '';
}
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;
}
}
// 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(
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",
}
/**
- *
* 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;
$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);
// 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...
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()) {
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(
// 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)) {
} // 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;
}
//* 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
}
// 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;
} // END - if
// Init the user
+ unset($GLOBALS['is_userdata_valid'][getCurrentUserId()]);
$GLOBALS['user_data'][getCurrentUserId()] = array();
}
// 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()])) {
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
// @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?
} // 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');
// 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
break;
case 'img':
- generateImageOrCode($img_code);
+ generateImageOrCode($realCode);
break;
case 'confirm':
$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';
}
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
$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')));
--- /dev/null
+<div align="center">
+<table border="0" cellspacing="0" cellpadding="0" class="mailid_table">
+ <tr>
+ <td width="220" align="center">
+ {%message,MEMBER_POINTS_NOT_ADDED2=$content[points]%}
+ </td>
+ <td align="center">
+ <div class="banner dashed">
+ $content[banner]
+ </div>
+ </td>
+ </tr>
+</table>
+</div>
-<div>
- Hallo {%pipe,translateGender=$content[gender]%} $content[surname] $content[family]!
+<div align="center">
+
+<div class="big">
+ Hallo {%user,gender,translateGender=$content[userid]%} {%user,surname=$content[userid]%} {%user,family=$content[userid]%}!
</div>
+
<div>
{%message,MEMBER_BONUS_SHOW_TITLE=$content[mailid]%}:
</div>
+
<table border="0" cellspacing="0" cellpadding="0" width="300" class="table dashed">
<tr>
- <td width="80" align="center" class="header_column bottom"><strong>{--BONUS_RANK--}:</strong></td>
- <td width="120" align="center" class="header_column bottom"><strong>{--_USERID--}:</strong></td>
- <td width="100" align="center" class="header_column bottom"><strong>{?POINTS?}:</strong></td>
+ <td width="80" align="center" class="header_column bottom">
+ <strong>{--BONUS_RANK--}:</strong>
+ </td>
+ <td width="120" align="center" class="header_column bottom">
+ <strong>{--_USERID--}:</strong>
+ </td>
+ <td width="100" align="center" class="header_column bottom">
+ <strong>{?POINTS?}:</strong>
+ </td>
</tr>
$content[rows]
<tr>
<td colspan="3" class="table_footer" align="center">
- <div class="tiny">$content[own]</div>
+ $content[own]
</td>
</tr>
</table>
$content[rankings]
</div>
-<div style="padding-top:5px;padding-bottom:5px" class="notice">
+<div style="padding-top:5px;padding-bottom:5px">
<div>
- Wir wünschen allen Gewinnern viel Glück bei der monatlichen Aktiv-Rallye!
+ {--MONTHLY_BONUS_RALLYE_GOOD_LUCK--}
</div>
<div>
- Es können nur die ersten <u>{?bonus_ranks?}</u> die Aktiv-Rallye gewinnen. Der Rechtsweg ist ausgeschlossen.
+ {--MONTHLY_BONUS_RALLYE_RANKS_NOTE--}
</div>
</div>
+</div>
-.mailid_table {
+table.mailid_table {
background-color: #ddeedd;
width: 100%;
height: 100%;