X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Freferral-functions.php;h=a60a8a2424b7c988f39fa8cf93ce4793e4d70258;hb=2da9cf7232d07581dffb77d8d549c15a46684a0c;hp=ad4b3f9feed2a9b4ce82ea769e87b9d0002cfce0;hpb=a36ec5d82756cd4db92ce27b6acc42b8a01920ce;p=mailer.git diff --git a/inc/referral-functions.php b/inc/referral-functions.php index ad4b3f9fee..a60a8a2424 100644 --- a/inc/referral-functions.php +++ b/inc/referral-functions.php @@ -44,7 +44,7 @@ if (!defined('__SECURITY')) { function initReferralSystem () { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ' Referral system initialized!'); $GLOBALS['ref_level'] = NULL; - $GLOBALS['ref_system'] = true; + $GLOBALS['ref_system'] = TRUE; } // Getter fro ref level percents @@ -56,7 +56,7 @@ function getReferralLevelPercents ($level) { if ((isset($GLOBALS['cache_array']['refdepths']['level'])) && (isExtensionActive('cache'))) { // First look for level $key = array_search($level, $GLOBALS['cache_array']['refdepths']['level']); - if ($key !== false) { + if ($key !== FALSE) { // Entry found $data['percents'] = $GLOBALS['cache_array']['refdepths']['percents'][$key]; @@ -93,7 +93,7 @@ function getReferralLevelPercents ($level) { function addPointsThroughReferralSystem ($subject, $userid, $points, $refid = NULL) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',userid=' . $userid . ',points=' . $points . ',refid=' . convertNullToZero($refid) . ' - ENTERED!'); // By default nothing has been added - $added = false; + $added = FALSE; // Determine payment method and notification $paymentMethod = strtoupper(getPaymentMethodFromSubject($subject)); @@ -200,7 +200,7 @@ function addPointsThroughReferralSystem ($subject, $userid, $points, $refid = NU //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',userid=' . $userid . ',refid=' . $refid . ',paymentMethod=' . $paymentMethod . ',sendNotify=' . intval($sendNotify) . ',isLocked=' . intval($isLocked)); // Send "referral confirmed" mails out? - if ((isValidUserid($refid)) && ($refid != $userid) && ($sendNotify === true)) { + if ((isValidUserid($refid)) && ($refid != $userid) && ($sendNotify === TRUE)) { // Calculate the referral's points and percents $percentsReferral = getReferralLevelPercents($GLOBALS['ref_level'] + 1); @@ -226,7 +226,7 @@ function addPointsThroughReferralSystem ($subject, $userid, $points, $refid = NU } // END - if // Points updated, maybe I shall send him an email? - if (($sendNotify === true) && ($isLocked === false)) { + if (($sendNotify === TRUE) && ($isLocked === FALSE)) { // "Explode" subject $subjectArray = explode(':', $subject); $subjectUserid = (isset($subjectArray[1])) ? $subjectArray[1] : '0'; @@ -372,6 +372,7 @@ function subtractPoints ($subject, $userid, $points) { 'userid' => $userid, 'points' => $points, 'points_mode' => 'sub', + 'column' => 'used_points', 'added' => (!SQL_HASZEROAFFECTED()) ); @@ -388,8 +389,14 @@ function getUserReferralPoints ($userid, $level) { $refs = array(); // Get refs from database - $result = SQL_QUERY_ESC("SELECT - ur.`id`, ur.`refid`, ud.`status`, ud.`last_online`, ud.`mails_confirmed`, ud.`emails_received` + $result = SQL_QUERY_ESC('SELECT + ur.`id`, + ur.`refid`, + ud.`status`, + ud.`last_online`, + ud.`mails_confirmed`, + ud.`emails_received`, + ud.`subid` FROM `{?_MYSQL_PREFIX?}_user_refs` AS `ur` LEFT JOIN @@ -405,7 +412,7 @@ WHERE ur.`userid`=%s AND ur.`level`=%s ORDER BY - ur.`refid` ASC", + ur.`refid` ASC', array( bigintval($userid), bigintval($level) @@ -512,7 +519,7 @@ function getPointsColumnNameFromSubjectLocked ($subject, $isLocked) { $columnName = $pointsData['column_name']; // Are the points locked? - if (($isLocked === true) && ($pointsData['locked_mode'] == 'LOCKED')) { + if (($isLocked === TRUE) && ($pointsData['locked_mode'] == 'LOCKED')) { // Locked points, so prefix it $columnName = 'locked_' . $pointsData['column_name']; } // END - if @@ -660,7 +667,7 @@ function addMissingReferralLevels ($userid) { } // END - foreach } // END - foreach } // END - foreach - //die('
'.print_r($GLOBALS['referral_refid'][$userid],true).'
'); + //die('
'.print_r($GLOBALS['referral_refid'][$userid],TRUE).'
'); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - EXIT!'); } @@ -683,7 +690,7 @@ function flushReferralTableToDatabase ($userid) { // Prepare SQL $SQL = 'INSERT INTO `{?_MYSQL_PREFIX?}_user_refs` (`userid`, `level`, `refid`) VALUES '; - $executeSql = false; + $executeSql = FALSE; // Now walk through the array, first levels foreach ($GLOBALS['referral_refid'][$userid] as $level => $levelArray) { @@ -705,7 +712,7 @@ function flushReferralTableToDatabase ($userid) { $SQL .= '(' . $userid . ',' . $level . ',' . $refid . '),'; // Some has been added, so execute the query - $executeSql = true; + $executeSql = TRUE; } // END - if } // END - foreach } // END - foreach @@ -715,7 +722,7 @@ function flushReferralTableToDatabase ($userid) { // And run it //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',SQL=' . $SQL); - if ($executeSql === true) { + if ($executeSql === TRUE) { SQL_QUERY($SQL, __FUNCTION__, __LINE__); } // END - if @@ -814,7 +821,7 @@ function determineReferralId () { return getReferralId(); } elseif ((!isHtmlOutputMode()) && (basename($_SERVER['PHP_SELF']) != 'ref.php')) { // Skip this in non-html-mode and outside ref.php - return false; + return FALSE; } // Check if refid is set @@ -828,11 +835,11 @@ function determineReferralId () { } elseif (isGetRequestElementSet('refid')) { // Get referral id from GET parameter refid //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using refid from GET data (' . getRequestElement('refid') . ')'); - setReferralId(secureString(getRequestElement('refid'))); + setReferralId(getRequestElement('refid')); } elseif (isGetRequestElementSet('ref')) { // Set refid=ref (the referral link uses such variable) //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using ref from GET data (' . getRequestElement('ref') . ')'); - setReferralId(secureString(getRequestElement('ref'))); + setReferralId(getRequestElement('ref')); } elseif ((isGetRequestElementSet('user')) && (basename($_SERVER['PHP_SELF']) == 'click.php')) { // The variable user comes from click.php //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using user from GET data (' . getRequestElement('user') . ')'); @@ -850,7 +857,7 @@ function determineReferralId () { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using default refid (' . getDefRefid() . ')'); setReferralId(getDefRefid()); } else { - // No default id when sql_patches is not installed or none set + // No default id when ext-sql_patches is not installed or none set //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using NULL as refid'); setReferralId(NULL); } @@ -858,7 +865,7 @@ function determineReferralId () { // Set cookie when default refid > 0 if ((!isSessionVariableSet('refid')) || (!isValidUserId(getReferralId())) || ((!isValidUserId(getSession('refid'))) && (isExtensionInstalledAndNewer('sql_patches', '0.1.2')) && (isValidUserId(getDefRefid())))) { // Default is not found - $found = false; + $found = FALSE; // Is there nickname or userid set? if ((isExtensionActive('nickname')) && (isNicknameUsed(getReferralId()))) { @@ -866,7 +873,7 @@ function determineReferralId () { $found = fetchUserData(getReferralId(), 'nickname'); // If we found it, use the userid as referral id - if ($found === true) { + if ($found === TRUE) { // Set the userid as 'refid' //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using refid from user account by nickname (' . getUserData('userid') . ')'); setReferralId(getUserData('userid')); @@ -878,7 +885,7 @@ function determineReferralId () { } // Is the record valid? - if ((($found === false) || (!isUserDataValid())) && (isExtensionInstalledAndNewer('sql_patches', '0.1.2'))) { + if ((($found === FALSE) || (!isUserDataValid())) && (isExtensionInstalledAndNewer('sql_patches', '0.1.2'))) { // No, then reset referral id //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using default refid (' . getDefRefid() . ')'); setReferralId(getDefRefid());