X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=f7238a64a85a8d71b6d5670f1b29f697dcfe2e94;hp=afd26d2bda99bc98233e00d388feda84281a292f;hb=e8ca54fe91872ab95a6ffdc4f1268bf18889021d;hpb=1c62a6c2a4ed2bb170e0f1888899625e67a27947 diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index afd26d2bda..f7238a64a8 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -72,8 +72,8 @@ function getTitleFromMenu ($mode, $what, $column = 'what', $ADD='') { return $data['title']; } -// Add menu description pending on given file name (without path!) -function addMenuDescription ($accessLevel, $FQFN, $return = false) { +// Add link into output stream (or return it) for 'You Are Here' navigation +function addYouAreHereLink ($accessLevel, $FQFN, $return = false) { // Use only filename of the FQFN... $file = basename($FQFN); @@ -237,7 +237,7 @@ ORDER BY // Do we have some entries? if (!SQL_HASZERONUMS($result_sub)) { // Init counter - $cnt = '0'; + $count = '0'; // Load all sub menus while ($content2 = SQL_FETCHARRAY($result_sub)) { @@ -279,7 +279,7 @@ ORDER BY } // Cunt it up - $cnt++; + $count++; // Rewrite array $content = array( @@ -290,7 +290,7 @@ ORDER BY ); // Add regular menu row or bottom row? - if ($cnt < SQL_NUMROWS($result_sub)) { + if ($count < SQL_NUMROWS($result_sub)) { $GLOBALS['rows'] .= loadTemplate($mode . '_menu_row', true, $content); } else { $GLOBALS['rows'] .= loadTemplate($mode . '_menu_bottom', true, $content); @@ -368,58 +368,53 @@ function isMember () { // @TODO Try to rewrite this to one or more functions if ((!isset($GLOBALS['last_online'])) || (!is_array($GLOBALS['last_online']))) $GLOBALS['last_online'] = array(); - // is the cache entry there? + // Is the cache entry there? if (isset($GLOBALS[__FUNCTION__])) { // Then return it //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'CACHED! (' . intval($GLOBALS[__FUNCTION__]) . ')'); return $GLOBALS[__FUNCTION__]; } elseif ((!isSessionVariableSet('userid')) || (!isSessionVariableSet('u_hash'))) { - // No member + // Destroy any existing user session data + destroyMemberSession(); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'No member set in cookie/session.'); + + // Abort further processing return false; - } else { - // Get it secured from session - setMemberId(getSession('userid')); - setCurrentUserId(getMemberId()); - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . getSession('userid') . ' used from cookie/session.'); } + // Get userid secured from session + setMemberId(getSession('userid')); + + // ... and set it as currently handled user id + setCurrentUserId(getMemberId()); + // Init user data array initUserData(); // Fix "deleted" cookies first fixDeletedCookies(array('userid', 'u_hash')); - // Are cookies set? - if ((isMemberIdSet()) && (isSessionVariableSet('u_hash'))) { - // Cookies are set with values, but are they valid? - if (fetchUserData(getMemberId()) === true) { - // Validate password by created the difference of it and the secret key - $valPass = encodeHashForCookie(getUserData('password')); + // Are cookies set and can the member data be loaded? + if ((isMemberIdSet()) && (isSessionVariableSet('u_hash')) && (fetchUserData(getMemberId()) === true)) { + // Validate password by created the difference of it and the secret key + $valPass = encodeHashForCookie(getUserData('password')); + // So did we now have valid data and an unlocked user? + if ((getUserData('status') == 'CONFIRMED') && ($valPass == getSession('u_hash'))) { // Transfer last module and online time $GLOBALS['last_online']['module'] = getUserData('last_module'); $GLOBALS['last_online']['online'] = getUserData('last_online'); - // So did we now have valid data and an unlocked user? - if ((getUserData('status') == 'CONFIRMED') && ($valPass == getSession('u_hash'))) { - // Account is confirmed and all cookie data is valid so he is definely logged in! :-) - $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')) . ')'); - destroyMemberSession(); - } - } else { - // Cookie data is invalid! - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cookie data invalid or user not found.'); - destroyMemberSession(); - } - } else { - // Cookie data is invalid! - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cookie data not complete.'); + // Account is confirmed and all cookie data is valid so he is definely logged in! :-) + $ret = true; + } // END - if + } // END - if + + // Is $ret still false? + if ($ret === false) { + // Yes, so destroy the session destroyMemberSession(); - } + } // END - if // Cache status $GLOBALS[__FUNCTION__] = $ret; @@ -693,10 +688,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 @@ -822,7 +817,7 @@ function getPaymentTitlePrice ($pid, $full=false) { if ($full === false) { $ret = $data['mail_title']; } else { - $ret = $data['mail_title'] . ' / {%pipe,translateComma=' . $data['price' . '%} {?POINTS?}'; + $ret = $data['mail_title'] . ' / {%pipe,translateComma=' . $data['price'] . '%} {?POINTS?}'; } } @@ -995,6 +990,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 ----------------------------------------------- '.__FUNCTION__.' - EXIT ------------------------
'); + //* DEBUG: */ debugOutput('----------------------- '.__FUNCTION__.': added=' . intval($added) . ' - EXIT ------------------------
'); + return $added; } // Updates the referal counter @@ -1135,10 +1143,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 @@ -1463,18 +1474,16 @@ function generateOptionList ($table, $id, $name, $default = '', $special = '', $ // Activate exchange function FILTER_ACTIVATE_EXCHANGE () { // Is the extension 'user' there? - if ((!isExtensionActive('user')) || (getConfig('activate_xchange') == '0')) { + if ((!isExtensionActive('user')) || (getActivateXchange() == '0')) { // Silently abort here return false; } // END - if // Check total amount of users - if (getTotalConfirmedUser() >= getConfig('activate_xchange')) { + if (getTotalConfirmedUser() >= getActivateXchange()) { // Activate System - setSqlsArray(array( - "UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='N', `hidden`='N', `mem_only`='Y' WHERE `module`='order' LIMIT 1", - "UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='order' OR `what`='unconfirmed' LIMIT 2", - )); + addSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='N', `hidden`='N', `mem_only`='Y' WHERE `module`='order' LIMIT 1"); + addSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='order' OR `what`='unconfirmed' LIMIT 2"); // Run SQLs runFilterChain('run_sqls'); @@ -1598,11 +1607,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