]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
add_mode in ADD_POINTS_REFSYSTEM() is now always lower-case
[mailer.git] / inc / mysql-manager.php
index 003589d527ec4ce6d1ead84f961a2a90dfdb5fcf..7e6d95f31ae89ab7fe7e6f4acc09be7dac53bc3a 100644 (file)
@@ -101,7 +101,7 @@ function CHECK_MODULE($mod) {
        $ret = "major";
 
        // Check if script is installed if not return a "done" to prevent some errors
-       if ((!defined('mxchange_installed')) || (isBooleanConstantAndTrue('mxchange_installing')) || (!defined('admin_registered'))) return "done";
+       if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isBooleanConstantAndTrue('mxchange_installing')) || (!isBooleanConstantAndTrue('admin_registered'))) return "done";
 
        // Check if cache is latest version
        $locked = "Y"; $hidden = "N"; $admin = "N"; $mem = "N"; $found = false;
@@ -583,10 +583,16 @@ function WHAT_IS_VALID($act, $wht, $type="guest")
 //
 function IS_MEMBER()
 {
-       global $status, $LAST;
+       global $status, $LAST, $cacheArray;
        if (!is_array($LAST)) $LAST = array();
        $ret = false;
 
+       // is the cache entry there?
+       if (isset($cacheArray['is_member'])) {
+               // Then return it
+               return $cacheArray['is_member'];
+       } // END - if
+
        // Fix "deleted" cookies first
        FIX_DELETED_COOKIES(array('userid', 'u_hash', 'lifetime'));
 
@@ -639,29 +645,26 @@ function IS_MEMBER()
                unset($GLOBALS['userid']);
        }
 
+       // Cache status
+       $cacheArray['is_member'] = $ret;
+
        // Return status
        return $ret;
 }
 //
-function UPDATE_LOGIN_DATA ($UPDATE=true) {
+function UPDATE_LOGIN_DATA () {
        global $LAST, $_CONFIG;
        if (!is_array($LAST)) $LAST = array();
 
-       // Are the required cookies set?
-       if ((!isset($GLOBALS['userid'])) || (!isSessionVariableSet('u_hash')) || (!isSessionVariableSet('lifetime'))) {
-               // Nope, then return here to caller function
-               return false;
-       } else {
-               // Secure user ID
-               $GLOBALS['userid'] = bigintval(get_session('userid'));
-       }
+       // Recheck if logged in
+       if (!IS_MEMBER()) return false;
+
+       // Secure user ID
+       $GLOBALS['userid'] = bigintval(get_session('userid'));
 
        // Extract last online time (life) and how long is auto-login valid (time)
        $newl = time() + bigintval(get_session('lifetime'));
 
-       // Recheck if logged in
-       if (!IS_MEMBER()) return false;
-
        // 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']), __FILE__, __LINE__);
        if (SQL_NUMROWS($result) == 1) {
@@ -1095,10 +1098,12 @@ function GET_TOTAL_DATA($search, $tableName, $lookFor, $whereStatement="userid",
  * add_mode    = Add points only to $uid or also refs? (WARNING! Changing "ref" to "direct"
  *               for default value will cause no referral will get points ever!!!)
  */
-function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $locked=false, $add_mode="ref")
-{
+function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $locked=false, $add_mode="ref") {
        global $DEPTH, $_CONFIG, $DATA;
 
+       // Convert mode to lower-case
+       $add_mode = strtolower($add_mode);
+
        // Debug message
        //DEBUG_LOG(__FUNCTION__.": uid={$uid},points={$points}");