X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=f6bc8baaeca843f8454a8a61ddd702ffc50030a0;hb=c744215dba419b52b84291622179c5e3a6ab17e2;hp=134282477552bcd52eddd173eafe2b040c136a17;hpb=53aff78b88e6e8756f0aa21bb30a5f6b3c569211;p=mailer.git diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 1342824775..f6bc8baaec 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -14,8 +14,6 @@ * $Date:: $ * * $Tag:: 0.2.1-FINAL $ * * $Author:: $ * - * Needs to be in all Files and every File needs "svn propset * - * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * * Copyright (c) 2009, 2010 by Mailer Developer Team * @@ -262,7 +260,7 @@ ORDER BY $OUT .= ''; } else { // Not found! - open - $OUT .= ''; + $OUT .= ''; } // Menu title @@ -409,7 +407,7 @@ function isMember () { $ret = true; } else { // Maybe got locked etc. - //* DEBUG */ logDebugMessage(__FUNCTION__, __LINE__, 'status=' . getUserData('status') . ',' . $valPass . '(' . strlen($valPass) . ')/' . getSession('u_hash') . '(' . strlen(getSession('u_hash')) . ')/' . getUserData('password') . '(' . strlen(getUserData('password')) . ')'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'status=' . getUserData('status') . ',' . $valPass . '(' . strlen($valPass) . ')/' . getSession('u_hash') . '(' . strlen(getSession('u_hash')) . ')/' . getUserData('password') . '(' . strlen(getUserData('password')) . ')'); destroyMemberSession(); } } else { @@ -695,10 +693,10 @@ function isMenuActionValid ($mode, $action, $what, $updateEntry=false) { // Should we look for affected rows (only update) or found rows? if ($updateEntry === true) { // Check updated/affected rows - $ret = (SQL_AFFECTEDROWS() == 1); + $ret = (!SQL_HASZEROAFFECTED()); } else { // Check found rows - $ret = (SQL_NUMROWS($result) == 1); + $ret = (!SQL_HASZERONUMS($result)); } // Free memory @@ -824,7 +822,7 @@ function getPaymentTitlePrice ($pid, $full=false) { if ($full === false) { $ret = $data['mail_title']; } else { - $ret = $data['mail_title'] . ' / ' . translateComma($data['price']) . ' {?POINTS?}'; + $ret = $data['mail_title'] . ' / {%pipe,translateComma=' . $data['price'] . '%} {?POINTS?}'; } } @@ -988,7 +986,7 @@ function getReferalLevelPercents ($level) { * Dynamic referal system, can also send mails! * * subject = Subject line, write in lower-case letters and underscore is allowed - * userid = Referal id wich should receive... + * userid = Referal id wich should receive... * points = ... xxx points * sendNotify = shall I send the referal an email or not? * refid = inc/modules/guest/what-confirm.php need this @@ -997,6 +995,9 @@ function getReferalLevelPercents ($level) { * for default value will cause no referal will get points ever!!!) */ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify = false, $refid = '0', $add_mode = 'ref') { + // By default nothing has been added + $added = false; + //* DEBUG: */ debugOutput('----------------------- ' . __FUNCTION__ . ' - ENTRY ------------------------
  • '); // Convert mode to lower-case $add_mode = strtolower($add_mode); @@ -1019,15 +1020,20 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify //* DEBUG: */ debugOutput(__FUNCTION__ . '(' . __LINE__ . '): Referal level increased. DEPTH='.$GLOBALS['ref_level']); } - // Default is 'normal' points - $data = 'points'; - - // Which points, locked or normal? - if ($locked === true) $data = 'locked_points'; - // Check user account //* DEBUG: */ debugOutput(__FUNCTION__ . '(' . __LINE__ . '):userid='.$userid.',points='.$points); if (fetchUserData($userid)) { + // Determine wether the user has some mails to click before he/she gets the points + $locked = ifUserPointsLocked($userid); + + // Default is 'normal' points + $data = 'points'; + + // Which points, locked or normal? + if ($locked === true) { + $data = 'locked_points'; + } // END - if + // This is the user and his ref $GLOBALS['cache_array']['add_userid'][getUserData('refid')] = $userid; @@ -1054,16 +1060,16 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify //* DEBUG: */ debugOutput(__FUNCTION__ . '(' . __LINE__ . '):data='.$data.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$add_mode.' - UPDATE! ('.SQL_AFFECTEDROWS().')'); // No entry updated? - if (SQL_AFFECTEDROWS() < 1) { + if (SQL_HASZEROAFFECTED()) { // First ref in this level! :-) SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_points` (`userid`,`ref_depth`,`%s`) VALUES (%s,%s,%s)", array($data, bigintval($userid), bigintval($GLOBALS['ref_level']), $ref_points), __FUNCTION__, __LINE__); //* DEBUG: */ debugOutput(__FUNCTION__ . '(' . __LINE__ . '):data='.$data.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$add_mode.' - INSERTED! ('.SQL_AFFECTEDROWS().')'); } // END - if - // Determine wether the user has some mails to click before he/she gets the points - $locked = false; - if ((getUserData('ref_payout') > 0) && (!isDirectPaymentEnabled())) $locked = true; + // Check affected rows + $added = SQL_AFFECTEDROWS(); + //* DEBUG: */ debugOutput(__FUNCTION__ . '(' . __LINE__ . '):added='.intval($added)); // Prepare data for the filter $filterData = array( @@ -1075,10 +1081,15 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify 'locked' => $locked, 'mode' => 'add', 'sub_mode' => $add_mode, + 'added' => $added ); // Filter it now - runFilterChain('add_points', $filterData); + $filterData = runFilterChain('add_points', $filterData); + + // Extract $added + $added = $filterData['added']; + //* DEBUG: */ debugOutput(__FUNCTION__ . '(' . __LINE__ . '):added='.intval($added)); // Points updated, maybe I shall send him an email? if (($sendNotify === true) && (isValidUserId(getUserData('refid'))) && ($locked === false)) { @@ -1094,10 +1105,10 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify // Send email sendEmail($userid, '{--THANX_REFERAL_ONE_SUBJECT--}', $message); - } elseif (($sendNotify === true) && (getUserData('refid') == '0') && ($locked === false) && ($add_mode == 'direct')) { + } elseif (($sendNotify === true) && (!isValidUserId(getUserData('refid'))) && ($locked === false) && ($add_mode == 'direct')) { // Prepare content $content = array( - 'text' => '{--REASON_DIRECT_PAYMENT--}', + 'reason' => '{--REASON_DIRECT_PAYMENT--}', 'points' => $ref_points ); @@ -1116,12 +1127,13 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify if ((isValidUserId(getUserData('refid'))) && ($points > 0) && (getUserData('refid') != $userid) && ($add_mode == 'ref')) { // Then let's credit him here... //* DEBUG: */ debugOutput(__FUNCTION__ . '(' . __LINE__ . '):userid='.$userid.',ref='.getUserData('refid').',points='.$points.' - ADVANCE!'); - addPointsThroughReferalSystem(sprintf("%s_ref:%s", $subject, $GLOBALS['ref_level']), getUserData('refid'), $points, $sendNotify, getUserData('refid')); + $added = ($added && addPointsThroughReferalSystem(sprintf("%s_ref:%s", $subject, $GLOBALS['ref_level']), getUserData('refid'), $points, $sendNotify, getUserData('refid'))); } // END - if } // END - if } // END - if - //* DEBUG: */ debugOutput('
