$OUT = $prefix . '<strong><a class="you_are_here" href="{%url=modules.php?module=' . $modCheck . '&' . $type . '=' . $search . $LINK_ADD . '%}">' . getTitleFromMenu($accessLevel, $search, $type, $ADD) . '</a></strong>';
// 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 .= '</div>';
$GLOBALS['nav_depth'] = '0';
`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);
$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
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
// 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);
);
// 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
}
$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') {
$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",
// 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()) {
// 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) {
}
} 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,
), __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,
}
// Return value
- //* DEBUG: */ debugOutput('ret=' . $data['res']);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'res=' . $data['res']);
return $data['res'];
}
// Getter fro ref level percents
// 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;
}
* 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
} // 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);
// 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...
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()) {
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(
// 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)) {
// 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
// Default is empty
$what = '';
- //* DEBUG: */ debugOutput(__LINE__.'!'.$modCheck.'!');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'modCheck=' . $modCheck);
switch ($modCheck) {
case 'admin':
$what = 'overview';
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(
);
// Insert booking record
- $filterData = runFilterChain('sub_points', $filterData);
+ $filterData = runFilterChain('post_sub_points', $filterData);
// Return result
return $filterData['added'];
// 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