'userid' => "%uid%", // User-ID
'surname' => "%vorname%", // Surname
'family' => "%nachname%", // Family name
- 'gender' => "%anrede%", // Gender
+ 'gender' => "%anrede%", // Gender
);
// One day
// Random number for e.g. the "cache-buster" used in OpenX script
define('CACHE_BUSTER', mt_rand(1000000, 9999999));
+// CFG: DEBUG-SQL (if enabled and DEBUG_MODE is enabled all SQL queries will be logged to debug.log)
+define('DEBUG_SQL', false);
+
// Extra title is empty by default
$EXTRA_TITLE = "";
if (!IS_MEMBER()) return false;
// Secure user ID
- $GLOBALS['userid'] = bigintval(get_session('userid'));
+ setUserId(get_session('userid'));
// Load last module and last online time
$result = SQL_QUERY_ESC("SELECT last_module, last_online FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FUNCTION__, __LINE__);
+ array(getUserId()), __FUNCTION__, __LINE__);
// Entry found?
if (SQL_NUMROWS($result) == 1) {
// Update last module / online time
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET last_module='%s', last_online=UNIX_TIMESTAMP(), REMOTE_ADDR='%s' WHERE userid=%s LIMIT 1",
- array($GLOBALS['what'], GET_REMOTE_ADDR(), $GLOBALS['userid']), __FUNCTION__, __LINE__);
+ array($GLOBALS['what'], GET_REMOTE_ADDR(), getUserId()), __FUNCTION__, __LINE__);
} else {
// Destroy session, we cannot update!
destroy_user_session();
if ($template == "member_support_form") {
// Support request of a member
$result = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FUNCTION__, __LINE__);
+ array(getUserId()), __FUNCTION__, __LINE__);
// Is content an array?
if (is_array($content)) {
// Add more additional data
if (isSessionVariableSet('u_hash')) $data .= ":".get_session('u_hash');
- if (isset($GLOBALS['userid'])) $data .= ":".$GLOBALS['userid'];
+ if (isUserIdSet()) $data .= ":".getUserId();
if (isSessionVariableSet('mxchange_theme')) $data .= ":".get_session('mxchange_theme');
if (isSessionVariableSet('mx_lang')) $data .= ":".GET_LANGUAGE();
if (isset($GLOBALS['refid'])) $data .= ":".$GLOBALS['refid'];
exit;
}
+// Setter for userid
+function setUserId ($userid) {
+ $GLOBALS['userid'] = bigintval($userid);
+}
+
+// Getter for userid or returns zero
+function getUserId () {
+ // Default userid
+ $userid = 0;
+
+ // Is the userid set?
+ if (isUserIdSet()) {
+ // Then use it
+ $userid = $GLOBALS['userid'];
+ } // END - if
+
+ // Return it
+ return $userid;
+}
+
+// Checks ether the userid is set
+function isUserIdSet () {
+ return (isset($GLOBALS['userid']));
+}
+
//////////////////////////////////////////////////
// AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS //
//////////////////////////////////////////////////
$uid = 0; $rid = 0; $MEM = "N"; $ADMIN = "N";
// Valid userid?
- if ((!empty($GLOBALS['userid'])) && ($GLOBALS['userid'] > 0) && (IS_MEMBER())) {
+ if ((isUserIdSet()) && (getUserId() > 0) && (IS_MEMBER())) {
// Is valid user
- $uid = bigintval($GLOBALS['userid']);
+ $uid = getUserId();
$MEM = "Y";
} // END - if
$api = new PrimeraApi(getConfig('primera_api_name'), getConfig('primera_api_md5'));
// Prepare purpose
- $eval = "\$purpose = \"".COMPILE_CODE(sprintf(getMessage('PRIMERA_API_PURPOSE_PAYOUT'), $GLOBALS['userid']))."\";";
+ $eval = "\$purpose = \"".COMPILE_CODE(sprintf(getMessage('PRIMERA_API_PURPOSE_PAYOUT'), getUserId()))."\";";
eval($eval);
// Pay the Primera
// Get entry from database
$result = SQL_QUERY_ESC("SELECT id, refid, refback, level FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE id=%s AND userid=%s LIMIT 1",
- array($id, $GLOBALS['userid']), __FUNCTION__, __LINE__);
+ array($id, getUserId()), __FUNCTION__, __LINE__);
// Is there an entry?
if (SQL_NUMROWS($result) == 1) {
// Update entry
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_refs` SET refback='%s' WHERE id=%s AND userid=%s LIMIT 1",
- array($percents, $id, $GLOBALS['userid']), __FUNCTION__, __LINE__);
+ array($percents, $id, getUserId()), __FUNCTION__, __LINE__);
// Entry updated?
if (SQL_AFFECTEDROWS() < 1) {
);
// Load member email template
- $mail = LOAD_EMAIL_TEMPLATE("member_refback", $content, $GLOBALS['userid']);
+ $mail = LOAD_EMAIL_TEMPLATE("member_refback", $content, getUserId());
// Send email to user
SEND_EMAIL($dummy['refid'], getMessage('MEMBER_REFBACK_SUBJECT'), $mail);
// Send admin notification
- SEND_ADMIN_NOTIFICATION(getMessage('ADMIN_REFBACK_SUBJECT'), "admin_refback", $content, $GLOBALS['userid']);
+ SEND_ADMIN_NOTIFICATION(getMessage('ADMIN_REFBACK_SUBJECT'), "admin_refback", $content, getUserId());
// All fine!
$status['ok'] = true;
} elseif (!VALIDATE_URL($url)) {
// URL invalid
return false;
- } elseif (SURFBAR_LOOKUP_BY_URL($url, $GLOBALS['userid'])) {
+ } elseif (SURFBAR_LOOKUP_BY_URL($url, getUserId())) {
// URL already found in surfbar!
return false;
- } elseif (!SURFBAR_IF_USER_BOOK_MORE_URLS($GLOBALS['userid'])) {
+ } elseif (!SURFBAR_IF_USER_BOOK_MORE_URLS(getUserId())) {
// No more allowed!
return false;
} elseif ("".($limit + 0)."" != "".$limit."") {
}
// Register the new URL
- return SURFBAR_REGISTER_URL($url, $GLOBALS['userid'], "PENDING", "reg", array('limit' => $limit));
+ return SURFBAR_REGISTER_URL($url, getUserId(), "PENDING", "reg", array('limit' => $limit));
}
// Create list of actions depending on status for the user
function SURFBAR_MEMBER_ACTIONS ($urlId, $status) {
ON u.id=l.url_id
WHERE l.userid=%s AND (UNIX_TIMESTAMP() - ".SURFBAR_GET_SURF_LOCK().") < UNIX_TIMESTAMP(l.last_surfed) AND (((UNIX_TIMESTAMP(l.last_surfed) - u.fixed_reload) < 0 AND u.fixed_reload > 0) OR u.fixed_reload = 0)
LIMIT 1",
- array($GLOBALS['userid']), __FUNCTION__, __LINE__
+ array(getUserId()), __FUNCTION__, __LINE__
);
// Fetch row
// Is the user 0 and user is logged in?
if (($uid == 0) && (IS_MEMBER())) {
// Then use this userid
- $uid = $GLOBALS['userid'];
+ $uid = getUserId();
} elseif ($uid == 0) {
// Error!
return (getConfig('surfbar_max_order') + 1);
}
// ... and now the validation code
- $valCode = generateRandomCodde($length, sha1(SURFBAR_GET_SALT().":".$urlId), $GLOBALS['userid']);
+ $valCode = generateRandomCodde($length, sha1(SURFBAR_GET_SALT().":".$urlId), getUserId());
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "valCode={$valCode}", false);
} // END - while
///* DEBUG: */ return;
// Just add it to the database
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_locks` (userid, url_id) VALUES (%s, %s)",
- array($GLOBALS['userid'], bigintval($urlId)), __FUNCTION__, __LINE__);
+ array(getUserId(), bigintval($urlId)), __FUNCTION__, __LINE__);
// Remove the salt from database
SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_surfbar_salts` WHERE url_id=%s AND userid=%s LIMIT 1",
- array(bigintval($urlId), $GLOBALS['userid']), __FUNCTION__, __LINE__);
+ array(bigintval($urlId), getUserId()), __FUNCTION__, __LINE__);
}
// Pay points to the user and remove it from the sender if userid is given else it is a "sponsored surf"
function SURFBAR_PAY_POINTS () {
} // END - if
// Book it to the user
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "uid=".$GLOBALS['userid'].",reward=".SURFBAR_GET_REWARD()."", false);
- ADD_POINTS_REFSYSTEM(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), $GLOBALS['userid'], SURFBAR_GET_DATA('reward'));
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "uid=".getUserId().",reward=".SURFBAR_GET_REWARD()."", false);
+ ADD_POINTS_REFSYSTEM(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), getUserId(), SURFBAR_GET_DATA('reward'));
}
// Updates the statistics of current URL/userid
function SURFBAR_UPDATE_INSERT_STATS_RECORD () {
// Update the stats entry
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_surfbar_stats` SET count=count+1 WHERE userid=%s AND url_id=%s LIMIT 1",
- array($GLOBALS['userid'], SURFBAR_GET_ID()), __FUNCTION__, __LINE__);
+ array(getUserId(), SURFBAR_GET_ID()), __FUNCTION__, __LINE__);
// Was that update okay?
if (SQL_AFFECTEDROWS() < 1) {
// No, then insert entry
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_stats` (userid,url_id,count) VALUES (%s,%s,1)",
- array($GLOBALS['userid'], SURFBAR_GET_ID()), __FUNCTION__, __LINE__);
+ array(getUserId(), SURFBAR_GET_ID()), __FUNCTION__, __LINE__);
} // END - if
// Update total/daily/weekly/monthly counter
// Simply store the salt from cache away in database...
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_surfbar_salts` SET last_salt='%s' WHERE url_id=%s AND userid=%s LIMIT 1",
- array(SURFBAR_GET_SALT(), SURFBAR_GET_ID(), $GLOBALS['userid']), __FUNCTION__, __LINE__);
+ array(SURFBAR_GET_SALT(), SURFBAR_GET_ID(), getUserId()), __FUNCTION__, __LINE__);
// Debug message
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "salt=".SURFBAR_GET_SALT().",id=".SURFBAR_GET_ID().",uid=".$GLOBALS['userid']."", false);
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "salt=".SURFBAR_GET_SALT().",id=".SURFBAR_GET_ID().",uid=".getUserId()."", false);
// Was that okay?
if (SQL_AFFECTEDROWS() < 1) {
// Insert missing entry!
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_salts` (url_id,userid,last_salt) VALUES (%s, %s, '%s')",
- array(SURFBAR_GET_ID(), $GLOBALS['userid'], SURFBAR_GET_SALT()), __FUNCTION__, __LINE__);
+ array(SURFBAR_GET_ID(), getUserId(), SURFBAR_GET_SALT()), __FUNCTION__, __LINE__);
} // END - if
// Debug message
WHERE userid=%s AND url_id=%s AND (UNIX_TIMESTAMP() - ".SURFBAR_GET_SURF_LOCK().") < UNIX_TIMESTAMP(last_surfed)
ORDER BY last_surfed ASC
LIMIT 1",
- array($GLOBALS['userid'], bigintval($urlId)), __FUNCTION__, __LINE__
+ array(getUserId(), bigintval($urlId)), __FUNCTION__, __LINE__
);
// Fetch counter
// Do we have a current user id?
if ((IS_MEMBER()) && ($limit == 0)) {
// Then add this as well
- $UIDs['uid'][$GLOBALS['userid']] = $GLOBALS['userid'];
- $UIDs['points'][$GLOBALS['userid']] = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points") - GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");
- $UIDs['notified'][$GLOBALS['userid']] = 0;
+ $UIDs['uid'][getUserId()] = getUserId();
+ $UIDs['points'][getUserId()] = GET_TOTAL_DATA(getUserId(), "user_points", "points") - GET_TOTAL_DATA(getUserId(), "user_data", "used_points");
+ $UIDs['notified'][getUserId()] = 0;
// Get all userid except logged in one
$result = SQL_QUERY_ESC("SELECT u.userid, UNIX_TIMESTAMP(d.surfbar_low_notified) AS notified
WHERE u.userid NOT IN (%s,0) AND u.`status`='ACTIVE'
GROUP BY u.userid
ORDER BY u.userid ASC",
- array($GLOBALS['userid']), __FUNCTION__, __LINE__);
+ array(getUserId()), __FUNCTION__, __LINE__);
} else {
// Get all userid
$result = SQL_QUERY("SELECT u.userid, UNIX_TIMESTAMP(d.surfbar_low_notified) AS notified
SQL_FREERESULT($result);
// Debug message
- //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "UIDs::count=".count($UIDs)." (with own userid=".$GLOBALS['userid'].")", false);
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "UIDs::count=".count($UIDs)." (with own userid=".getUserId().")", false);
// Return result
return $UIDs;
WHERE
userid=%s
ORDER BY
- id ASC", array($GLOBALS['userid']),
+ id ASC", array(getUserId()),
__FUNCTION__, __LINE__);
// Load all entries
FROM `{!_MYSQL_PREFIX!}_surfbar_urls` AS u
WHERE u.userid=%s AND u.status != 'DELETED'
ORDER BY u.id ASC",
- array($GLOBALS['userid']), __FUNCTION__, __LINE__);
+ array(getUserId()), __FUNCTION__, __LINE__);
// Are there entries?
if (SQL_NUMROWS($result) > 0) {
ON sbu.id=l.url_id
WHERE sbu.userid != %s AND sbu.`status`='ACTIVE' AND sbu.id=%s AND (sbu.views_allowed=0 OR (sbu.views_allowed > 0 AND sbu.views_max > 0))
LIMIT 1",
- array($GLOBALS['userid'], bigintval($urlId)), __FUNCTION__, __LINE__
+ array(getUserId(), bigintval($urlId)), __FUNCTION__, __LINE__
);
}
// Update global array
// @TODO Make this filter working: $URL = runFilterChain('do_login', array('uid' => $uid, 'hash' => $hash, 'addon' => $ADDON));
- $GLOBALS['userid'] = $uid;
+ setUserId($uid);
// Try to set session data (which shall normally always work!)
if ((set_session('userid', $uid )) && (set_session('u_hash', $hash))) {
$result = false;
// Prepare the purpose
- $eval = "\$purpose = \"".COMPILE_CODE(sprintf(WERNIS_API_PURPOSE_WITHDRAW, $GLOBALS['userid']))."\";";
+ $eval = "\$purpose = \"".COMPILE_CODE(sprintf(WERNIS_API_PURPOSE_WITHDRAW, getUserId()))."\";";
eval($eval);
// Prepare the request data
$result = false;
// Prepare the purpose
- $eval = "\$purpose = \"".COMPILE_CODE(sprintf(getMessage('WERNIS_API_PURPOSE_PAYOUT'), $GLOBALS['userid']))."\";";
+ $eval = "\$purpose = \"".COMPILE_CODE(sprintf(getMessage('WERNIS_API_PURPOSE_PAYOUT'), getUserId()))."\";";
eval($eval);
// Prepare the request data
function WERNIS_LOG_TRANSFER ($wdsId, $amount, $type = 'FAILED', $message = "", $status = "") {
// Register this wernis movement
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_wernis` (`userid`, `wernis_account`, `wernis_amount`, `wernis_timestamp`, `wernis_type`, `wernis_api_message`, `wernis_api_status`) VALUES (%d, %d, %d, UNIX_TIMESTAMP(), '%s', '%s', '%s')",
- array($GLOBALS['userid'], bigintval($wdsId), bigintval($amount), $type, $message, $status), __FUNCTION__, __LINE__);
+ array(getUserId(), bigintval($wdsId), bigintval($amount), $type, $message, $status), __FUNCTION__, __LINE__);
}
// Take fees and factor
//* DEBUG: */ echo "mode={$mode},points={$points}<br />\n";
if (!in_array($mode, array('payout', 'withdraw'))) {
// Log error and abort
- DEBUG_LOG(__FUNCTION__, __LINE__, "uid={$GLOBALS['userid']},mode={$mode},points={$points}");
+ DEBUG_LOG(__FUNCTION__, __LINE__, "uid={getUserId()},mode={$mode},points={$points}");
return false;
} // END - if
// Initial message part
$MSG = "<strong>{--VALIDATING_LOGIN--}</strong>";
-if (!empty($GLOBALS['userid']) && (isSessionVariableSet('u_hash'))) {
+if (isUserIdSet() && (isSessionVariableSet('u_hash'))) {
// Login failures are supported since 0.4.7
// Do we have 0.4.7 of sql_patches or later?
$ADD = "";
// Get theme from profile
$result = SQL_QUERY_ESC("SELECT curr_theme".$ADD." FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
// Load data
$data = SQL_FETCHARRAY($result);
SET login_failures=0, last_failure='0000-00-00 00:00:00'
WHERE userid=%s
LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
// Store it in session
set_session('mxchange_member_failures', $data['login_failures']);
WHERE userid=%s AND last_login < (UNIX_TIMESTAMP() - %s)
LIMIT 1",
array(
- $GLOBALS['userid'],
+ getUserId(),
getConfig('login_timeout')
), __FILE__, __LINE__
);
if (IS_MEMBER()) {
// Ok, test passed... :)
$result = SQL_QUERY_ESC("SELECT subject, url FROM `{!_MYSQL_PREFIX!}_pool` WHERE id=%s AND sender=%s AND data_type='TEMP' LIMIT 1",
- array(bigintval(REQUEST_GET('order')), $GLOBALS['userid']), __FILE__, __LINE__);
+ array(bigintval(REQUEST_GET('order')), getUserId()), __FILE__, __LINE__);
// Finally is the entry valid?
if (SQL_NUMROWS($result) == 1) {
$ADD = "";
// Already logged in?
-if ((!empty($GLOBALS['userid'])) && (isSessionVariableSet('u_hash'))) {
+if ((isUserIdSet()) && (isSessionVariableSet('u_hash'))) {
// Maybe, then continue with it
- $uid = $GLOBALS['userid'];
+ $uid = getUserId();
} elseif ((REQUEST_ISSET_POST(('id'))) && (REQUEST_ISSET_POST(('password'))) && (IS_FORM_SENT())) {
// Set userid and crypt password when login data was submitted
if ((EXT_IS_ACTIVE("nickname")) && (NICKNAME_PROBE_ON_USERID(REQUEST_POST('id')))) {
define('__RALLYE_CAN_WIN_THIS', RALLYE_OUR_WINNERS_ARE);
} else {
define('__RALLYE_PRICES', RALLYE_ADD_PRICES($id, "html"));
- define('__RALLYE_TOP_USERS', RALLYE_ADD_TOPUSERS($id, $GLOBALS['userid']));
+ define('__RALLYE_TOP_USERS', RALLYE_ADD_TOPUSERS($id, getUserId()));
define('__RALLYE_CAN_WIN_THIS', RALLYE_YOU_CAN_WIN);
}
// Add description as navigation point
ADD_DESCR("member", __FILE__);
-$uid = $GLOBALS['userid'];
+$uid = getUserId();
if (EXT_IS_ACTIVE("nickname"))
{
// Load nickname
// Set User-ID when no nickname was found
$nickname = true;
-if (empty($uid)) { $uid = $GLOBALS['userid']; $nickname = false; }
+if (empty($uid)) { $uid = getUserId(); $nickname = false; }
// Prepare constants
define('__BEG_UID' , $uid);
// Add description as navigation point
ADD_DESCR("member", __FILE__);
-$UID = $GLOBALS['userid'];
+$UID = getUserId();
$whereStatement = " WHERE `visible`='Y'";
if (IS_ADMIN()) $whereStatement = "";
// Transfer referal ID
if (EXT_IS_ACTIVE("nickname")) {
// Load nickname from DB
- $nick = NICKNAME_GET_NICK($GLOBALS['userid']);
+ $nick = NICKNAME_GET_NICK(getUserId());
if (!empty($nick)) {
// Set nickname
define('__USERID', $nick);
} else {
// Use direct userid
- define('__USERID', $GLOBALS['userid']);
+ define('__USERID', getUserId());
}
} else {
// Use direct userid
- define('__USERID', $GLOBALS['userid']);
+ define('__USERID', getUserId());
}
// Usage counter
}
// Generate table with already payed out doubles
-define('__DOUBLER_PAYOUT_HISTORY', DOUBLER_GENERATE_TABLE($GLOBALS['userid'], "Y", "N", "DESC"));
+define('__DOUBLER_PAYOUT_HISTORY', DOUBLER_GENERATE_TABLE(getUserId(), "Y", "N", "DESC"));
// Generate table with next-to-run payouts
-define('__DOUBLER_PAYOUT_NEXT', DOUBLER_GENERATE_TABLE($GLOBALS['userid']));
+define('__DOUBLER_PAYOUT_NEXT', DOUBLER_GENERATE_TABLE(getUserId()));
// Generate table with refferal payouts
-define('__DOUBLER_PAYOUT_REF', DOUBLER_GENERATE_TABLE($GLOBALS['userid'], "N", "Y", "DESC"));
+define('__DOUBLER_PAYOUT_REF', DOUBLER_GENERATE_TABLE(getUserId(), "N", "Y", "DESC"));
// Generate timemark
define('__TIMEOUT_MARK', CREATE_FANCY_TIME(getConfig('doubler_timeout')));
// Check for running mail orders in pool
$result1 = SQL_QUERY_ESC("SELECT timestamp FROM `{!_MYSQL_PREFIX!}_pool`
-WHERE sender=%s ORDER BY timestamp DESC LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
+WHERE sender=%s ORDER BY timestamp DESC LIMIT 1", array(getUserId()), __FILE__, __LINE__);
// Check for sent mail orders in stats
$result2 = SQL_QUERY_ESC("SELECT timestamp_ordered FROM `{!_MYSQL_PREFIX!}_user_stats`
-WHERE userid=%s ORDER BY timestamp_ordered DESC LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
+WHERE userid=%s ORDER BY timestamp_ordered DESC LIMIT 1", array(getUserId()), __FILE__, __LINE__);
if ((SQL_NUMROWS($result1) == 1) || (SQL_NUMROWS($result2) == 1)) {
// Mail order found!
} else {
// Everything went okay so let's store his request and send mails
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_holidays` (userid, holiday_start, holiday_end, comments) VALUES ('%s','%s','%s','%s')",
- array($GLOBALS['userid'], $START, $END, REQUEST_POST('comments')), __FILE__, __LINE__);
+ array(getUserId(), $START, $END, REQUEST_POST('comments')), __FILE__, __LINE__);
// Activate holiday system
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data`
SET holiday_active='N', holiday_activated=UNIX_TIMESTAMP()
WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
// Prepare constants
define('_START_DAY' , REQUEST_POST('start_day'));
define('_END_YEAR' , REQUEST_POST('end_year'));
// Send mail to member
- $msg = LOAD_EMAIL_TEMPLATE("member_holiday_request", REQUEST_POST('comments'), $GLOBALS['userid']);
- SEND_EMAIL($GLOBALS['userid'], getMessage('HOLIDAY_MEMBER_SUBJECT'), $msg);
+ $msg = LOAD_EMAIL_TEMPLATE("member_holiday_request", REQUEST_POST('comments'), getUserId());
+ SEND_EMAIL(getUserId(), getMessage('HOLIDAY_MEMBER_SUBJECT'), $msg);
// Send mail to all admins
- SEND_ADMIN_NOTIFICATION(getMessage('HOLIDAY_ADMIN_SUBJECT'), "admin_holiday_request", REQUEST_POST('comments'), $GLOBALS['userid']);
+ SEND_ADMIN_NOTIFICATION(getMessage('HOLIDAY_ADMIN_SUBJECT'), "admin_holiday_request", REQUEST_POST('comments'), getUserId());
// Create task
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (userid, assigned_admin, status, task_type, subject, text, task_created) VALUES ('%s','0','NEW','HOLIDAY_REQUEST','{--HOLIDAY_ADMIN_SUBJECT--}','%s', UNIX_TIMESTAMP())",
- array($GLOBALS['userid'], $msg), __FILE__, __LINE__);
+ array(getUserId(), $msg), __FILE__, __LINE__);
// Display message
LOAD_TEMPLATE("admin_settings_saved", false, getMessage('HOLIDAY_IS_ACTIVATED_NOW'));
{
// Okay, end the holiday here...
$result = SQL_QUERY_ESC("SELECT holiday_active, holiday_activated FROM `{!_MYSQL_PREFIX!}_user_data`
-WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
+WHERE userid=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__);
list($active, $locked) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
{
// Load data
$result = SQL_QUERY_ESC("SELECT holiday_start, holiday_end FROM `{!_MYSQL_PREFIX!}_user_holidays`
-WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
+WHERE userid=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1)
{
// Data was found
// Deactivate it now
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data`
SET holiday_active='N', holiday_activated='0'
-WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
+WHERE userid=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__);
// Remove entry
SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_holidays`
-WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
+WHERE userid=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__);
// Send email to admin
- SEND_ADMIN_NOTIFICATION(getMessage('HOLIDAY_ADMIN_DEAC_SUBJ'), "admin_holiday_deactivated", array(), $GLOBALS['userid']);
+ SEND_ADMIN_NOTIFICATION(getMessage('HOLIDAY_ADMIN_DEAC_SUBJ'), "admin_holiday_deactivated", array(), getUserId());
// Display message to user
LOAD_TEMPLATE("admin_settings_saved", false, getMessage('HOLIDAY_MEMBER_DEACTIVATED_NOW'));
{
// Check if user is in holiday...
$result = SQL_QUERY_ESC("SELECT holiday_active, holiday_activated FROM `{!_MYSQL_PREFIX!}_user_data`
-WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
+WHERE userid=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__);
list($active, $locked) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
case "Y": // Display deactivation form
// Load starting and ending date
$result = SQL_QUERY_ESC("SELECT holiday_start, holiday_end FROM `{!_MYSQL_PREFIX!}_user_holidays`
-WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
+WHERE userid=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1)
{
// Data was found
// Remove entry and reload URL
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data`
SET holiday_active='N'
-WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
+WHERE userid=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__);
LOAD_URL("modules.php?module=login&what=holiday");
return;
}
if (IS_FORM_SENT()) {
// Save settings
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET html='%s' WHERE userid=%s LIMIT 1",
- array(REQUEST_POST('html'), $GLOBALS['userid']), __FILE__, __LINE__);
+ array(REQUEST_POST('html'), getUserId()), __FILE__, __LINE__);
LOAD_TEMPLATE("admin_settings_saved", false, getMessage('MEMBER_SETTINGS_SAVED'));
} else {
// Load template for changing settings
$result = SQL_QUERY_ESC("SELECT html FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
list($mode) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
// Add description as navigation point
ADD_DESCR("member", __FILE__);
-define('UID_VALUE', $GLOBALS['userid']); $URL = "";
+define('UID_VALUE', getUserId()); $URL = "";
// Detect what the member wants to do
$MODE = "show"; // Show his data
case "notify": // Switch off notfication
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET notified='N', last_update=UNIX_TIMESTAMP() WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
$URL = "modules.php?module=login&what=welcome&msg=".urlencode(getMessage('PROFILE_UPDATED'));
break;
}
// Load status
$result = SQL_QUERY_ESC("SELECT nl_receive, nl_until, nl_timespan FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
list($status, $until, $span) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
if ((IS_FORM_SENT()) && ($status == "Y") && ($span == "0")) {
// Save request
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET nl_timespan='".(getConfig('one_day') * 30)."' WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
// Load admin message
- $admin_msg = LOAD_EMAIL_TEMPLATE("admin_newsletter_request", array(), $GLOBALS['userid']);
+ $admin_msg = LOAD_EMAIL_TEMPLATE("admin_newsletter_request", array(), getUserId());
// Add task
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (assigned_admin, status, task_type, subject, text, task_created, userid)
-VALUES ('0','NEW','NL_UNSUBSCRIBE','{--ADMIN_NL_SUBJECT--}','".$admin_msg."', UNIX_TIMESTAMP(),'%s')", array($GLOBALS['userid']), __FILE__, __LINE__);
+VALUES ('0','NEW','NL_UNSUBSCRIBE','{--ADMIN_NL_SUBJECT--}','".$admin_msg."', UNIX_TIMESTAMP(),'%s')", array(getUserId()), __FILE__, __LINE__);
// Send mail to member
- $msg = LOAD_EMAIL_TEMPLATE("member_newsletter_request", array(), $GLOBALS['userid']);
- SEND_EMAIL($GLOBALS['userid'], getMessage('NL_MEMBER_SUBJECT'), $msg);
+ $msg = LOAD_EMAIL_TEMPLATE("member_newsletter_request", array(), getUserId());
+ SEND_EMAIL(getUserId(), getMessage('NL_MEMBER_SUBJECT'), $msg);
// Send mail to all admins
- SEND_ADMIN_NOTIFICATION(getMessage('NL_ADMIN_SUBJECT'), "admin_newsletter_request", array(), $GLOBALS['userid']);
+ SEND_ADMIN_NOTIFICATION(getMessage('NL_ADMIN_SUBJECT'), "admin_newsletter_request", array(), getUserId());
// Display message
LOAD_TEMPLATE("admin_settings_saved", false, getMessage('NL_MEMBER_REQUEST_DONE'));
if ($VALID) {
// Look for nickname in database (we only need just one entry so don't worry about the "LIMIT 1" !
$result = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE nickname='%s' AND userid != '%s' LIMIT 1",
- array(REQUEST_POST('nickname'), $GLOBALS['userid']), __FILE__, __LINE__);
+ array(REQUEST_POST('nickname'), getUserId()), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 0) {
// Nickname not in use, so set it now
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET nickname='%s' WHERE userid=%s LIMIT 1",
- array(REQUEST_POST('nickname'), $GLOBALS['userid']), __FILE__, __LINE__);
+ array(REQUEST_POST('nickname'), getUserId()), __FILE__, __LINE__);
$content = NICKNAME_SAVED;
} else {
// Free result
SQL_FREERESULT($result);
// Nickname already in use!
- $content = NICKNAME_ALREADY_IN_USE;
+ $content = getMessage('NICKNAME_ALREADY_IN_USE');
}
// Load template
LOAD_TEMPLATE("admin_settings_saved", false, $content);
} else {
// Load current nickname
- define('__NICKNAME', NICKNAME_GET_NICK($GLOBALS['userid']));
+ define('__NICKNAME', NICKNAME_GET_NICK(getUserId()));
// Do we have already submit the form?
if (REQUEST_ISSET_POST(('nickname'))) {
define('__MIN_VALUE', getConfig('order_min'));
// Count unconfirmed mails
-$links = GET_TOTAL_DATA($GLOBALS['userid'], "user_links", "id", "userid", true);
+$links = GET_TOTAL_DATA(getUserId(), "user_links", "id", "userid", true);
// Does the user has more than 0 mails per day set?
$HOLIDAY = "userid";
$result_mmails = SQL_QUERY_ESC("SELECT userid, receive_mails, mail_orders, ".$HOLIDAY."
FROM `{!_MYSQL_PREFIX!}_user_data`
WHERE userid=%s AND max_mails > 0 LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
$mmails = SQL_NUMROWS($result_mmails);
list($DMY, $MAXI, $ORDERS, $HOLIDAY) = SQL_FETCHROW($result_mmails);
if (getConfig('order_max_full') == "MAX") $ALLOWED = $MAXI;
// Now check his points amount
-$TOTAL = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points") - GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");;
+$TOTAL = GET_TOTAL_DATA(getUserId(), "user_points", "points") - GET_TOTAL_DATA(getUserId(), "user_data", "used_points");;
if (($HOLIDAY == "Y") && (GET_EXT_VERSION("holiday") >= "0.1.3")) {
// Holiday is active!
$result = SQL_QUERY_ESC("SELECT id, data_type
FROM `{!_MYSQL_PREFIX!}_pool`
WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
- array($GLOBALS['userid'], REQUEST_POST('url'), getConfig('url_tlock')), __FILE__, __LINE__);
+ array(getUserId(), REQUEST_POST('url'), getConfig('url_tlock')), __FILE__, __LINE__);
$type = "TEMP"; $id = 0;
if (SQL_NUMROWS($result) == 1) {
ORDER BY d.%s %s",
array(
bigintval(REQUEST_POST('cat')),
- $GLOBALS['userid'],
+ getUserId(),
getConfig('order_select'),
getConfig('order_mode'),
), __FILE__, __LINE__);
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_pool` (sender, subject, text, receivers, payment_id, data_type, timestamp, url, cat_id, target_send, zip, html_msg)
VALUES ('%s','%s','%s','%s','%s','TEMP','%s','%s','%s','%s','%s','%s')",
array(
- $GLOBALS['userid'],
+ getUserId(),
REQUEST_POST('subject'),
REQUEST_POST('text'),
$RECEIVER,
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_pool` (sender, subject, text, receivers, payment_id, data_type, timestamp, url, cat_id, target_send, zip)
VALUES ('%s','%s','%s','%s','%s','TEMP','%s','%s','%s','%s','%s')",
array(
- $GLOBALS['userid'],
+ getUserId(),
REQUEST_POST('subject'),
REQUEST_POST('text'),
$RECEIVER,
// Order is placed as temporary. We need to get it's id for the frametester
$result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_pool` WHERE sender=%s AND subject='%s' AND payment_id=%s AND data_type='TEMP' AND timestamp=%s LIMIT 1",
array(
- $GLOBALS['userid'],
+ getUserId(),
REQUEST_POST('subject'),
bigintval(REQUEST_POST('type')),
$TIME
// Select users in current category
$result_uids = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_cats` WHERE cat_id=%s AND userid != '%s' ORDER BY userid",
- array(bigintval($content['id']), $GLOBALS['userid']), __FILE__, __LINE__);
+ array(bigintval($content['id']), getUserId()), __FILE__, __LINE__);
$uid_cnt = 0;
while (list($ucat) = SQL_FETCHROW($result_uids)) {
// Check if we already have an order placed and make it editable
$result = SQL_QUERY_ESC("SELECT subject, text, payment_id, timestamp, url, target_send, cat_id, zip FROM `{!_MYSQL_PREFIX!}_pool` WHERE sender=%s AND data_type='TEMP' LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Old order found
while ($content = SQL_FETCHARRAY($result_depths)) {
// Load referal points
$result_points = SQL_QUERY_ESC("SELECT points FROM `{!_MYSQL_PREFIX_user_points!}` WHERE userid=%s AND ref_depth=%d LIMIT 1",
- array($GLOBALS['userid'], bigintval($content['level'])), __FILE__, __LINE__);
+ array(getUserId(), bigintval($content['level'])), __FILE__, __LINE__);
// Entry found?
if (SQL_NUMROWS($result_points) == 1) {
SQL_FREERESULT($result_depths);
// Get used points
-$USED = GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");
+$USED = GET_TOTAL_DATA(getUserId(), "user_data", "used_points");
// Translate point into comma
$TPTS = TRANSLATE_COMMA($TPTS - $USED);
ON p.payout_id = t.id
WHERE p.userid = %s
ORDER BY p.payout_timestamp DESC",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
if (SQL_NUMROWS($result_payouts) > 0) {
// List all his requests
$OUT = ""; $SW = 2;
define('PAYOUT_POINTS_VALUE', $PAYOUT);
// Subtract points from member's account
- SUB_POINTS("payout", $GLOBALS['userid'], $PAYOUT);
+ SUB_POINTS("payout", getUserId(), $PAYOUT);
// Add entry to his tranfer history
if ($content['allow'] == "Y") {
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_payouts` (userid, payout_total, payout_id, payout_timestamp, status, target_url, link_text, banner_url)
VALUES (%s,%s,%s, UNIX_TIMESTAMP(), 'NEW','%s','%s','%s')",
array(
- $GLOBALS['userid'],
+ getUserId(),
bigintval(REQUEST_POST('payout')),
bigintval(REQUEST_GET('payout')),
REQUEST_POST('turl'),
), __FILE__, __LINE__);
// Load templates
- $msg_mem = LOAD_EMAIL_TEMPLATE("member_payout_request_banner", array(), $GLOBALS['userid']);
+ $msg_mem = LOAD_EMAIL_TEMPLATE("member_payout_request_banner", array(), getUserId());
if (GET_EXT_VERSION("admins") >= "0.4.1") {
$adm_tpl = "admin_payout_request_banner";
} else {
- $msg_adm = LOAD_EMAIL_TEMPLATE("admin_payout_request_banner", array(), $GLOBALS['userid']);
+ $msg_adm = LOAD_EMAIL_TEMPLATE("admin_payout_request_banner", array(), getUserId());
}
} else {
// e-currency payout requested
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_payouts` (userid, payout_total, target_account, target_bank, payout_id, payout_timestamp, status, password)
VALUES (%s,%s,%s,'%s',%s, UNIX_TIMESTAMP(), 'NEW','%s')",
array(
- $GLOBALS['userid'],
+ getUserId(),
bigintval(REQUEST_POST('payout')),
bigintval(REQUEST_POST('account')),
REQUEST_POST('bank'),
), __FILE__, __LINE__);
// Load templates
- $msg_mem = LOAD_EMAIL_TEMPLATE("member_payout_request", array(), $GLOBALS['userid']);
- $msg_adm = LOAD_EMAIL_TEMPLATE("admin_payout_request", array(), $GLOBALS['userid']);
+ $msg_mem = LOAD_EMAIL_TEMPLATE("member_payout_request", array(), getUserId());
+ $msg_adm = LOAD_EMAIL_TEMPLATE("admin_payout_request", array(), getUserId());
$admin_tpl = "";
if (GET_EXT_VERSION("admins") >= "0.4.1")
{
VALUES (0, 'NEW','PAYOUT_REQUEST','[payout:] {--PAYOUT_REQUEST_ADMIN--}','%s', UNIX_TIMESTAMP(), %s)",
array(
$msg_adm,
- $GLOBALS['userid']
+ getUserId()
), __FILE__, __LINE__);
// Send out mails
- SEND_EMAIL($GLOBALS['userid'], getMessage('PAYOUT_REQUEST_MEMBER'), $msg_mem);
+ SEND_EMAIL(getUserId(), getMessage('PAYOUT_REQUEST_MEMBER'), $msg_mem);
// To admin(s)
- SEND_ADMIN_NOTIFICATION(getMessage('PAYOUT_REQUEST_ADMIN'), $admin_tpl, array(), $GLOBALS['userid']);
+ SEND_ADMIN_NOTIFICATION(getMessage('PAYOUT_REQUEST_ADMIN'), $admin_tpl, array(), getUserId());
// Load template and output it
LOAD_TEMPLATE("admin_settings_saved", false, getMessage('PAYOUT_REQUEST_SENT'));
$REFS = 0;
// Load referal points
- $result_points = SQL_QUERY_ESC("SELECT points, locked_points FROM `{!_MYSQL_PREFIX!}_user_points` WHERE userid=%s AND ref_depth=%d LIMIT 1", array($GLOBALS['userid'], bigintval($content['level'])), __FILE__, __LINE__);
+ $result_points = SQL_QUERY_ESC("SELECT points, locked_points FROM `{!_MYSQL_PREFIX!}_user_points` WHERE userid=%s AND ref_depth=%d LIMIT 1", array(getUserId(), bigintval($content['level'])), __FILE__, __LINE__);
if (SQL_NUMROWS($result_points) == 1) {
list($points, $locked) = SQL_FETCHROW($result_points);
SQL_FREERESULT($result_points);
// Load referal counts
$result_refs = SQL_QUERY_ESC("SELECT counter FROM `{!_MYSQL_PREFIX!}_refsystem` WHERE userid=%s AND level='%s' LIMIT 1",
- array($GLOBALS['userid'], bigintval($content['level'])), __FILE__, __LINE__);
+ array(getUserId(), bigintval($content['level'])), __FILE__, __LINE__);
if (SQL_NUMROWS($result_refs) == 1) {
list($REFS) = SQL_FETCHROW($result_refs);
SQL_FREERESULT($result_refs);
define('__REF_LEVEL_ROWS', $OUT);
$result = SQL_QUERY_ESC("SELECT used_points, ref_payout FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
list($USED, $PAY) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
if (GET_EXT_VERSION("user") >= "0.1.4") {
$ADD = ", emails_sent, emails_received";
}
- $result = SQL_QUERY_ESC("SELECT mails_confirmed".$ADD." FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT mails_confirmed".$ADD." FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__);
list($CONFIRMED, $SENT, $RECEIVED) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
// Load data
$result = SQL_QUERY_ESC("SELECT login_bonus, turbo_bonus".$ADD." FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
// We don't add this points now. This will be done after each month
list($login, $turbo, $ref, $order, $stats) = SQL_FETCHROW($result);
// Get Primus id
$result = SQL_QUERY_ESC("SELECT primera_userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
// Are there some entries?
if (SQL_NUMROWS($result) == 1) {
// And load all rows!
$result = SQL_QUERY_ESC("SELECT `id`, `primera_account`, `primera_amount`, `primera_timestamp`, `primera_type` FROM `{!_MYSQL_PREFIX!}_user_primera` WHERE `userid` = %s ORDER BY `primera_timestamp` DESC",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
// Load all rows
$content['rows'] = ""; $SW = 2;
} // END - if
if (REQUEST_GET('mode') == "pay") {
// Get total points and check if the user can request a payout
- $points = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points") - GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");
+ $points = GET_TOTAL_DATA(getUserId(), "user_points", "points") - GET_TOTAL_DATA(getUserId(), "user_data", "used_points");
// No dots here...
$points = explode(".", $points);
// Get Primera id
$content['primera_nickname'] = "";
$result = SQL_QUERY_ESC("SELECT primera_userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
// Are there some entries?
if (SQL_NUMROWS($result) == 1) {
} // END - if
// Remove points from account
- SUB_POINTS("primera_payout", $GLOBALS['userid'], REQUEST_POST('amount'));
+ SUB_POINTS("primera_payout", getUserId(), REQUEST_POST('amount'));
// Update primera nickname
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `primera_userid`=%s WHERE userid=%s LIMIT 1",
- array(REQUEST_POST('primera_nickname'), $GLOBALS['userid']), __FILE__, __LINE__);
+ array(REQUEST_POST('primera_nickname'), getUserId()), __FILE__, __LINE__);
// All done!
LOAD_TEMPLATE("admin_settings_saved", false, getMessage('PRIMERA_MEMBER_PAYOUT_DONE'));
define('__RALLYE_CAN_WIN_THIS', getMessage('RALLYE_OUR_WINNERS_ARE'));
} else {
define('__RALLYE_PRICES', RALLYE_ADD_PRICES($id, "html"));
- define('__RALLYE_TOP_USERS', RALLYE_ADD_TOPUSERS($id, $GLOBALS['userid']));
+ define('__RALLYE_TOP_USERS', RALLYE_ADD_TOPUSERS($id, getUserId()));
define('__RALLYE_CAN_WIN_THIS', getMessage('RALLYE_YOU_CAN_WIN'));
}
FROM `{!_MYSQL_PREFIX!}_refdepths` AS r
WHERE r.level > 0
ORDER BY r.level ASC",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
// Are there some entries? (Shall be!)
if (SQL_NUMROWS($result) > 0) {
$SW = 2;
// Check for users ref in this level
- foreach (GET_USER_REFS($GLOBALS['userid'], $content['level']) as $refRow) {
+ foreach (GET_USER_REFS(getUserId(), $content['level']) as $refRow) {
// Not-deleted account is default
$deleted = false;
if (is_null($refRow['status'])) $deleted = true;
// Load current referal clicks
$result = SQL_QUERY_ESC("SELECT ref_clicks FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
list($c) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
OUTPUT_HTML("<div class=\"tiny\">{--YOUR_PERSONAL_REFLINK--}:<br />
-<strong><a href=\"{!URL!}/ref.php?refid=".$GLOBALS['userid']."\" target=\"_blank\">{!URL!}/ref.php?ref=".$GLOBALS['userid']."</a></strong><br />
+<strong><a href=\"{!URL!}/ref.php?refid=".getUserId()."\" target=\"_blank\">{!URL!}/ref.php?ref=".getUserId()."</a></strong><br />
<br />");
if (EXT_IS_ACTIVE("nickname")) {
// Add nickname link when nickname is entered
- $nick = NICKNAME_GET_NICK($GLOBALS['userid']);
+ $nick = NICKNAME_GET_NICK(getUserId());
if (!empty($nick)) {
// Display nickname link
'alt' => $content['alternate'],
'cnt' => $content['counter'],
'cks' => $content['clicks'],
- 'uid' => $GLOBALS['userid'],
+ 'uid' => getUserId(),
'id' => $content['id'],
);
define('__REFLINKS_ROWS', $OUT);
// Load final template
- LOAD_TEMPLATE("member_reflinks_table", false, $GLOBALS['userid']);
+ LOAD_TEMPLATE("member_reflinks_table", false, getUserId());
} else {
// No refbanner found!
LOAD_TEMPLATE("admin_settings_saved", false, getMessage('MEMBER_NO_REFBANNER_FOUND'));
FROM `{!_MYSQL_PREFIX!}_refdepths` AS r
WHERE r.level > 0
ORDER BY r.level ASC",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
// Are there some entries? (Shall be!)
if (SQL_NUMROWS($result) > 0) {
$SW = 2;
// Check for users ref in this level
- foreach (GET_USER_REF_POINTS($GLOBALS['userid'], $content['level']) as $refRow) {
+ foreach (GET_USER_REF_POINTS(getUserId(), $content['level']) as $refRow) {
// Add/"translate" more content
$refRow['sw'] = $SW;
$refRow['points'] = TRANSLATE_COMMA($refRow['points']);
FROM `{!_MYSQL_PREFIX!}_pool`
WHERE sender=%s AND data_type != 'SEND'
ORDER BY timestamp DESC",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
// Are there mails left in pool?
if (SQL_NUMROWS($result) > 0) {
FROM `{!_MYSQL_PREFIX!}_user_stats`
WHERE userid=%s
ORDER BY timestamp_ordered DESC",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
if (SQL_NUMROWS($result) > 0) {
// Mail orders are in pool so we can display them
if (GET_EXT_VERSION("admins") >= "0.4.1") {
$a_tpl = "admin_support-".REQUEST_POST('qsummary');
} else {
- $msg_a = LOAD_EMAIL_TEMPLATE("admin_support-".REQUEST_POST('qsummary'), array('text' => REQUEST_POST('qdetails')), $GLOBALS['userid']);
+ $msg_a = LOAD_EMAIL_TEMPLATE("admin_support-".REQUEST_POST('qsummary'), array('text' => REQUEST_POST('qdetails')), getUserId());
}
- $msg_m = LOAD_EMAIL_TEMPLATE("member_support-".REQUEST_POST('qsummary'), array('text' => REQUEST_POST('qdetails')), $GLOBALS['userid']);
+ $msg_m = LOAD_EMAIL_TEMPLATE("member_support-".REQUEST_POST('qsummary'), array('text' => REQUEST_POST('qdetails')), getUserId());
// Select right subject
switch (REQUEST_POST('qsummary')) {
} // END - switch
// Send mail to admin
- SEND_ADMIN_NOTIFICATION($subj_a, $a_tpl, array('text' => REQUEST_POST('qdetails')), $GLOBALS['userid']);
+ SEND_ADMIN_NOTIFICATION($subj_a, $a_tpl, array('text' => REQUEST_POST('qdetails')), getUserId());
// Send mail to user
- SEND_EMAIL($GLOBALS['userid'], $subj_m, $msg_m);
+ SEND_EMAIL(getUserId(), $subj_m, $msg_m);
// Drop a message in the admin's area
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_task_system` (userid, assigned_admin, status, task_type, subject, text, task_created) VALUES ('%s','0','NEW','SUPPORT_MEMBER','%s','%s', UNIX_TIMESTAMP())",
- array($GLOBALS['userid'], $subj_a, REQUEST_POST('qsummary').":".array('text' => REQUEST_POST('qdetails'))), __FILE__, __LINE__);
+ array(getUserId(), $subj_a, REQUEST_POST('qsummary').":".array('text' => REQUEST_POST('qdetails'))), __FILE__, __LINE__);
// Form sent
LOAD_TEMPLATE("member_support_contcted");
if (REQUEST_ISSET_POST(('member_theme'))) {
// Save theme to member's profile
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET curr_theme='%s' WHERE userid=%s LIMIT 1",
- array(REQUEST_POST('member_theme'), $GLOBALS['userid']), __FILE__, __LINE__);
+ array(REQUEST_POST('member_theme'), getUserId()), __FILE__, __LINE__);
// Set new theme for guests
$newTheme = SQL_ESCAPE(REQUEST_POST('member_theme'));
// Load data
$result = SQL_QUERY_ESC("SELECT opt_in FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
list($opt_in) = SQL_FETCHROW($result);
// Free memory
{
case "new": // Start new transfer
// Get total points and subtract the balance amount from it = maximum transferable points
- $total = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points") - GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");
+ $total = GET_TOTAL_DATA(getUserId(), "user_points", "points") - GET_TOTAL_DATA(getUserId(), "user_data", "used_points");
// Remember maximum value for template
define('__TRANSFER_MAX_VALUE', round($total - getConfig('transfer_balance') - 0.5));
// Add new transfer
if (getConfig('transfer_code') > 0) {
// Check for code
- $code = generateRandomCodde(getConfig('transfer_code'), REQUEST_POST('code_chk'), $GLOBALS['userid'], constant('__TRANSFER_MAX_VALUE'));
+ $code = generateRandomCodde(getConfig('transfer_code'), REQUEST_POST('code_chk'), getUserId(), constant('__TRANSFER_MAX_VALUE'));
$valid_code = ($code == REQUEST_POST('code'));
} else {
// Zero length (= disabled) is always valid!
// Re-check receivers and own personal data
$result = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email".$ADD." FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid IN ('%s','%s') AND `status`='CONFIRMED' ORDER BY userid LIMIT 2",
- array($GLOBALS['userid'], bigintval(REQUEST_POST('to_uid'))), __FILE__, __LINE__);
+ array(getUserId(), bigintval(REQUEST_POST('to_uid'))), __FILE__, __LINE__);
$valid_data = (SQL_NUMROWS($result) == 2);
if ($valid_code && $valid_pass && $valid_amount && $valid_reason && $valid_recipient) {
list($uid2, $gender2, $sname2, $fname2, $email2, $nick2) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
// @TODO Rewrite all these constants to array elements
- if ($uid1 == $GLOBALS['userid']) {
+ if ($uid1 == getUserId()) {
// Data row 1 is sender's data
define('__SENDER_GENDER' , TRANSLATE_GENDER($gender1));
define('__SENDER_NICK' , $nick1);
}
// Sender's UID is always currently stored in cookie userid...
- define('__SENDER_UID' , $GLOBALS['userid']);
+ define('__SENDER_UID' , getUserId());
define('__RECIPIENT_UID' , REQUEST_POST('to_uid'));
$SENDER = constant('__SENDER_UID');
define('__TRANSFER_EXPIRES', CREATE_FANCY_TIME(getConfig('transfer_age')));
// Generate tranafer id
- define('__TRANS_ID', bigintval(generateRandomCodde("10", mt_rand(0, 99999), $GLOBALS['userid'], REQUEST_POST('reason'))));
+ define('__TRANS_ID', bigintval(generateRandomCodde("10", mt_rand(0, 99999), getUserId(), REQUEST_POST('reason'))));
// Add entries to both tables
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_transfers_in` (userid, from_uid, points, reason, time_trans, trans_id) VALUES ('%s','%s','%s','%s', UNIX_TIMESTAMP(),'%s')",
- array(bigintval(REQUEST_POST('to_uid')), $GLOBALS['userid'], bigintval(REQUEST_POST('points')), REQUEST_POST('reason'), __TRANS_ID),
+ array(bigintval(REQUEST_POST('to_uid')), getUserId(), bigintval(REQUEST_POST('points')), REQUEST_POST('reason'), __TRANS_ID),
__FILE__, __LINE__);
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_transfers_out` (userid, to_uid, points, reason, time_trans, trans_id) VALUES ('%s','%s','%s','%s', UNIX_TIMESTAMP(),'%s')",
- array($GLOBALS['userid'], bigintval(REQUEST_POST('to_uid')), bigintval(REQUEST_POST('points')), REQUEST_POST('reason'), __TRANS_ID),
+ array(getUserId(), bigintval(REQUEST_POST('to_uid')), bigintval(REQUEST_POST('points')), REQUEST_POST('reason'), __TRANS_ID),
__FILE__, __LINE__);
// Add points to account *directly* ...
ADD_POINTS_REFSYSTEM("member_transfer", bigintval(REQUEST_POST('to_uid')), bigintval(REQUEST_POST('points')), false, "0", false, "direct");
// ... and add it to current user's used points
- SUB_POINTS("transfer", $GLOBALS['userid'], REQUEST_POST('points'));
+ SUB_POINTS("transfer", getUserId(), REQUEST_POST('points'));
// First send email to recipient
$msg = LOAD_EMAIL_TEMPLATE("member_transfer_recipient", "", constant('__RECIPIENT_UID'));
if (EXT_IS_ACTIVE("nickname")) {
// Load userid and nickname
$result = SQL_QUERY_ESC("SELECT userid, nickname FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `status`='CONFIRMED' AND opt_in='Y' AND userid != '%s' ORDER BY userid",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
} else {
// Load only userid
$result = SQL_QUERY_ESC("SELECT userid, userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `status`='CONFIRMED' AND opt_in='Y' AND userid != '%s' ORDER BY userid",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
}
if (SQL_NUMROWS($result) > 0) {
// Generate Code
if (getConfig('transfer_code') > 0) {
$rand = mt_rand(0, 99999);
- $code = generateRandomCodde(getConfig('transfer_code'), $rand, $GLOBALS['userid'], constant('__TRANSFER_MAX_VALUE'));
+ $code = generateRandomCodde(getConfig('transfer_code'), $rand, getUserId(), constant('__TRANSFER_MAX_VALUE'));
$img = GENERATE_IMAGE($code, false);
define('__TRANSFER_IMAGE_INPUT', "<input type=\"hidden\" name=\"code_chk\" value=\"".$rand."\" /><input type=\"text\" name=\"code\" class=\"member_normal\" size=\"5\" maxlength=\"7\"{!__TRANSFER_TO_DISABLED!} /> ".$img);
} else {
// Run the SQL command
$total = 0;
- $result = SQL_QUERY_ESC($sql, array($GLOBALS['userid']), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC($sql, array(getUserId()), __FILE__, __LINE__);
if (SQL_NUMROWS($result) > 0) {
$OUT = ""; $SW = 2;
// @TODO This should be somehow rewritten to $content = SQL_FETCHARRAY(), see switch() block above for SQL queries
// Let's begin with the incoming list
$result = SQL_QUERY_ESC("SELECT trans_id, from_uid, points, reason, time_trans FROM `{!_MYSQL_PREFIX!}_user_transfers_in` WHERE userid=%s ORDER BY `id` LIMIT %s",
-array($GLOBALS['userid'], getConfig('transfer_max')), __FILE__, __LINE__);
+array(getUserId(), getConfig('transfer_max')), __FILE__, __LINE__);
while ($DATA = SQL_FETCHROW($result)) {
$DATA[] = "IN";
$DATA = implode("','", $DATA);
// As the last table transfer data from outgoing table to temporary
$result = SQL_QUERY_ESC("SELECT trans_id, to_uid, points, reason, time_trans FROM `{!_MYSQL_PREFIX!}_user_transfers_out` WHERE userid=%s ORDER BY `id` LIMIT %s",
-array($GLOBALS['userid'], getConfig('transfer_max')), __FILE__, __LINE__);
+array(getUserId(), getConfig('transfer_max')), __FILE__, __LINE__);
while ($DATA = SQL_FETCHROW($result)) {
$DATA[] = "OUT";
$DATA = implode("','", $DATA);
case "": // Overview page
// Check incoming transfers
- $result = SQL_QUERY_ESC("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_user_transfers_in` WHERE userid=%s", array($GLOBALS['userid']), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_user_transfers_in` WHERE userid=%s", array(getUserId()), __FILE__, __LINE__);
list($dmy) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
}
// Check outgoing transfers
- $result = SQL_QUERY_ESC("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_user_transfers_out` WHERE userid=%s", array($GLOBALS['userid']), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_user_transfers_out` WHERE userid=%s", array(getUserId()), __FILE__, __LINE__);
list($dmy) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
if (IS_FORM_SENT()) {
// Save settings
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET opt_in='%s' WHERE userid=%s LIMIT 1",
- array(REQUEST_POST('opt_in'), $GLOBALS['userid']), __FILE__, __LINE__);
+ array(REQUEST_POST('opt_in'), getUserId()), __FILE__, __LINE__);
// Rember for next switch() command
$opt_in = REQUEST_POST('opt_in');
FROM `{!_MYSQL_PREFIX!}_user_transfers_out`
WHERE time_trans > (UNIX_TIMESTAMP() - %s) AND userid=%s
ORDER BY time_trans DESC
-LIMIT 1", array(getConfig('transfer_timeout'), $GLOBALS['userid']), __FILE__, __LINE__);
+LIMIT 1", array(getConfig('transfer_timeout'), getUserId()), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 0) {
// Load template
define('__TRANSFER_SETTINGS_CONTENT', LOAD_TEMPLATE("member_transfer_settings", true));
$content['is_notify'] = TRANSLATE_YESNO($content['is_notify']);
$content['sender'] = _ADMIN_SHORT;
$content['time'] = CREATE_FANCY_TIME($content['time']);
- $content['uid'] = $GLOBALS['userid'];
+ $content['uid'] = getUserId();
// Get timestamp from insert
$content['user_status'] = sprintf(getMessage('MEMBER_MAIL_BONUS_CONFIRMED_ON'),
$content['category'] = GET_CATEGORY($content['cat_id']);
$content['points'] = TRANSLATE_COMMA($content['points']);
$content['time'] = CREATE_FANCY_TIME($content['time']);
- $content['uid'] = $GLOBALS['userid'];
+ $content['uid'] = getUserId();
// Get timestamp from insert
$content['user_status'] = sprintf(getMessage('MEMBER_MAIL_NORMAL_CONFIRMED_ON'),
if (EXT_IS_ACTIVE("bonus")) {
// Load bonus ID
$result = SQL_QUERY_ESC("SELECT stats_id, bonus_id, link_type FROM `{!_MYSQL_PREFIX!}_user_links` WHERE userid=%s ORDER BY bonus_id DESC, stats_id DESC",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
} else {
// Don't load bonus ID
$result = SQL_QUERY_ESC("SELECT stats_id, stats_id, link_type FROM `{!_MYSQL_PREFIX!}_user_links` WHERE userid=%s ORDER BY stats_id DESC",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
}
// Mails left for confirmation?
// Prepare data for template
$content = array(
'sw' => $SW,
- 'uid' => $GLOBALS['userid'],
+ 'uid' => getUserId(),
'data' => bigintval($DATA),
'type' => $type,
'subject' => $subject,
// Chedk if he is returning from a profile update notification
$result = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE notified='Y' AND userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
if ((SQL_NUMROWS($result) == 1) && (EXT_IS_ACTIVE("profile"))) {
// Yes, he is so let's place him his wanted buttons
// Get WDS66 id
$result = SQL_QUERY_ESC("SELECT wernis_userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
// Are there some entries?
if (SQL_NUMROWS($result) == 1) {
// And load all rows!
$result = SQL_QUERY_ESC("SELECT `id`, `wernis_account`, `wernis_amount`, `wernis_timestamp`, `wernis_type` FROM `{!_MYSQL_PREFIX!}_user_wernis` WHERE `userid` = %s ORDER BY `wernis_timestamp` DESC",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
// Load all rows
$content['rows'] = ""; $SW = 2;
}
} elseif ((REQUEST_GET('mode') == "payout") && (getConfig('wernis_payout_active') == "Y")) {
// Get total points and check if the user can request a payout
- $points = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points") - GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");
+ $points = GET_TOTAL_DATA(getUserId(), "user_points", "points") - GET_TOTAL_DATA(getUserId(), "user_data", "used_points");
// Remove the registration fee
$points = $points - getConfig('points_register');
// Get WDS66 id
$content['wds66_id'] = "";
$result = SQL_QUERY_ESC("SELECT wernis_userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
// Are there some entries?
if (SQL_NUMROWS($result) == 1) {
SQL_FREERESULT($result);
} elseif ((REQUEST_GET('mode') == "withdraw") && (getConfig('wernis_withdraw_active') == "Y")) {
// Get total points for just displaying them
- $points = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points") - GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");
+ $points = GET_TOTAL_DATA(getUserId(), "user_points", "points") - GET_TOTAL_DATA(getUserId(), "user_data", "used_points");
// Prepare data for the template
$content['points'] = TRANSLATE_COMMA($points);
// Get WDS66 id
$result = SQL_QUERY_ESC("SELECT wernis_userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
// Are there some entries?
if (SQL_NUMROWS($result) == 1) {
if ($success) {
// Add it to this amount
unset($GLOBALS['ref_level']);
- ADD_POINTS_REFSYSTEM("wernis_withdraw", $GLOBALS['userid'], bigintval(REQUEST_POST('amount')), false, 0, false, "direct");
+ ADD_POINTS_REFSYSTEM("wernis_withdraw", getUserId(), bigintval(REQUEST_POST('amount')), false, 0, false, "direct");
// Update the user data as well..
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `wernis_userid`=%s WHERE userid=%s LIMIT 1",
- array(bigintval(REQUEST_POST('wds66_id')), $GLOBALS['userid']), __FILE__, __LINE__);
+ array(bigintval(REQUEST_POST('wds66_id')), getUserId()), __FILE__, __LINE__);
// All done!
LOAD_TEMPLATE("admin_settings_saved", false, getMessage('WERNIS_MEMBER_WITHDRAW_DONE'));
$success = WERNIS_EXECUTE_PAYOUT(REQUEST_POST('wds66_id'), REQUEST_POST('amount'));
if ($success) {
// Sub points
- SUB_POINTS("wernis_payout", $GLOBALS['userid'], REQUEST_POST('amount'));
+ SUB_POINTS("wernis_payout", getUserId(), REQUEST_POST('amount'));
// Update WDS66 id
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `wernis_userid`=%s WHERE userid=%s LIMIT 1",
- array(bigintval(REQUEST_POST('wds66_id')), $GLOBALS['userid']), __FILE__, __LINE__);
+ array(bigintval(REQUEST_POST('wds66_id')), getUserId()), __FILE__, __LINE__);
// All done!
LOAD_TEMPLATE("admin_settings_saved", false, getMessage('WERNIS_MEMBER_PAYOUT_DONE'));
// Update sending pool
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET data_type='%s' WHERE id=%s AND sender=%s AND data_type='TEMP' LIMIT 1",
- array($type, bigintval(REQUEST_GET('order')), $GLOBALS['userid']), __FILE__, __LINE__);
+ array($type, bigintval(REQUEST_GET('order')), getUserId()), __FILE__, __LINE__);
// Finally is the entry valid?
if (SQL_AFFECTEDROWS() == 1) {
// Load personal data...
$result = SQL_QUERY_ESC("SELECT gender, surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
list($gender, $sname, $fname, $email) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
// Load mail again... 0 1 2 3 4 5 6 7
$result = SQL_QUERY_ESC("SELECT subject, text, receivers, payment_id, timestamp, url, cat_id, target_send FROM `{!_MYSQL_PREFIX!}_pool` WHERE id=%s AND sender=%s LIMIT 1",
- array(bigintval(REQUEST_GET('order')), $GLOBALS['userid']), __FILE__, __LINE__);
+ array(bigintval(REQUEST_GET('order')), getUserId()), __FILE__, __LINE__);
$DATA = SQL_FETCHROW($result);
SQL_FREERESULT($result);
if (empty($DATA[0])) $DATA[0] = getMessage('DEFAULT_SUBJECT_LINE');
// Update used points
$ADD = "";
if (getConfig('order_max_full') == "ORDER") $ADD = ", mail_orders=mail_orders+1";
- SUB_POINTS("order", $GLOBALS['userid'], $USED);
+ SUB_POINTS("order", getUserId(), $USED);
// Prepare content
$content = array(
);
// Send an email to the user
- $msg_mem = LOAD_EMAIL_TEMPLATE("order-member", $content, $GLOBALS['userid']);
+ $msg_mem = LOAD_EMAIL_TEMPLATE("order-member", $content, getUserId());
SEND_EMAIL($email, getMessage('MEMBER_NEW_QUEUE'), $msg_mem);
// Notify admins about this
- SEND_ADMIN_NOTIFICATION(getMessage('ADMIN_NEW_QUEUE'), "order-admin", $content, $GLOBALS['userid']);
+ SEND_ADMIN_NOTIFICATION(getMessage('ADMIN_NEW_QUEUE'), "order-admin", $content, getUserId());
// Output back bottom
LOAD_TEMPLATE("member_order-back", false);
SEND_EMAIL($content['email'], getMessage('NL_MEMBER_RESET_SUBJECT'), $msg);
// Send email to admin
- SEND_ADMIN_NOTIFICATION(getMessage('NL_ADMIN_SUBJECT'), "admin_newsletter_reset", array(), $GLOBALS['userid']);
+ SEND_ADMIN_NOTIFICATION(getMessage('NL_ADMIN_SUBJECT'), "admin_newsletter_reset", array(), getUserId());
} // END - if
// Free memory
require($INC);
}
-// CFG: DEBUG-SQL (if enabled and DEBUG_MODE is enabled all SQL queries will be logged to debug.log)
-define('DEBUG_SQL', false);
-
// Non-database functions
require("inc/functions.php");
// Is the extension sql_patches installed and at least 0.3.6?
if (GET_EXT_VERSION("sql_patches") >= "0.3.6") {
// Generate random number
- if (isset($GLOBALS['userid'])) {
- define('RAND_NUMBER', generateRandomCodde(10, mt_rand(10000,32766), $GLOBALS['userid'], ""));
+ if (isset(getUserId())) {
+ define('RAND_NUMBER', generateRandomCodde(10, mt_rand(10000,32766), getUserId(), ""));
} else {
define('RAND_NUMBER', generateRandomCodde(10, mt_rand(10000,32766), 0, ""));
}
FIX_DELETED_COOKIES(array('userid', 'u_hash'));
// Are cookies set?
- if ((!empty($GLOBALS['userid'])) && (isSessionVariableSet('u_hash'))) {
+ if ((isUserIdSet()) && (isSessionVariableSet('u_hash'))) {
// Cookies are set with values, but are they valid?
$result = SQL_QUERY_ESC("SELECT password, status, last_module, last_online FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FUNCTION__, __LINE__);
+ array(getUserId()), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Load data from cookies
list($password, $status, $mod, $onl) = SQL_FETCHROW($result);
// Load hash
$result_main = SQL_QUERY_ESC("SELECT password FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s AND `status`='CONFIRMED' LIMIT 1",
- array($GLOBALS['userid']), __FUNCTION__, __LINE__);
+ array(getUserId()), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result_main) == 1) {
// Load hash from database
list($hashDB) = SQL_FETCHROW($result_main);
if (($hash == get_session('u_hash')) || (REQUEST_POST('pass1') == REQUEST_POST('pass2'))) {
// Load user's data
$result = SQL_QUERY_ESC("SELECT gender, surname, family, street_nr, country, zip, city, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s AND password='%s' LIMIT 1",
- array($GLOBALS['userid'], $hashDB), __FUNCTION__, __LINE__);
+ array(getUserId(), $hashDB), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Load the data
$DATA = SQL_FETCHROW($result);
} // END - if
// Load template
- $msg = LOAD_EMAIL_TEMPLATE("member_mydata_notify", $content, $GLOBALS['userid']);
+ $msg = LOAD_EMAIL_TEMPLATE("member_mydata_notify", $content, getUserId());
if (getConfig('admin_notify') == "Y") {
// The admin needs to be notified about a profile change
if (empty($content)) {
if ((!empty($sub_adm)) && (!empty($msg_admin))) {
// Send admin mail
- SEND_ADMIN_NOTIFICATION($sub_adm, $msg_admin, $content, $GLOBALS['userid']);
+ SEND_ADMIN_NOTIFICATION($sub_adm, $msg_admin, $content, getUserId());
} elseif (getConfig('admin_notify') == "Y") {
// Cannot send mails to admin!
$content = getMessage('CANNOT_SEND_ADMIN_MAILS');
$stamp = 0;
// User id set?
- if ((isset($GLOBALS['userid'])) && ($uid == 0)) {
- $uid = $GLOBALS['userid'];
+ if ((isUserIdSet()) && ($uid == 0)) {
+ $uid = getUserId();
} // END - if
// Is the extension installed and updated?
// Destroy user session
function destroy_user_session () {
// Reset userid
- $GLOBALS['userid'] = 0;
+ setUserId(0);
// Remove all user data from session
return ((set_session('userid', "")) && (set_session('u_hash', "")));
DETERMINE_REFID();
// Transfer userid from session and validate it
-if (isset($_SESSION['userid'])) {
+if (isSessionVariableSet('userid')) {
// Get it secured from session
- $GLOBALS['userid'] = bigintval($_SESSION['userid']);
+ setUserId(GET_SESSION('userid'));
// Is it valid?
if (!IS_MEMBER()) {
destroy_user_session();
// Kill userid
- $GLOBALS['userid'] = 0;
+ setUserId(0);
} // END - if
} // END - if
$GLOBALS['output_mode'] = 0;
$GLOBALS['what'] = "";
$GLOBALS['action'] = "";
-$GLOBALS['userid'] = 0;
$GLOBALS['module'] = "";
// Needed include files
if (IS_MEMBER()) {
// Is still logged in so we welcome him with his name
$result = SQL_QUERY_ESC("SELECT surname, family FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array(getUserId()), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Load surname and family's name and build the username
list($s, $f) = SQL_FETCHROW($result);
destroy_user_session();
// Kill userid
- $GLOBALS['userid'] = 0;
+ setUserId(0);
}
// Free memory
REQUEST_UNSET_GET(('frame'));
} elseif ((REQUEST_ISSET_GET(('frame'))) && (REQUEST_GET('frame') == "stats")) {
// Get total points amount
- $points = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points") - GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");
+ $points = GET_TOTAL_DATA(getUserId(), "user_points", "points") - GET_TOTAL_DATA(getUserId(), "user_data", "used_points");
// Prepare content
$content = array(