----------------------- '.__FUNCTION__.' - EXIT ------------------------
'); + //* DEBUG: */ debugOutput('----------------------- '.__FUNCTION__.': added=' . intval($added) . ' - EXIT ------------------------
'); + return $added; } // Updates the referal counter @@ -1136,10 +1148,13 @@ function updateReferalCounter ($userid) { // When no entry was updated then we have to create it here //* DEBUG: */ debugOutput(__FUNCTION__ . '(' . __LINE__ . '):updated=' . SQL_AFFECTEDROWS()); - if (SQL_AFFECTEDROWS() < 1) { + if (SQL_HASZEROAFFECTED()) { // First count! SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_refsystem` (`userid`, `level`, `counter`) VALUES (%s,%s,1)", - array(bigintval($userid), $GLOBALS['cache_array']['ref_level'][$userid]), __FUNCTION__, __LINE__); + array( + bigintval($userid), + $GLOBALS['cache_array']['ref_level'][$userid] + ), __FUNCTION__, __LINE__); //* DEBUG: */ debugOutput(__FUNCTION__ . '(' . __LINE__ . '):userid='.$userid); } // END - if @@ -1599,11 +1614,15 @@ function subtractPoints ($subject, $userid, $points) { 'subject' => $subject, 'userid' => $userid, 'points' => $points, - 'mode' => 'sub' + 'mode' => 'sub', + 'added' => (!SQL_HASZEROAFFECTED()) ); // Insert booking record - runFilterChain('sub_points', $filterData); + $filterData = runFilterChain('sub_points', $filterData); + + // Return result + return $filterData['added']; } // "Getter" for total available receivers @@ -1671,7 +1690,7 @@ function generateCategoryOptionsList ($mode) { } // END - foreach } else { // No cateogries are defined yet - $OUT = ''; + $OUT = ''; } // Return HTML code @@ -1955,110 +1974,5 @@ function updateLastActivity($userid) { ), __FUNCTION__, __LINE__); } -// Confirms a user account -function doConfirmUserAccount () { - // Init content - $content = array( - 'message' => '{--GUEST_CONFIRMED_FAILED--}', - 'userid' => 0, - ); - - // Initialize the user id - $userid = '0'; - - // Search for an unconfirmed or confirmed account - $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", - array(getRequestParameter('hash')), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) { - // Ok, he want's to confirm now so we load some data - list($userid, $email, $refid) = SQL_FETCHROW($result); - - // Fetch user data - if (!fetchUserData($userid)) { - // Not found, should not happen - debug_report_bug(__FILE__, __LINE__, 'User account ' . $userid . ' not found.'); - } // END - if - - // Load all data and add points - $content = getUserDataArray(); - - // Unlock his account (but only when it is on UNCONFIRMED!) - SQL_QUERY_ESC("UPDATE - `{?_MYSQL_PREFIX?}_user_data` -SET - `status`='CONFIRMED', - `ref_payout`={?ref_payout?}, - `user_hash`=NULL -WHERE - `user_hash`='%s' AND - `status`='UNCONFIRMED' -LIMIT 1", - array(getRequestParameter('hash')), __FILE__, __LINE__); - if (SQL_AFFECTEDROWS() == 1) { - // Send email if updated - $message = loadEmailTemplate('confirm-member', $content, bigintval($userid)); - - // And send him right away the confirmation mail - sendEmail($email, '{--GUEST_THANX_CONFIRM--}', $message); - - // Maybe he got "referaled"? - if (($refid > 0) && ($refid != $userid)) { - // Select the referal userid - if (fetchUserData($refid)) { - // Update ref counter... - updateReferalCounter($refid); - - // If version matches add ref bonus to refid's account - if ((isExtensionInstalledAndNewer('bonus', '0.4.4')) && (isBonusRallyeActive())) { - // Add points (directly only!) - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `bonus_ref`=`bonus_ref`+{?bonus_ref?} WHERE `userid`=%s LIMIT 1", - array(bigintval($refid)), __FILE__, __LINE__); - - // Subtract points from system - handleBonusPoints(getConfig('bonus_ref')); - } // END - if - - // 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')); - } // END - if - } // END - if - - if (isExtensionActive('rallye')) { - // Add user to rallye (or not?) - addUserToReferalRallye(bigintval($userid)); - } // END - if - - // Account confirmed! - if (isExtensionActive('lead')) { - // Set special lead cookie - setSession('lead_userid', bigintval($userid)); - - // Lead-Code mode enabled - redirectToUrl('lead-confirm.php'); - } else { - $content['message'] = '{--GUEST_CONFIRMED_DONE--}'; - $content['userid'] = bigintval($userid); - } - } elseif (isExtensionActive('lead')) { - // Set special lead cookie - setSession('lead_userid', bigintval($userid)); - - // Lead-Code mode enabled - redirectToUrl('lead-confirm.php'); - } else { - // Nobody was found unter this hash key... or our new member want's to confirm twice? - $content['message'] = '{--GUEST_CONFIRMED_TWICE--}'; - } - } else { - // Nobody was found unter this hash key... or our new member want's to confirm twice? - $content['message'] = '{--GUEST_CONFIRMED_TWICE--}'; - } - - // Load template - loadTemplate('admin_settings_saved', false, $content['message']); -} - // [EOF] ?>