* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
* Copyright (c) 2009 - 2011 by Mailer Developer Team *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
* Copyright (c) 2009 - 2011 by Mailer Developer Team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
-function alpha ($sortby, $colspan, $return=false) {
- if (!isGetRequestParameterSet('offset')) setGetRequestParameter('offset', 0);
- $add = '&page='.getRequestParameter('page').'&offset='.getRequestParameter('offset');
- if (isGetRequestParameterSet('mode')) $add .= '&mode='.getRequestParameter('mode');
+function alpha ($sortby) {
+ $add = '';
+ foreach (array('page','offset','mode','status') as $param) {
+ if (isGetRequestElementSet($param)) {
+ $add .= '&' . $param . '=' . getRequestElement($param);
+ } // END - if
+ } // END - foreach
/* Creates the list of letters and makes them a link. */
$alphabet = explode(',', 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,');
$num = count($alphabet) - 1;
$OUT = '';
while (list($counter, $ltr) = each($alphabet)) {
/* Creates the list of letters and makes them a link. */
$alphabet = explode(',', 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,');
$num = count($alphabet) - 1;
$OUT = '';
while (list($counter, $ltr) = each($alphabet)) {
- $OUT .= '<a href="{%url=modules.php?module=admin&what=' . getWhat();
- if (isGetRequestParameterSet('mode')) $OUT .= '&mode=' . getRequestParameter('mode');
- $OUT .= '&letter=' . $ltr . '&sortby=' . $sortby . $add . '%}">' . $ltr . '</a>';
+ $OUT .= '<a href="{%url=modules.php?module=admin&what=' . getWhat() . '&letter=' . $ltr . '&sortby=' . $sortby . $add . '%}">' . $ltr . '</a>';
'alpha_selection' => $OUT
);
// Load template
$OUT = loadTemplate('admin_list_user_alpha', true, $content);
'alpha_selection' => $OUT
);
// Load template
$OUT = loadTemplate('admin_list_user_alpha', true, $content);
- if (!isGetRequestParameterSet('offset')) setGetRequestParameter('offset', 0);
- if (!isGetRequestParameterSet('page')) setGetRequestParameter('page' , 0);
+ if (!isGetRequestElementSet('offset')) setGetRequestElement('offset', 0);
+ if (!isGetRequestElementSet('page')) setGetRequestElement('page' , 0);
- // Add status or mode
- if (isGetRequestParameterSet('status')) $add .= '&mode=' . getRequestParameter('status');
- elseif (isGetRequestParameterSet('mode')) $add .= '&mode=' . getRequestParameter('mode');
+ // Add status/ mode
+ foreach (array('mode','status') as $param) {
+ if (isGetRequestElementSet($param)) {
+ $add .= '&' . $param . '=' . getRequestElement($param);
+ } // END - if
+ } // END - foreach
-function addPageNavigation ($numPages, $offset, $showForm, $colspan, $return=false) {
- // @TODO These two constants are no longer used, maybe we reactivate this code?
- //if ($showForm === true) {
- // // Load form for changing number of lines
- // define('__FORM_HEADER', loadTemplate('admin_list_user_sort_form', true));
- // define('__FORM_FOOTER', '<tr><td colspan="'.$colspan.'" class="seperator bottom"> </td></tr>');
- //} else {
- // // Empty row
- // define('__FORM_HEADER', '<tr><td colspan="' . $colspan . '" class="seperator"> </td></tr>');
- // define('__FORM_FOOTER', '<tr><td colspan="' . $colspan . '" class="seperator bottom"> </td></tr>');
- //}
-
+function addPageNavigation ($numPages) {
+ // Start with empty content
- for ($page = 1; $page <= $numPages; $page++) {
- if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
- $OUT .= '<strong>-';
- } else {
- if (!isGetRequestParameterSet('letter')) setGetRequestParameter('letter', '');
- if (!isGetRequestParameterSet('sortby')) setGetRequestParameter('sortby', 'userid');
- // Base link
- $OUT .= '<a href="{%url=modules.php?module=admin&what=' . getWhat();
+ // Create only the navigation if page count > 1
+ if ($numPages > 1) {
+ // Create navigation links for every page
+ for ($page = 1; $page <= $numPages; $page++) {
+ if (($page == getRequestElement('page')) || ((!isGetRequestElementSet('page')) && ($page == 1))) {
+ $OUT .= '<strong>-';
+ } else {
+ if (!isGetRequestElementSet('letter')) setGetRequestElement('letter', '');
+ if (!isGetRequestElementSet('sortby')) setGetRequestElement('sortby', 'userid');
- // Letter and so on
- $OUT .= '&letter=' . getRequestParameter('letter') . '&sortby=' . getRequestParameter('sortby') . '&page=' . $page . '&offset=' . $offset . '%}">';
- }
+ // Add status/mode
+ foreach (array('mode','status') as $param) {
+ if (isGetRequestElementSet($param)) {
+ $OUT .= '&' . $param . '=' . getRequestElement($param);
+ } // END - if
+ } // END - foreach
- // Load template
- $OUT = loadTemplate('admin_list_user_pagenav', true, $content);
- if ($return === true) {
- // Return code
- return $OUT;
- } else {
- // Output code
- outputHtml($OUT);
- }
+ // Add list output
+ $content['list'] = $OUT;
+
+ // Load template
+ $OUT = loadTemplate('admin_list_user_pagenav', true, $content);
+ } // END - if
+
+ // Return code
+ return $OUT;
// Is the extension version fine?
if (isExtensionInstalledAndNewer('user', '0.3.4')) {
// Is the extension version fine?
if (isExtensionInstalledAndNewer('user', '0.3.4')) {
-
- // Reset all users, this makes this random referal id more challenging
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `rand_confirmed`=0",
- array($refid), __FUNCTION__, __LINE__);
if (($errorCode == '0') && ($isFound === true)) {
// Get user data array and set userid (e.g. important if we login with nickname)
$content = getUserDataArray();
if (($errorCode == '0') && ($isFound === true)) {
// Get user data array and set userid (e.g. important if we login with nickname)
$content = getUserDataArray();
// Check for old MD5 passwords
if ((strlen(getUserData('password')) == 32) && (md5($passwd) == getUserData('password'))) {
// Just set the hash to the password from DB... :)
// Check for old MD5 passwords
if ((strlen(getUserData('password')) == 32) && (md5($passwd) == getUserData('password'))) {
// Just set the hash to the password from DB... :)
// Is the timeout reached?
if ($probe >= getConfig('login_timeout')) {
// Add login bonus to user's account
// Is the timeout reached?
if ($probe >= getConfig('login_timeout')) {
// Add login bonus to user's account
$GLOBALS['bonus_payed'] = true;
// Subtract login bonus from userid's account or jackpot
if ((isExtensionInstalledAndNewer('bonus', '0.3.5')) && (getBonusMode() != 'ADD')) {
$GLOBALS['bonus_payed'] = true;
// Subtract login bonus from userid's account or jackpot
if ((isExtensionInstalledAndNewer('bonus', '0.3.5')) && (getBonusMode() != 'ADD')) {
// Try to send a new password for the given user account
function doNewUserPassword ($email, $userid) {
// Try to send a new password for the given user account
function doNewUserPassword ($email, $userid) {
- // Init result and error
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'email=' . $email . ',userid=' . $userid . ' - ENTERED!');
+ // Init found-status and error
- $result = SQL_QUERY_ESC("SELECT `userid`, `status` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `email`='%s' OR `email`='%s' LIMIT 1",
- array($email, str_replace('.', '{DOT}', $email)), __FUNCTION__, __LINE__);
+ $accountFound = fetchUserData($email, 'email');
- $result = SQL_QUERY_ESC("SELECT `userid`, `status` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `nickname`='%s' OR `userid`='%s' OR `email`='%s' LIMIT 1",
- array($userid, $userid, $email), __FUNCTION__, __LINE__);
+ $accountFound = fetchUserData($userid, 'nickname');
- $result = SQL_QUERY_ESC("SELECT `userid`, `status` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
- array(bigintval($userid)), __FUNCTION__, __LINE__);
+ $accountFound = fetchUserData($userid);
- logDebugMessage(__FUNCTION__, __LINE__, 'Userid is not set! BUG!');
- $errorCode = getCode('WRONG_ID');
+ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',email=' . $email . ': Important variables are empty.');
- if (SQL_NUMROWS($result) == 1) {
- // This data is valid, so we create a new pass... :-)
- list($userid, $status) = SQL_FETCHROW($result);
-
- if ($status == 'CONFIRMED') {
- // Ooppps, this was missing! ;-) We should update the database...
+ if ($accountFound === true) {
+ // Is the account confirmed
+ if (getUserData('status') == 'CONFIRMED') {
+ // Generate new password
- array(generateHash($NEW_PASS), $userid), __FUNCTION__, __LINE__);
+ array(generateHash($NEW_PASS), getUserData('userid')), __FUNCTION__, __LINE__);
- $message = loadEmailTemplate('guest_new_password', array('new_pass' => $NEW_PASS, 'nickname' => $userid), $userid);
+ $message = loadEmailTemplate('guest_new_password',
+ array(
+ 'new_pass' => $NEW_PASS,
+ 'nickname' => $userid
+ ), bigintval(getUserData('userid')));
} elseif (is_array($statsData)) {
// Invalid data!
logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',type=' . $statsType . ',data=' . gettype($statsData) . ': Invalid statistics data type!');
}
} elseif (is_array($statsData)) {
// Invalid data!
logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',type=' . $statsType . ',data=' . gettype($statsData) . ': Invalid statistics data type!');
}
- $result = SQL_QUERY_ESC("SELECT `userid`, `email`, `refid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `user_hash`='%s' AND (`status`='UNCONFIRMED' OR `status`='CONFIRMED') LIMIT 1",
+ $result = SQL_QUERY_ESC("SELECT `userid`,`refid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `user_hash`='%s' AND (`status`='UNCONFIRMED' OR `status`='CONFIRMED') LIMIT 1",
array($hash), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Ok, he want's to confirm now so we load some data
array($hash), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Ok, he want's to confirm now so we load some data
$message = loadEmailTemplate('guest_user_confirmed', $content, bigintval($userid));
// And send him right away the confirmation mail
$message = loadEmailTemplate('guest_user_confirmed', $content, bigintval($userid));
// And send him right away the confirmation mail
- // Maybe he got "referaled"?
- if (($refid > 0) && ($refid != $userid)) {
- // Select the referal userid
+ // Maybe he got "referraled"?
+ if ((isValidUserId($refid)) && ($refid != $userid)) {
+ // Select the referral userid
// If version matches add ref bonus to refid's account
if ((isExtensionInstalledAndNewer('bonus', '0.4.4')) && (isBonusRallyeActive())) {
// If version matches add ref bonus to refid's account
if ((isExtensionInstalledAndNewer('bonus', '0.4.4')) && (isBonusRallyeActive())) {
array(bigintval($refid)), __FILE__, __LINE__);
// Subtract points from system
array(bigintval($refid)), __FILE__, __LINE__);
// Subtract points from system
- // Add one-time referal bonus over referal system or directly
- // @TODO Try to rewrite the following unset()
- unset($GLOBALS['ref_level']);
- addPointsThroughReferalSystem('referal_bonus', $refid, getPointsRef(), true, bigintval($userid), getConfig('reg_points_mode'));
+ // Add one-time referral bonus over referral system or directly
+ initReferralSystem();
+ addPointsThroughReferralSystem('referral_bonus', $refid, getPointsRef(), bigintval($userid));
- $message = loadEmailTemplate('guest_request_confirm', array('hash' => $content['user_hash']), $content['userid']);
+ $message = loadEmailTemplate('guest_request_confirm', array(), $content['userid']);
// This is different to translateUserStatus() in text messages.
function getConfirmationMessageFromUserStatus ($status) {
// Default is 'UNKNOWN'
// This is different to translateUserStatus() in text messages.
function getConfirmationMessageFromUserStatus ($status) {
// Default is 'UNKNOWN'
// User-related data, so is there a userid?
if (!empty($data['matches'][4][$data['key']])) {
// Do we have a userid or $userid?
// User-related data, so is there a userid?
if (!empty($data['matches'][4][$data['key']])) {
// Do we have a userid or $userid?
- $functionName = "getFetchedUserData('userid', \$userid, '" . $data['callback'] . "')";
+ $functionName = "getFetchedUserData('userid', " . $data['matches'][4][$data['key']] . ", '" . $data['callback'] . "')";
+ // Do we have a number or a dollar sign in front of it?
+ if (preg_replace('/[^0123456789]/', '', $data['matches'][4][$data['key']]) != $data['matches'][4][$data['key']]) {
+ // Possible database column, so get it again
+ $data['matches'][4][$data['key']] = "getFetchedUserData('userid', getMemberId(), '" . $data['matches'][4][$data['key']] . "')";
+ } // END - if
+
+ // Fix all together
$functionName = "getFetchedUserData('userid', " . $data['matches'][4][$data['key']] . ", '" . $data['callback'] . "')";
}
} elseif ((!empty($data['callback'])) && (isUserDataValid())) {
$functionName = "getFetchedUserData('userid', " . $data['matches'][4][$data['key']] . ", '" . $data['callback'] . "')";
}
} elseif ((!empty($data['callback'])) && (isUserDataValid())) {
// Surround the original function call with it
$functionName = $data['extra_func'] . '(' . $functionName . ')';
} // END - if
// Surround the original function call with it
$functionName = $data['extra_func'] . '(' . $functionName . ')';
} // END - if
// Init title with "all accounts"
$code = '{--ADMIN_LIST_ALL_ACCOUNTS--}';
// Do we have a 'status' or 'mode' set?
// Init title with "all accounts"
$code = '{--ADMIN_LIST_ALL_ACCOUNTS--}';
// Do we have a 'status' or 'mode' set?
- $code = sprintf("{--ADMIN_LIST_STATUS_%s_ACCOUNTS--}", strtoupper(getRequestParameter('status')));
- } elseif (isGetRequestParameterSet('mode')) {
+ $code = sprintf("{--ADMIN_LIST_STATUS_%s_ACCOUNTS--}", strtoupper(getRequestElement('status')));
+ } elseif (isGetRequestElementSet('mode')) {
+// Template call-back function for displaying "username"
+function doTemplateDisplayUsername ($template, $clear = false, $userid = NULL) {
+ // Is a userid set?
+ if (!isValidUserId($userid)) {
+ // Please don't call this without a valid userid
+ debug_report_bug(__FUNCTION__, __LINE__, 'template=' . $template . ',clear=' . intval($clear) . ',userid[' . gettype($userid) . ']=' . intval($userid) . ' - Invalid userid provided.');
+ } // END - if
+
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__][$userid])) {
+ // Generate code
+ $GLOBALS[__FUNCTION__][$userid] = $userid . ' ({%user,nickname,fixEmptyContentToDashes=' . $userid . '%})';
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__][$userid];
+}
+