//
function handleSponsorRequest ($postData, $update=false, $messageArray = array(), $RET_STATUS=false) {
// Init a lot variables
- $SAVE = true;
- $UPDATE = false;
- $skip = false;
- $ALREADY = false;
+ $SAVE = TRUE;
+ $UPDATE = FALSE;
+ $skip = FALSE;
+ $ALREADY = FALSE;
$ret = 'unused';
// Skip these entries
// Check only posted input entries not the submit button
switch ($k) {
case 'email':
- $ALREADY = false;
+ $ALREADY = FALSE;
if (!isEmailValid($v)) {
// Email address is not valid
- $SAVE = false;
+ $SAVE = FALSE;
} else {
- // Do we want to add a new sponsor or update his data?
+ // Add a new sponsor or update his data?
$result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE email='%s' LIMIT 1",
- array($postData['email']), __FUNCTION__, __LINE__);
+ array($postData['email']), __FUNCTION__, __LINE__);
// Is a sponsor alread in the db?
if (SQL_NUMROWS($result) == 1) {
// Yes, he is!
if ((getWhat() == 'add_sponsor') || ($update)) {
// Already found
- $ALREADY = true;
+ $ALREADY = TRUE;
} else {
// Update his data
- $UPDATE = true;
+ $UPDATE = TRUE;
}
}
case 'url':
if (!isUrlValid($v)) {
// Don't save the URL
- $SAVE = false;
+ $SAVE = FALSE;
} // END - if
break;
break;
} // END - switch
- if ((!empty($k)) && ($skip == false)) {
+ if ((!empty($k)) && ($skip == FALSE)) {
// Add data
array_push($DATA['keys'] , $k);
array_push($DATA['values'], $v);
} // END - foreach
// Save sponsor?
- if ($SAVE === true) {
+ if ($SAVE === TRUE) {
// Default is no force even when a guest want to abuse this force switch
if ((empty($postData['force'])) || (!isAdmin())) $postData['force'] = '0';
// Generate message
$message = getMessageFromIndexedArray('{--ADMIN_SPONSOR_UPDATED--}', 'updated', $messageArray);
$ret = 'updated';
- } elseif (($ALREADY === false) || (($postData['force'] == 1) && (isAdmin()))) {
+ } elseif (($ALREADY === FALSE) || (($postData['force'] == 1) && (isAdmin()))) {
// Add new sponsor, first add more data
array_push($DATA['keys'], 'status');
- if (($update === true) && (isAdmin()) && (getWhat() == 'add_sponsor')) {
+ if (($update === TRUE) && (isAdmin()) && (getWhat() == 'add_sponsor')) {
// Only allowed for admin
array_push($DATA['values'], 'PENDING');
unset($DATA['values'][$key]);
// Implode all data into strings
- $keyArray = implode('`,`' , $DATA['keys']);
+ $keyArray = implode('`, `' , $DATA['keys']);
$valueArray = str_repeat("%s', '", count($DATA['values']) - 1);
// Generate string
// Generate message
$message = getMessageFromIndexedArray('{--ADMIN_SPONSOR_ADDED--}', 'added', $messageArray);
$ret = 'added';
- } elseif (($update === true) && (isAdmin())) {
+ } elseif (($update === TRUE) && (isAdmin())) {
// Add all data as hidden data
$OUT = '';
foreach ($postData as $k => $v) {
$content['email'] = $postData['email'];
// Ask for adding a sponsor with same email address
- loadTemplate('admin_add_sponsor_already', false, $content);
+ loadTemplate('admin_add_sponsor_already', FALSE, $content);
return;
} else {
// Already added!
// Search for an email address in the database
function isSponsorRegisteredWithEmail ($email) {
- // Do we already have the provided email address in our DB?
- $ret = (countSumTotalData($email, 'sponsor_data', 'id', 'email', true) == 1);
+ // Is there already the provided email address in database?
+ $ret = (countSumTotalData($email, 'sponsor_data', 'id', 'email', TRUE) == 1);
// Return result
return $ret;
// Wether the current user is a sponsor
function isSponsor () {
// Failed is default
- $ret = false;
+ $ret = FALSE;
// Determine it
$ret = (
if ($current == $content2['sub_what']) $content2['sub_title'] = '<strong>' . $content2['sub_title'] . '</strong>';
// Load row template
- $SUB .= loadTemplate('sponsor_what', true, $content2);
+ $SUB .= loadTemplate('sponsor_what', TRUE, $content2);
} // END - while
// Prepare data for the main template
$content['menu'] = $SUB;
// Load menu template
- $OUT .= loadTemplate('sponsor_action', true, $content);
+ $OUT .= loadTemplate('sponsor_action', TRUE, $content);
} else {
// No sub menus active
- $OUT .= displayMessage('{--SPONSOR_NO_SUB_MENUS_ACTIVE--}', true);
+ $OUT .= displayMessage('{--SPONSOR_NO_SUB_MENUS_ACTIVE--}', TRUE);
}
// Free memory
} // END - while
} else {
// No main menus active
- $OUT .= displayMessage('{--SPONSOR_NO_MAIN_MENUS_ACTIVE--}', true);
+ $OUT .= displayMessage('{--SPONSOR_NO_MAIN_MENUS_ACTIVE--}', TRUE);
}
// Free memory
loadIncludeOnce($INC);
} else {
// File not found
- $GLOBALS['sponsor_output'] .= displayMessage('{%message,SPONSOR_CONTENT_404=' . $what . '%}', true);
+ $GLOBALS['sponsor_output'] .= displayMessage('{%message,SPONSOR_CONTENT_404=' . $what . '%}', TRUE);
}
// Return content
//
function updateSponsorLogin () {
// Failed by default
- $login = false;
+ $login = FALSE;
// Is sponsor?
if (isSponsor()) {
// Saves sponsor's data
function saveSponsorData ($postData, $content) {
- $EMAIL = false;
+ $EMAIL = FALSE;
// Unsecure data which we don't want
$UNSAFE = array('password', 'id', 'remote_addr', 'sponsor_created', 'last_online', 'status', 'ref_count',
if ((!empty($content['email'])) && (!empty($postData['email']))) {
if ($content['email'] != $postData['email']) {
// Change email address
- $EMAIL = true;
+ $EMAIL = TRUE;
// Okay, has changed then add status with UNCONFIRMED and new hash code
$sql .= " `status`='EMAIL',`hash`='%s',";
// Saving data was completed... ufff...
switch (getWhat()) {
case 'account': // Change account data
- if ($EMAIL === true) {
+ if ($EMAIL === TRUE) {
$message = '{--SPONSOR_ACCOUNT_EMAIL_CHANGED--}';
$templ = 'admin_sponsor_change_email';
$subject = '{--ADMIN_SPONSOR_ACC_EMAIL_SUBJECT--}';
$email_msg = loadEmailTemplate('sponsor_change_data', $content);
sendEmail($content['email'], '{--SPONSOR_ACC_DATA_SUBJECT--}', $email_msg);
- if ($EMAIL === true) {
+ if ($EMAIL === TRUE) {
// Add hash code to content array
$content['hash'] = $HASH;
$message = '';
// Handle the request
- $status = handleSponsorRequest(postRequestArray(), true, $messageArray, true);
+ $status = handleSponsorRequest(postRequestArray(), TRUE, $messageArray, TRUE);
// Check the status of the registration process
switch ($status) {
// Sponsor-related data, so is there a sponsor_id?
if (!empty($data['matches'][4][$data['key']])) {
- // Do we have a sponsor_id or $sponsor_id?
+ // Is there a sponsor_id or $sponsor_id?
if ($data['matches'][4][$data['key']] == '$userid') {
// Use dynamic call
$functionName = "getFetchedSponsorData('id', \$userid, '" . $data['callback'] . "')";
$functionName = "getSponsorData('" . $data['callback'] . "')";
}
- // Do we have another function to run (e.g. translations)
+ // Is there another function to run (e.g. translations)
if (!empty($data['extra_func'])) {
// Surround the original function call with it
$functionName = $data['extra_func'] . '(' . $functionName . ')';
reportBug(__FUNCTION__, __LINE__, 'Sponsor id ' . $sponsor_id . ' is invalid.');
} elseif (isSponsorDataValid()) {
// Use cache, so it is fine
- return true;
+ return TRUE;
}
} elseif (isSponsorDataValid()) {
// Use cache, so it is fine
- return true;
+ return TRUE;
}
// By default none was found
- $found = false;
+ $found = FALSE;
// Extra statements
$ADD = '';
$result = SQL_QUERY_ESC("SELECT *".$ADD." FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `%s`='%s' LIMIT 1",
array($column, $sponsor_id), __FUNCTION__, __LINE__);
- // Do we have a record?
+ // Is there a record?
if (SQL_NUMROWS($result) == 1) {
// Load data from cookies
$data = SQL_FETCHARRAY($result);
// in, but you should use isMember() if you want to find that out.
function isSponsorDataValid () {
// Sponsor id should not be zero so abort here
- if (!isCurrentSponsorIdSet()) return false;
+ if (!isCurrentSponsorIdSet()) return FALSE;
// Is it cached?
if (!isset($GLOBALS['is_sponsor_data_valid'][getCurrentSponsorId()])) {
// Is given sponsor_id valid?
function isValidSponsorId ($sponsor_id) {
- // Do we have cache?
+ // Is there cache?
if (!isset($GLOBALS[__FUNCTION__][$sponsor_id])) {
// Check it out
$GLOBALS[__FUNCTION__][$sponsor_id] = ((!is_null($sponsor_id)) && (!empty($sponsor_id)) && ($sponsor_id > 0));
// Getter for sponsor_min_points
function getSponsorMinPoints () {
- // Do we have cache?
+ // Is there cache?
if (!isset($GLOBALS[__FUNCTION__])) {
// Determine it
$GLOBALS[__FUNCTION__] = getConfig('sponsor_min_points');
// Getter for sponsor_ref_points
function getSponsorRefPoints () {
- // Do we have cache?
+ // Is there cache?
if (!isset($GLOBALS[__FUNCTION__])) {
// Determine it
$GLOBALS[__FUNCTION__] = getConfig('sponsor_ref_points');